https://gcc.gnu.org/g:880792f641a31e41a05a236e608b6e87caa9675b

commit r17-4027-g880792f641a31e41a05a236e608b6e87caa9675b
Author: Tobias Burnus <[email protected]>
Date:   Wed Sep 9 14:10:05 2026 +0200

    libgomp: Add tests for 'requires self_maps' with global static vars 
[PR122205]
    
    Note that usm_env_handling-1-self.c segfaults in nvptx lto1,
    when compiling with nvptx offloading and using -fopenmp -O1.
    Hence, the test is xfailed; the issue is tacked in PR target/127273
    
    libgomp/ChangeLog:
    
            PR middle-end/122205
            * testsuite/libgomp.c/usm_env_handling-2.c: Improve debug printf.
            * testsuite/libgomp.c/usm_env_handling-1.c: likewise; add
            '#ifdef USE_SELF_MAPS'.
            * testsuite/libgomp.c/usm_env_handling-1-self.c: New test.
            * testsuite/libgomp.c/usm_env_handling-2-self.c: New test.
            * testsuite/libgomp.c/usm_env_handling-3-self.c: New test.

Diff:
---
 libgomp/testsuite/libgomp.c/usm_env_handling-1-self.c | 13 +++++++++++++
 libgomp/testsuite/libgomp.c/usm_env_handling-1.c      |  8 ++++++--
 libgomp/testsuite/libgomp.c/usm_env_handling-2-self.c |  6 ++++++
 libgomp/testsuite/libgomp.c/usm_env_handling-2.c      |  4 ++--
 libgomp/testsuite/libgomp.c/usm_env_handling-3-self.c |  6 ++++++
 5 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/libgomp/testsuite/libgomp.c/usm_env_handling-1-self.c 
b/libgomp/testsuite/libgomp.c/usm_env_handling-1-self.c
new file mode 100644
index 000000000000..37a7b915b18d
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/usm_env_handling-1-self.c
@@ -0,0 +1,13 @@
+/* { dg-do run }  */
+
+/* Check that a global static variable is consistently updated on the device. 
*/
+
+// ICE for A$linkptr in nvptx lto1 with ipa_reference_var_uid
+// when compiling with -fopenmp -O1 or higher
+// {Segmentation [Ff]ault}{ offload_target_nvptx } }
+// { dg-ice "PR target/127273" { offload_target_nvptx } }
+// { dg-excess-errors "'mkoffload' failure etc." { xfail { 
offload_target_nvptx } } } */
+
+
+#define USE_SELF_MAPS 1
+#include "usm_env_handling-1.c"
diff --git a/libgomp/testsuite/libgomp.c/usm_env_handling-1.c 
b/libgomp/testsuite/libgomp.c/usm_env_handling-1.c
index f909851ff6fa..0cdbcc754c8c 100644
--- a/libgomp/testsuite/libgomp.c/usm_env_handling-1.c
+++ b/libgomp/testsuite/libgomp.c/usm_env_handling-1.c
@@ -17,6 +17,10 @@
 #include <stdlib.h>
 #include <string.h>
 
+#ifdef USE_SELF_MAPS
+#pragma omp requires self_maps
+#endif
+
 
 int A[1] = {1};
 #pragma omp declare target enter(A)
@@ -56,9 +60,9 @@ main ()
   bool is_usm = (is_shared_mem && env_var
                 && strcasecmp ("enabled", env_var) == 0
                 && omp_get_num_devices () > 0);
-  printf ("DEBUG: GOMP_RUNTIME_USM = %s, is_shared_mem = %s -> usm = %s\n",
+  printf ("DEBUG: GOMP_RUNTIME_USM = %s, is_shared_mem = %s, num devs = %d -> 
env var usm = %s\n",
          env_var ? env_var : "<unset>", is_shared_mem ? "true" : "false",
-         is_usm ? "true" : "false");
+         omp_get_num_devices (), is_usm ? "true" : "false");
 
 
   // Check that 'TARGET UPDATE' works
diff --git a/libgomp/testsuite/libgomp.c/usm_env_handling-2-self.c 
b/libgomp/testsuite/libgomp.c/usm_env_handling-2-self.c
new file mode 100644
index 000000000000..6de2a7bba979
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/usm_env_handling-2-self.c
@@ -0,0 +1,6 @@
+/* { dg-do run }  */
+
+/* Check that a global static variable is consistently updated on the device. 
*/
+
+#define USE_SELF_MAPS 1
+#include "usm_env_handling-2.c"
diff --git a/libgomp/testsuite/libgomp.c/usm_env_handling-2.c 
b/libgomp/testsuite/libgomp.c/usm_env_handling-2.c
index 2683e1091c21..c250becf376c 100644
--- a/libgomp/testsuite/libgomp.c/usm_env_handling-2.c
+++ b/libgomp/testsuite/libgomp.c/usm_env_handling-2.c
@@ -83,9 +83,9 @@ main ()
   bool is_usm = (is_shared_mem && env_var
                 && strcasecmp ("enabled", env_var) == 0
                 && omp_get_num_devices () > 0);
-  printf ("DEBUG: GOMP_RUNTIME_USM = %s, is_shared_mem = %s -> usm = %s\n",
+  printf ("DEBUG: GOMP_RUNTIME_USM = %s, is_shared_mem = %s, num devs = %d -> 
evn var usm = %s\n",
          env_var ? env_var : "<unset>", is_shared_mem ? "true" : "false",
-         is_usm ? "true" : "false");
+         omp_get_num_devices (), is_usm ? "true" : "false");
 
 
   // Target update + modifying the data in TARGET
diff --git a/libgomp/testsuite/libgomp.c/usm_env_handling-3-self.c 
b/libgomp/testsuite/libgomp.c/usm_env_handling-3-self.c
new file mode 100644
index 000000000000..ecaa5a58e9fc
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/usm_env_handling-3-self.c
@@ -0,0 +1,6 @@
+/* { dg-do run }  */
+
+/* Check that a global static variable is consistently updated on the device. 
*/
+
+#define USE_SELF_MAPS 1
+#include "usm_env_handling-3.c"

Reply via email to