Debian Codegraph @

flang/test/Semantics/OpenMP/device-constructs.f90

raw
1 ! RUN: %python %S/../test_errors.py %s %flang -fopenmp
2 ! Check OpenMP clause validity for the following directives:
3 ! 2.10 Device constructs
4 program main
5 use iso_c_binding
6
7 real(8) :: arrayA(256), arrayB(256)
8 integer :: N
9 type(c_ptr) :: cptr
10
11 arrayA = 1.414
12 arrayB = 3.14
13 N = 256
14
15 !$omp target map(arrayA)
16 do i = 1, N
17 a = 3.14
18 enddo
19 !$omp end target
20
21 !$omp target device(0)
22 do i = 1, N
23 a = 3.14
24 enddo
25 !$omp end target
26
27 !ERROR: At most one DEVICE clause can appear on the TARGET directive
28 !$omp target device(0) device(1)
29 do i = 1, N
30 a = 3.14
31 enddo
32 !$omp end target
33
34 !ERROR: SCHEDULE clause is not allowed on the TARGET directive
35 !$omp target schedule(static)
36 do i = 1, N
37 a = 3.14
38 enddo
39 !$omp end target
40
41 !$omp target defaultmap(tofrom:scalar)
42 do i = 1, N
43 a = 3.14
44 enddo
45 !$omp end target
46
47 !ERROR: The argument TOFROM:SCALAR must be specified on the DEFAULTMAP clause
48 !$omp target defaultmap(tofrom)
49 do i = 1, N
50 a = 3.14
51 enddo
52 !$omp end target
53
54 !ERROR: At most one DEFAULTMAP clause can appear on the TARGET directive
55 !$omp target defaultmap(tofrom:scalar) defaultmap(tofrom:scalar)
56 do i = 1, N
57 a = 3.14
58 enddo
59 !$omp end target
60
61 !$omp target thread_limit(4)
62 do i = 1, N
63 a = 3.14
64 enddo
65 !$omp end target
66
67 !ERROR: At most one THREAD_LIMIT clause can appear on the TARGET directive
68 !$omp target thread_limit(4) thread_limit(8)
69 do i = 1, N
70 a = 3.14
71 enddo
72 !$omp end target
73
74 !$omp teams num_teams(3) thread_limit(10) default(shared) private(i) shared(a)
75 do i = 1, N
76 a = 3.14
77 enddo
78 !$omp end teams
79
80 !ERROR: At most one NUM_TEAMS clause can appear on the TEAMS directive
81 !$omp teams num_teams(2) num_teams(3)
82 do i = 1, N
83 a = 3.14
84 enddo
85 !$omp end teams
86
87 !ERROR: The parameter of the NUM_TEAMS clause must be a positive integer expression
88 !$omp teams num_teams(-1)
89 do i = 1, N
90 a = 3.14
91 enddo
92 !$omp end teams
93
94 !ERROR: At most one THREAD_LIMIT clause can appear on the TEAMS directive
95 !$omp teams thread_limit(2) thread_limit(3)
96 do i = 1, N
97 a = 3.14
98 enddo
99 !$omp end teams
100
101 !ERROR: The parameter of the THREAD_LIMIT clause must be a positive integer expression
102 !$omp teams thread_limit(-1)
103 do i = 1, N
104 a = 3.14
105 enddo
106 !$omp end teams
107
108 !ERROR: At most one DEFAULT clause can appear on the TEAMS directive
109 !$omp teams default(shared) default(private)
110 do i = 1, N
111 a = 3.14
112 enddo
113 !$omp end teams
114
115 !$omp target teams num_teams(2) defaultmap(tofrom:scalar)
116 do i = 1, N
117 a = 3.14
118 enddo
119 !$omp end target teams
120
121 !$omp target map(tofrom:a)
122 do i = 1, N
123 a = 3.14
124 enddo
125 !$omp end target
126
127 !ERROR: Only the TO, FROM, TOFROM, ALLOC map types are permitted for MAP clauses on the TARGET directive
128 !$omp target map(delete:a)
129 do i = 1, N
130 a = 3.14
131 enddo
132 !$omp end target
133
134 !$omp target data device(0) map(to:a)
135 do i = 1, N
136 a = 3.14
137 enddo
138 !$omp end target data
139
140 !$omp target data device(0) use_device_addr(cptr)
141 cptr = c_null_ptr
142 !$omp end target data
143
144 !$omp target data device(0) use_device_addr(cptr)
145 cptr = c_null_ptr
146 !$omp end target data
147
148 !ERROR: At least one of MAP, USE_DEVICE_ADDR, USE_DEVICE_PTR clause must appear on the TARGET DATA directive
149 !$omp target data device(0)
150 do i = 1, N
151 a = 3.14
152 enddo
153 !$omp end target data
154
155 !ERROR: The device expression of the DEVICE clause must be a positive integer expression
156 !$omp target enter data map(alloc:A) device(-2)
157
158 !ERROR: The device expression of the DEVICE clause must be a positive integer expression
159 !$omp target exit data map(delete:A) device(-2)
160
161 !ERROR: At most one IF clause can appear on the TARGET ENTER DATA directive
162 !$omp target enter data map(to:a) if(.true.) if(.false.)
163
164 !ERROR: Only the TO, ALLOC map types are permitted for MAP clauses on the TARGET ENTER DATA directive
165 !$omp target enter data map(from:a)
166
167 !$omp target exit data map(delete:a)
168
169 !ERROR: At most one DEVICE clause can appear on the TARGET EXIT DATA directive
170 !$omp target exit data map(from:a) device(0) device(1)
171
172 !ERROR: Only the FROM, RELEASE, DELETE map types are permitted for MAP clauses on the TARGET EXIT DATA directive
173 !$omp target exit data map(to:a)
174
175 !$omp target update if(.true.) device(1) to(a) from(b) depend(inout:c) nowait
176
177 !ERROR: At most one IF clause can appear on the TARGET UPDATE directive
178 !$omp target update to(a) if(.true.) if(.false.)
179
180 !ERROR: At most one DEVICE clause can appear on the TARGET UPDATE directive
181 !$omp target update device(0) device(1) from(b)
182
183 !$omp target
184 !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
185 !$omp distribute
186 do i = 1, N
187 a = 3.14
188 enddo
189 !$omp end distribute
190 !$omp end target
191
192 !$omp target
193 !$omp teams
194 !$omp distribute
195 do i = 1, N
196 a = 3.14
197 enddo
198 !$omp end distribute
199 !$omp end teams
200 !$omp end target
201
202 !$omp target
203 !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
204 !ERROR: At most one COLLAPSE clause can appear on the DISTRIBUTE directive
205 !$omp distribute collapse(2) collapse(3)
206 do i = 1, N
207 do j = 1, N
208 do k = 1, N
209 a = 3.14
210 enddo
211 enddo
212 enddo
213 !$omp end distribute
214 !$omp end target
215
216 !$omp target
217 !$omp teams
218 !ERROR: At most one COLLAPSE clause can appear on the DISTRIBUTE directive
219 !$omp distribute collapse(2) collapse(3)
220 do i = 1, N
221 do j = 1, N
222 do k = 1, N
223 a = 3.14
224 enddo
225 enddo
226 enddo
227 !$omp end distribute
228 !$omp end teams
229 !$omp end target
230
231 !$omp target
232 !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
233 !$omp distribute dist_schedule(static, 2)
234 do i = 1, N
235 a = 3.14
236 enddo
237 !$omp end distribute
238 !$omp end target
239
240 !$omp target
241 !$omp teams
242 !$omp distribute dist_schedule(static, 2)
243 do i = 1, N
244 a = 3.14
245 enddo
246 !$omp end distribute
247 !$omp end teams
248 !$omp end target
249
250 !$omp target
251 !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
252 !ERROR: At most one DIST_SCHEDULE clause can appear on the DISTRIBUTE directive
253 !$omp distribute dist_schedule(static, 2) dist_schedule(static, 3)
254 do i = 1, N
255 a = 3.14
256 enddo
257 !$omp end distribute
258 !$omp end target
259
260 !$omp target
261 !$omp teams
262 !ERROR: At most one DIST_SCHEDULE clause can appear on the DISTRIBUTE directive
263 !$omp distribute dist_schedule(static, 2) dist_schedule(static, 3)
264 do i = 1, N
265 a = 3.14
266 enddo
267 !$omp end distribute
268 !$omp end teams
269 !$omp end target
270
271 end program main