| 1 |
/* { dg-do compile { target c++11 } } */ |
| 2 |
|
| 3 |
/* This test case is expected to fail due to errors. */ |
| 4 |
|
| 5 |
int f1 (int depth, int iter); |
| 6 |
int f2 (int depth, int iter); |
| 7 |
int ijk (int x, int y, int z); |
| 8 |
void f3 (int sum); |
| 9 |
|
| 10 |
/* This function isn't particularly meaningful, but it should compile without |
| 11 |
error. */ |
| 12 |
int s1 (int a1, int a2, int a3) |
| 13 |
{ |
| 14 |
int i, j, k; |
| 15 |
int r = 0; |
| 16 |
|
| 17 |
[[ omp :: directive (simd, collapse(3), reduction (inscan, +:r)) ]] |
| 18 |
for (i = 0; i < a1; i++) |
| 19 |
{ |
| 20 |
for (j = 0; j < a2; j++) |
| 21 |
{ |
| 22 |
for (k = 0; k < a3; k++) |
| 23 |
{ |
| 24 |
r = r + ijk (i, j, k); |
| 25 |
[[ omp :: directive (scan, exclusive (r)) ]] ; |
| 26 |
f3 (r); |
| 27 |
} |
| 28 |
} |
| 29 |
} |
| 30 |
return r; |
| 31 |
} |
| 32 |
|
| 33 |
/* Adding intervening code should trigger an error. */ |
| 34 |
int s2 (int a1, int a2, int a3) |
| 35 |
{ |
| 36 |
int i, j, k; |
| 37 |
int r = 0; |
| 38 |
|
| 39 |
[[ omp :: directive (simd, collapse(3), reduction (inscan, +:r)) ]] |
| 40 |
for (i = 0; i < a1; i++) /* { dg-error "inner loops must be perfectly nested" } */ |
| 41 |
{ |
| 42 |
f1 (0, i); |
| 43 |
for (j = 0; j < a2; j++) |
| 44 |
{ |
| 45 |
f1 (1, j); |
| 46 |
for (k = 0; k < a3; k++) |
| 47 |
{ |
| 48 |
r = r + ijk (i, j, k); |
| 49 |
[[ omp :: directive (scan, exclusive (r)) ]] ; |
| 50 |
f3 (r); |
| 51 |
} |
| 52 |
f2 (1, j); |
| 53 |
} |
| 54 |
f2 (0, i); |
| 55 |
} |
| 56 |
return r; |
| 57 |
} |