Files
clang-p2996/flang/test/Semantics/omp-ordered01.f90
PeixinQiao 6fb01a9470 [flang][OpenMP] Add semantic checks for ordered construct
This patch implements the following semantic checks according to
OpenMP Version 5.1 Ordered construct restriction:

```
At most one threads clause can appear on an ordered construct; At most
one simd clause can appear on an ordered construct; At most one
depend(source) clause can appear on an ordered construct; Either
depend(sink:vec) clauses or depend(source) clauses may appear on an
ordered construct, but not both.
```

This patch also implements the following semantic checks according to
the syntax and descriptions in OpenMP Version 5.1 Ordered construct:

```
The dependence types of sink or source are only allowed on an ordered
construct. The depend(*) clauses are not allowed when ordered construct
is a block construct with an ordered region. The threads or simd clauses
are not allowed when the ordered construct is a standalone construct
with no ordered region.
```

Co-authored-by: Sameeran Joshi <sameeranjayant.joshi@amd.com>

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D108512
2021-09-17 21:53:07 +08:00

81 lines
2.8 KiB
Fortran

! RUN: %python %S/test_errors.py %s %flang -fopenmp
! OpenMP Version 5.1
! Check OpenMP construct validity for the following directives:
! 2.19.9 Ordered Construct
program main
integer :: i, N = 10
real :: a, arrayA(10), arrayB(10), arrayC(10)
real, external :: foo, bar, baz
!$omp do ordered
do i = 1, N
!ERROR: At most one THREADS clause can appear on the ORDERED directive
!$omp ordered threads threads
arrayA(i) = i
!$omp end ordered
end do
!$omp end do
!$omp simd
do i = 1, N
!ERROR: At most one SIMD clause can appear on the ORDERED directive
!$omp ordered simd simd
arrayA(i) = i
!$omp end ordered
end do
!$omp end simd
!$omp do simd ordered
do i = 1, N
!ERROR: At most one SIMD clause can appear on the ORDERED directive
!$omp ordered simd simd
arrayA(i) = i
!$omp end ordered
end do
!$omp end do simd
!$omp do ordered(1)
do i = 2, N
!ERROR: Only DEPEND(SOURCE) or DEPEND(SINK: vec) are allowed when ORDERED construct is a standalone construct with no ORDERED region
!ERROR: At most one DEPEND(SOURCE) clause can appear on the ORDERED directive
!$omp ordered depend(source) depend(inout: arrayA) depend(source)
arrayA(i) = foo(i)
!ERROR: DEPEND(SOURCE) is not allowed when DEPEND(SINK: vec) is present on ORDERED directive
!ERROR: DEPEND(SOURCE) is not allowed when DEPEND(SINK: vec) is present on ORDERED directive
!ERROR: At most one DEPEND(SOURCE) clause can appear on the ORDERED directive
!$omp ordered depend(sink: i - 1) depend(source) depend(source)
arrayB(i) = bar(arrayA(i), arrayB(i-1))
!ERROR: Only DEPEND(SOURCE) or DEPEND(SINK: vec) are allowed when ORDERED construct is a standalone construct with no ORDERED region
!ERROR: Only DEPEND(SOURCE) or DEPEND(SINK: vec) are allowed when ORDERED construct is a standalone construct with no ORDERED region
!$omp ordered depend(out: arrayC) depend(in: arrayB)
arrayC(i) = baz(arrayB(i-1))
end do
!$omp end do
!$omp do ordered(1)
do i = 2, N
!ERROR: DEPEND(*) clauses are not allowed when ORDERED construct is a block construct with an ORDERED region
!$omp ordered depend(source)
arrayA(i) = foo(i)
!$omp end ordered
!ERROR: DEPEND(*) clauses are not allowed when ORDERED construct is a block construct with an ORDERED region
!$omp ordered depend(sink: i - 1)
arrayB(i) = bar(arrayA(i), arrayB(i-1))
!$omp end ordered
end do
!$omp end do
contains
subroutine work1()
!ERROR: THREADS, SIMD clauses are not allowed when ORDERED construct is a standalone construct with no ORDERED region
!$omp ordered simd
end subroutine work1
subroutine work2()
!ERROR: THREADS, SIMD clauses are not allowed when ORDERED construct is a standalone construct with no ORDERED region
!$omp ordered threads
end subroutine work2
end program main