1 /* Test erroneous cases of nested 'reduction' clauses. */
2
3 /* See also 'gfortran.dg/goacc/nested-reductions-2-parallel.f90'. */
4
acc_parallel(void)5 void acc_parallel (void)
6 {
7 int i, j, k, l, sum, diff;
8
9 #pragma acc parallel
10 {
11 #pragma acc loop reduction(+:sum)
12 for (i = 0; i < 10; i++)
13 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
14 for (j = 0; j < 10; j++)
15 #pragma acc loop reduction(+:sum)
16 for (k = 0; k < 10; k++)
17 sum = 1;
18
19 #pragma acc loop reduction(+:sum)
20 for (i = 0; i < 10; i++)
21 #pragma acc loop collapse(2) // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
22 for (j = 0; j < 10; j++)
23 for (k = 0; k < 10; k++)
24 #pragma acc loop reduction(+:sum)
25 for (l = 0; l < 10; l++)
26 sum = 1;
27
28 #pragma acc loop reduction(+:sum)
29 for (i = 0; i < 10; i++)
30 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
31 for (j = 0; j < 10; j++)
32 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
33 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
34 for (k = 0; k < 10; k++)
35 #pragma acc loop reduction(+:sum)
36 for (l = 0; l < 10; l++)
37 sum = 1;
38
39 #pragma acc loop reduction(+:sum)
40 for (i = 0; i < 10; i++)
41 #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." }
42 for (j = 0; j < 10; j++)
43 #pragma acc loop reduction(+:sum) // { dg-warning "conflicting reduction operations for .sum." }
44 for (k = 0; k < 10; k++)
45 sum = 1;
46
47 #pragma acc loop reduction(+:sum)
48 for (i = 0; i < 10; i++)
49 #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." }
50 for (j = 0; j < 10; j++)
51 #pragma acc loop reduction(-:sum)
52 for (k = 0; k < 10; k++)
53 sum = 1;
54
55 #pragma acc loop reduction(+:sum)
56 for (i = 0; i < 10; i++)
57 #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." }
58 for (j = 0; j < 10; j++)
59 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
60 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
61 for (k = 0; k < 10; k++)
62 #pragma acc loop reduction(*:sum) // { dg-warning "conflicting reduction operations for .sum." }
63 for (l = 0; l < 10; l++)
64 sum = 1;
65
66 #pragma acc loop reduction(+:sum)
67 for (i = 0; i < 10; i++)
68 #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." }
69 for (j = 0; j < 10; j++)
70 #pragma acc loop reduction(+:sum) // { dg-warning "conflicting reduction operations for .sum." }
71 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
72 for (k = 0; k < 10; k++)
73 #pragma acc loop reduction(*:sum) // { dg-warning "conflicting reduction operations for .sum." }
74 for (l = 0; l < 10; l++)
75 sum = 1;
76
77 #pragma acc loop reduction(+:sum) reduction(-:diff)
78 for (i = 0; i < 10; i++)
79 {
80 #pragma acc loop reduction(-:diff) // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
81 for (j = 0; j < 10; j++)
82 #pragma acc loop reduction(+:sum)
83 for (k = 0; k < 10; k++)
84 sum = 1;
85
86 #pragma acc loop reduction(+:sum) // { dg-warning "nested loop in reduction needs reduction clause for .diff." }
87 for (j = 0; j < 10; j++)
88 #pragma acc loop reduction(-:diff)
89 for (k = 0; k < 10; k++)
90 diff = 1;
91 }
92 }
93 }
94
95 /* The same tests as above, but using a combined parallel loop construct. */
96
acc_parallel_loop(void)97 void acc_parallel_loop (void)
98 {
99 int i, j, k, l, sum, diff;
100
101 #pragma acc parallel loop
102 for (int h = 0; h < 10; ++h)
103 {
104 #pragma acc loop reduction(+:sum)
105 for (i = 0; i < 10; i++)
106 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
107 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
108 for (j = 0; j < 10; j++)
109 #pragma acc loop reduction(+:sum)
110 for (k = 0; k < 10; k++)
111 sum = 1;
112
113 #pragma acc loop reduction(+:sum)
114 for (i = 0; i < 10; i++)
115 #pragma acc loop collapse(2) // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
116 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
117 for (j = 0; j < 10; j++)
118 for (k = 0; k < 10; k++)
119 #pragma acc loop reduction(+:sum)
120 for (l = 0; l < 10; l++)
121 sum = 1;
122
123 #pragma acc loop reduction(+:sum)
124 for (i = 0; i < 10; i++)
125 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
126 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
127 for (j = 0; j < 10; j++)
128 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
129 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
130 for (k = 0; k < 10; k++)
131 #pragma acc loop reduction(+:sum)
132 for (l = 0; l < 10; l++)
133 sum = 1;
134
135 #pragma acc loop reduction(+:sum)
136 for (i = 0; i < 10; i++)
137 #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." }
138 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
139 for (j = 0; j < 10; j++)
140 #pragma acc loop reduction(+:sum) // { dg-warning "conflicting reduction operations for .sum." }
141 for (k = 0; k < 10; k++)
142 sum = 1;
143
144 #pragma acc loop reduction(+:sum)
145 for (i = 0; i < 10; i++)
146 #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." }
147 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
148 for (j = 0; j < 10; j++)
149 #pragma acc loop reduction(-:sum)
150 for (k = 0; k < 10; k++)
151 sum = 1;
152
153 #pragma acc loop reduction(+:sum)
154 for (i = 0; i < 10; i++)
155 #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." }
156 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
157 for (j = 0; j < 10; j++)
158 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
159 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
160 for (k = 0; k < 10; k++)
161 #pragma acc loop reduction(*:sum) // { dg-warning "conflicting reduction operations for .sum." }
162 for (l = 0; l < 10; l++)
163 sum = 1;
164
165 #pragma acc loop reduction(+:sum)
166 for (i = 0; i < 10; i++)
167 #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." }
168 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
169 for (j = 0; j < 10; j++)
170 #pragma acc loop reduction(+:sum) // { dg-warning "conflicting reduction operations for .sum." }
171 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
172 for (k = 0; k < 10; k++)
173 #pragma acc loop reduction(*:sum) // { dg-warning "conflicting reduction operations for .sum." }
174 for (l = 0; l < 10; l++)
175 sum = 1;
176
177 #pragma acc loop reduction(+:sum) reduction(-:diff)
178 for (i = 0; i < 10; i++)
179 {
180 #pragma acc loop reduction(-:diff) // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
181 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
182 for (j = 0; j < 10; j++)
183 #pragma acc loop reduction(+:sum)
184 for (k = 0; k < 10; k++)
185 sum = 1;
186
187 #pragma acc loop reduction(+:sum) // { dg-warning "nested loop in reduction needs reduction clause for .diff." }
188 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
189 for (j = 0; j < 10; j++)
190 #pragma acc loop reduction(-:diff)
191 for (k = 0; k < 10; k++)
192 diff = 1;
193 }
194 }
195 }
196
197 /* The same tests as above, but now the outermost reduction clause is on
198 the parallel region, not the outermost loop. */
acc_parallel_reduction(void)199 void acc_parallel_reduction (void)
200 {
201 int i, j, k, l, sum, diff;
202
203 #pragma acc parallel reduction(+:sum)
204 {
205 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
206 for (i = 0; i < 10; i++)
207 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
208 for (j = 0; j < 10; j++)
209 #pragma acc loop reduction(+:sum)
210 for (k = 0; k < 10; k++)
211 sum = 1;
212
213 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
214 for (i = 0; i < 10; i++)
215 #pragma acc loop collapse(2) // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
216 for (j = 0; j < 10; j++)
217 for (k = 0; k < 10; k++)
218 #pragma acc loop reduction(+:sum)
219 for (l = 0; l < 10; l++)
220 sum = 1;
221
222 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
223 for (i = 0; i < 10; i++)
224 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
225 for (j = 0; j < 10; j++)
226 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
227 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
228 for (k = 0; k < 10; k++)
229 #pragma acc loop reduction(+:sum)
230 for (l = 0; l < 10; l++)
231 sum = 1;
232
233 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
234 for (i = 0; i < 10; i++)
235 #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." }
236 for (j = 0; j < 10; j++)
237 #pragma acc loop reduction(+:sum) // { dg-warning "conflicting reduction operations for .sum." }
238 for (k = 0; k < 10; k++)
239 sum = 1;
240
241 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
242 for (i = 0; i < 10; i++)
243 #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." }
244 for (j = 0; j < 10; j++)
245 #pragma acc loop reduction(-:sum)
246 for (k = 0; k < 10; k++)
247 sum = 1;
248
249 #pragma acc loop reduction(max:sum) // { dg-warning "conflicting reduction operations for .sum." }
250 for (i = 0; i < 10; i++)
251 #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." }
252 for (j = 0; j < 10; j++)
253 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
254 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
255 for (k = 0; k < 10; k++)
256 #pragma acc loop reduction(*:sum) // { dg-warning "conflicting reduction operations for .sum." }
257 for (l = 0; l < 10; l++)
258 sum = 1;
259
260 #pragma acc loop reduction(max:sum) // { dg-warning "conflicting reduction operations for .sum." }
261 for (i = 0; i < 10; i++)
262 #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." }
263 for (j = 0; j < 10; j++)
264 #pragma acc loop reduction(+:sum) // { dg-warning "conflicting reduction operations for .sum." })
265 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
266 for (k = 0; k < 10; k++)
267 #pragma acc loop reduction(*:sum) // { dg-warning "conflicting reduction operations for .sum." }
268 for (l = 0; l < 10; l++)
269 sum = 1;
270
271 #pragma acc loop reduction(-:diff) // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
272 for (i = 0; i < 10; i++)
273 {
274 #pragma acc loop reduction(-:diff) // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
275 for (j = 0; j < 10; j++)
276 #pragma acc loop reduction(+:sum)
277 for (k = 0; k < 10; k++)
278 sum = 1;
279
280 #pragma acc loop reduction(+:sum) // { dg-warning "nested loop in reduction needs reduction clause for .diff." }
281 for (j = 0; j < 10; j++)
282 #pragma acc loop reduction(-:diff)
283 for (k = 0; k < 10; k++)
284 diff = 1;
285 }
286 }
287 }
288
289 /* The same tests as above, but using a combined parallel loop construct, and
290 the outermost reduction clause is on that one, not the outermost loop. */
acc_parallel_loop_reduction(void)291 void acc_parallel_loop_reduction (void)
292 {
293 int i, j, k, l, sum, diff;
294
295 #pragma acc parallel loop reduction(+:sum)
296 for (int h = 0; h < 10; ++h)
297 {
298 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
299 for (i = 0; i < 10; i++)
300 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
301 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
302 for (j = 0; j < 10; j++)
303 #pragma acc loop reduction(+:sum)
304 for (k = 0; k < 10; k++)
305 sum = 1;
306
307 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
308 for (i = 0; i < 10; i++)
309 #pragma acc loop collapse(2) // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
310 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
311 for (j = 0; j < 10; j++)
312 for (k = 0; k < 10; k++)
313 #pragma acc loop reduction(+:sum)
314 for (l = 0; l < 10; l++)
315 sum = 1;
316
317 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
318 for (i = 0; i < 10; i++)
319 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
320 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
321 for (j = 0; j < 10; j++)
322 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
323 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
324 for (k = 0; k < 10; k++)
325 #pragma acc loop reduction(+:sum)
326 for (l = 0; l < 10; l++)
327 sum = 1;
328
329 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
330 for (i = 0; i < 10; i++)
331 #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." }
332 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
333 for (j = 0; j < 10; j++)
334 #pragma acc loop reduction(+:sum) // { dg-warning "conflicting reduction operations for .sum." }
335 for (k = 0; k < 10; k++)
336 sum = 1;
337
338 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
339 for (i = 0; i < 10; i++)
340 #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." }
341 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
342 for (j = 0; j < 10; j++)
343 #pragma acc loop reduction(-:sum)
344 for (k = 0; k < 10; k++)
345 sum = 1;
346
347 #pragma acc loop reduction(max:sum) // { dg-warning "conflicting reduction operations for .sum." }
348 for (i = 0; i < 10; i++)
349 #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." }
350 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
351 for (j = 0; j < 10; j++)
352 #pragma acc loop // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
353 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
354 for (k = 0; k < 10; k++)
355 #pragma acc loop reduction(*:sum) // { dg-warning "conflicting reduction operations for .sum." }
356 for (l = 0; l < 10; l++)
357 sum = 1;
358
359 #pragma acc loop reduction(max:sum) // { dg-warning "conflicting reduction operations for .sum." }
360 for (i = 0; i < 10; i++)
361 #pragma acc loop reduction(-:sum) // { dg-warning "conflicting reduction operations for .sum." }
362 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
363 for (j = 0; j < 10; j++)
364 #pragma acc loop reduction(+:sum) // { dg-warning "conflicting reduction operations for .sum." })
365 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
366 for (k = 0; k < 10; k++)
367 #pragma acc loop reduction(*:sum) // { dg-warning "conflicting reduction operations for .sum." }
368 for (l = 0; l < 10; l++)
369 sum = 1;
370
371 #pragma acc loop reduction(-:diff) // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
372 for (i = 0; i < 10; i++)
373 {
374 #pragma acc loop reduction(-:diff) // { dg-warning "nested loop in reduction needs reduction clause for .sum." }
375 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
376 for (j = 0; j < 10; j++)
377 #pragma acc loop reduction(+:sum)
378 for (k = 0; k < 10; k++)
379 sum = 1;
380
381 #pragma acc loop reduction(+:sum) // { dg-warning "nested loop in reduction needs reduction clause for .diff." }
382 // { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
383 for (j = 0; j < 10; j++)
384 #pragma acc loop reduction(-:diff)
385 for (k = 0; k < 10; k++)
386 diff = 1;
387 }
388 }
389 }
390