| 1 |
#include <stdlib.h> |
| 2 |
#include <unistd.h> |
| 3 |
|
| 4 |
int |
| 5 |
main () |
| 6 |
{ |
| 7 |
int x = 0, y = 0, z = 0, s = 11, t = 12, u = 13, w = 7, err; |
| 8 |
#pragma omp parallel |
| 9 |
#pragma omp single |
| 10 |
{ |
| 11 |
#pragma omp task depend(in: x) |
| 12 |
{ |
| 13 |
usleep (5000); |
| 14 |
x = 1; |
| 15 |
} |
| 16 |
#pragma omp task depend(in: x) |
| 17 |
{ |
| 18 |
usleep (6000); |
| 19 |
y = 2; |
| 20 |
} |
| 21 |
#pragma omp task depend(out: z) |
| 22 |
{ |
| 23 |
usleep (7000); |
| 24 |
z = 3; |
| 25 |
} |
| 26 |
#pragma omp target map(tofrom: x) map(from: err) map (to: y, z) depend(inout: x, z) |
| 27 |
err = (x != 1 || y != 2 || z != 3); |
| 28 |
if (err) |
| 29 |
abort (); |
| 30 |
#pragma omp task depend(in: x) |
| 31 |
{ |
| 32 |
usleep (5000); |
| 33 |
x = 4; |
| 34 |
} |
| 35 |
#pragma omp task depend(in: x) |
| 36 |
{ |
| 37 |
usleep (4000); |
| 38 |
y = 5; |
| 39 |
} |
| 40 |
#pragma omp task depend(in: z) |
| 41 |
{ |
| 42 |
usleep (3000); |
| 43 |
z = 6; |
| 44 |
} |
| 45 |
#pragma omp target enter data nowait map (to: w) |
| 46 |
#pragma omp target enter data depend (inout: x, z) map (to: x, y, z) |
| 47 |
#pragma omp target map (alloc: x, y, z) map(from: err) |
| 48 |
{ |
| 49 |
err = (x != 4 || y != 5 || z != 6); |
| 50 |
x = 7; |
| 51 |
y = 8; |
| 52 |
z = 9; |
| 53 |
} |
| 54 |
if (err) |
| 55 |
abort (); |
| 56 |
#pragma omp taskwait |
| 57 |
#pragma omp target map (alloc: w) map(from: err) |
| 58 |
{ |
| 59 |
err = w != 7; |
| 60 |
w = 17; |
| 61 |
} |
| 62 |
if (err) |
| 63 |
abort (); |
| 64 |
#pragma omp task depend(in: x) |
| 65 |
{ |
| 66 |
usleep (2000); |
| 67 |
s = 14; |
| 68 |
} |
| 69 |
#pragma omp task depend(in: x) |
| 70 |
{ |
| 71 |
usleep (3000); |
| 72 |
t = 15; |
| 73 |
} |
| 74 |
#pragma omp task depend(in: z) |
| 75 |
{ |
| 76 |
usleep (4000); |
| 77 |
u = 16; |
| 78 |
} |
| 79 |
#pragma omp target exit data depend (inout: x, z) map (from: x, y, z, w) |
| 80 |
if (x != 7 || y != 8 || z != 9 || s != 14 || t != 15 || u != 16 || w != 17) |
| 81 |
abort (); |
| 82 |
} |
| 83 |
return 0; |
| 84 |
} |