| 1 |
extern "C" void abort (); |
| 2 |
int w; |
| 3 |
struct S { int s, &t; S () : s (0), t (w) {}; void foo (short &); bool bar (int, int); void baz (short &); }; |
| 4 |
|
| 5 |
bool |
| 6 |
S::bar (int i, int q) |
| 7 |
{ |
| 8 |
switch (q) |
| 9 |
{ |
| 10 |
case 0: return (i % 17) == 7; |
| 11 |
case 1: return (i % 19) == 2; |
| 12 |
case 2: return (i % 23) == 5; |
| 13 |
default: abort (); |
| 14 |
} |
| 15 |
} |
| 16 |
|
| 17 |
void |
| 18 |
S::foo (short &x) |
| 19 |
{ |
| 20 |
#pragma omp for lastprivate (conditional: x, s, t) |
| 21 |
for (int i = 0; i < 1025; ++i) |
| 22 |
{ |
| 23 |
if (bar (i, 0)) |
| 24 |
x = i; |
| 25 |
if (bar (i, 1)) |
| 26 |
s = i + 3; |
| 27 |
if (bar (i, 2)) |
| 28 |
t = i + 6; |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
void |
| 33 |
S::baz (short &x) |
| 34 |
{ |
| 35 |
#pragma omp parallel for lastprivate (conditional: x, s, t) collapse (3) |
| 36 |
for (int i = 0; i < 15; ++i) |
| 37 |
for (int j = -4; j < 9; j++) |
| 38 |
for (int k = 12; k > 7; --k) |
| 39 |
{ |
| 40 |
int l = (k - 8) + (j + 4) * 5 + i * 13 * 5; |
| 41 |
if (bar (l, 0)) |
| 42 |
x = l; |
| 43 |
if (bar (l, 1)) |
| 44 |
s = l + 3; |
| 45 |
if (bar (l, 2)) |
| 46 |
t = l + 6; |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
int |
| 51 |
main () |
| 52 |
{ |
| 53 |
short x; |
| 54 |
S s; |
| 55 |
#pragma omp parallel |
| 56 |
s.foo (x); |
| 57 |
if (x != 1010 || s.s != 1012 || s.t != 1023) |
| 58 |
abort (); |
| 59 |
s.baz (x); |
| 60 |
if (x != 959 || s.s != 974 || s.t != 977) |
| 61 |
abort (); |
| 62 |
} |