[Openmp-commits] [openmp] f3ff0a6 - [OpenMP][FIX] Ensure test runs correct with (at least) 2 threads

Johannes Doerfert via Openmp-commits openmp-commits at lists.llvm.org
Sun Oct 22 13:22:51 PDT 2023


Author: Johannes Doerfert
Date: 2023-10-22T13:22:36-07:00
New Revision: f3ff0a67be46f2380ca597d21fe551cf2bbf41fd

URL: https://github.com/llvm/llvm-project/commit/f3ff0a67be46f2380ca597d21fe551cf2bbf41fd
DIFF: https://github.com/llvm/llvm-project/commit/f3ff0a67be46f2380ca597d21fe551cf2bbf41fd.diff

LOG: [OpenMP][FIX] Ensure test runs correct with (at least) 2 threads

Added: 
    

Modified: 
    openmp/libomptarget/test/offloading/thread_state_1.c

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/test/offloading/thread_state_1.c b/openmp/libomptarget/test/offloading/thread_state_1.c
index 4d31214553e8e79..a53e90882470589 100644
--- a/openmp/libomptarget/test/offloading/thread_state_1.c
+++ b/openmp/libomptarget/test/offloading/thread_state_1.c
@@ -8,23 +8,29 @@
 
 int main() {
   // TODO: Test all ICVs on all levels
-  int lvl = 333, tid = 666, nt = 999;
-#pragma omp target teams map(tofrom : lvl, tid, nt) num_teams(2)
+  int o_lvl = 111, i_lvl = 222, o_tid = 333, i_tid = 333, o_nt = 444,
+      i_nt = 555;
+#pragma omp target teams map(tofrom : o_lvl, i_lvl, o_tid, i_tid, o_nt, i_nt)  \
+    num_teams(2) thread_limit(2)
   {
     if (omp_get_team_num() == 0) {
 #pragma omp parallel num_threads(128)
-      if (omp_get_thread_num() == 17) {
+      if (omp_get_thread_num() == omp_get_num_threads() - 1) {
+        o_lvl = omp_get_level();
+        o_tid = omp_get_thread_num();
+        o_nt = omp_get_num_threads();
 #pragma omp parallel num_threads(64)
         if (omp_get_thread_num() == omp_get_num_threads() - 1) {
-          lvl = omp_get_level();
-          tid = omp_get_thread_num();
-          nt = omp_get_num_threads();
+          i_lvl = omp_get_level();
+          i_tid = omp_get_thread_num();
+          i_nt = omp_get_num_threads();
         }
       }
     }
   }
-  // TODO: This is wrong, but at least it doesn't crash
-  // CHECK: lvl: 2, tid: 0, nt: 1
-  printf("lvl: %i, tid: %i, nt: %i\n", lvl, tid, nt);
+  // CHECK: outer: lvl: 1, tid: 1, nt: 2
+  // CHECK: inner: lvl: 2, tid: 0, nt: 1
+  printf("outer: lvl: %i, tid: %i, nt: %i\n", o_lvl, o_tid, o_nt);
+  printf("inner: lvl: %i, tid: %i, nt: %i\n", i_lvl, i_tid, i_nt);
   return 0;
 }


        


More information about the Openmp-commits mailing list