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