This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [hsa merge 07/10] IPA-HSA pass
- From: Ilya Verbin <iverbin at gmail dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Martin Jambor <mjambor at suse dot cz>, Alexander Monakov <amonakov at ispras dot ru>, Thomas Schwinge <thomas at codesourcery dot com>, Kirill Yukhin <kirill dot yukhin at gmail dot com>
- Date: Wed, 20 Jan 2016 21:53:30 +0300
- Subject: Re: [hsa merge 07/10] IPA-HSA pass
- Authentication-results: sourceware.org; auth=none
- References: <20160113173925 dot 220029649 at virgil dot suse dot cz> <20160113173925 dot 776317025 at virgil dot suse dot cz> <20160114125858 dot GE3017 at tucnak dot redhat dot com> <20160115145323 dot GL3982 at virgil dot suse dot cz> <20160115150149 dot GX3017 at tucnak dot redhat dot com> <20160115160234 dot GO3982 at virgil dot suse dot cz> <20160115160954 dot GZ3017 at tucnak dot redhat dot com> <20160115163814 dot GB48907 at msticlxl57 dot ims dot intel dot com> <20160115164522 dot GA3017 at tucnak dot redhat dot com> <20160115180547 dot GC48907 at msticlxl57 dot ims dot intel dot com>
On Fri, Jan 15, 2016 at 21:05:47 +0300, Ilya Verbin wrote:
> On Fri, Jan 15, 2016 at 17:45:22 +0100, Jakub Jelinek wrote:
> > On Fri, Jan 15, 2016 at 07:38:14PM +0300, Ilya Verbin wrote:
> > > On Fri, Jan 15, 2016 at 17:09:54 +0100, Jakub Jelinek wrote:
> > > > On Fri, Jan 15, 2016 at 05:02:34PM +0100, Martin Jambor wrote:
> > > > > How do other accelerators cope with the situation when half of the
> > > > > application is compiled with the accelerator disabled? (Would some of
> > > > > their calls to GOMP_target_ext lead to abort?)
> > > >
> > > > GOMP_target_ext should never abort (unless internal error), worst case it
> > > > just falls back into the host fallback.
> > >
> > > Wouldn't that lead to hard-to-find problems in case of nonshared memory?
> > > I mean when someone expects that all target regions are executed on the device,
> > > but in fact some of them are silently executed on the host with different data
> > > environment.
> >
> > E.g. for HSA it really shouldn't matter, as it is shared memory accelerator.
> > For XeonPhi we hopefully can offload anything.
>
> As you said, if compilation of target image fails with ICE or somehow, host
> fallback and offloading to other targets should still work:
> https://gcc.gnu.org/ml/gcc-patches/2015-02/msg00951.html
> That patch was not applied, but it can be simulated by -foffload=disable,
I agree that OpenMP doesn't guarantee that all target regions must be executed
on the device, but in this case a user can't be sure that some library function
always will offload (because the library might be replaced by fallback version),
and he/she will have to write something like:
{
map_data_to_target ();
some_library1_fn_with_offload ();
get_data_from_target (); /* ! */
send_data_to_target (); /* ! */
some_library2_fn_with_offload ();
get_data_from_target (); /* ! */
send_data_to_target (); /* ! */
some_library3_fn_with_offload ();
unmap_data_from_target ();
}
If you're OK with this, I'll install this patch:
libgomp/
* target.c (gomp_get_target_fn_addr): Allow host fallback if target
function wasn't mapped to the device with non-shared memory.
diff --git a/libgomp/target.c b/libgomp/target.c
index f1f5849..96fe3d5 100644
--- a/libgomp/target.c
+++ b/libgomp/target.c
@@ -1436,12 +1436,7 @@ gomp_get_target_fn_addr (struct gomp_device_descr *devicep,
splay_tree_key tgt_fn = splay_tree_lookup (&devicep->mem_map, &k);
gomp_mutex_unlock (&devicep->lock);
if (tgt_fn == NULL)
- {
- if (devicep->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM)
- return NULL;
- else
- gomp_fatal ("Target function wasn't mapped");
- }
+ return NULL;
return (void *) tgt_fn->tgt_offset;
}
-- Ilya