[mlir][scf] Track replacements using a listener in TileAndFuse (#120999)
[llvm-project.git] / flang / test / Examples / omp-nowait.f90
blob091a952ae9106beb054f6974eb07b478bce983eb
1 ! REQUIRES: plugins, examples, shell
3 ! RUN: %flang_fc1 -load %llvmshlibdir/flangOmpReport.so -plugin flang-omp-report -fopenmp %s -o - | FileCheck %s
5 subroutine sb(n)
6 implicit none
8 integer :: n
9 integer :: arr(n,n), brr(n,n), crr(n,n)
10 integer :: arr_single(n),arr_quad(n,n,n,n)
11 integer :: i,j,k,l,tmp,tmp1,tmp2
13 ! CHECK:---
15 !Simple check with nowait
16 !$omp do
17 do i = 1, n
18 arr_single(i) = i
19 end do
20 !$omp end do nowait
21 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
22 ! CHECK-NEXT: line: [[@LINE-6]]
23 ! CHECK-NEXT: construct: do
24 ! CHECK-NEXT: clauses:
25 ! CHECK-NEXT: - clause: nowait
26 ! CHECK-NEXT: details: ''
28 !Check for no effects on loop without nowait
29 !$omp do
30 do i = 1, n
31 arr_single(i) = i
32 end do
33 !$omp end do
34 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
35 ! CHECK-NEXT: line: [[@LINE-6]]
36 ! CHECK-NEXT: construct: do
37 ! CHECK-NEXT: clauses: []
39 !Check with another construct nested inside loop with nowait
40 !$omp parallel shared(arr)
41 !$omp do
42 do i = 1, n
43 !$omp critical
44 arr_single(i) = i
45 !$omp end critical
46 end do
47 !$omp end do nowait
48 !$omp end parallel
49 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
50 ! CHECK-NEXT: line: [[@LINE-7]]
51 ! CHECK-NEXT: construct: critical
52 ! CHECK-NEXT: clauses: []
53 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
54 ! CHECK-NEXT: line: [[@LINE-13]]
55 ! CHECK-NEXT: construct: do
56 ! CHECK-NEXT: clauses:
57 ! CHECK-NEXT: - clause: nowait
58 ! CHECK-NEXT: details: ''
59 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
60 ! CHECK-NEXT: line: [[@LINE-20]]
61 ! CHECK-NEXT: construct: parallel
62 ! CHECK-NEXT: clauses:
63 ! CHECK-NEXT: - clause: shared
64 ! CHECK-NEXT: details: arr
66 !Check with back to back loops (one with nowait) inside a parallel construct
67 !$omp parallel shared(arr)
68 !$omp do
69 do i=1,10
70 arr(i,j) = i+j
71 end do
72 !$omp end do nowait
73 !$omp do schedule(guided)
74 do j=1,10
75 end do
76 !$omp end do
77 !$omp end parallel
78 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
79 ! CHECK-NEXT: line: [[@LINE-11]]
80 ! CHECK-NEXT: construct: do
81 ! CHECK-NEXT: clauses:
82 ! CHECK-NEXT: - clause: nowait
83 ! CHECK-NEXT: details: ''
84 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
85 ! CHECK-NEXT: line: [[@LINE-12]]
86 ! CHECK-NEXT: construct: do
87 ! CHECK-NEXT: clauses:
88 ! CHECK-NEXT: - clause: schedule
89 ! CHECK-NEXT: details: guided
90 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
91 ! CHECK-NEXT: line: [[@LINE-24]]
92 ! CHECK-NEXT: construct: parallel
93 ! CHECK-NEXT: clauses:
94 ! CHECK-NEXT: - clause: shared
95 ! CHECK-NEXT: details: arr
98 !Check nested parallel do loops with a nowait outside
99 !$omp parallel shared(arr)
100 !$omp do
101 do i=1,10
102 arr_single(i)=i
103 !$omp parallel
104 !$omp do
105 do j=1,10
106 !$omp critical
107 arr(i,j) = i+j
108 !$omp end critical
109 end do
110 !$omp end do
111 !$omp end parallel
112 end do
113 !$omp end do nowait
114 !$omp end parallel
115 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
116 ! CHECK-NEXT: line: [[@LINE-10]]
117 ! CHECK-NEXT: construct: critical
118 ! CHECK-NEXT: clauses: []
119 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
120 ! CHECK-NEXT: line: [[@LINE-16]]
121 ! CHECK-NEXT: construct: do
122 ! CHECK-NEXT: clauses: []
123 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
124 ! CHECK-NEXT: line: [[@LINE-21]]
125 ! CHECK-NEXT: construct: parallel
126 ! CHECK-NEXT: clauses: []
127 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
128 ! CHECK-NEXT: line: [[@LINE-28]]
129 ! CHECK-NEXT: construct: do
130 ! CHECK-NEXT: clauses:
131 ! CHECK-NEXT: - clause: nowait
132 ! CHECK-NEXT: details: ''
133 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
134 ! CHECK-NEXT: line: [[@LINE-35]]
135 ! CHECK-NEXT: construct: parallel
136 ! CHECK-NEXT: clauses:
137 ! CHECK-NEXT: - clause: shared
138 ! CHECK-NEXT: details: arr
140 !Check nested parallel do loops with a nowait inside
141 !$omp parallel shared(arr)
142 !$omp do
143 do i=1,10
144 arr_single(i)=i
145 !$omp parallel
146 !$omp do
147 do j=1,10
148 !$omp critical
149 arr(i,j) = i+j
150 !$omp end critical
151 end do
152 !$omp end do nowait
153 !$omp end parallel
154 end do
155 !$omp end do
156 !$omp end parallel
157 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
158 ! CHECK-NEXT: line: [[@LINE-10]]
159 ! CHECK-NEXT: construct: critical
160 ! CHECK-NEXT: clauses: []
161 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
162 ! CHECK-NEXT: line: [[@LINE-16]]
163 ! CHECK-NEXT: construct: do
164 ! CHECK-NEXT: clauses:
165 ! CHECK-NEXT: - clause: nowait
166 ! CHECK-NEXT: details: ''
167 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
168 ! CHECK-NEXT: line: [[@LINE-23]]
169 ! CHECK-NEXT: construct: parallel
170 ! CHECK-NEXT: clauses: []
171 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
172 ! CHECK-NEXT: line: [[@LINE-30]]
173 ! CHECK-NEXT: construct: do
174 ! CHECK-NEXT: clauses: []
175 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
176 ! CHECK-NEXT: line: [[@LINE-35]]
177 ! CHECK-NEXT: construct: parallel
178 ! CHECK-NEXT: clauses:
179 ! CHECK-NEXT: - clause: shared
180 ! CHECK-NEXT: details: arr
182 !Check nested parallel do loops with a nowait inside
183 !$omp parallel
184 !$omp do
185 do i=1,10
186 arr_single(i)=i
187 !$omp parallel shared(arr_quad)
188 !$omp do schedule(dynamic)
189 do j=1,10
190 !$omp parallel
191 !$omp do
192 do k=1,10
193 !$omp parallel
194 !$omp do
195 do l=1,10
196 arr_quad(i,j,k,l) = i+j+k+l
197 end do
198 !$omp end do nowait
199 !$omp end parallel
200 end do
201 !$omp end do
202 !$omp end parallel
203 end do
204 !$omp end do nowait
205 !$omp end parallel
206 end do
207 !$omp end do
208 !$omp end parallel
209 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
210 ! CHECK-NEXT: line: [[@LINE-16]]
211 ! CHECK-NEXT: construct: do
212 ! CHECK-NEXT: clauses:
213 ! CHECK-NEXT: - clause: nowait
214 ! CHECK-NEXT: details: ''
215 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
216 ! CHECK-NEXT: line: [[@LINE-23]]
217 ! CHECK-NEXT: construct: parallel
218 ! CHECK-NEXT: clauses: []
219 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
220 ! CHECK-NEXT: line: [[@LINE-29]]
221 ! CHECK-NEXT: construct: do
222 ! CHECK-NEXT: clauses: []
223 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
224 ! CHECK-NEXT: line: [[@LINE-34]]
225 ! CHECK-NEXT: construct: parallel
226 ! CHECK-NEXT: clauses: []
227 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
228 ! CHECK-NEXT: line: [[@LINE-40]]
229 ! CHECK-NEXT: construct: do
230 ! CHECK-NEXT: clauses:
231 ! CHECK-NEXT: - clause: nowait
232 ! CHECK-NEXT: details: ''
233 ! CHECK-NEXT: - clause: schedule
234 ! CHECK-NEXT: details: dynamic
235 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
236 ! CHECK-NEXT: line: [[@LINE-49]]
237 ! CHECK-NEXT: construct: parallel
238 ! CHECK-NEXT: clauses:
239 ! CHECK-NEXT: - clause: shared
240 ! CHECK-NEXT: details: arr_quad
241 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
242 ! CHECK-NEXT: line: [[@LINE-58]]
243 ! CHECK-NEXT: construct: do
244 ! CHECK-NEXT: clauses: []
245 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
246 ! CHECK-NEXT: line: [[@LINE-63]]
247 ! CHECK-NEXT: construct: parallel
248 ! CHECK-NEXT: clauses: []
251 !Check a do simd with nowait
252 !$omp do simd private(tmp)
253 do j = 1,n
254 do i = 1,n
255 tmp = arr(i,j) + brr(i,j)
256 crr(i,j) = tmp
257 end do
258 end do
259 !$omp end do simd nowait
260 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
261 ! CHECK-NEXT: line: [[@LINE-9]]
262 ! CHECK-NEXT: construct: do simd
263 ! CHECK-NEXT: clauses:
264 ! CHECK-NEXT: - clause: nowait
265 ! CHECK-NEXT: details: ''
266 ! CHECK-NEXT: - clause: private
267 ! CHECK-NEXT: details: tmp
270 !test nowait on non-do construct
271 !$omp parallel
272 !$omp single
273 tmp1 = i+j
274 !$omp end single
276 !$omp single
277 tmp2 = i-j
278 !$omp end single nowait
279 !$omp end parallel
280 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
281 ! CHECK-NEXT: line: [[@LINE-9]]
282 ! CHECK-NEXT: construct: single
283 ! CHECK-NEXT: clauses: []
284 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
285 ! CHECK-NEXT: line: [[@LINE-9]]
286 ! CHECK-NEXT: construct: single
287 ! CHECK-NEXT: clauses:
288 ! CHECK-NEXT: - clause: nowait
289 ! CHECK-NEXT: details: ''
290 ! CHECK-NEXT:- file: '{{[^"]*}}omp-nowait.f90'
291 ! CHECK-NEXT: line: [[@LINE-20]]
292 ! CHECK-NEXT: construct: parallel
293 ! CHECK-NEXT: clauses: []
295 end subroutine
297 ! CHECK-NEXT:...