1 extern void abort (void);
2 
3 int
main()4 main ()
5 {
6   int a = 1, b = 2, c = 4, d[7];
7   #pragma omp parallel
8   {
9     #pragma omp single
10     {
11       #pragma omp taskgroup
12       {
13 	#pragma omp target enter data nowait map (to: a, b, c) depend(out: d[0])
14 	#pragma omp target nowait map (alloc: a, b) depend(in: d[0]) depend(out: d[1])
15 	{
16 	  #pragma omp atomic update
17 	  a |= 4;
18 	  #pragma omp atomic update
19 	  b |= 8;
20 	}
21 	#pragma omp target nowait map (alloc: a, c) depend(in: d[0]) depend(out: d[2])
22 	{
23 	  #pragma omp atomic update
24 	  a |= 16;
25 	  #pragma omp atomic update
26 	  c |= 32;
27 	}
28 	#pragma omp target exit data nowait map (from: a, b, c) depend(in: d[1], d[2])
29       }
30       if (a != 21 || b != 10 || c != 36)
31 	abort ();
32       #pragma omp target map (tofrom: a, b) nowait
33       {
34 	a &= ~16;
35 	b &= ~2;
36       }
37       #pragma omp target map (tofrom: c) nowait
38       {
39 	c |= 8;
40       }
41     } /* Implicit barrier here.  */
42     #pragma omp single
43     {
44       if (a != 5 || b != 8 || c != 44)
45 	abort ();
46       #pragma omp target map (tofrom: a, b) nowait
47       {
48 	a |= 32;
49 	b |= 4;
50       }
51       #pragma omp target map (tofrom: c) nowait
52       c &= ~4;
53       #pragma omp taskwait
54       if (a != 37 || b != 12 || c != 40)
55 	abort ();
56       #pragma omp target nowait map (tofrom: a, b) depend(out: d[3])
57       {
58 	#pragma omp atomic update
59 	a = a + 9;
60 	b -= 8;
61       }
62       #pragma omp target nowait map (tofrom: a, c) depend(out: d[4])
63       {
64 	#pragma omp atomic update
65 	a = a + 4;
66 	c >>= 1;
67       }
68       #pragma omp task if (0) depend (in: d[3], d[4]) shared (a, b, c)
69       if (a != 50 || b != 4 || c != 20)
70 	abort ();
71       #pragma omp task shared (a)
72       a += 50;
73       #pragma omp target nowait map (tofrom: b)
74       b++;
75       #pragma omp target map (tofrom: c) nowait
76       c--;
77       #pragma omp taskwait
78       if (a != 100 || b != 5 || c != 19)
79 	abort ();
80       #pragma omp target map (tofrom: a) nowait depend(out: d[5])
81       a++;
82       #pragma omp target map (tofrom: b) nowait depend(out: d[6])
83       b++;
84       #pragma omp target map (tofrom: a, b) depend(in: d[5], d[6])
85       {
86 	if (a != 101 || b != 6)
87 	  a = -9;
88 	else
89 	  {
90 	    a = 24;
91 	    b = 38;
92 	  }
93       }
94       if (a != 24 || b != 38)
95 	abort ();
96     } /* Implicit barrier here.  */
97     #pragma omp master
98     {
99       #pragma omp target nowait map (tofrom: a, b)
100       {
101 	a *= 2;
102 	b++;
103       }
104       #pragma omp target map (tofrom: c) nowait
105       c--;
106     }
107     #pragma omp barrier
108     if (a != 48 || b != 39 || c != 18)
109       abort ();
110   }
111   return 0;
112 }
113