| 1 | // RUN: %libomp-compile-and-run |
| 2 | |
| 3 | // XFAIL: icc |
| 4 | // UNSUPPORTED: clang-4, clang-5, clang-6, clang-7, clang-8, clang-9, clang-10 |
| 5 | // UNSUPPORTED: gcc-4, gcc-5, gcc-6, gcc-7, gcc-8 |
| 6 | |
| 7 | #include <stdio.h> |
| 8 | #include <stdlib.h> |
| 9 | |
| 10 | int a = 0, b = 1; |
| 11 | |
| 12 | int main(int argc, char **argv) { |
| 13 | |
| 14 | #pragma omp parallel reduction(task, +:a) reduction(task, *:b) |
| 15 | { |
| 16 | #pragma omp single |
| 17 | { |
| 18 | int i; |
| 19 | for (i = 1; i <= 5; ++i) { |
| 20 | #pragma omp task in_reduction(+: a) in_reduction(*: b) |
| 21 | { |
| 22 | a += i; |
| 23 | b *= i; |
| 24 | } |
| 25 | } |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | if (a != 15) { |
| 30 | fprintf(stderr, format: "error: a != 15. Instead a = %d\n" , a); |
| 31 | exit(EXIT_FAILURE); |
| 32 | } |
| 33 | if (b != 120) { |
| 34 | fprintf(stderr, format: "error: b != 120. Instead b = %d\n" , b); |
| 35 | exit(EXIT_FAILURE); |
| 36 | } |
| 37 | |
| 38 | return EXIT_SUCCESS; |
| 39 | } |
| 40 | |