| 1 |
extern |
| 2 |
#ifdef __cplusplus |
| 3 |
"C" |
| 4 |
#endif |
| 5 |
void abort (void); |
| 6 |
int a, b[3] = { 1, 1, 1 }; |
| 7 |
unsigned long int c[2] = { ~0UL, ~0UL }; |
| 8 |
|
| 9 |
void |
| 10 |
bar (int i) |
| 11 |
{ |
| 12 |
#pragma omp task in_reduction (*: b[:3]) in_reduction (&: c[1:]) \ |
| 13 |
in_reduction (+: a) |
| 14 |
{ |
| 15 |
a += 4; |
| 16 |
b[1] *= 4; |
| 17 |
c[1] &= ~(1UL << (i + 16)); |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
void |
| 22 |
foo (unsigned long long int x, unsigned long long int y, unsigned long long int z) |
| 23 |
{ |
| 24 |
unsigned long long int i; |
| 25 |
#pragma omp for schedule(runtime) reduction (task, +: a) \ |
| 26 |
reduction (task, *: b) reduction (task, &: c[1:1]) |
| 27 |
for (i = x; i < y; i += z) |
| 28 |
{ |
| 29 |
a++; |
| 30 |
b[0] *= 2; |
| 31 |
bar (i); |
| 32 |
b[2] *= 3; |
| 33 |
c[1] &= ~(1UL << i); |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
int |
| 38 |
main () |
| 39 |
{ |
| 40 |
volatile int two = 2; |
| 41 |
foo (two, 7 * two, two); |
| 42 |
if (a != 30 || b[0] != 64 || b[1] != (1 << 12) || b[2] != 3 * 3 * 3 * 3 * 3 * 3 |
| 43 |
|| c[0] != ~0UL || c[1] != ~0x15541554UL) |
| 44 |
abort (); |
| 45 |
a = 0; |
| 46 |
b[0] = 1; |
| 47 |
b[1] = 1; |
| 48 |
b[2] = 1; |
| 49 |
c[1] = ~0UL; |
| 50 |
#pragma omp parallel |
| 51 |
foo (two, 8 * two, two); |
| 52 |
if (a != 35 || b[0] != 128 || b[1] != (1 << 14) || b[2] != 3 * 3 * 3 * 3 * 3 * 3 * 3 |
| 53 |
|| c[0] != ~0UL || c[1] != ~0x55545554UL) |
| 54 |
abort (); |
| 55 |
return 0; |
| 56 |
} |