Daily bump.
[official-gcc.git] / libgomp / testsuite / libgomp.c / target-27.c
blobc86651b02e3be6872661da53e5b682425b083b27
1 #include <stdlib.h>
2 #include <unistd.h>
4 int
5 main ()
7 int x = 0, y = 0, z = 0, err;
8 int shared_mem = 0;
9 #pragma omp target map(to: shared_mem)
10 shared_mem = 1;
11 #pragma omp parallel
12 #pragma omp single
14 #pragma omp task depend(in: x)
16 usleep (5000);
17 x = 1;
19 #pragma omp task depend(in: x)
21 usleep (6000);
22 y = 2;
24 #pragma omp task depend(out: z)
26 usleep (7000);
27 z = 3;
29 #pragma omp target enter data map(to: x, y, z) depend(inout: x, z) nowait
30 #pragma omp task depend(inout: x, z)
32 x++; y++; z++;
34 #pragma omp target update to(x, y) depend(inout: x) nowait
35 #pragma omp target enter data map(always, to: z) depend(inout: z) nowait
36 #pragma omp target map (alloc: x, y, z) map (from: err) depend(inout: x, z)
38 err = x != 2 || y != 3 || z != 4;
39 x = 5; y = 6; z = 7;
41 #pragma omp task depend(in: x)
43 usleep (5000);
44 if (!shared_mem)
45 x = 1;
47 #pragma omp task depend(in: x)
49 usleep (6000);
50 if (!shared_mem)
51 y = 2;
53 #pragma omp task depend(out: z)
55 usleep (3000);
56 if (!shared_mem)
57 z = 3;
59 #pragma omp target exit data map(release: z) depend(inout: z) nowait
60 #pragma omp target exit data map(from: x, y) depend(inout: x) nowait
61 #pragma omp target exit data map(from: z) depend(inout: z) nowait
62 #pragma omp taskwait
63 if (err || x != 5 || y != 6 || z != 7)
64 abort ();
66 return 0;