[llvm] Stop including unordered_map (NFC)
[llvm-project.git] / openmp / runtime / test / env / kmp_set_dispatch_buf.c
blob539bb5a819783f3f42aa435c4038e4fe202dd1fd
1 // RUN: %libomp-compile
2 // RUN: env KMP_DISP_NUM_BUFFERS=0 %libomp-run
3 // RUN: env KMP_DISP_NUM_BUFFERS=1 %libomp-run
4 // RUN: env KMP_DISP_NUM_BUFFERS=3 %libomp-run
5 // RUN: env KMP_DISP_NUM_BUFFERS=4 %libomp-run
6 // RUN: env KMP_DISP_NUM_BUFFERS=7 %libomp-run
7 // RUN: %libomp-compile -DMY_SCHEDULE=guided
8 // RUN: env KMP_DISP_NUM_BUFFERS=1 %libomp-run
9 // RUN: env KMP_DISP_NUM_BUFFERS=3 %libomp-run
10 // RUN: env KMP_DISP_NUM_BUFFERS=4 %libomp-run
11 // RUN: env KMP_DISP_NUM_BUFFERS=7 %libomp-run
12 // UNSUPPORTED: clang-11, clang-12
13 #include <stdio.h>
14 #include <omp.h>
15 #include <stdlib.h>
16 #include <limits.h>
17 #include "omp_testsuite.h"
19 #define INCR 7
20 #define MY_MAX 200
21 #define MY_MIN -200
22 #define NUM_LOOPS 100
23 #ifndef MY_SCHEDULE
24 # define MY_SCHEDULE dynamic
25 #endif
27 int a, b, a_known_value, b_known_value;
29 int test_kmp_set_disp_num_buffers()
31 int success = 1;
32 a = 0;
33 b = 0;
34 // run many small dynamic loops to stress the dispatch buffer system
35 #pragma omp parallel
37 int i,j;
38 for (j = 0; j < NUM_LOOPS; j++) {
39 #pragma omp for schedule(MY_SCHEDULE) nowait
40 for (i = MY_MIN; i < MY_MAX; i+=INCR) {
41 #pragma omp atomic
42 a++;
44 #pragma omp for schedule(MY_SCHEDULE) nowait
45 for (i = MY_MAX; i >= MY_MIN; i-=INCR) {
46 #pragma omp atomic
47 b++;
51 // detect failure
52 if (a != a_known_value || b != b_known_value) {
53 success = 0;
54 printf("a = %d (should be %d), b = %d (should be %d)\n", a, a_known_value,
55 b, b_known_value);
57 return success;
60 int main(int argc, char** argv)
62 int i,j;
63 int num_failed=0;
65 // figure out the known values to compare with calculated result
66 a_known_value = 0;
67 b_known_value = 0;
69 for (j = 0; j < NUM_LOOPS; j++) {
70 for (i = MY_MIN; i < MY_MAX; i+=INCR)
71 a_known_value++;
72 for (i = MY_MAX; i >= MY_MIN; i-=INCR)
73 b_known_value++;
76 for(i = 0; i < REPETITIONS; i++) {
77 if(!test_kmp_set_disp_num_buffers()) {
78 num_failed++;
81 if (num_failed == 0)
82 printf("passed\n");
83 else
84 printf("failed %d\n", num_failed);
85 return num_failed;