Debian Codegraph @

libgomp/testsuite/libgomp.c/target-32.c

raw
1 #include <stdlib.h>
2 #include <unistd.h>
3 #include "usleep.h"
4
5 int main ()
6 {
7 int a = 0, b = 0, c = 0, d[7];
8
9 #pragma omp parallel
10 #pragma omp single
11 {
12 #pragma omp task depend(out: d[0])
13 a = 2;
14
15 #pragma omp target enter data nowait map(to: a,b,c) depend(in: d[0]) depend(out: d[1])
16
17 #pragma omp target nowait map(alloc: a) depend(in: d[1]) depend(out: d[2])
18 a++;
19
20 #pragma omp target nowait map(alloc: b) depend(in: d[2]) depend(out: d[3])
21 {
22 tgt_usleep (1000);
23 #pragma omp atomic update
24 b |= 4;
25 }
26
27 #pragma omp target nowait map(alloc: b) depend(in: d[2]) depend(out: d[4])
28 {
29 tgt_usleep (5000);
30 #pragma omp atomic update
31 b |= 1;
32 }
33
34 #pragma omp target nowait map(alloc: c) depend(in: d[3], d[4]) depend(out: d[5])
35 {
36 tgt_usleep (5000);
37 #pragma omp atomic update
38 c |= 8;
39 }
40
41 #pragma omp target nowait map(alloc: c) depend(in: d[3], d[4]) depend(out: d[6])
42 {
43 tgt_usleep (1000);
44 #pragma omp atomic update
45 c |= 2;
46 }
47
48 #pragma omp target exit data map(always,from: a,b,c) depend(in: d[5], d[6])
49 }
50
51 if (a != 3 || b != 5 || c != 10)
52 abort ();
53
54 return 0;
55 }