[Openmp-commits] [openmp] r358902 - [OPENMP][NVPTX] Fix the test, NFC.

Alexey Bataev via Openmp-commits openmp-commits at lists.llvm.org
Mon Apr 22 10:25:31 PDT 2019


Author: abataev
Date: Mon Apr 22 10:25:31 2019
New Revision: 358902

URL: http://llvm.org/viewvc/llvm-project?rev=358902&view=rev
Log:
[OPENMP][NVPTX] Fix the test, NFC.

Fix the test to run it really in SPMD mode without runtime. Previously
it was run in SPMD + full runtime mode and does not allow to cehck the
functionality correctly.

Modified:
    openmp/trunk/libomptarget/deviceRTLs/nvptx/test/parallel/spmd_parallel_regions.cpp

Modified: openmp/trunk/libomptarget/deviceRTLs/nvptx/test/parallel/spmd_parallel_regions.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/libomptarget/deviceRTLs/nvptx/test/parallel/spmd_parallel_regions.cpp?rev=358902&r1=358901&r2=358902&view=diff
==============================================================================
--- openmp/trunk/libomptarget/deviceRTLs/nvptx/test/parallel/spmd_parallel_regions.cpp (original)
+++ openmp/trunk/libomptarget/deviceRTLs/nvptx/test/parallel/spmd_parallel_regions.cpp Mon Apr 22 10:25:31 2019
@@ -5,15 +5,25 @@
 
 int main(void) {
   int isHost = -1;
-  int ParallelLevel1, ParallelLevel2 = -1;
+  int ParallelLevel1 = -1, ParallelLevel2 = -1;
 
-#pragma omp target parallel map(from: isHost, ParallelLevel1, ParallelLevel2)
-  {
-    isHost = omp_is_initial_device();
-    ParallelLevel1 = omp_get_level();
-#pragma omp parallel for schedule(dynamic) lastprivate(ParallelLevel2)
+#pragma omp target parallel for map(tofrom                                     \
+                                    : isHost, ParallelLevel1, ParallelLevel2)
+  for (int J = 0; J < 10; ++J) {
+#pragma omp critical
+    {
+      isHost = (isHost < 0 || isHost == omp_is_initial_device())
+                   ? omp_is_initial_device()
+                   : 1;
+      ParallelLevel1 =
+          (ParallelLevel1 < 0 || ParallelLevel1 == 1) ? omp_get_level() : 2;
+    }
+    int L2;
+#pragma omp parallel for schedule(dynamic) lastprivate(L2)
     for (int I = 0; I < 10; ++I)
-      ParallelLevel2 = omp_get_level();
+      L2 = omp_get_level();
+#pragma omp critical
+    ParallelLevel2 = (ParallelLevel2 < 0 || ParallelLevel2 == 2) ? L2 : 1;
   }
 
   if (isHost < 0) {




More information about the Openmp-commits mailing list