1 ! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
3 ! Check OpenMP clause validity for the following directives:
5 ! 2.5 PARALLEL construct
11 integer, parameter :: num
= 16
12 real(8) :: arrayA(256), arrayB(512)
14 integer(omp_memspace_handle_kind
) :: xy_memspace
= omp_default_mem_space
15 type(omp_alloctrait
) :: xy_traits(1) = [omp_alloctrait(omp_atk_alignment
,64)]
16 integer(omp_allocator_handle_kind
) :: xy_alloc
17 xy_alloc
= omp_init_allocator(xy_memspace
, 1, xy_traits
)
23 ! 2.5 parallel-clause -> if-clause |
24 ! num-threads-clause |
27 ! firstprivate-clause |
40 !$omp parallel private(b) allocate(b)
46 !$omp parallel private(c, b) allocate(omp_default_mem_space : b, c)
52 !$omp parallel allocate(b) allocate(c) private(b, c)
58 !$omp parallel allocate(xy_alloc :b) private(b)
64 !$omp task private(b) allocate(b)
70 !$omp teams private(b) allocate(b)
76 !$omp target private(b) allocate(b)
82 !ERROR: ALLOCATE clause is not allowed on the TARGET DATA directive
83 !$omp target data map(from: b) allocate(b)
89 !ERROR: SCHEDULE clause is not allowed on the PARALLEL directive
90 !$omp parallel schedule(static)
96 !ERROR: COLLAPSE clause is not allowed on the PARALLEL directive
97 !$omp parallel collapse(2)
105 !ERROR: The parameter of the COLLAPSE clause must be a constant positive integer expression
106 !$omp do collapse(-1)
115 !$omp parallel firstprivate(a)
119 !ERROR: NUM_THREADS clause is not allowed on the END PARALLEL directive
120 !$omp end parallel num_threads(4)
122 !ERROR: LASTPRIVATE clause is not allowed on the PARALLEL directive
123 !ERROR: NUM_TASKS clause is not allowed on the PARALLEL directive
124 !ERROR: INBRANCH clause is not allowed on the PARALLEL directive
125 !$omp parallel lastprivate(a) NUM_TASKS(4) inbranch
131 !ERROR: At most one NUM_THREADS clause can appear on the PARALLEL directive
132 !$omp parallel num_threads(2) num_threads(4)
138 !ERROR: The parameter of the NUM_THREADS clause must be a positive integer expression
139 !$omp parallel num_threads(1-4)
143 !ERROR: NOWAIT clause is not allowed on the END PARALLEL directive
144 !$omp end parallel nowait
146 !$omp parallel num_threads(num-10)
152 !$omp parallel num_threads(b+1)
161 !ERROR: Unmatched END TARGET directive
164 ! OMP 5.0 - 2.6 Restriction point 1
165 outofparallel
: do k
=1, 10
172 !ERROR: EXIT to construct 'outofparallel' outside of PARALLEL construct is not allowed
173 !ERROR: EXIT to construct 'outofparallel' outside of DO construct is not allowed
181 ! 2.7.1 do-clause -> private-clause |
182 ! firstprivate-clause |
183 ! lastprivate-clause |
190 !ERROR: When SCHEDULE clause has AUTO specified, it must not have chunk size specified
191 !ERROR: At most one SCHEDULE clause can appear on the DO directive
192 !ERROR: When SCHEDULE clause has RUNTIME specified, it must not have chunk size specified
193 !$omp do schedule(auto, 2) schedule(runtime, 2)
198 !ERROR: A modifier may not be specified in a LINEAR clause on the DO directive
199 !$omp do linear(ref(b))
204 !ERROR: The NONMONOTONIC modifier can only be specified with SCHEDULE(DYNAMIC) or SCHEDULE(GUIDED)
205 !ERROR: The NONMONOTONIC modifier cannot be specified if an ORDERED clause is specified
206 !$omp do schedule(NONMONOTONIC:static) ordered
211 !$omp do schedule(simd, monotonic:dynamic)
216 !ERROR: Clause LINEAR is not allowed if clause ORDERED appears on the DO directive
217 !ERROR: The parameter of the ORDERED clause must be a constant positive integer expression
218 !$omp do ordered(1-1) private(b) linear(b) linear(a)
223 !ERROR: The parameter of the ORDERED clause must be greater than or equal to the parameter of the COLLAPSE clause
224 !$omp do collapse(num-14) ordered(1)
233 !$omp parallel do simd if(parallel:a>1.)
236 !$omp end parallel do simd
238 !ERROR: Unmatched directive name modifier TARGET on the IF clause
239 !$omp parallel do if(target:a>1.)
242 !ERROR: Unmatched END SIMD directive
245 ! 2.7.2 sections-clause -> private-clause |
246 ! firstprivate-clause |
247 ! lastprivate-clause |
256 !$omp end sections nowait
263 !ERROR: Unmatched END PARALLEL SECTIONS directive
264 !$omp end parallel sections
274 !ERROR: NUM_THREADS clause is not allowed on the END SECTIONS directive
275 !$omp end sections num_threads(4)
283 !ERROR: At most one NOWAIT clause can appear on the END SECTIONS directive
284 !$omp end sections nowait nowait
289 ! 2.11.2 parallel-sections-clause -> parallel-clause |
292 !$omp parallel sections num_threads(4) private(b) lastprivate(d)
299 !$omp end parallel sections
301 !ERROR: At most one NUM_THREADS clause can appear on the PARALLEL SECTIONS directive
302 !$omp parallel sections num_threads(1) num_threads(4)
304 !ERROR: Unmatched END SECTIONS directive
307 !$omp parallel sections
308 !ERROR: NOWAIT clause is not allowed on the END PARALLEL SECTIONS directive
309 !$omp end parallel sections nowait
311 ! 2.7.3 single-clause -> private-clause |
312 ! firstprivate-clause
313 ! end-single-clause -> copyprivate-clause |
318 !ERROR: LASTPRIVATE clause is not allowed on the SINGLE directive
319 !$omp single private(a) lastprivate(c)
321 !ERROR: Clause NOWAIT is not allowed if clause COPYPRIVATE appears on the END SINGLE directive
322 !ERROR: COPYPRIVATE variable 'a' may not appear on a PRIVATE or FIRSTPRIVATE clause on a SINGLE construct
323 !ERROR: At most one NOWAIT clause can appear on the END SINGLE directive
324 !$omp end single copyprivate(a) nowait nowait
333 !$omp end workshare nowait
334 !ERROR: NUM_THREADS clause is not allowed on the WORKSHARE directive
335 !$omp workshare num_threads(4)
337 !ERROR: COPYPRIVATE clause is not allowed on the END WORKSHARE directive
338 !$omp end workshare nowait copyprivate(a)
341 ! 2.8.1 simd-clause -> safelen-clause |
346 ! lastprivate-clause |
351 !ERROR: TASK_REDUCTION clause is not allowed on the SIMD directive
352 !$omp simd private(b) reduction(+:a) task_reduction(+:a)
357 !ERROR: At most one SAFELEN clause can appear on the SIMD directive
358 !$omp simd safelen(1) safelen(2)
363 !ERROR: The parameter of the SIMDLEN clause must be a constant positive integer expression
364 !$omp simd simdlen(-1)
369 !ERROR: The parameter of the ALIGNED clause must be a constant positive integer expression
370 !$omp simd aligned(b:-2)
376 !ERROR: The parameter of the SIMDLEN clause must be less than or equal to the parameter of the SAFELEN clause
377 !$omp simd safelen(1+1) simdlen(1+2)
383 ! 2.11.1 parallel-do-clause -> parallel-clause |
386 !ERROR: At most one PROC_BIND clause can appear on the PARALLEL DO directive
387 !ERROR: A modifier may not be specified in a LINEAR clause on the PARALLEL DO directive
388 !$omp parallel do proc_bind(master) proc_bind(close) linear(val(b))
393 ! 2.8.3 do-simd-clause -> do-clause |
397 !ERROR: No ORDERED clause with a parameter can be specified on the DO SIMD directive
398 !ERROR: NOGROUP clause is not allowed on the DO SIMD directive
399 !$omp do simd ordered(2) NOGROUP
407 ! 2.11.4 parallel-do-simd-clause -> parallel-clause |
410 !$omp parallel do simd collapse(2) safelen(2) &
411 !$omp & simdlen(1) private(c) firstprivate(a) proc_bind(spread)
418 ! 2.9.2 taskloop -> TASKLOOP [taskloop-clause[ [,] taskloop-clause]...]
419 ! taskloop-clause -> if-clause |
422 ! firstprivate-clause |
423 ! lastprivate-clause |
439 !ERROR: SCHEDULE clause is not allowed on the TASKLOOP directive
440 !$omp taskloop schedule(static)
445 !ERROR: GRAINSIZE and NUM_TASKS clauses are mutually exclusive and may not appear on the same TASKLOOP directive
446 !$omp taskloop num_tasks(3) grainsize(2)
451 !ERROR: At most one NUM_TASKS clause can appear on the TASKLOOP directive
452 !ERROR: TASK_REDUCTION clause is not allowed on the TASKLOOP directive
453 !$omp taskloop num_tasks(3) num_tasks(2) task_reduction(*:a)
467 !ERROR: NUM_THREADS clause is not allowed on the MASTER directive
468 !$omp master num_threads(4)
473 ! Standalone Directives (basic)
478 !$omp taskwait depend(source)
479 ! !$omp taskwait depend(sink:i-1)
480 ! !$omp target enter data map(to:arrayA) map(alloc:arrayB)
481 ! !$omp target update from(arrayA) to(arrayB)
482 ! !$omp target exit data map(from:arrayA) map(delete:arrayB)
487 !ERROR: If memory-order-clause is RELEASE, ACQUIRE, or ACQ_REL, list items must not be specified on the FLUSH directive
488 !$omp flush release (c)
489 !ERROR: SEQ_CST clause is not allowed on the FLUSH directive
491 !ERROR: RELAXED clause is not allowed on the FLUSH directive
494 ! 2.13.2 critical Construct
496 ! !$omp critical (first)
498 ! !$omp end critical (first)
500 ! 2.9.1 task-clause -> if-clause |
506 ! firstprivate-clause |
511 !$omp task shared(a) default(none) if(task:a > 1.)
515 !ERROR: Unmatched directive name modifier TASKLOOP on the IF clause
516 !$omp task private(a) if(taskloop:a.eq.1)
520 !ERROR: LASTPRIVATE clause is not allowed on the TASK directive
521 !ERROR: At most one FINAL clause can appear on the TASK directive
522 !$omp task lastprivate(b) final(a.GE.1) final(.false.)
526 !ERROR: The parameter of the PRIORITY clause must be a positive integer expression
527 !$omp task priority(-1) firstprivate(a) mergeable
531 ! 2.9.3 taskloop-simd-clause -> taskloop-clause |
538 !$omp end taskloop simd
540 !$omp taskloop simd reduction(+:a)
544 !ERROR: Unmatched END TASKLOOP directive
547 !ERROR: GRAINSIZE and NUM_TASKS clauses are mutually exclusive and may not appear on the same TASKLOOP SIMD directive
548 !$omp taskloop simd num_tasks(3) grainsize(2)
553 !ERROR: The parameter of the SIMDLEN clause must be a constant positive integer expression
554 !ERROR: The parameter of the ALIGNED clause must be a constant positive integer expression
555 !$omp taskloop simd simdlen(-1) aligned(a:-2)
560 !$omp target enter data map(alloc:A) device(0)
561 !$omp target exit data map(delete:A) device(0)