| 1 |
/* PR c++/26943 */ |
| 2 |
/* { dg-do run } */ |
| 3 |
|
| 4 |
extern int omp_set_dynamic (int); |
| 5 |
extern void omp_set_nested (int); |
| 6 |
extern int omp_get_thread_num (void); |
| 7 |
extern void abort (void); |
| 8 |
extern void GOMP_barrier (void); |
| 9 |
|
| 10 |
int a = 8, b = 12, c = 16, d = 20, j = 0, l = 0; |
| 11 |
char e[10] = "a", f[10] = "b", g[10] = "c", h[10] = "d"; |
| 12 |
volatile int k; |
| 13 |
|
| 14 |
int |
| 15 |
main (void) |
| 16 |
{ |
| 17 |
int i; |
| 18 |
omp_set_dynamic (0); |
| 19 |
omp_set_nested (1); |
| 20 |
#pragma omp parallel num_threads (2) reduction (+:l) \ |
| 21 |
firstprivate (a, b, c, d, e, f, g, h, j) |
| 22 |
if (k == omp_get_thread_num ()) |
| 23 |
{ |
| 24 |
#pragma omp parallel for shared (a, e) firstprivate (b, f) \ |
| 25 |
lastprivate (c, g) private (d, h) \ |
| 26 |
schedule (static, 1) num_threads (4) \ |
| 27 |
reduction (+:j) |
| 28 |
for (i = 0; i < 4; i++) |
| 29 |
{ |
| 30 |
if (a != 8 || b != 12 || e[0] != 'a' || f[0] != 'b') |
| 31 |
j++; |
| 32 |
GOMP_barrier (); |
| 33 |
#pragma omp atomic |
| 34 |
a += i; |
| 35 |
b += i; |
| 36 |
c = i; |
| 37 |
d = i; |
| 38 |
#pragma omp atomic |
| 39 |
e[0] += i; |
| 40 |
f[0] += i; |
| 41 |
g[0] = 'g' + i; |
| 42 |
h[0] = 'h' + i; |
| 43 |
GOMP_barrier (); |
| 44 |
if (a != 8 + 6 || b != 12 + i || c != i || d != i) |
| 45 |
j += 8; |
| 46 |
if (e[0] != 'a' + 6 || f[0] != 'b' + i || g[0] != 'g' + i) |
| 47 |
j += 64; |
| 48 |
if (h[0] != 'h' + i) |
| 49 |
j += 512; |
| 50 |
} |
| 51 |
if (j || a != 8 + 6 || b != 12 || c != 3 || d != 20) |
| 52 |
++l; |
| 53 |
if (e[0] != 'a' + 6 || f[0] != 'b' || g[0] != 'g' + 3 || h[0] != 'd') |
| 54 |
l += 8; |
| 55 |
} |
| 56 |
if (l) |
| 57 |
abort (); |
| 58 |
if (a != 8 || b != 12 || c != 16 || d != 20) |
| 59 |
abort (); |
| 60 |
if (e[0] != 'a' || f[0] != 'b' || g[0] != 'c' || h[0] != 'd') |
| 61 |
abort (); |
| 62 |
return 0; |
| 63 |
} |