https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81688
--- Comment #4 from Tom de Vries <vries at gcc dot gnu.org> --- (In reply to Tom de Vries from comment #3) > Created attachment 42484 [details] > Patch that moves async_run from plugin-hsa.c to default_sync_run > > I wonder if this will work. That got me this error for target-33.c: ... libgomp: libgomp: cuMemAlloc error: invalid device context cuMemAlloc error: invalid device context libgomp: cuCtxPushCurrent_v2 error: unknown cuda error libgomp: device finalization failed ... Using this patch in addition, both target-33.c and target34.c pass: ... diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c index d5262639578..4e0009f650e 100644 --- a/libgomp/plugin/plugin-nvptx.c +++ b/libgomp/plugin/plugin-nvptx.c @@ -2127,6 +2127,8 @@ GOMP_OFFLOAD_run (int ord, void *tgt_fn, void *tgt_vars, void **args) const char *maybe_abort_msg = "(perhaps abort was called)"; int teams = 0, threads = 0; + nvptx_attach_host_thread_to_device (ord); + if (!args) GOMP_PLUGIN_fatal ("No target arguments provided"); while (*args) ...