| 1 |
/* { dg-do compile } */ |
| 2 |
|
| 3 |
/* This test case is expected to fail due to errors. */ |
| 4 |
|
| 5 |
#define N 30 |
| 6 |
#define M 3 |
| 7 |
|
| 8 |
int a[N][M], b[N][M], c[N][M]; |
| 9 |
|
| 10 |
extern void dostuff (int, int); |
| 11 |
|
| 12 |
/* good1 and good2 should compile without error. */ |
| 13 |
void |
| 14 |
good1 (void) |
| 15 |
{ |
| 16 |
int x, shift; |
| 17 |
|
| 18 |
x = 0; |
| 19 |
#pragma omp parallel for simd collapse(2) reduction(inscan,+: x) private(shift) |
| 20 |
for (int i = 0; i < N; i++) |
| 21 |
{ |
| 22 |
for (int j = 0; j < M; j++) |
| 23 |
{ |
| 24 |
x += a[i][j]; |
| 25 |
x += b[i][j]; |
| 26 |
#pragma omp scan inclusive(x) |
| 27 |
shift = i + 29*j; |
| 28 |
c[i][j] = x + shift; |
| 29 |
} |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
void |
| 34 |
good2 (void) |
| 35 |
{ |
| 36 |
int x, shift; |
| 37 |
x = 0; |
| 38 |
|
| 39 |
#pragma omp parallel for simd collapse(2) reduction(inscan,+: x) private(shift) |
| 40 |
for (int i = 0; i < N; i++) |
| 41 |
{ |
| 42 |
for (int j = 0; j < M; j++) |
| 43 |
{ |
| 44 |
shift = i + 29*j; |
| 45 |
c[i][j] = x + shift; |
| 46 |
#pragma omp scan exclusive(x) |
| 47 |
x += a[i][j]; |
| 48 |
x += b[i][j]; |
| 49 |
} |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
/* Adding intervening code should trigger an error. */ |
| 54 |
|
| 55 |
void |
| 56 |
bad1 (void) |
| 57 |
{ |
| 58 |
int x, shift; |
| 59 |
|
| 60 |
x = 0; |
| 61 |
#pragma omp parallel for simd collapse(2) reduction(inscan,+: x) private(shift) |
| 62 |
for (int i = 0; i < N; i++) /* { dg-error "inner loops must be perfectly nested" } */ |
| 63 |
{ |
| 64 |
dostuff (i, 0); |
| 65 |
for (int j = 0; j < M; j++) |
| 66 |
{ |
| 67 |
x += a[i][j]; |
| 68 |
x += b[i][j]; |
| 69 |
#pragma omp scan inclusive(x) |
| 70 |
shift = i + 29*j; |
| 71 |
c[i][j] = x + shift; |
| 72 |
} |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
void |
| 77 |
bad2 (void) |
| 78 |
{ |
| 79 |
int x, shift; |
| 80 |
x = 0; |
| 81 |
|
| 82 |
#pragma omp parallel for simd collapse(2) reduction(inscan,+: x) private(shift) |
| 83 |
for (int i = 0; i < N; i++) /* { dg-error "inner loops must be perfectly nested" } */ |
| 84 |
{ |
| 85 |
for (int j = 0; j < M; j++) |
| 86 |
{ |
| 87 |
shift = i + 29*j; |
| 88 |
c[i][j] = x + shift; |
| 89 |
#pragma omp scan exclusive(x) |
| 90 |
x += a[i][j]; |
| 91 |
x += b[i][j]; |
| 92 |
} |
| 93 |
dostuff (i, 1); |
| 94 |
} |
| 95 |
} |