1 // RUN: %libomp-compile && %libomp-run 7
2 // RUN: %libomp-run 0 && %libomp-run -1
3 // RUN: %libomp-run 1 && %libomp-run 2 && %libomp-run 5
4 // RUN: %libomp-compile -DMY_SCHEDULE=guided && %libomp-run 7
5 // RUN: %libomp-run 1 && %libomp-run 2 && %libomp-run 5
6 // UNSUPPORTED: clang-11, clang-12
11 #include "omp_testsuite.h"
17 # define MY_SCHEDULE dynamic
20 int num_disp_buffers
, num_loops
;
21 int a
, b
, a_known_value
, b_known_value
;
23 int test_kmp_set_disp_num_buffers()
28 // run many small dynamic loops to stress the dispatch buffer system
32 for (j
= 0; j
< num_loops
; j
++) {
33 #pragma omp for schedule(MY_SCHEDULE) nowait
34 for (i
= MY_MIN
; i
< MY_MAX
; i
+=INCR
) {
38 #pragma omp for schedule(MY_SCHEDULE) nowait
39 for (i
= MY_MAX
; i
>= MY_MIN
; i
-=INCR
) {
46 if (a
!= a_known_value
|| b
!= b_known_value
) {
48 printf("a = %d (should be %d), b = %d (should be %d)\n", a
, a_known_value
,
54 int main(int argc
, char** argv
)
60 fprintf(stderr
, "usage: %s num_disp_buffers\n", argv
[0]);
64 // set the number of dispatch buffers
65 num_disp_buffers
= atoi(argv
[1]);
66 kmp_set_disp_num_buffers(num_disp_buffers
);
68 // figure out the known values to compare with calculated result
72 // if specified to use bad num_disp_buffers set num_loops
73 // to something reasonable
74 if (num_disp_buffers
<= 0)
77 num_loops
= num_disp_buffers
*10;
79 for (j
= 0; j
< num_loops
; j
++) {
80 for (i
= MY_MIN
; i
< MY_MAX
; i
+=INCR
)
82 for (i
= MY_MAX
; i
>= MY_MIN
; i
-=INCR
)
86 for(i
= 0; i
< REPETITIONS
; i
++) {
87 if(!test_kmp_set_disp_num_buffers()) {
94 printf("failed %d\n", num_failed
);