[LoopReroll] Add an extra defensive check to avoid SCEV assertion.
[llvm-project.git] / flang / test / Semantics / OpenACC / acc-loop.f90
blob2cd71751beac8b5986bf319930fc8437d7ffe083
1 ! RUN: %S/../test_errors.sh %s %t %flang -fopenacc
2 ! REQUIRES: shell
4 ! Check OpenACC clause validity for the following construct and directive:
5 ! 2.9 Loop
7 program openacc_loop_validity
9 implicit none
11 type atype
12 real(8), dimension(10) :: arr
13 real(8) :: s
14 end type atype
16 integer :: i, j, b, gang_size, vector_size, worker_size
17 integer, parameter :: N = 256
18 integer, dimension(N) :: c
19 logical, dimension(N) :: d, e
20 integer :: async1
21 integer :: wait1, wait2
22 real :: reduction_r
23 logical :: reduction_l
24 real(8), dimension(N, N) :: aa, bb, cc
25 logical :: ifCondition = .TRUE.
26 type(atype) :: t
27 type(atype), dimension(10) :: ta
29 real(8), dimension(N) :: a, f, g, h
31 !$acc parallel
32 !$acc loop tile(2)
33 do i = 1, N
34 a(i) = 3.14
35 end do
36 !$acc end parallel
38 !$acc parallel device_type(*) num_gangs(2)
39 !$acc loop
40 do i = 1, N
41 a(i) = 3.14
42 end do
43 !$acc end parallel
45 !$acc parallel
46 !$acc loop seq
47 do i = 1, N
48 a(i) = 3.14
49 end do
50 !$acc end parallel
52 !$acc parallel
53 !$acc loop independent
54 do i = 1, N
55 a(i) = 3.14
56 end do
57 !$acc end parallel
59 !$acc parallel
60 !$acc loop auto
61 do i = 1, N
62 a(i) = 3.14
63 end do
64 !$acc end parallel
66 !$acc parallel
67 !ERROR: At most one VECTOR clause can appear on the LOOP directive
68 !$acc loop vector vector(128)
69 do i = 1, N
70 a(i) = 3.14
71 end do
72 !$acc end parallel
74 !$acc parallel
75 !$acc loop vector
76 do i = 1, N
77 a(i) = 3.14
78 end do
79 !$acc end parallel
81 !$acc parallel
82 !$acc loop vector(10)
83 do i = 1, N
84 a(i) = 3.14
85 end do
86 !$acc end parallel
88 !$acc parallel
89 !$acc loop vector(vector_size)
90 do i = 1, N
91 a(i) = 3.14
92 end do
93 !$acc end parallel
95 !$acc parallel
96 !$acc loop vector(length: vector_size)
97 do i = 1, N
98 a(i) = 3.14
99 end do
100 !$acc end parallel
102 !$acc parallel
103 !ERROR: At most one WORKER clause can appear on the LOOP directive
104 !$acc loop worker worker(10)
105 do i = 1, N
106 a(i) = 3.14
107 end do
108 !$acc end parallel
110 !$acc parallel
111 !$acc loop worker
112 do i = 1, N
113 a(i) = 3.14
114 end do
115 !$acc end parallel
117 !$acc parallel
118 !$acc loop worker(10)
119 do i = 1, N
120 a(i) = 3.14
121 end do
122 !$acc end parallel
124 !$acc parallel
125 !$acc loop worker(worker_size)
126 do i = 1, N
127 a(i) = 3.14
128 end do
129 !$acc end parallel
131 !$acc parallel
132 !$acc loop worker(num: worker_size)
133 do i = 1, N
134 a(i) = 3.14
135 end do
136 !$acc end parallel
138 !$acc parallel
139 !ERROR: At most one GANG clause can appear on the LOOP directive
140 !$acc loop gang gang(gang_size)
141 do i = 1, N
142 a(i) = 3.14
143 end do
144 !$acc end parallel
146 !$acc parallel
147 !$acc loop gang(gang_size)
148 do i = 1, N
149 a(i) = 3.14
150 end do
151 !$acc end parallel
153 !$acc parallel
154 !$acc loop gang(num: gang_size)
155 do i = 1, N
156 a(i) = 3.14
157 end do
158 !$acc end parallel
160 !$acc parallel
161 !$acc loop gang(gang_size, static:*)
162 do i = 1, N
163 a(i) = 3.14
164 end do
165 !$acc end parallel
167 !$acc parallel
168 !$acc loop gang(num: gang_size, static:*)
169 do i = 1, N
170 a(i) = 3.14
171 end do
172 !$acc end parallel
174 !$acc parallel
175 !$acc loop gang(num: gang_size, static: gang_size)
176 do i = 1, N
177 a(i) = 3.14
178 end do
179 !$acc end parallel
181 !$acc parallel
182 !$acc loop private(b, a(:))
183 do i = 1, N
184 a(i) = b
185 end do
186 !$acc end parallel
188 !$acc parallel
189 !$acc loop tile(*)
190 do i = 1, N
191 a(i) = b
192 end do
193 !$acc end parallel
195 !$acc parallel
196 !$acc loop tile(2, 2)
197 do i = 1, N
198 do j = 1, N
199 a(i) = b
200 end do
201 end do
202 !$acc end parallel
204 !$acc parallel
205 !ERROR: The parameter of the COLLAPSE clause must be a constant positive integer expression
206 !$acc loop collapse(-1)
207 do i = 1, N
208 do j = 1, N
209 a(i) = 3.14 + j
210 end do
211 end do
212 !$acc end parallel
214 !$acc parallel
215 !ERROR: Clause PRIVATE is not allowed after clause DEVICE_TYPE on the LOOP directive
216 !$acc loop device_type(*) private(i)
217 do i = 1, N
218 a(i) = 3.14
219 end do
220 !$acc end parallel
222 !$acc parallel
223 !ERROR: Clause GANG is not allowed if clause SEQ appears on the LOOP directive
224 !$acc loop gang seq
225 do i = 1, N
226 a(i) = 3.14
227 end do
228 !$acc end parallel
230 !$acc parallel
231 !ERROR: Clause WORKER is not allowed if clause SEQ appears on the LOOP directive
232 !$acc loop worker seq
233 do i = 1, N
234 a(i) = 3.14
235 end do
236 !$acc end parallel
238 !$acc parallel
239 !ERROR: Clause VECTOR is not allowed if clause SEQ appears on the LOOP directive
240 !$acc loop vector seq
241 do i = 1, N
242 a(i) = 3.14
243 end do
244 !$acc end parallel
246 !ERROR: Clause IF is not allowed after clause DEVICE_TYPE on the PARALLEL directive
247 !$acc parallel device_type(*) if(.TRUE.)
248 !$acc loop
249 do i = 1, N
250 a(i) = 3.14
251 end do
252 !$acc end parallel
254 end program openacc_loop_validity