[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.

git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@358902 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/libomptarget/deviceRTLs/nvptx/test/parallel/spmd_parallel_regions.cpp b/libomptarget/deviceRTLs/nvptx/test/parallel/spmd_parallel_regions.cpp
index bf5843b..3e08d1d 100644
--- a/libomptarget/deviceRTLs/nvptx/test/parallel/spmd_parallel_regions.cpp
+++ b/libomptarget/deviceRTLs/nvptx/test/parallel/spmd_parallel_regions.cpp
@@ -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) {