Bug 81688 - libgomp.c/target-3{3,4}.c fails: GOMP_OFFLOAD_async_run unimplemented for nvptx
Summary: libgomp.c/target-3{3,4}.c fails: GOMP_OFFLOAD_async_run unimplemented for nvptx
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libgomp (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: openmp, patch
Depends on:
Blocks:
 
Reported: 2017-08-03 08:31 UTC by Tom de Vries
Modified: 2020-09-30 20:25 UTC (History)
2 users (show)

See Also:
Host:
Target: nvptx
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Patch that moves async_run from plugin-hsa.c to default_sync_run (1.62 KB, patch)
2017-10-27 09:09 UTC, Tom de Vries
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tom de Vries 2017-08-03 08:31:33 UTC

    
Comment 1 Tom de Vries 2017-08-03 08:38:11 UTC
Already mentioned here ( https://gcc.gnu.org/ml/gcc-patches/2016-11/msg00972.html ):
...
With OpenMP/PTX offloading there are 5 additional failures in check-target-libgomp:

<SNIP>

Two with 'target nowait' (not implemented)
FAIL: libgomp.c/target-33.c execution test
FAIL: libgomp.c/target-34.c execution test
...
Comment 2 Tom de Vries 2017-08-03 08:46:31 UTC
These tests pass on gomp-4_0-branch, because there GOMP_OFFLOAD_get_caps does not return GOMP_OFFLOAD_CAP_OPENMP_400, while on trunk it does.
Comment 3 Tom de Vries 2017-10-27 09:09:14 UTC
Created attachment 42484 [details]
Patch that moves async_run from plugin-hsa.c to default_sync_run

I wonder if this will work.
Comment 4 Tom de Vries 2017-10-27 11:50:06 UTC
(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)
...
Comment 5 Tom de Vries 2017-10-27 13:59:37 UTC
patch submitted: https://gcc.gnu.org/ml/gcc-patches/2017-10/msg02079.html
Comment 6 Tom de Vries 2020-09-30 20:25:54 UTC
This no longer fails at current trunk.