1 // RUN: %libomptarget-compilexx-run-and-check-generic
2 // RUN: %libomptarget-compileoptxx-run-and-check-generic
4 // TODO: This requires malloc support for the threads states.
5 // UNSUPPORTED: amdgcn-amd-amdhsa
11 int isCPU() { return 1; }
13 #pragma omp begin declare variant match(device = {kind(gpu)})
14 int isCPU() { return 0; }
15 #pragma omp end declare variant
25 #pragma omp target map(from : nxyz, ng, cmom)
27 nxyz
= isCPU() ? 2 : 5000;
28 ng
= isCPU() ? 2 : 12;
29 cmom
= isCPU() ? 2 : 14;
32 #pragma omp target teams distribute num_teams(nxyz) \
33 thread_limit(ng *(cmom - 1)) map(tofrom : aa)
34 for (int gid
= 0; gid
< nxyz
; gid
++) {
35 #pragma omp parallel for collapse(2)
36 for (unsigned int g
= 0; g
< ng
; g
++) {
37 for (unsigned int l
= 0; l
< cmom
- 1; l
++) {
39 #pragma omp parallel for reduction(+ : a)
40 for (int i
= 0; i
< N
; i
++) {
48 long exp
= (long)ng
* (cmom
- 1) * nxyz
* (N
* (N
- 1) / 2);
49 printf("The result is = %ld exp:%ld!\n", aa
, exp
);
51 printf("Failed %ld\n", aa
);