[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Semantics / OpenACC / acc-loop.f90
blob75e09958909cd5ada026359bf8c3d37d77d1bdbb
1 ! RUN: %python %S/../test_errors.py %s %flang -fopenacc
3 ! Check OpenACC clause validity for the following construct and directive:
4 ! 2.9 Loop
6 program openacc_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 logical :: ifCondition = .TRUE.
25 type(atype) :: t
26 type(atype), dimension(10) :: ta
28 real(8), dimension(N) :: a, f, g, h
30 !$acc parallel
31 !$acc loop tile(2)
32 do i = 1, N
33 a(i) = 3.14
34 end do
35 !$acc end parallel
37 !$acc parallel device_type(*) num_gangs(2)
38 !$acc loop
39 do i = 1, N
40 a(i) = 3.14
41 end do
42 !$acc end parallel
44 !$acc parallel
45 !$acc loop seq
46 do i = 1, N
47 a(i) = 3.14
48 end do
49 !$acc end parallel
51 !$acc parallel
52 !$acc loop independent
53 do i = 1, N
54 a(i) = 3.14
55 end do
56 !$acc end parallel
58 !$acc parallel
59 !$acc loop auto
60 do i = 1, N
61 a(i) = 3.14
62 end do
63 !$acc end parallel
65 !$acc parallel
66 !ERROR: At most one VECTOR clause can appear on the LOOP directive
67 !$acc loop vector vector(128)
68 do i = 1, N
69 a(i) = 3.14
70 end do
71 !$acc end parallel
73 !$acc parallel
74 !$acc loop vector
75 do i = 1, N
76 a(i) = 3.14
77 end do
78 !$acc end parallel
80 !$acc parallel
81 !$acc loop vector(10)
82 do i = 1, N
83 a(i) = 3.14
84 end do
85 !$acc end parallel
87 !$acc parallel
88 !$acc loop vector(vector_size)
89 do i = 1, N
90 a(i) = 3.14
91 end do
92 !$acc end parallel
94 !$acc parallel
95 !$acc loop vector(length: vector_size)
96 do i = 1, N
97 a(i) = 3.14
98 end do
99 !$acc end parallel
101 !$acc parallel
102 !ERROR: At most one WORKER clause can appear on the LOOP directive
103 !$acc loop worker worker(10)
104 do i = 1, N
105 a(i) = 3.14
106 end do
107 !$acc end parallel
109 !$acc parallel
110 !$acc loop worker
111 do i = 1, N
112 a(i) = 3.14
113 end do
114 !$acc end parallel
116 !$acc parallel
117 !$acc loop worker(10)
118 do i = 1, N
119 a(i) = 3.14
120 end do
121 !$acc end parallel
123 !$acc parallel
124 !$acc loop worker(worker_size)
125 do i = 1, N
126 a(i) = 3.14
127 end do
128 !$acc end parallel
130 !$acc parallel
131 !$acc loop worker(num: worker_size)
132 do i = 1, N
133 a(i) = 3.14
134 end do
135 !$acc end parallel
137 !$acc parallel
138 !ERROR: At most one GANG clause can appear on the LOOP directive
139 !$acc loop gang gang(gang_size)
140 do i = 1, N
141 a(i) = 3.14
142 end do
143 !$acc end parallel
145 !$acc parallel
146 !$acc loop gang(gang_size)
147 do i = 1, N
148 a(i) = 3.14
149 end do
150 !$acc end parallel
152 !$acc parallel
153 !$acc loop gang(num: gang_size)
154 do i = 1, N
155 a(i) = 3.14
156 end do
157 !$acc end parallel
159 !$acc parallel
160 !$acc loop gang(gang_size, static:*)
161 do i = 1, N
162 a(i) = 3.14
163 end do
164 !$acc end parallel
166 !$acc parallel
167 !$acc loop gang(num: gang_size, static:*)
168 do i = 1, N
169 a(i) = 3.14
170 end do
171 !$acc end parallel
173 !$acc parallel
174 !$acc loop gang(num: gang_size, static: gang_size)
175 do i = 1, N
176 a(i) = 3.14
177 end do
178 !$acc end parallel
180 !$acc parallel
181 !$acc loop private(b, a(:))
182 do i = 1, N
183 a(i) = b
184 end do
185 !$acc end parallel
187 !$acc parallel
188 !$acc loop tile(*)
189 do i = 1, N
190 a(i) = b
191 end do
192 !$acc end parallel
194 !$acc parallel
195 !$acc loop tile(2, 2)
196 do i = 1, N
197 do j = 1, N
198 a(i) = b
199 end do
200 end do
201 !$acc end parallel
203 !$acc parallel
204 !ERROR: The parameter of the COLLAPSE clause must be a constant positive integer expression
205 !$acc loop collapse(-1)
206 do i = 1, N
207 do j = 1, N
208 a(i) = 3.14 + j
209 end do
210 end do
211 !$acc end parallel
213 !$acc parallel
214 !ERROR: Clause PRIVATE is not allowed after clause DEVICE_TYPE on the LOOP directive
215 !$acc loop device_type(*) private(i)
216 do i = 1, N
217 a(i) = 3.14
218 end do
219 !$acc end parallel
221 !$acc parallel
222 !ERROR: Clause GANG is not allowed if clause SEQ appears on the LOOP directive
223 !$acc loop gang seq
224 do i = 1, N
225 a(i) = 3.14
226 end do
227 !$acc end parallel
229 !$acc parallel
230 !ERROR: Clause WORKER is not allowed if clause SEQ appears on the LOOP directive
231 !$acc loop worker seq
232 do i = 1, N
233 a(i) = 3.14
234 end do
235 !$acc end parallel
237 !$acc parallel
238 !ERROR: Clause VECTOR is not allowed if clause SEQ appears on the LOOP directive
239 !$acc loop vector seq
240 do i = 1, N
241 a(i) = 3.14
242 end do
243 !$acc end parallel
245 !ERROR: Clause IF is not allowed after clause DEVICE_TYPE on the PARALLEL directive
246 !$acc parallel device_type(*) if(.TRUE.)
247 !$acc loop
248 do i = 1, N
249 a(i) = 3.14
250 end do
251 !$acc end parallel
253 end program openacc_loop_validity