| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-additional-options "-msse2" { target sse2_runtime } } */ |
| 3 |
/* { dg-additional-options "-mavx" { target avx_runtime } } */ |
| 4 |
/* { dg-additional-options "-std=c99" { target c } } */ |
| 5 |
|
| 6 |
static inline void |
| 7 |
foo (int *b, int *i, int *j, int x) |
| 8 |
{ |
| 9 |
*b = *b + x + (*i - *i) + (*j - *j); |
| 10 |
} |
| 11 |
|
| 12 |
int |
| 13 |
main () |
| 14 |
{ |
| 15 |
int b, c = 0; |
| 16 |
b = 7; |
| 17 |
#pragma omp simd linear(b:2) reduction(+:c) |
| 18 |
for (int i = 0; i < 64; i++) |
| 19 |
{ |
| 20 |
c = c + (b != 7 + 2 * i); |
| 21 |
foo (&b, &i, &i, 2); |
| 22 |
} |
| 23 |
if (c || b != 7 + 64 * 2) |
| 24 |
__builtin_abort (); |
| 25 |
b = 7; |
| 26 |
#pragma omp simd linear(b:3) reduction(+:c) |
| 27 |
for (int i = 0; i < 64; i += 4) |
| 28 |
{ |
| 29 |
c = c + (b != 7 + i / 4 * 3); |
| 30 |
foo (&b, &i, &i, 3); |
| 31 |
} |
| 32 |
if (c || b != 7 + 16 * 3) |
| 33 |
__builtin_abort (); |
| 34 |
b = 7; |
| 35 |
#pragma omp simd collapse (2) linear(b:2) reduction(+:c) |
| 36 |
for (int i = 0; i < 8; i++) |
| 37 |
for (int j = 0; j < 8; j++) |
| 38 |
{ |
| 39 |
c = c + (b != 7 + 2 * j + 2 * 8 * i); |
| 40 |
foo (&b, &i, &j, 2); |
| 41 |
} |
| 42 |
if (c || b != 7 + 64 * 2) |
| 43 |
__builtin_abort (); |
| 44 |
b = 7; |
| 45 |
#pragma omp parallel for simd schedule (static, 4) linear(b:2) reduction(+:c) |
| 46 |
for (int i = 0; i < 64; i++) |
| 47 |
{ |
| 48 |
c = c + (b != 7 + 2 * i); |
| 49 |
foo (&b, &i, &i, 2); |
| 50 |
} |
| 51 |
if (c || b != 7 + 64 * 2) |
| 52 |
__builtin_abort (); |
| 53 |
b = 7; |
| 54 |
#pragma omp parallel for simd schedule (static, 4) linear(b:3) reduction(+:c) |
| 55 |
for (int i = 0; i < 64; i += 4) |
| 56 |
{ |
| 57 |
c = c + (b != 7 + i / 4 * 3); |
| 58 |
foo (&b, &i, &i, 3); |
| 59 |
} |
| 60 |
if (c || b != 7 + 16 * 3) |
| 61 |
__builtin_abort (); |
| 62 |
b = 7; |
| 63 |
#pragma omp parallel for simd collapse (2) schedule (static, 4) linear(b:2) reduction(+:c) |
| 64 |
for (int i = 0; i < 8; i++) |
| 65 |
for (int j = 0; j < 8; j++) |
| 66 |
{ |
| 67 |
c = c + (b != 7 + 2 * j + 2 * 8 * i); |
| 68 |
foo (&b, &i, &j, 2); |
| 69 |
} |
| 70 |
if (c || b != 7 + 64 * 2) |
| 71 |
__builtin_abort (); |
| 72 |
return 0; |
| 73 |
} |