[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Semantics / OpenACC / acc-kernels-loop.f90
blobd84e1c2dedf400de78076c293d5cb885e08f9a40
1 ! RUN: %python %S/../test_errors.py %s %flang -fopenacc
3 ! Check OpenACC clause validity for the following construct and directive:
4 ! 2.11 Kernels Loop
6 program openacc_kernels_loop_validity
8 implicit none
10 type atype
11 real(8), dimension(10) :: arr
12 real(8) :: s
13 end type atype
15 integer :: i, j, b, gang_size, vector_size, worker_size
16 integer, parameter :: N = 256
17 integer, dimension(N) :: c
18 logical, dimension(N) :: d, e
19 integer :: async1
20 integer :: wait1, wait2
21 real :: reduction_r
22 logical :: reduction_l
23 real(8), dimension(N, N) :: aa, bb, cc
24 real(8), dimension(:), allocatable :: dd
25 real(8), pointer :: p
26 logical :: ifCondition = .TRUE.
27 type(atype) :: t
28 type(atype), dimension(10) :: ta
30 real(8), dimension(N) :: a, f, g, h
32 !$acc kernels loop
33 do i = 1, N
34 a(i) = 3.14
35 end do
37 !$acc kernels loop num_gangs(8)
38 do i = 1, N
39 a(i) = 3.14
40 end do
42 !$acc kernels loop num_gangs(gang_size)
43 do i = 1, N
44 a(i) = 3.14
45 end do
47 !$acc kernels loop num_gangs(8)
48 do i = 1, N
49 a(i) = 3.14
50 end do
52 !$acc kernels loop num_workers(worker_size)
53 do i = 1, N
54 a(i) = 3.14
55 end do
57 !$acc kernels loop num_workers(8)
58 do i = 1, N
59 a(i) = 3.14
60 end do
62 !$acc kernels loop vector_length(vector_size)
63 do i = 1, N
64 a(i) = 3.14
65 end do
67 !$acc kernels loop vector_length(128)
68 do i = 1, N
69 a(i) = 3.14
70 end do
72 !$acc kernels loop num_gangs(gang_size)
73 do i = 1, N
74 a(i) = 3.14
75 end do
78 !$acc kernels loop if(.TRUE.)
79 do i = 1, N
80 a(i) = 3.14
81 end do
83 !$acc kernels loop if(ifCondition)
84 do i = 1, N
85 a(i) = 3.14
86 end do
88 !$acc kernels loop
89 do i = 1, N
90 a(i) = 3.14
91 end do
92 !ERROR: Unmatched END SERIAL LOOP directive
93 !$acc end serial loop
95 !ERROR: Clause IF is not allowed after clause DEVICE_TYPE on the KERNELS LOOP directive
96 !$acc kernels loop device_type(*) if(.TRUE.)
97 do i = 1, N
98 a(i) = 3.14
99 end do
100 !$acc end kernels loop
102 !$acc kernels loop async
103 do i = 1, N
104 a(i) = 3.14
105 end do
107 !$acc kernels loop async(1)
108 do i = 1, N
109 a(i) = 3.14
110 end do
112 !$acc kernels loop async(async1)
113 do i = 1, N
114 a(i) = 3.14
115 end do
117 !$acc kernels loop wait(wait1)
118 do i = 1, N
119 a(i) = 3.14
120 end do
122 !$acc kernels loop wait(wait1, wait2)
123 do i = 1, N
124 a(i) = 3.14
125 end do
127 !$acc kernels loop wait(wait1) wait(wait2)
128 do i = 1, N
129 a(i) = 3.14
130 end do
132 !$acc kernels loop wait(1, 2) async(3)
133 do i = 1, N
134 a(i) = 3.14
135 end do
137 !$acc kernels loop wait(queues: 1, 2) async(3)
138 do i = 1, N
139 a(i) = 3.14
140 end do
142 !$acc kernels loop wait(devnum: 1: 1, 2) async(3)
143 do i = 1, N
144 a(i) = 3.14
145 end do
147 !$acc kernels loop wait(devnum: 1: queues: 1, 2) async(3)
148 do i = 1, N
149 a(i) = 3.14
150 end do
152 !$acc kernels loop num_gangs(8)
153 do i = 1, N
154 a(i) = 3.14
155 end do
157 !$acc kernels loop num_workers(8)
158 do i = 1, N
159 a(i) = 3.14
160 end do
162 !$acc kernels loop vector_length(128)
163 do i = 1, N
164 a(i) = 3.14
165 end do
167 !$acc kernels loop if(.true.)
168 do i = 1, N
169 a(i) = 3.14
170 end do
172 !$acc kernels loop if(ifCondition)
173 do i = 1, N
174 a(i) = 3.14
175 end do
177 !ERROR: At most one IF clause can appear on the KERNELS LOOP directive
178 !$acc kernels loop if(.true.) if(ifCondition)
179 do i = 1, N
180 a(i) = 3.14
181 end do
183 !$acc kernels loop self
184 do i = 1, N
185 a(i) = 3.14
186 end do
188 !$acc kernels loop self(.true.)
189 do i = 1, N
190 a(i) = 3.14
191 end do
193 !$acc kernels loop self(ifCondition)
194 do i = 1, N
195 a(i) = 3.14
196 end do
198 !$acc kernels loop copy(aa) copyin(bb) copyout(cc)
199 do i = 1, N
200 a(i) = 3.14
201 end do
203 !$acc kernels loop copy(aa, bb) copyout(zero: cc)
204 do i = 1, N
205 a(i) = 3.14
206 end do
208 !$acc kernels loop present(aa, bb) create(cc)
209 do i = 1, N
210 a(i) = 3.14
211 end do
213 !$acc kernels loop copyin(readonly: aa, bb) create(zero: cc)
214 do i = 1, N
215 a(i) = 3.14
216 end do
218 !$acc kernels loop deviceptr(aa, bb) no_create(cc)
219 do i = 1, N
220 a(i) = 3.14
221 end do
223 !ERROR: Argument `aa` on the ATTACH clause must be a variable or array with the POINTER or ALLOCATABLE attribute
224 !$acc kernels loop attach(aa, dd, p)
225 do i = 1, N
226 a(i) = 3.14
227 end do
229 !$acc kernels loop private(aa, bb, cc)
230 do i = 1, N
231 a(i) = 3.14
232 end do
234 !$acc kernels loop default(none)
235 do i = 1, N
236 a(i) = 3.14
237 end do
239 !$acc kernels loop default(present)
240 do i = 1, N
241 a(i) = 3.14
242 end do
244 !ERROR: At most one DEFAULT clause can appear on the KERNELS LOOP directive
245 !$acc kernels loop default(none) default(present)
246 do i = 1, N
247 a(i) = 3.14
248 end do
250 !$acc kernels loop device_type(*)
251 do i = 1, N
252 a(i) = 3.14
253 end do
255 !$acc kernels loop device_type(1)
256 do i = 1, N
257 a(i) = 3.14
258 end do
260 !$acc kernels loop device_type(1, 3)
261 do i = 1, N
262 a(i) = 3.14
263 end do
265 !$acc kernels loop device_type(*) async wait num_gangs(8) num_workers(8) vector_length(128)
266 do i = 1, N
267 a(i) = 3.14
268 end do
270 !$acc kernels loop device_type(*) async
271 do i = 1, N
272 a(i) = 3.14
273 end do
275 !ERROR: Clause IF is not allowed after clause DEVICE_TYPE on the KERNELS LOOP directive
276 !$acc kernels loop device_type(*) if(.TRUE.)
277 do i = 1, N
278 a(i) = 3.14
279 end do
281 end program openacc_kernels_loop_validity