blob: ba3ed37e0405292867c8ecae4be394130a742d3c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/* PR libgomp/61200 */
/* { dg-do run } */
#include <omp.h>
#include <stdlib.h>
#include <unistd.h>
volatile int x;
void
foo ()
{
int var = 1;
int i;
for (i = 0; i < 2; i++)
{
if (i == 1)
{
#pragma omp parallel num_threads(2)
if (x)
var++;
else
{
#pragma omp single
sleep (2);
}
}
else
{
#pragma omp task shared(var)
{
sleep (1);
var = 2;
}
}
}
#pragma omp taskwait
if (var != 2)
abort ();
}
void
bar ()
{
int var = 1;
int i;
for (i = 0; i < 2; i++)
{
if (i == 0)
{
#pragma omp task shared(var)
{
sleep (1);
var = 2;
}
}
else
{
#pragma omp parallel num_threads(2)
if (x)
var++;
else
{
#pragma omp single
sleep (2);
}
}
}
#pragma omp taskwait
if (var != 2)
abort ();
}
int
main ()
{
omp_set_nested (1);
#pragma omp parallel num_threads(2)
#pragma omp single
foo ();
#pragma omp parallel num_threads(2)
#pragma omp single
bar ();
return 0;
}
|