[Openmp-commits] [openmp] 7e23b46 - [OpenMP] Possible fix for sporadic test failure from loop_dispatch.c

Hansang Bae via Openmp-commits openmp-commits at lists.llvm.org
Tue May 3 12:47:19 PDT 2022


Author: Hansang Bae
Date: 2022-05-03T14:46:32-05:00
New Revision: 7e23b46ab8da7ccd038a0987e947e4bec5ce2d4b

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

LOG: [OpenMP] Possible fix for sporadic test failure from loop_dispatch.c

This patch tries to fix sporadic test failure after the change
https://reviews.llvm.org/D122107.
Made the test wait until every thread has at least one loop iteration.

Differential Revision: https://reviews.llvm.org/D124812

Added: 
    

Modified: 
    openmp/runtime/test/ompt/worksharing/for/loop_dispatch.c

Removed: 
    


################################################################################
diff  --git a/openmp/runtime/test/ompt/worksharing/for/loop_dispatch.c b/openmp/runtime/test/ompt/worksharing/for/loop_dispatch.c
index 9fe3616847adf..2bd8af427f61d 100644
--- a/openmp/runtime/test/ompt/worksharing/for/loop_dispatch.c
+++ b/openmp/runtime/test/ompt/worksharing/for/loop_dispatch.c
@@ -9,22 +9,33 @@
 
 int main() {
   int i;
+  int wait_s = 0;
 
 #pragma omp parallel num_threads(4)
   {
+    int wait_id = 0;
+    int team_size = omp_get_num_threads();
 #pragma omp for schedule(static, WORK_SIZE / 4)
     for (i = 0; i < WORK_SIZE; i++) {}
 
 #pragma omp for schedule(dynamic)
     for (i = 0; i < WORK_SIZE; i++) {
-      // Make every iteration takes at least 1ms.
-      delay(1000);
+      if (wait_id == 0) {
+        // Wait until every thread has at least one iteration assigned
+        OMPT_SIGNAL(wait_s);
+        OMPT_WAIT(wait_s, team_size);
+        wait_id++;
+      }
     }
 
 #pragma omp for schedule(guided)
     for (i = 0; i < WORK_SIZE; i++) {
-      // Make every iteration takes at least 1ms.
-      delay(1000);
+      if (wait_id == 1) {
+        // Wait until every thread has at least one iteration assigned
+        OMPT_SIGNAL(wait_s);
+        OMPT_WAIT(wait_s, 2 * team_size);
+        wait_id++;
+      }
     }
   }
 


        


More information about the Openmp-commits mailing list