Daily bump.
[official-gcc.git] / libgomp / testsuite / libgomp.c / depend-5.c
blob192c6ddfeba68135b3e4a14489fe7cb55bf78ac2
1 #include <stdlib.h>
3 __attribute__((noinline, noclone)) void
4 f1 (int ifval)
6 int x = 1, y = 2, z = 3;
7 #pragma omp parallel
8 #pragma omp single
10 #pragma omp task shared (x) depend(out: x)
11 x = 2;
12 #pragma omp task shared (x) depend(inout: x)
14 if (x != 2)
15 abort ();
16 x = 3;
18 #pragma omp task shared (x) depend(inout: x)
20 if (x != 3)
21 abort ();
22 x = 4;
24 #pragma omp task shared (z) depend(in: z)
25 if (z != 3)
26 abort ();
27 #pragma omp task shared (z) depend(in: z)
28 if (z != 3)
29 abort ();
30 #pragma omp task shared (z) depend(in: z)
31 if (z != 3)
32 abort ();
33 #pragma omp task shared (z) depend(in: z)
34 if (z != 3)
35 abort ();
36 #pragma omp task shared (z) depend(in: z)
37 if (z != 3)
38 abort ();
39 #pragma omp task shared (z) depend(in: z)
40 if (z != 3)
41 abort ();
42 #pragma omp task shared (y) depend(in: y)
43 if (y != 2)
44 abort ();
45 #pragma omp task shared (y) depend(in: y)
46 if (y != 2)
47 abort ();
48 #pragma omp task shared (y) depend(in: y)
49 if (y != 2)
50 abort ();
51 #pragma omp task shared (y) depend(in: y)
52 if (y != 2)
53 abort ();
54 #pragma omp task if (ifval) shared (x, y) depend(in: x) depend(inout: y)
56 if (x != 4 || y != 2)
57 abort ();
58 y = 3;
60 if (ifval == 0)
62 /* The above if (0) task should have waited till all
63 the tasks with x and y dependencies finish. */
64 if (x != 4 || y != 3)
65 abort ();
66 x = 5;
67 y = 4;
69 #pragma omp task shared (z) depend(inout: z)
71 if (z != 3)
72 abort ();
73 z = 4;
75 #pragma omp task shared (z) depend(inout: z)
77 if (z != 4)
78 abort ();
79 z = 5;
81 #pragma omp taskwait
82 if (x != (ifval ? 4 : 5) || y != (ifval ? 3 : 4) || z != 5)
83 abort ();
84 #pragma omp task if (ifval) shared (x, y) depend(in: x) depend(inout: y)
86 if (x != (ifval ? 4 : 5) || y != (ifval ? 3 : 4))
87 abort ();
92 int
93 main ()
95 f1 (0);
96 f1 (1);
97 return 0;