]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add 'libgomp.c++/target-std__[...]-concurrent-usm.C' test cases for C++ 'std::flat_ma...
authorThomas Schwinge <tschwinge@baylibre.com>
Fri, 30 May 2025 09:37:46 +0000 (11:37 +0200)
committerThomas Schwinge <tschwinge@baylibre.com>
Wed, 14 Jan 2026 15:00:56 +0000 (16:00 +0100)
libgomp/
* testsuite/libgomp.c++/target-std__flat_map-concurrent-usm.C:
New.
* testsuite/libgomp.c++/target-std__flat_multimap-concurrent-usm.C:
Likewise.
* testsuite/libgomp.c++/target-std__flat_multiset-concurrent-usm.C:
Likewise.
* testsuite/libgomp.c++/target-std__flat_set-concurrent-usm.C:
Likewise.
* testsuite/libgomp.c++/target-std__flat_map-concurrent.C: Adjust.
* testsuite/libgomp.c++/target-std__flat_multimap-concurrent.C:
Likewise.
* testsuite/libgomp.c++/target-std__flat_multiset-concurrent.C:
Likewise.
* testsuite/libgomp.c++/target-std__flat_set-concurrent.C:
Likewise.

libgomp/testsuite/libgomp.c++/target-std__flat_map-concurrent-usm.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/target-std__flat_map-concurrent.C
libgomp/testsuite/libgomp.c++/target-std__flat_multimap-concurrent-usm.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/target-std__flat_multimap-concurrent.C
libgomp/testsuite/libgomp.c++/target-std__flat_multiset-concurrent-usm.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/target-std__flat_multiset-concurrent.C
libgomp/testsuite/libgomp.c++/target-std__flat_set-concurrent-usm.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/target-std__flat_set-concurrent.C

diff --git a/libgomp/testsuite/libgomp.c++/target-std__flat_map-concurrent-usm.C b/libgomp/testsuite/libgomp.c++/target-std__flat_map-concurrent-usm.C
new file mode 100644 (file)
index 0000000..ac1fc9b
--- /dev/null
@@ -0,0 +1,8 @@
+// { dg-additional-options "-std=c++23" }
+
+/* { dg-require-effective-target omp_usm } */
+#pragma omp requires unified_shared_memory self_maps
+#define OMP_USM
+#define MEM_SHARED
+
+#include "target-std__flat_map-concurrent.C"
index 958b75e720925d0993c151ebd80d365d88a4c25c..311f9fc4ef62b052d301e5b26d36a3db92148877 100644 (file)
@@ -39,7 +39,9 @@ int main (void)
   init (keys, true);
   init (data, false);
 
+#ifndef MEM_SHARED
   #pragma omp target enter data map (to: keys[ :N], data[ :N]) map (alloc: _map)
+#endif
 
   #pragma omp target
     {
@@ -55,12 +57,22 @@ int main (void)
     for (int i = 0; i < N; ++i)
       sum += (long long) keys[i] * _map[keys[i]];
 
+#ifdef OMP_USM
+  #pragma omp target
+    /* Restore the object into pristine state.  In particular, deallocate
+       any memory allocated during device execution, which otherwise, back
+       on the host, we'd SIGSEGV on, when attempting to deallocate during
+       destruction of the object.  */
+    __typeof__ (_map){}.swap (_map);
+#endif
 #ifndef MEM_SHARED
   #pragma omp target
     _map.~flat_map ();
 #endif
 
+#ifndef MEM_SHARED
   #pragma omp target exit data map (release: _map)
+#endif
 
   bool ok = validate (sum, keys, data);
   return ok ? 0 : 1;
diff --git a/libgomp/testsuite/libgomp.c++/target-std__flat_multimap-concurrent-usm.C b/libgomp/testsuite/libgomp.c++/target-std__flat_multimap-concurrent-usm.C
new file mode 100644 (file)
index 0000000..d772f63
--- /dev/null
@@ -0,0 +1,8 @@
+// { dg-additional-options "-std=c++23" }
+
+/* { dg-require-effective-target omp_usm } */
+#pragma omp requires unified_shared_memory self_maps
+#define OMP_USM
+#define MEM_SHARED
+
+#include "target-std__flat_multimap-concurrent.C"
index cee63236750c69029ecb8de6c7bd69a404a2b3ee..0afbd56138f8e415102a0fafc8232cda3dc1e26c 100644 (file)
@@ -33,7 +33,9 @@ int main (void)
   init (keys, KEY_MAX);
   init (data, RAND_MAX);
 
+#ifndef MEM_SHARED
   #pragma omp target enter data map (to: keys[ :N], data[ :N]) map (alloc: _map)
+#endif
 
   #pragma omp target
     {
@@ -54,12 +56,22 @@ int main (void)
        }
       }
 
+#ifdef OMP_USM
+  #pragma omp target
+    /* Restore the object into pristine state.  In particular, deallocate
+       any memory allocated during device execution, which otherwise, back
+       on the host, we'd SIGSEGV on, when attempting to deallocate during
+       destruction of the object.  */
+    __typeof__ (_map){}.swap (_map);
+#endif
 #ifndef MEM_SHARED
   #pragma omp target
     _map.~flat_multimap ();
 #endif
 
+#ifndef MEM_SHARED
   #pragma omp target exit data map (release: _map)
+#endif
 
   bool ok = validate (sum, keys, data);
   return ok ? 0 : 1;
diff --git a/libgomp/testsuite/libgomp.c++/target-std__flat_multiset-concurrent-usm.C b/libgomp/testsuite/libgomp.c++/target-std__flat_multiset-concurrent-usm.C
new file mode 100644 (file)
index 0000000..56d60a2
--- /dev/null
@@ -0,0 +1,8 @@
+// { dg-additional-options "-std=c++23" }
+
+/* { dg-require-effective-target omp_usm } */
+#pragma omp requires unified_shared_memory self_maps
+#define OMP_USM
+#define MEM_SHARED
+
+#include "target-std__flat_multiset-concurrent.C"
index 13d2ff921d054a0d34b740d25e0c99c021d3ce18..a2af7f24ff0d889ee4da7cc304c430f984cb418f 100644 (file)
@@ -34,7 +34,9 @@ int main (void)
   srand (time (NULL));
   init (data);
 
+#ifndef MEM_SHARED
   #pragma omp target data map (to: data[ :N]) map (alloc: set)
+#endif
     {
       #pragma omp target
        {
@@ -49,6 +51,14 @@ int main (void)
        for (int i = 0; i < MAX; ++i)
          sum += i * set.count (i);
 
+#ifdef OMP_USM
+      #pragma omp target
+       /* Restore the object into pristine state.  In particular, deallocate
+          any memory allocated during device execution, which otherwise, back
+          on the host, we'd SIGSEGV on, when attempting to deallocate during
+          destruction of the object.  */
+       __typeof__ (set){}.swap (set);
+#endif
 #ifndef MEM_SHARED
       #pragma omp target
        set.~flat_multiset ();
diff --git a/libgomp/testsuite/libgomp.c++/target-std__flat_set-concurrent-usm.C b/libgomp/testsuite/libgomp.c++/target-std__flat_set-concurrent-usm.C
new file mode 100644 (file)
index 0000000..1532e6c
--- /dev/null
@@ -0,0 +1,8 @@
+// { dg-additional-options "-std=c++23" }
+
+/* { dg-require-effective-target omp_usm } */
+#pragma omp requires unified_shared_memory self_maps
+#define OMP_USM
+#define MEM_SHARED
+
+#include "target-std__flat_set-concurrent.C"
index 0f4a1a8e374f05e565029d91430a1556e6da4fb4..dce213c213c87597dc30b0f79cc22a18c4ddd1e6 100644 (file)
@@ -40,7 +40,9 @@ int main (void)
   srand (time (NULL));
   init (data);
 
+#ifndef MEM_SHARED
   #pragma omp target data map (to: data[ :N]) map (alloc: _set)
+#endif
     {
       #pragma omp target
        {
@@ -56,6 +58,14 @@ int main (void)
          if (_set.count (i) > 0)
            sum += i;
 
+#ifdef OMP_USM
+      #pragma omp target
+       /* Restore the object into pristine state.  In particular, deallocate
+          any memory allocated during device execution, which otherwise, back
+          on the host, we'd SIGSEGV on, when attempting to deallocate during
+          destruction of the object.  */
+       __typeof__ (_set){}.swap (_set);
+#endif
 #ifndef MEM_SHARED
       #pragma omp target
        _set.~flat_set ();