| 1 | // RUN: %libomp-compile-and-run |
| 2 | #include <stdio.h> |
| 3 | #include <stdlib.h> |
| 4 | |
| 5 | int a; |
| 6 | |
| 7 | void run(int nteams, int nth) { |
| 8 | a = 0; |
| 9 | #pragma omp teams num_teams(nteams) |
| 10 | { |
| 11 | #pragma omp parallel num_threads(nth) |
| 12 | { |
| 13 | #pragma omp task |
| 14 | { |
| 15 | #pragma omp atomic |
| 16 | a++; |
| 17 | } |
| 18 | } |
| 19 | } |
| 20 | if (a == 0) |
| 21 | exit(EXIT_FAILURE); |
| 22 | } |
| 23 | |
| 24 | int main() { |
| 25 | int i, nteams, nth; |
| 26 | for (nteams = 1; nteams <= 2; ++nteams) |
| 27 | for (nth = 1; nth <= 3; ++nth) |
| 28 | for (i = 0; i < 10; ++i) { |
| 29 | printf(format: "run(%d, %d)\n" , nteams, nth); |
| 30 | run(nteams, nth); |
| 31 | } |
| 32 | return EXIT_SUCCESS; |
| 33 | } |
| 34 | |