1 // RUN: %libomp-compile -DMY_SCHEDULE=static && %libomp-run
2 // RUN: %libomp-compile -DMY_SCHEDULE=dynamic && %libomp-run
3 // RUN: %libomp-compile -DMY_SCHEDULE=guided && %libomp-run
5 // Only works with Intel Compiler since at least version 15.0 and clang since
8 // XFAIL: gcc, clang-3, clang-4, clang-5, clang-6, clang-7, clang-8, clang-9, clang-10
10 // icc 21 seems to have an issue with the loop boundaries and runs very long
11 // UNSUPPORTED: icc-21
14 * Test that large bounds are handled properly and calculations of
15 * loop iterations don't accidentally overflow
21 #include "omp_testsuite.h"
24 #define MY_MAX 2000000000
25 #define MY_MIN -2000000000
27 # define MY_SCHEDULE static
30 int a
, b
, a_known_value
, b_known_value
;
32 int test_omp_for_bigbounds()
39 #pragma omp for schedule(MY_SCHEDULE) reduction(+:a)
40 for (i
= INT_MIN
; i
< MY_MAX
; i
+=INCR
) {
43 #pragma omp for schedule(MY_SCHEDULE) reduction(+:b)
44 for (i
= INT_MAX
; i
>= MY_MIN
; i
-=INCR
) {
48 printf("a = %d (should be %d), b = %d (should be %d)\n", a
, a_known_value
, b
, b_known_value
);
49 return (a
== a_known_value
&& b
== b_known_value
);
58 for (i
= INT_MIN
; i
< MY_MAX
; i
+=INCR
) {
63 for (i
= INT_MAX
; i
>= MY_MIN
; i
-=INCR
) {
67 for(i
= 0; i
< REPETITIONS
; i
++) {
68 if(!test_omp_for_bigbounds()) {