| 1 | // RUN: %libomptarget-compile-generic |
| 2 | // RUN: %libomptarget-compileopt-generic |
| 3 | |
| 4 | #include <stdio.h> |
| 5 | #define N 10 |
| 6 | |
| 7 | int main(void) { |
| 8 | long int aa = 0; |
| 9 | int res = 0; |
| 10 | |
| 11 | int ng = 12; |
| 12 | int cmom = 14; |
| 13 | int nxyz = 5000; |
| 14 | |
| 15 | #pragma omp target teams distribute num_teams(nxyz) \ |
| 16 | thread_limit(ng *(cmom - 1)) map(tofrom : aa) |
| 17 | for (int gid = 0; gid < nxyz; gid++) { |
| 18 | #pragma omp parallel for collapse(2) |
| 19 | for (unsigned int g = 0; g < ng; g++) { |
| 20 | for (unsigned int l = 0; l < cmom - 1; l++) { |
| 21 | int a = 0; |
| 22 | #pragma omp parallel for reduction(+ : a) |
| 23 | for (int i = 0; i < N; i++) { |
| 24 | a += i; |
| 25 | } |
| 26 | #pragma omp atomic |
| 27 | aa += a; |
| 28 | } |
| 29 | } |
| 30 | } |
| 31 | long exp = (long)ng * (cmom - 1) * nxyz * (N * (N - 1) / 2); |
| 32 | printf(format: "The result is = %ld exp:%ld!\n" , aa, exp); |
| 33 | if (aa != exp) { |
| 34 | printf(format: "Failed %ld\n" , aa); |
| 35 | return 1; |
| 36 | } |
| 37 | // CHECK: Success |
| 38 | printf(format: "Success\n" ); |
| 39 | return 0; |
| 40 | } |
| 41 | |