173
|
1 ! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
|
|
2
|
|
3 ! Check OpenMP clause validity for the following directives:
|
|
4 !
|
|
5 ! 2.5 PARALLEL construct
|
|
6 ! 2.7.1 Loop construct
|
|
7 ! ...
|
|
8
|
|
9 ! TODO: all the internal errors
|
|
10
|
|
11 integer :: b = 128
|
|
12 integer :: c = 32
|
|
13 integer, parameter :: num = 16
|
|
14 real(8) :: arrayA(256), arrayB(512)
|
|
15
|
|
16 arrayA = 1.414
|
|
17 arrayB = 3.14
|
|
18 N = 1024
|
|
19
|
|
20 ! 2.5 parallel-clause -> if-clause |
|
|
21 ! num-threads-clause |
|
|
22 ! default-clause |
|
|
23 ! private-clause |
|
|
24 ! firstprivate-clause |
|
|
25 ! shared-clause |
|
|
26 ! copyin-clause |
|
|
27 ! reduction-clause |
|
|
28 ! proc-bind-clause
|
|
29
|
|
30 !$omp parallel
|
|
31 do i = 1, N
|
|
32 a = 3.14
|
|
33 enddo
|
|
34 !$omp end parallel
|
|
35
|
|
36 !ERROR: SCHEDULE clause is not allowed on the PARALLEL directive
|
|
37 !$omp parallel schedule(static)
|
|
38 do i = 1, N
|
|
39 a = 3.14
|
|
40 enddo
|
|
41 !$omp end parallel
|
|
42
|
|
43 !ERROR: COLLAPSE clause is not allowed on the PARALLEL directive
|
|
44 !$omp parallel collapse(2)
|
|
45 do i = 1, N
|
|
46 do j = 1, N
|
|
47 a = 3.14
|
|
48 enddo
|
|
49 enddo
|
|
50 !$omp end parallel
|
|
51
|
|
52 !ERROR: The parameter of the COLLAPSE clause must be a constant positive integer expression
|
|
53 !$omp do collapse(-1)
|
|
54 do i = 1, N
|
|
55 do j = 1, N
|
|
56 a = 3.14
|
|
57 enddo
|
|
58 enddo
|
|
59 !$omp end do
|
|
60
|
|
61 a = 1.0
|
|
62 !$omp parallel firstprivate(a)
|
|
63 do i = 1, N
|
|
64 a = 3.14
|
|
65 enddo
|
|
66 !ERROR: NUM_THREADS clause is not allowed on the END PARALLEL directive
|
|
67 !$omp end parallel num_threads(4)
|
|
68
|
|
69 !ERROR: LASTPRIVATE clause is not allowed on the PARALLEL directive
|
|
70 !ERROR: NUM_TASKS clause is not allowed on the PARALLEL directive
|
|
71 !ERROR: INBRANCH clause is not allowed on the PARALLEL directive
|
|
72 !$omp parallel lastprivate(a) NUM_TASKS(4) inbranch
|
|
73 do i = 1, N
|
|
74 a = 3.14
|
|
75 enddo
|
|
76 !$omp end parallel
|
|
77
|
|
78 !ERROR: At most one NUM_THREADS clause can appear on the PARALLEL directive
|
|
79 !$omp parallel num_threads(2) num_threads(4)
|
|
80 do i = 1, N
|
|
81 a = 3.14
|
|
82 enddo
|
|
83 !$omp end parallel
|
|
84
|
|
85 !ERROR: The parameter of the NUM_THREADS clause must be a positive integer expression
|
|
86 !$omp parallel num_threads(1-4)
|
|
87 do i = 1, N
|
|
88 a = 3.14
|
|
89 enddo
|
|
90 !ERROR: NOWAIT clause is not allowed on the END PARALLEL directive
|
|
91 !$omp end parallel nowait
|
|
92
|
|
93 !$omp parallel num_threads(num-10)
|
|
94 do i = 1, N
|
|
95 a = 3.14
|
|
96 enddo
|
|
97 !$omp end parallel
|
|
98
|
|
99 !$omp parallel num_threads(b+1)
|
|
100 do i = 1, N
|
|
101 a = 3.14
|
|
102 enddo
|
|
103 !$omp end parallel
|
|
104
|
|
105 !$omp parallel
|
|
106 do i = 1, N
|
|
107 enddo
|
|
108 !ERROR: Unmatched END TARGET directive
|
|
109 !$omp end target
|
|
110
|
|
111 ! 2.7.1 do-clause -> private-clause |
|
|
112 ! firstprivate-clause |
|
|
113 ! lastprivate-clause |
|
|
114 ! linear-clause |
|
|
115 ! reduction-clause |
|
|
116 ! schedule-clause |
|
|
117 ! collapse-clause |
|
|
118 ! ordered-clause
|
|
119
|
|
120 !ERROR: When SCHEDULE clause has AUTO specified, it must not have chunk size specified
|
|
121 !ERROR: At most one SCHEDULE clause can appear on the DO directive
|
|
122 !ERROR: When SCHEDULE clause has RUNTIME specified, it must not have chunk size specified
|
|
123 !$omp do schedule(auto, 2) schedule(runtime, 2)
|
|
124 do i = 1, N
|
|
125 a = 3.14
|
|
126 enddo
|
|
127
|
|
128 !ERROR: A modifier may not be specified in a LINEAR clause on the DO directive
|
|
129 !ERROR: Internal: no symbol found for 'b'
|
|
130 !$omp do linear(ref(b))
|
|
131 do i = 1, N
|
|
132 a = 3.14
|
|
133 enddo
|
|
134
|
|
135 !ERROR: The NONMONOTONIC modifier can only be specified with SCHEDULE(DYNAMIC) or SCHEDULE(GUIDED)
|
|
136 !ERROR: The NONMONOTONIC modifier cannot be specified if an ORDERED clause is specified
|
|
137 !$omp do schedule(NONMONOTONIC:static) ordered
|
|
138 do i = 1, N
|
|
139 a = 3.14
|
|
140 enddo
|
|
141
|
|
142 !$omp do schedule(simd, monotonic:dynamic)
|
|
143 do i = 1, N
|
|
144 a = 3.14
|
|
145 enddo
|
|
146
|
|
147 !ERROR: The parameter of the ORDERED clause must be a constant positive integer expression
|
|
148 !ERROR: A loop directive may not have both a LINEAR clause and an ORDERED clause with a parameter
|
|
149 !ERROR: Internal: no symbol found for 'b'
|
|
150 !ERROR: Internal: no symbol found for 'a'
|
|
151 !$omp do ordered(1-1) private(b) linear(b) linear(a)
|
|
152 do i = 1, N
|
|
153 a = 3.14
|
|
154 enddo
|
|
155
|
|
156 !ERROR: The parameter of the ORDERED clause must be greater than or equal to the parameter of the COLLAPSE clause
|
|
157 !$omp do collapse(num-14) ordered(1)
|
|
158 do i = 1, N
|
|
159 do j = 1, N
|
|
160 do k = 1, N
|
|
161 a = 3.14
|
|
162 enddo
|
|
163 enddo
|
|
164 enddo
|
|
165
|
|
166 !$omp parallel do simd if(parallel:a>1.)
|
|
167 do i = 1, N
|
|
168 enddo
|
|
169 !$omp end parallel do simd
|
|
170
|
|
171 !ERROR: Unmatched directive name modifier TARGET on the IF clause
|
|
172 !$omp parallel do if(target:a>1.)
|
|
173 do i = 1, N
|
|
174 enddo
|
|
175 !ERROR: Unmatched END SIMD directive
|
|
176 !$omp end simd
|
|
177
|
|
178 ! 2.7.2 sections-clause -> private-clause |
|
|
179 ! firstprivate-clause |
|
|
180 ! lastprivate-clause |
|
|
181 ! reduction-clause
|
|
182
|
|
183 !$omp parallel
|
|
184 !$omp sections
|
|
185 !$omp section
|
|
186 a = 0.0
|
|
187 !$omp section
|
|
188 b = 1
|
|
189 !$omp end sections nowait
|
|
190 !$omp end parallel
|
|
191
|
|
192 !$omp parallel
|
|
193 !$omp sections
|
|
194 !$omp section
|
|
195 a = 0.0
|
|
196 !ERROR: Unmatched END PARALLEL SECTIONS directive
|
|
197 !$omp end parallel sections
|
|
198 !$omp end parallel
|
|
199
|
|
200 !$omp parallel
|
|
201 !$omp sections
|
|
202 a = 0.0
|
|
203 b = 1
|
|
204 !$omp section
|
|
205 c = 1
|
|
206 d = 2
|
|
207 !ERROR: NUM_THREADS clause is not allowed on the END SECTIONS directive
|
|
208 !$omp end sections num_threads(4)
|
|
209 !$omp end parallel
|
|
210
|
|
211 ! 2.11.2 parallel-sections-clause -> parallel-clause |
|
|
212 ! sections-clause
|
|
213
|
|
214 !$omp parallel sections num_threads(4) private(b) lastprivate(d)
|
|
215 a = 0.0
|
|
216 !$omp section
|
|
217 b = 1
|
|
218 c = 2
|
|
219 !$omp section
|
|
220 d = 3
|
|
221 !$omp end parallel sections
|
|
222
|
|
223 !ERROR: At most one NUM_THREADS clause can appear on the PARALLEL SECTIONS directive
|
|
224 !$omp parallel sections num_threads(1) num_threads(4)
|
|
225 a = 0.0
|
|
226 !ERROR: Unmatched END SECTIONS directive
|
|
227 !$omp end sections
|
|
228
|
|
229 !$omp parallel sections
|
|
230 !ERROR: NOWAIT clause is not allowed on the END PARALLEL SECTIONS directive
|
|
231 !$omp end parallel sections nowait
|
|
232
|
|
233 ! 2.7.3 single-clause -> private-clause |
|
|
234 ! firstprivate-clause
|
|
235 ! end-single-clause -> copyprivate-clause |
|
|
236 ! nowait-clause
|
|
237
|
|
238 !$omp parallel
|
|
239 b = 1
|
|
240 !ERROR: LASTPRIVATE clause is not allowed on the SINGLE directive
|
|
241 !$omp single private(a) lastprivate(c)
|
|
242 a = 3.14
|
|
243 !ERROR: The COPYPRIVATE clause must not be used with the NOWAIT clause
|
|
244 !ERROR: At most one NOWAIT clause can appear on the END SINGLE directive
|
|
245 !$omp end single copyprivate(a) nowait nowait
|
|
246 c = 2
|
|
247 !$omp end parallel
|
|
248
|
|
249 ! 2.7.4 workshare
|
|
250
|
|
251 !$omp parallel
|
|
252 !$omp workshare
|
|
253 a = 1.0
|
|
254 !$omp end workshare nowait
|
|
255 !ERROR: NUM_THREADS clause is not allowed on the WORKSHARE directive
|
|
256 !$omp workshare num_threads(4)
|
|
257 a = 1.0
|
|
258 !ERROR: COPYPRIVATE clause is not allowed on the END WORKSHARE directive
|
|
259 !$omp end workshare nowait copyprivate(a)
|
|
260 !$omp end parallel
|
|
261
|
|
262 ! 2.8.1 simd-clause -> safelen-clause |
|
|
263 ! simdlen-clause |
|
|
264 ! linear-clause |
|
|
265 ! aligned-clause |
|
|
266 ! private-clause |
|
|
267 ! lastprivate-clause |
|
|
268 ! reduction-clause |
|
|
269 ! collapse-clause
|
|
270
|
|
271 a = 0.0
|
|
272 !$omp simd private(b) reduction(+:a)
|
|
273 do i = 1, N
|
|
274 a = a + b + 3.14
|
|
275 enddo
|
|
276
|
|
277 !ERROR: At most one SAFELEN clause can appear on the SIMD directive
|
|
278 !$omp simd safelen(1) safelen(2)
|
|
279 do i = 1, N
|
|
280 a = 3.14
|
|
281 enddo
|
|
282
|
|
283 !ERROR: The parameter of the SIMDLEN clause must be a constant positive integer expression
|
|
284 !$omp simd simdlen(-1)
|
|
285 do i = 1, N
|
|
286 a = 3.14
|
|
287 enddo
|
|
288
|
|
289 !ERROR: The ALIGNMENT parameter of the ALIGNED clause must be a constant positive integer expression
|
|
290 !ERROR: Internal: no symbol found for 'b'
|
|
291 !$omp simd aligned(b:-2)
|
|
292 do i = 1, N
|
|
293 a = 3.14
|
|
294 enddo
|
|
295
|
|
296 !$omp parallel
|
|
297 !ERROR: The parameter of the SIMDLEN clause must be less than or equal to the parameter of the SAFELEN clause
|
|
298 !$omp simd safelen(1+1) simdlen(1+2)
|
|
299 do i = 1, N
|
|
300 a = 3.14
|
|
301 enddo
|
|
302 !$omp end parallel
|
|
303
|
|
304 ! 2.11.1 parallel-do-clause -> parallel-clause |
|
|
305 ! do-clause
|
|
306
|
|
307 !ERROR: At most one PROC_BIND clause can appear on the PARALLEL DO directive
|
|
308 !ERROR: A modifier may not be specified in a LINEAR clause on the PARALLEL DO directive
|
|
309 !ERROR: Internal: no symbol found for 'b'
|
|
310 !$omp parallel do proc_bind(master) proc_bind(close) linear(val(b))
|
|
311 do i = 1, N
|
|
312 a = 3.14
|
|
313 enddo
|
|
314
|
|
315 ! 2.8.3 do-simd-clause -> do-clause |
|
|
316 ! simd-clause
|
|
317
|
|
318 !$omp parallel
|
|
319 !ERROR: No ORDERED clause with a parameter can be specified on the DO SIMD directive
|
|
320 !ERROR: NOGROUP clause is not allowed on the DO SIMD directive
|
|
321 !$omp do simd ordered(2) NOGROUP
|
|
322 do i = 1, N
|
|
323 do j = 1, N
|
|
324 a = 3.14
|
|
325 enddo
|
|
326 enddo
|
|
327 !$omp end parallel
|
|
328
|
|
329 ! 2.11.4 parallel-do-simd-clause -> parallel-clause |
|
|
330 ! do-simd-clause
|
|
331
|
|
332 !$omp parallel do simd collapse(2) safelen(2) &
|
|
333 !$omp & simdlen(1) private(c) firstprivate(a) proc_bind(spread)
|
|
334 do i = 1, N
|
|
335 do j = 1, N
|
|
336 a = 3.14
|
|
337 enddo
|
|
338 enddo
|
|
339
|
|
340 ! 2.9.2 taskloop -> TASKLOOP [taskloop-clause[ [,] taskloop-clause]...]
|
|
341 ! taskloop-clause -> if-clause |
|
|
342 ! shared-clause |
|
|
343 ! private-clause |
|
|
344 ! firstprivate-clause |
|
|
345 ! lastprivate-clause |
|
|
346 ! default-clause |
|
|
347 ! grainsize-clause |
|
|
348 ! num-tasks-clause |
|
|
349 ! collapse-clause |
|
|
350 ! final-clause |
|
|
351 ! priority-clause |
|
|
352 ! untied-clause |
|
|
353 ! mergeable-clause |
|
|
354 ! nogroup-clause
|
|
355
|
|
356 !$omp taskloop
|
|
357 do i = 1, N
|
|
358 a = 3.14
|
|
359 enddo
|
|
360
|
|
361 !ERROR: SCHEDULE clause is not allowed on the TASKLOOP directive
|
|
362 !$omp taskloop schedule(static)
|
|
363 do i = 1, N
|
|
364 a = 3.14
|
|
365 enddo
|
|
366
|
|
367 !ERROR: GRAINSIZE and NUM_TASKS are mutually exclusive and may not appear on the same TASKLOOP directive
|
|
368 !$omp taskloop num_tasks(3) grainsize(2)
|
|
369 do i = 1,N
|
|
370 a = 3.14
|
|
371 enddo
|
|
372
|
|
373 !ERROR: At most one NUM_TASKS clause can appear on the TASKLOOP directive
|
|
374 !$omp taskloop num_tasks(3) num_tasks(2)
|
|
375 do i = 1,N
|
|
376 a = 3.14
|
|
377 enddo
|
|
378
|
|
379 ! 2.13.1 master
|
|
380
|
|
381 !$omp parallel
|
|
382 !$omp master
|
|
383 a=3.14
|
|
384 !$omp end master
|
|
385 !$omp end parallel
|
|
386
|
|
387 !$omp parallel
|
|
388 !ERROR: NUM_THREADS clause is not allowed on the MASTER directive
|
|
389 !$omp master num_threads(4)
|
|
390 a=3.14
|
|
391 !$omp end master
|
|
392 !$omp end parallel
|
|
393
|
|
394 ! Standalone Directives (basic)
|
|
395
|
|
396 !$omp taskyield
|
|
397 !$omp barrier
|
|
398 !$omp taskwait
|
|
399 ! !$omp target enter data map(to:arrayA) map(alloc:arrayB)
|
|
400 ! !$omp target update from(arrayA) to(arrayB)
|
|
401 ! !$omp target exit data map(from:arrayA) map(delete:arrayB)
|
|
402 !$omp ordered depend(source)
|
|
403 !ERROR: Internal: no symbol found for 'i'
|
|
404 !$omp ordered depend(sink:i-1)
|
|
405 !$omp flush (c)
|
|
406 !$omp cancel DO
|
|
407 !$omp cancellation point parallel
|
|
408
|
|
409 ! 2.13.2 critical Construct
|
|
410
|
|
411 !ERROR: Internal: no symbol found for 'first'
|
|
412 !$omp critical (first)
|
|
413 a = 3.14
|
|
414 !ERROR: Internal: no symbol found for 'first'
|
|
415 !$omp end critical (first)
|
|
416
|
|
417 ! 2.9.1 task-clause -> if-clause |
|
|
418 ! final-clause |
|
|
419 ! untied-clause |
|
|
420 ! default-clause |
|
|
421 ! mergeable-clause |
|
|
422 ! private-clause |
|
|
423 ! firstprivate-clause |
|
|
424 ! shared-clause |
|
|
425 ! depend-clause |
|
|
426 ! priority-clause
|
|
427
|
|
428 !$omp task shared(a) default(none) if(task:a > 1.)
|
|
429 a = 1.
|
|
430 !$omp end task
|
|
431
|
|
432 !ERROR: Unmatched directive name modifier TASKLOOP on the IF clause
|
|
433 !$omp task private(a) if(taskloop:a.eq.1)
|
|
434 a = 1.
|
|
435 !$omp end task
|
|
436
|
|
437 !ERROR: LASTPRIVATE clause is not allowed on the TASK directive
|
|
438 !ERROR: At most one FINAL clause can appear on the TASK directive
|
|
439 !$omp task lastprivate(b) final(a.GE.1) final(.false.)
|
|
440 b = 1
|
|
441 !$omp end task
|
|
442
|
|
443 !ERROR: The parameter of the PRIORITY clause must be a positive integer expression
|
|
444 !$omp task priority(-1) firstprivate(a) mergeable
|
|
445 a = 3.14
|
|
446 !$omp end task
|
|
447
|
|
448 ! 2.9.3 taskloop-simd-clause -> taskloop-clause |
|
|
449 ! simd-clause
|
|
450
|
|
451 !$omp taskloop simd
|
|
452 do i = 1, N
|
|
453 a = 3.14
|
|
454 enddo
|
|
455 !$omp end taskloop simd
|
|
456
|
|
457 !ERROR: REDUCTION clause is not allowed on the TASKLOOP SIMD directive
|
|
458 !$omp taskloop simd reduction(+:a)
|
|
459 do i = 1, N
|
|
460 a = a + 3.14
|
|
461 enddo
|
|
462 !ERROR: Unmatched END TASKLOOP directive
|
|
463 !$omp end taskloop
|
|
464
|
|
465 !ERROR: GRAINSIZE and NUM_TASKS are mutually exclusive and may not appear on the same TASKLOOP SIMD directive
|
|
466 !$omp taskloop simd num_tasks(3) grainsize(2)
|
|
467 do i = 1,N
|
|
468 a = 3.14
|
|
469 enddo
|
|
470
|
|
471 !ERROR: The parameter of the SIMDLEN clause must be a constant positive integer expression
|
|
472 !ERROR: The ALIGNMENT parameter of the ALIGNED clause must be a constant positive integer expression
|
|
473 !ERROR: Internal: no symbol found for 'a'
|
|
474 !$omp taskloop simd simdlen(-1) aligned(a:-2)
|
|
475 do i = 1, N
|
|
476 a = 3.14
|
|
477 enddo
|
|
478 end program
|