| 1 |
#include <omp.h> |
| 2 |
|
| 3 |
__attribute__((noinline, noclone)) void |
| 4 |
foo (int &b) |
| 5 |
{ |
| 6 |
#pragma omp parallel |
| 7 |
#pragma omp single |
| 8 |
{ |
| 9 |
bool f = false; |
| 10 |
#pragma omp taskloop firstprivate (b, f) |
| 11 |
for (int i = 0; i < 30; i++) |
| 12 |
{ |
| 13 |
int q = omp_get_thread_num (); |
| 14 |
if (!f) |
| 15 |
{ |
| 16 |
if (b != 2) |
| 17 |
__builtin_abort (); |
| 18 |
} |
| 19 |
else if (b != 8 * q) |
| 20 |
__builtin_abort (); |
| 21 |
b = 8 * q; |
| 22 |
f = true; |
| 23 |
} |
| 24 |
} |
| 25 |
int n; |
| 26 |
#pragma omp parallel |
| 27 |
#pragma omp single |
| 28 |
{ |
| 29 |
bool f = false; |
| 30 |
#pragma omp taskloop firstprivate (f) lastprivate (b, n) |
| 31 |
for (int i = 0; i < 30; i++) |
| 32 |
{ |
| 33 |
int q = omp_get_thread_num (); |
| 34 |
if (f && b != 8 * q) |
| 35 |
__builtin_abort (); |
| 36 |
b = 8 * q; |
| 37 |
n = q; |
| 38 |
f = true; |
| 39 |
} |
| 40 |
} |
| 41 |
if (b != 8 * n) |
| 42 |
__builtin_abort (); |
| 43 |
b = 9; |
| 44 |
#pragma omp parallel |
| 45 |
#pragma omp single |
| 46 |
{ |
| 47 |
bool f = false; |
| 48 |
#pragma omp taskloop firstprivate (b, f) lastprivate (b, n) |
| 49 |
for (int i = 0; i < 30; i++) |
| 50 |
{ |
| 51 |
int q = omp_get_thread_num (); |
| 52 |
if (!f) |
| 53 |
{ |
| 54 |
if (b != 9) |
| 55 |
__builtin_abort (); |
| 56 |
} |
| 57 |
else if (b != 11 * q) |
| 58 |
__builtin_abort (); |
| 59 |
b = 11 * q; |
| 60 |
n = q; |
| 61 |
f = true; |
| 62 |
} |
| 63 |
} |
| 64 |
if (b != 11 * n) |
| 65 |
__builtin_abort (); |
| 66 |
} |
| 67 |
|
| 68 |
int |
| 69 |
main () |
| 70 |
{ |
| 71 |
int b = 2; |
| 72 |
foo (b); |
| 73 |
} |