[Openmp-commits] [openmp] r252338 - Fix for zero chunk size

Jonathan Peyton via Openmp-commits openmp-commits at lists.llvm.org
Fri Nov 6 12:32:45 PST 2015


Author: jlpeyton
Date: Fri Nov  6 14:32:44 2015
New Revision: 252338

URL: http://llvm.org/viewvc/llvm-project?rev=252338&view=rev
Log:
Fix for zero chunk size

Setting dynamic schedule with chunk size 0 via omp_set_schedule(dynamic,0)
and then using "schedule (runtime)" causes infinite loop because for the 
chunked dynamic schedule we didn't correct zero chunk to the default (1).

Added:
    openmp/trunk/runtime/test/worksharing/for/bug_set_schedule_0.c   (with props)
Modified:
    openmp/trunk/runtime/src/kmp_dispatch.cpp

Modified: openmp/trunk/runtime/src/kmp_dispatch.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_dispatch.cpp?rev=252338&r1=252337&r2=252338&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_dispatch.cpp (original)
+++ openmp/trunk/runtime/src/kmp_dispatch.cpp Fri Nov  6 14:32:44 2015
@@ -1060,6 +1060,9 @@ __kmp_dispatch_init(
         break;
     case kmp_sch_static_chunked :
     case kmp_sch_dynamic_chunked :
+        if ( pr->u.p.parm1 <= 0 ) {
+            pr->u.p.parm1 = KMP_DEFAULT_CHUNK;
+        }
         KD_TRACE(100,("__kmp_dispatch_init: T#%d kmp_sch_static_chunked/kmp_sch_dynamic_chunked cases\n", gtid));
         break;
     case kmp_sch_trapezoidal :

Added: openmp/trunk/runtime/test/worksharing/for/bug_set_schedule_0.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/worksharing/for/bug_set_schedule_0.c?rev=252338&view=auto
==============================================================================
--- openmp/trunk/runtime/test/worksharing/for/bug_set_schedule_0.c (added)
+++ openmp/trunk/runtime/test/worksharing/for/bug_set_schedule_0.c Fri Nov  6 14:32:44 2015
@@ -0,0 +1,39 @@
+// RUN: %libomp-compile-and-run
+#include <stdio.h>
+#include <omp.h>
+#include "omp_testsuite.h"
+
+/* Test that the chunk size is set to default (1) when
+   chunk size <= 0 is specified */
+int a = 0;
+
+int test_set_schedule_0()
+{
+  a = 0;
+  omp_set_schedule(omp_sched_dynamic,0);
+
+  #pragma omp parallel
+  {
+    #pragma omp for schedule(runtime)
+    for(int i = 0; i < 10; i++) {
+      #pragma omp atomic
+      a++;
+      if(a > 10)
+        exit(1);
+    }
+  }    
+  return a==10;
+}
+
+int main()
+{
+  int i;
+  int num_failed=0;
+
+  for(i = 0; i < REPETITIONS; i++) {
+    if(!test_set_schedule_0()) {
+      num_failed++;
+    }
+  }
+  return num_failed;
+}

Propchange: openmp/trunk/runtime/test/worksharing/for/bug_set_schedule_0.c
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: openmp/trunk/runtime/test/worksharing/for/bug_set_schedule_0.c
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Rev URL

Propchange: openmp/trunk/runtime/test/worksharing/for/bug_set_schedule_0.c
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the Openmp-commits mailing list