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
|
#include <stdlib.h>
#include <unistd.h>
int
main ()
{
int x = 0, y = 0, z = 0, s = 11, t = 12, u = 13, w = 7, err;
#pragma omp parallel
#pragma omp single
{
#pragma omp task depend(in: x)
{
usleep (5000);
x = 1;
}
#pragma omp task depend(in: x)
{
usleep (6000);
y = 2;
}
#pragma omp task depend(out: z)
{
usleep (7000);
z = 3;
}
#pragma omp target map(tofrom: x) map(from: err) map (to: y, z) depend(inout: x, z)
err = (x != 1 || y != 2 || z != 3);
if (err)
abort ();
#pragma omp task depend(in: x)
{
usleep (5000);
x = 4;
}
#pragma omp task depend(in: x)
{
usleep (4000);
y = 5;
}
#pragma omp task depend(in: z)
{
usleep (3000);
z = 6;
}
#pragma omp target enter data nowait map (to: w)
#pragma omp target enter data depend (inout: x, z) map (to: x, y, z)
#pragma omp target map (alloc: x, y, z) map(from: err)
{
err = (x != 4 || y != 5 || z != 6);
x = 7;
y = 8;
z = 9;
}
if (err)
abort ();
#pragma omp taskwait
#pragma omp target map (alloc: w) map(from: err)
{
err = w != 7;
w = 17;
}
if (err)
abort ();
#pragma omp task depend(in: x)
{
usleep (2000);
s = 14;
}
#pragma omp task depend(in: x)
{
usleep (3000);
t = 15;
}
#pragma omp task depend(in: z)
{
usleep (4000);
u = 16;
}
#pragma omp target exit data depend (inout: x, z) map (from: x, y, z, w)
if (x != 7 || y != 8 || z != 9 || s != 14 || t != 15 || u != 16 || w != 17)
abort ();
}
return 0;
}
|