| 1 |
/* { dg-do compile } */ |
| 2 |
|
| 3 |
#define N 100 |
| 4 |
|
| 5 |
int |
| 6 |
main (void) |
| 7 |
{ |
| 8 |
int x = 0; |
| 9 |
int y = 0; |
| 10 |
|
| 11 |
/* Test implicit default (nothing). */ |
| 12 |
#pragma omp metadirective \ |
| 13 |
when (device={arch("nvptx")}: barrier) |
| 14 |
x = 1; |
| 15 |
|
| 16 |
/* Test with multiple standalone directives. */ |
| 17 |
#pragma omp metadirective \ |
| 18 |
when (device={arch("nvptx")}: barrier) \ |
| 19 |
default (flush) |
| 20 |
x = 1; |
| 21 |
|
| 22 |
/* Test combining a standalone directive with one that takes a statement |
| 23 |
body. */ |
| 24 |
#pragma omp metadirective \ |
| 25 |
when (device={arch("nvptx")}: parallel) \ |
| 26 |
default (barrier) |
| 27 |
x = 1; |
| 28 |
|
| 29 |
/* Test combining a standalone directive with one that takes a for loop. */ |
| 30 |
#pragma omp metadirective \ |
| 31 |
when (device={arch("nvptx")}: parallel for) \ |
| 32 |
default (barrier) |
| 33 |
for (int i = 0; i < N; i++) |
| 34 |
x += i; |
| 35 |
|
| 36 |
/* Test combining a directive that takes a for loop with one that takes |
| 37 |
a regular statement body. */ |
| 38 |
#pragma omp metadirective \ |
| 39 |
when (device={arch("nvptx")}: parallel for) \ |
| 40 |
default (parallel) |
| 41 |
for (int i = 0; i < N; i++) |
| 42 |
x += i; |
| 43 |
|
| 44 |
/* Test labels inside statement body. */ |
| 45 |
#pragma omp metadirective \ |
| 46 |
when (device={arch("nvptx")}: teams num_teams(512)) \ |
| 47 |
when (device={arch("gcn")}: teams num_teams(256)) \ |
| 48 |
default (teams num_teams(4)) |
| 49 |
{ |
| 50 |
if (x) |
| 51 |
goto l1; |
| 52 |
else |
| 53 |
goto l2; |
| 54 |
l1: ; |
| 55 |
l2: ; |
| 56 |
} |
| 57 |
|
| 58 |
/* Test local labels inside statement body. */ |
| 59 |
#pragma omp metadirective \ |
| 60 |
when (device={arch("nvptx")}: teams num_teams(512)) \ |
| 61 |
when (device={arch("gcn")}: teams num_teams(256)) \ |
| 62 |
default (teams num_teams(4)) |
| 63 |
{ |
| 64 |
//__label__ l1, l2; |
| 65 |
|
| 66 |
if (x) |
| 67 |
goto l1; |
| 68 |
else |
| 69 |
goto l2; |
| 70 |
l1: ; |
| 71 |
l2: ; |
| 72 |
} |
| 73 |
|
| 74 |
return 0; |
| 75 |
} |