summaryrefslogtreecommitdiffstats
path: root/openmp/runtime/test
diff options
context:
space:
mode:
authorAndreyChurbanov <andrey.churbanov@intel.com>2019-11-27 15:26:51 +0300
committerAndreyChurbanov <andrey.churbanov@intel.com>2019-11-27 15:26:51 +0300
commitbd2fb41c2dd537d1ab0dbce5795a1fef3de6cd52 (patch)
tree54efca4c984ed33ea32a0056e3a7ddbc4202b852 /openmp/runtime/test
parent755dfaa1048ef216cfdce68b05185d8ab1b00ae7 (diff)
downloadbcm5719-llvm-bd2fb41c2dd537d1ab0dbce5795a1fef3de6cd52.tar.gz
bcm5719-llvm-bd2fb41c2dd537d1ab0dbce5795a1fef3de6cd52.zip
[openmp] Fixed nonmonotonic schedule when #threads > #chunks in a loop.
Differential Revision: https://reviews.llvm.org/D70713
Diffstat (limited to 'openmp/runtime/test')
-rw-r--r--openmp/runtime/test/worksharing/for/omp_nonmonotonic_dynamic1.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/openmp/runtime/test/worksharing/for/omp_nonmonotonic_dynamic1.c b/openmp/runtime/test/worksharing/for/omp_nonmonotonic_dynamic1.c
new file mode 100644
index 00000000000..0691353fe59
--- /dev/null
+++ b/openmp/runtime/test/worksharing/for/omp_nonmonotonic_dynamic1.c
@@ -0,0 +1,40 @@
+// RUN: %libomp-compile
+// RUN: env OMP_SCHEDULE=nonmonotonic:dynamic,10 %libomp-run
+
+// The test checks iterations distribution for OMP 5.0 nonmonotonic OMP_SCHEDULE
+// case #threads > #chunks (fallback to monotonic dynamic)
+
+#include <stdio.h>
+#include <omp.h>
+
+#define ITERS 100
+#define CHUNK 10
+int err = 0;
+
+int main(int argc, char **argv) {
+ int i, ch, it[ITERS];
+ omp_set_num_threads(16); // #threads is bigger than #chunks
+#pragma omp parallel for schedule(runtime)
+ for (i = 0; i < ITERS; ++i) {
+ it[i] = omp_get_thread_num();
+ }
+ // check that each chunk executed by single thread
+ for (ch = 0; ch < ITERS/CHUNK; ++ch) {
+ int iter = ch * CHUNK;
+ int nt = it[iter]; // thread number
+ for (i = 1; i < CHUNK; ++i) {
+#if _DEBUG
+ printf("iter %d: (%d %d)\n", iter + i, nt, it[iter + i]);
+#endif
+ if (nt != it[iter + i]) {
+ err++;
+ }
+ }
+ }
+ if (err > 0) {
+ printf("Failed, err = %d\n", err);
+ return 1;
+ }
+ printf("Passed\n");
+ return 0;
+}
OpenPOWER on IntegriCloud