[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Semantics / OpenMP / omp-device-constructs.f90
blob51f00700b6daf74f7f14d64b8d64e479d96989c3
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
6 real(8) :: arrayA(256), arrayB(256)
7 integer :: N
9 arrayA = 1.414
10 arrayB = 3.14
11 N = 256
13 !$omp target map(arrayA)
14 do i = 1, N
15 a = 3.14
16 enddo
17 !$omp end target
19 !$omp target device(0)
20 do i = 1, N
21 a = 3.14
22 enddo
23 !$omp end target
25 !ERROR: At most one DEVICE clause can appear on the TARGET directive
26 !$omp target device(0) device(1)
27 do i = 1, N
28 a = 3.14
29 enddo
30 !$omp end target
32 !ERROR: SCHEDULE clause is not allowed on the TARGET directive
33 !$omp target schedule(static)
34 do i = 1, N
35 a = 3.14
36 enddo
37 !$omp end target
39 !$omp target defaultmap(tofrom:scalar)
40 do i = 1, N
41 a = 3.14
42 enddo
43 !$omp end target
45 !ERROR: The argument TOFROM:SCALAR must be specified on the DEFAULTMAP clause
46 !$omp target defaultmap(tofrom)
47 do i = 1, N
48 a = 3.14
49 enddo
50 !$omp end target
52 !ERROR: At most one DEFAULTMAP clause can appear on the TARGET directive
53 !$omp target defaultmap(tofrom:scalar) defaultmap(tofrom:scalar)
54 do i = 1, N
55 a = 3.14
56 enddo
57 !$omp end target
59 !$omp target thread_limit(4)
60 do i = 1, N
61 a = 3.14
62 enddo
63 !$omp end target
65 !ERROR: At most one THREAD_LIMIT clause can appear on the TARGET directive
66 !$omp target thread_limit(4) thread_limit(8)
67 do i = 1, N
68 a = 3.14
69 enddo
70 !$omp end target
72 !$omp teams num_teams(3) thread_limit(10) default(shared) private(i) shared(a)
73 do i = 1, N
74 a = 3.14
75 enddo
76 !$omp end teams
78 !ERROR: At most one NUM_TEAMS clause can appear on the TEAMS directive
79 !$omp teams num_teams(2) num_teams(3)
80 do i = 1, N
81 a = 3.14
82 enddo
83 !$omp end teams
85 !ERROR: The parameter of the NUM_TEAMS clause must be a positive integer expression
86 !$omp teams num_teams(-1)
87 do i = 1, N
88 a = 3.14
89 enddo
90 !$omp end teams
92 !ERROR: At most one THREAD_LIMIT clause can appear on the TEAMS directive
93 !$omp teams thread_limit(2) thread_limit(3)
94 do i = 1, N
95 a = 3.14
96 enddo
97 !$omp end teams
99 !ERROR: The parameter of the THREAD_LIMIT clause must be a positive integer expression
100 !$omp teams thread_limit(-1)
101 do i = 1, N
102 a = 3.14
103 enddo
104 !$omp end teams
106 !ERROR: At most one DEFAULT clause can appear on the TEAMS directive
107 !$omp teams default(shared) default(private)
108 do i = 1, N
109 a = 3.14
110 enddo
111 !$omp end teams
113 !$omp target teams num_teams(2) defaultmap(tofrom:scalar)
114 do i = 1, N
115 a = 3.14
116 enddo
117 !$omp end target teams
119 !$omp target map(tofrom:a)
120 do i = 1, N
121 a = 3.14
122 enddo
123 !$omp end target
125 !ERROR: Only the TO, FROM, TOFROM, ALLOC map types are permitted for MAP clauses on the TARGET directive
126 !$omp target map(delete:a)
127 do i = 1, N
128 a = 3.14
129 enddo
130 !$omp end target
132 !$omp target data device(0) map(to:a)
133 do i = 1, N
134 a = 3.14
135 enddo
136 !$omp end target data
138 !ERROR: At least one of MAP clause must appear on the TARGET DATA directive
139 !$omp target data device(0)
140 do i = 1, N
141 a = 3.14
142 enddo
143 !$omp end target data
145 !ERROR: The device expression of the DEVICE clause must be a positive integer expression
146 !$omp target enter data map(alloc:A) device(-2)
148 !ERROR: The device expression of the DEVICE clause must be a positive integer expression
149 !$omp target exit data map(delete:A) device(-2)
151 !ERROR: At most one IF clause can appear on the TARGET ENTER DATA directive
152 !$omp target enter data map(to:a) if(.true.) if(.false.)
154 !ERROR: Only the TO, ALLOC map types are permitted for MAP clauses on the TARGET ENTER DATA directive
155 !$omp target enter data map(from:a)
157 !$omp target exit data map(delete:a)
159 !ERROR: At most one DEVICE clause can appear on the TARGET EXIT DATA directive
160 !$omp target exit data map(from:a) device(0) device(1)
162 !ERROR: Only the FROM, RELEASE, DELETE map types are permitted for MAP clauses on the TARGET EXIT DATA directive
163 !$omp target exit data map(to:a)
165 !$omp target update if(.true.) device(1) to(a) from(b) depend(inout:c) nowait
167 !ERROR: At most one IF clause can appear on the TARGET UPDATE directive
168 !$omp target update to(a) if(.true.) if(.false.)
170 !ERROR: At most one DEVICE clause can appear on the TARGET UPDATE directive
171 !$omp target update device(0) device(1) from(b)
173 !$omp target
174 !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
175 !$omp distribute
176 do i = 1, N
177 a = 3.14
178 enddo
179 !$omp end distribute
180 !$omp end target
182 !$omp target
183 !$omp teams
184 !$omp distribute
185 do i = 1, N
186 a = 3.14
187 enddo
188 !$omp end distribute
189 !$omp end teams
190 !$omp end target
192 !$omp target
193 !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
194 !ERROR: At most one COLLAPSE clause can appear on the DISTRIBUTE directive
195 !$omp distribute collapse(2) collapse(3)
196 do i = 1, N
197 do j = 1, N
198 do k = 1, N
199 a = 3.14
200 enddo
201 enddo
202 enddo
203 !$omp end distribute
204 !$omp end target
206 !$omp target
207 !$omp teams
208 !ERROR: At most one COLLAPSE clause can appear on the DISTRIBUTE directive
209 !$omp distribute collapse(2) collapse(3)
210 do i = 1, N
211 do j = 1, N
212 do k = 1, N
213 a = 3.14
214 enddo
215 enddo
216 enddo
217 !$omp end distribute
218 !$omp end teams
219 !$omp end target
221 !$omp target
222 !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
223 !$omp distribute dist_schedule(static, 2)
224 do i = 1, N
225 a = 3.14
226 enddo
227 !$omp end distribute
228 !$omp end target
230 !$omp target
231 !$omp teams
232 !$omp distribute dist_schedule(static, 2)
233 do i = 1, N
234 a = 3.14
235 enddo
236 !$omp end distribute
237 !$omp end teams
238 !$omp end target
240 !$omp target
241 !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
242 !ERROR: At most one DIST_SCHEDULE clause can appear on the DISTRIBUTE directive
243 !$omp distribute dist_schedule(static, 2) dist_schedule(static, 3)
244 do i = 1, N
245 a = 3.14
246 enddo
247 !$omp end distribute
248 !$omp end target
250 !$omp target
251 !$omp teams
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 teams
259 !$omp end target
261 end program main