| 1 |
/* { dg-do run { target { ! offload_target_nvptx } } } */ |
| 2 |
/* { dg-do compile { target offload_target_nvptx } } */ |
| 3 |
|
| 4 |
#define N 100 |
| 5 |
|
| 6 |
void |
| 7 |
f (int x[], int y[], int z[]) |
| 8 |
{ |
| 9 |
int i; |
| 10 |
|
| 11 |
// The following fails as on the host the target side cannot be |
| 12 |
// resolved - and the 'teams' or not status affects how 'target' |
| 13 |
// is called. |
| 14 |
// Note also the dg-do compile above for offload_target_nvptx |
| 15 |
#pragma omp target map(to: x[0:N], y[0:N]) map(from: z[0:N]) |
| 16 |
#pragma omp metadirective \ |
| 17 |
when (device={arch("nvptx")}: teams loop) \ |
| 18 |
default (parallel loop) |
| 19 |
for (i = 0; i < N; i++) |
| 20 |
z[i] = x[i] * y[i]; |
| 21 |
/* { dg-bogus "'target' construct with nested 'teams' construct contains directives outside of the 'teams' construct" "PR118694" { xfail offload_target_nvptx } .-6 } */ |
| 22 |
} |
| 23 |
|
| 24 |
int |
| 25 |
main (void) |
| 26 |
{ |
| 27 |
int x[N], y[N], z[N]; |
| 28 |
int i; |
| 29 |
|
| 30 |
for (i = 0; i < N; i++) |
| 31 |
{ |
| 32 |
x[i] = i; |
| 33 |
y[i] = -i; |
| 34 |
} |
| 35 |
|
| 36 |
f (x, y, z); |
| 37 |
|
| 38 |
for (i = 0; i < N; i++) |
| 39 |
if (z[i] != x[i] * y[i]) |
| 40 |
return 1; |
| 41 |
|
| 42 |
return 0; |
| 43 |
} |