[llvm] Stop including unordered_map (NFC)
[llvm-project.git] / openmp / runtime / test / worksharing / for / omp_nonmonotonic_dynamic1.c
blob0691353fe59e57af3b29ca4e7b560f56479d4032
1 // RUN: %libomp-compile
2 // RUN: env OMP_SCHEDULE=nonmonotonic:dynamic,10 %libomp-run
4 // The test checks iterations distribution for OMP 5.0 nonmonotonic OMP_SCHEDULE
5 // case #threads > #chunks (fallback to monotonic dynamic)
7 #include <stdio.h>
8 #include <omp.h>
10 #define ITERS 100
11 #define CHUNK 10
12 int err = 0;
14 int main(int argc, char **argv) {
15 int i, ch, it[ITERS];
16 omp_set_num_threads(16); // #threads is bigger than #chunks
17 #pragma omp parallel for schedule(runtime)
18 for (i = 0; i < ITERS; ++i) {
19 it[i] = omp_get_thread_num();
21 // check that each chunk executed by single thread
22 for (ch = 0; ch < ITERS/CHUNK; ++ch) {
23 int iter = ch * CHUNK;
24 int nt = it[iter]; // thread number
25 for (i = 1; i < CHUNK; ++i) {
26 #if _DEBUG
27 printf("iter %d: (%d %d)\n", iter + i, nt, it[iter + i]);
28 #endif
29 if (nt != it[iter + i]) {
30 err++;
34 if (err > 0) {
35 printf("Failed, err = %d\n", err);
36 return 1;
38 printf("Passed\n");
39 return 0;