1 | // RUN: %libomptarget-compile-generic -fopenmp-extensions |
2 | // RUN: %libomptarget-run-generic | %fcheck-generic -strict-whitespace |
3 | |
4 | #include <omp.h> |
5 | #include <stdio.h> |
6 | |
7 | #define CHECK_PRESENCE(Var1, Var2, Var3) \ |
8 | printf(" presence of %s, %s, %s: %d, %d, %d\n", #Var1, #Var2, #Var3, \ |
9 | omp_target_is_present(&Var1, omp_get_default_device()), \ |
10 | omp_target_is_present(&Var2, omp_get_default_device()), \ |
11 | omp_target_is_present(&Var3, omp_get_default_device())) |
12 | |
13 | int main() { |
14 | int m, r, d; |
15 | // CHECK: presence of m, r, d: 0, 0, 0 |
16 | CHECK_PRESENCE(m, r, d); |
17 | |
18 | // ----------------------------------------------------------------------- |
19 | // CHECK-NEXT: check:{{.*}} |
20 | printf(format: "check: dyn>0, hold=0, dec dyn=0\n" ); |
21 | |
22 | // CHECK-NEXT: once |
23 | printf(format: " once\n" ); |
24 | #pragma omp target map(tofrom : m) map(alloc : r, d) |
25 | ; |
26 | // CHECK-NEXT: presence of m, r, d: 0, 0, 0 |
27 | CHECK_PRESENCE(m, r, d); |
28 | |
29 | // CHECK-NEXT: twice |
30 | printf(format: " twice\n" ); |
31 | #pragma omp target data map(tofrom : m) map(alloc : r, d) |
32 | { |
33 | // CHECK-NEXT: presence of m, r, d: 1, 1, 1 |
34 | CHECK_PRESENCE(m, r, d); |
35 | #pragma omp target map(tofrom : m) map(alloc : r, d) |
36 | ; |
37 | // CHECK-NEXT: presence of m, r, d: 1, 1, 1 |
38 | CHECK_PRESENCE(m, r, d); |
39 | } |
40 | // CHECK-NEXT: presence of m, r, d: 0, 0, 0 |
41 | CHECK_PRESENCE(m, r, d); |
42 | |
43 | // ----------------------------------------------------------------------- |
44 | // CHECK: check:{{.*}} |
45 | printf(format: "check: dyn=0, hold>0, dec hold=0\n" ); |
46 | |
47 | // CHECK-NEXT: once |
48 | printf(format: " once\n" ); |
49 | #pragma omp target map(ompx_hold, tofrom : m) map(ompx_hold, alloc : r, d) |
50 | ; |
51 | // CHECK-NEXT: presence of m, r, d: 0, 0, 0 |
52 | CHECK_PRESENCE(m, r, d); |
53 | |
54 | // CHECK-NEXT: twice |
55 | printf(format: " twice\n" ); |
56 | #pragma omp target data map(ompx_hold, tofrom : m) map(ompx_hold, alloc : r, d) |
57 | { |
58 | // CHECK-NEXT: presence of m, r, d: 1, 1, 1 |
59 | CHECK_PRESENCE(m, r, d); |
60 | #pragma omp target map(ompx_hold, tofrom : m) map(ompx_hold, alloc : r, d) |
61 | ; |
62 | // CHECK-NEXT: presence of m, r, d: 1, 1, 1 |
63 | CHECK_PRESENCE(m, r, d); |
64 | } |
65 | // CHECK-NEXT: presence of m, r, d: 0, 0, 0 |
66 | CHECK_PRESENCE(m, r, d); |
67 | |
68 | // ----------------------------------------------------------------------- |
69 | // CHECK: check:{{.*}} |
70 | printf(format: "check: dyn>0, hold>0, dec dyn=0, dec hold=0\n" ); |
71 | |
72 | // CHECK-NEXT: once each |
73 | printf(format: " once each\n" ); |
74 | #pragma omp target data map(ompx_hold, tofrom : m) map(ompx_hold, alloc : r, d) |
75 | { |
76 | // CHECK-NEXT: presence of m, r, d: 1, 1, 1 |
77 | CHECK_PRESENCE(m, r, d); |
78 | #pragma omp target map(tofrom : m) map(alloc : r, d) |
79 | ; |
80 | // CHECK-NEXT: presence of m, r, d: 1, 1, 1 |
81 | CHECK_PRESENCE(m, r, d); |
82 | } |
83 | // CHECK-NEXT: presence of m, r, d: 0, 0, 0 |
84 | CHECK_PRESENCE(m, r, d); |
85 | |
86 | // CHECK-NEXT: twice each |
87 | printf(format: " twice each\n" ); |
88 | #pragma omp target data map(ompx_hold, tofrom : m) map(ompx_hold, alloc : r, d) |
89 | { |
90 | // CHECK-NEXT: presence of m, r, d: 1, 1, 1 |
91 | CHECK_PRESENCE(m, r, d); |
92 | #pragma omp target data map(ompx_hold, tofrom : m) map(ompx_hold, alloc : r, d) |
93 | { |
94 | // CHECK-NEXT: presence of m, r, d: 1, 1, 1 |
95 | CHECK_PRESENCE(m, r, d); |
96 | #pragma omp target data map(tofrom : m) map(alloc : r, d) |
97 | { |
98 | // CHECK-NEXT: presence of m, r, d: 1, 1, 1 |
99 | CHECK_PRESENCE(m, r, d); |
100 | #pragma omp target map(tofrom : m) map(alloc : r, d) |
101 | ; |
102 | // CHECK-NEXT: presence of m, r, d: 1, 1, 1 |
103 | CHECK_PRESENCE(m, r, d); |
104 | } |
105 | // CHECK-NEXT: presence of m, r, d: 1, 1, 1 |
106 | CHECK_PRESENCE(m, r, d); |
107 | } |
108 | // CHECK-NEXT: presence of m, r, d: 1, 1, 1 |
109 | CHECK_PRESENCE(m, r, d); |
110 | } |
111 | // CHECK-NEXT: presence of m, r, d: 0, 0, 0 |
112 | CHECK_PRESENCE(m, r, d); |
113 | |
114 | // ----------------------------------------------------------------------- |
115 | // CHECK: check:{{.*}} |
116 | printf(format: "check: dyn>0, hold>0, dec hold=0, dec dyn=0\n" ); |
117 | |
118 | // CHECK-NEXT: once each |
119 | printf(format: " once each\n" ); |
120 | #pragma omp target data map(tofrom : m) map(alloc : r, d) |
121 | { |
122 | // CHECK-NEXT: presence of m, r, d: 1, 1, 1 |
123 | CHECK_PRESENCE(m, r, d); |
124 | #pragma omp target map(ompx_hold, tofrom : m) map(ompx_hold, alloc : r, d) |
125 | ; |
126 | // CHECK-NEXT: presence of m, r, d: 1, 1, 1 |
127 | CHECK_PRESENCE(m, r, d); |
128 | } |
129 | // CHECK-NEXT: presence of m, r, d: 0, 0, 0 |
130 | CHECK_PRESENCE(m, r, d); |
131 | |
132 | // CHECK-NEXT: twice each |
133 | printf(format: " twice each\n" ); |
134 | #pragma omp target data map(tofrom : m) map(alloc : r, d) |
135 | { |
136 | // CHECK-NEXT: presence of m, r, d: 1, 1, 1 |
137 | CHECK_PRESENCE(m, r, d); |
138 | #pragma omp target data map(tofrom : m) map(alloc : r, d) |
139 | { |
140 | // CHECK-NEXT: presence of m, r, d: 1, 1, 1 |
141 | CHECK_PRESENCE(m, r, d); |
142 | #pragma omp target data map(ompx_hold, tofrom : m) map(ompx_hold, alloc : r, d) |
143 | { |
144 | // CHECK-NEXT: presence of m, r, d: 1, 1, 1 |
145 | CHECK_PRESENCE(m, r, d); |
146 | #pragma omp target map(ompx_hold, tofrom : m) map(ompx_hold, alloc : r, d) |
147 | ; |
148 | // CHECK-NEXT: presence of m, r, d: 1, 1, 1 |
149 | CHECK_PRESENCE(m, r, d); |
150 | } |
151 | // CHECK-NEXT: presence of m, r, d: 1, 1, 1 |
152 | CHECK_PRESENCE(m, r, d); |
153 | } |
154 | // CHECK-NEXT: presence of m, r, d: 1, 1, 1 |
155 | CHECK_PRESENCE(m, r, d); |
156 | } |
157 | // CHECK-NEXT: presence of m, r, d: 0, 0, 0 |
158 | CHECK_PRESENCE(m, r, d); |
159 | |
160 | return 0; |
161 | } |
162 | |