[Instrumentation] Fix a warning
[llvm-project.git] / openmp / runtime / test / worksharing / for / omp_for_bigbounds.c
blobc6f1693a8d227accd5e3581715f261a64cc5bc8d
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
6 // version 11.
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
17 #include <stdio.h>
18 #include <omp.h>
19 #include <stdlib.h>
20 #include <limits.h>
21 #include "omp_testsuite.h"
23 #define INCR 50000000
24 #define MY_MAX 2000000000
25 #define MY_MIN -2000000000
26 #ifndef MY_SCHEDULE
27 # define MY_SCHEDULE static
28 #endif
30 int a, b, a_known_value, b_known_value;
32 int test_omp_for_bigbounds()
34 a = 0;
35 b = 0;
36 #pragma omp parallel
38 int i;
39 #pragma omp for schedule(MY_SCHEDULE) reduction(+:a)
40 for (i = INT_MIN; i < MY_MAX; i+=INCR) {
41 a++;
43 #pragma omp for schedule(MY_SCHEDULE) reduction(+:b)
44 for (i = INT_MAX; i >= MY_MIN; i-=INCR) {
45 b++;
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);
52 int main()
54 int i;
55 int num_failed=0;
57 a_known_value = 0;
58 for (i = INT_MIN; i < MY_MAX; i+=INCR) {
59 a_known_value++;
62 b_known_value = 0;
63 for (i = INT_MAX; i >= MY_MIN; i-=INCR) {
64 b_known_value++;
67 for(i = 0; i < REPETITIONS; i++) {
68 if(!test_omp_for_bigbounds()) {
69 num_failed++;
72 return num_failed;