PR target/82855
[official-gcc.git] / libgomp / testsuite / libgomp.c / target-33.c
blob1bed4b6bc6738c5a733bd9bbdb7242a95fae1391
1 extern void abort (void);
3 int
4 main ()
6 int a = 1, b = 2, c = 4, d[7];
7 #pragma omp taskgroup
9 #pragma omp target enter data nowait map (to: a, b, c) depend(out: d[0])
10 #pragma omp target nowait map (alloc: a, b) depend(in: d[0]) depend(out: d[1])
12 #pragma omp atomic update
13 a |= 4;
14 #pragma omp atomic update
15 b |= 8;
17 #pragma omp target nowait map (alloc: a, c) depend(in: d[0]) depend(out: d[2])
19 #pragma omp atomic update
20 a |= 16;
21 #pragma omp atomic update
22 c |= 32;
24 #pragma omp target exit data nowait map (from: a, b, c) depend(in: d[1], d[2])
26 if (a != 21 || b != 10 || c != 36)
27 abort ();
28 #pragma omp target map (tofrom: a, b) nowait
30 a &= ~16;
31 b &= ~2;
33 #pragma omp target map (tofrom: c) nowait
35 c |= 8;
37 #pragma omp barrier
38 if (a != 5 || b != 8 || c != 44)
39 abort ();
40 #pragma omp target map (tofrom: a, b) nowait
42 a |= 32;
43 b |= 4;
45 #pragma omp target map (tofrom: c) nowait
47 c &= ~4;
49 #pragma omp taskwait
50 if (a != 37 || b != 12 || c != 40)
51 abort ();
52 #pragma omp target nowait map (tofrom: a, b) depend(out: d[3])
54 #pragma omp atomic update
55 a = a + 9;
56 b -= 8;
58 #pragma omp target nowait map (tofrom: a, c) depend(out: d[4])
60 #pragma omp atomic update
61 a = a + 4;
62 c >>= 1;
64 #pragma omp task if (0) depend (in: d[3], d[4]) shared (a, b, c)
65 if (a != 50 || b != 4 || c != 20)
66 abort ();
67 #pragma omp task shared (a)
68 a += 50;
69 #pragma omp target nowait map (tofrom: b)
70 b++;
71 #pragma omp target map (tofrom: c) nowait
72 c--;
73 #pragma omp taskwait
74 if (a != 100 || b != 5 || c != 19)
75 abort ();
76 #pragma omp target map (tofrom: a) nowait depend(out: d[5])
77 a++;
78 #pragma omp target map (tofrom: b) nowait depend(out: d[6])
79 b++;
80 #pragma omp target map (tofrom: a, b) depend(in: d[5], d[6])
82 if (a != 101 || b != 6)
83 a = -9;
84 else
86 a = 24;
87 b = 38;
90 if (a != 24 || b != 38)
91 abort ();
92 return 0;