| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-require-effective-target tls_runtime } */ |
| 3 |
/* { dg-additional-options "-std=gnu99" {target c } } */ |
| 4 |
|
| 5 |
#include <omp.h> |
| 6 |
#include <stdlib.h> |
| 7 |
|
| 8 |
int r, s, u, v, t; |
| 9 |
int *x; |
| 10 |
|
| 11 |
void |
| 12 |
foo (int *a) |
| 13 |
{ |
| 14 |
int i; |
| 15 |
long long j; |
| 16 |
#pragma omp for lastprivate (conditional: u, x) ordered |
| 17 |
for (i = 15; i < 64; i++) |
| 18 |
{ |
| 19 |
#pragma omp critical |
| 20 |
{ |
| 21 |
if ((a[i] % 5) == 3) |
| 22 |
u = i; |
| 23 |
} |
| 24 |
#pragma omp ordered |
| 25 |
{ |
| 26 |
if ((a[i] % 7) == 2) |
| 27 |
x = &a[i]; |
| 28 |
} |
| 29 |
} |
| 30 |
#pragma omp for lastprivate (conditional: v) reduction (+:r, s) schedule (nonmonotonic: static) reduction (task, +: t) |
| 31 |
for (i = -3; i < 119; i += 2) |
| 32 |
{ |
| 33 |
++s; |
| 34 |
#pragma omp taskgroup |
| 35 |
{ |
| 36 |
#pragma omp task in_reduction (+: t) |
| 37 |
++t; |
| 38 |
if ((a[i + 4] % 11) == 9) |
| 39 |
v = i; |
| 40 |
else |
| 41 |
++r; |
| 42 |
} |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
int |
| 47 |
main () |
| 48 |
{ |
| 49 |
int a[128], i; |
| 50 |
for (i = 0; i < 128; i++) |
| 51 |
a[i] = i; |
| 52 |
#pragma omp parallel |
| 53 |
foo (a); |
| 54 |
if (u != 63 || v != 115 || x != &a[58] || r != 55 || s != 61 || t != 61) |
| 55 |
abort (); |
| 56 |
return 0; |
| 57 |
} |