diff options
-rw-r--r-- | openmp/runtime/src/kmp_dispatch.cpp | 3 | ||||
-rw-r--r-- | openmp/runtime/test/worksharing/for/bug_set_schedule_0.c | 39 |
2 files changed, 42 insertions, 0 deletions
diff --git a/openmp/runtime/src/kmp_dispatch.cpp b/openmp/runtime/src/kmp_dispatch.cpp index a1d0fc44f2b..b0d472c40ec 100644 --- a/openmp/runtime/src/kmp_dispatch.cpp +++ b/openmp/runtime/src/kmp_dispatch.cpp @@ -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 : diff --git a/openmp/runtime/test/worksharing/for/bug_set_schedule_0.c b/openmp/runtime/test/worksharing/for/bug_set_schedule_0.c new file mode 100644 index 00000000000..2d39cddd1c4 --- /dev/null +++ b/openmp/runtime/test/worksharing/for/bug_set_schedule_0.c @@ -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; +} |