[Openmp-commits] [PATCH] D124812: [OpenMP] Possible fix for sporadic test failure from loop_dispatch.c

Hansang Bae via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Mon May 2 16:08:43 PDT 2022


hbae created this revision.
hbae added a reviewer: protze.joachim.
hbae added a project: OpenMP.
Herald added subscribers: guansong, yaxunl.
Herald added a project: All.
hbae requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

Made the test wait until every thread has at least one loop iteration.
We may need to relax the check if this does not fix the problem.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124812

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


Index: openmp/runtime/test/ompt/worksharing/for/loop_dispatch.c
===================================================================
--- openmp/runtime/test/ompt/worksharing/for/loop_dispatch.c
+++ openmp/runtime/test/ompt/worksharing/for/loop_dispatch.c
@@ -9,22 +9,32 @@
 
 int main() {
   int i;
+  int wait_s = 0;
 
 #pragma omp parallel num_threads(4)
   {
+    int wait_id = 0;
 #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, 4);
+        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, 8);
+        wait_id++;
+      }
     }
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124812.426539.patch
Type: text/x-patch
Size: 1164 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220502/262e26ac/attachment.bin>


More information about the Openmp-commits mailing list