| 1 |
extern "C" void abort (); |
| 2 |
int w; |
| 3 |
struct S { |
| 4 |
int s, &t; |
| 5 |
int *p; |
| 6 |
S (int *x) : s (0), t (w), p(x) {}; |
| 7 |
void foo (short &); |
| 8 |
void bar (short &); |
| 9 |
void baz (short &); |
| 10 |
void qux (short &); |
| 11 |
}; |
| 12 |
|
| 13 |
void |
| 14 |
S::foo (short &x) |
| 15 |
{ |
| 16 |
#pragma omp simd lastprivate (conditional: x, s, t) |
| 17 |
for (int i = 0; i < 1025; ++i) |
| 18 |
{ |
| 19 |
if (p[i]) |
| 20 |
x = i; |
| 21 |
if (p[i + 1025]) |
| 22 |
s = i + 3; |
| 23 |
if (p[i + 2 * 1025]) |
| 24 |
t = i + 6; |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
void |
| 29 |
S::bar (short &x) |
| 30 |
{ |
| 31 |
#pragma omp simd lastprivate (conditional: x, s, t) collapse (3) if (0) |
| 32 |
for (int i = 0; i < 15; ++i) |
| 33 |
for (int j = -4; j < 9; j++) |
| 34 |
for (int k = 12; k > 7; --k) |
| 35 |
{ |
| 36 |
int l = (k - 8) + (j + 4) * 5 + i * 13 * 5; |
| 37 |
if (p[l]) |
| 38 |
x = l; |
| 39 |
if (p[l + 1025]) |
| 40 |
s = l + 3; |
| 41 |
if (p[l + 1025 * 2]) |
| 42 |
t = l + 6; |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
void |
| 47 |
S::baz (short &x) |
| 48 |
{ |
| 49 |
#pragma omp parallel for simd lastprivate (conditional: x, s, t) if (simd: 0) |
| 50 |
for (int i = 0; i < 1025; ++i) |
| 51 |
{ |
| 52 |
if (p[i]) |
| 53 |
x = i; |
| 54 |
if (p[i + 1025]) |
| 55 |
s = i + 3; |
| 56 |
if (p[i + 2 * 1025]) |
| 57 |
t = i + 6; |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
void |
| 62 |
S::qux (short &x) |
| 63 |
{ |
| 64 |
#pragma omp for simd lastprivate (conditional: x, s, t) collapse (3) schedule (simd: guided, 8) |
| 65 |
for (int i = 0; i < 15; ++i) |
| 66 |
for (int j = -4; j < 9; j++) |
| 67 |
for (int k = 12; k > 7; --k) |
| 68 |
{ |
| 69 |
int l = (k - 8) + (j + 4) * 5 + i * 13 * 5; |
| 70 |
if (p[l]) |
| 71 |
x = l; |
| 72 |
if (p[l + 1025]) |
| 73 |
s = l + 3; |
| 74 |
if (p[l + 1025 * 2]) |
| 75 |
t = l + 6; |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
int |
| 80 |
main () |
| 81 |
{ |
| 82 |
short x; |
| 83 |
int a[3 * 1025]; |
| 84 |
for (int i = 0; i < 1025; ++i) |
| 85 |
{ |
| 86 |
a[i] = ((i % 17) == 7); |
| 87 |
a[1025 + i] = ((i % 19) == 2); |
| 88 |
a[2 * 1025 + i] = ((i % 23) == 5); |
| 89 |
} |
| 90 |
S s = a; |
| 91 |
s.foo (x); |
| 92 |
if (x != 1010 || s.s != 1012 || s.t != 1023) |
| 93 |
abort (); |
| 94 |
s.bar (x); |
| 95 |
if (x != 959 || s.s != 974 || s.t != 977) |
| 96 |
abort (); |
| 97 |
#pragma omp parallel |
| 98 |
s.baz (x); |
| 99 |
if (x != 1010 || s.s != 1012 || s.t != 1023) |
| 100 |
abort (); |
| 101 |
s.qux (x); |
| 102 |
if (x != 959 || s.s != 974 || s.t != 977) |
| 103 |
abort (); |
| 104 |
} |