The parser will accept a wide variety of illegal attempts at forming an ATOMIC construct, leaving it to the semantic analysis to diagnose any issues. This consolidates the analysis into one place and allows us to produce more informative diagnostics. The parser's outcome will be parser::OpenMPAtomicConstruct object holding the directive, parser::Body, and an optional end-directive. The prior variety of OmpAtomicXyz classes, as well as OmpAtomicClause have been removed. READ, WRITE, etc. are now proper clauses. The semantic analysis consistently operates on "evaluation" representations, mainly evaluate::Expr (as SomeExpr) and evaluate::Assignment. The results of the semantic analysis are stored in a mutable member of the OpenMPAtomicConstruct node. This follows a precedent of having `typedExpr` member in parser::Expr, for example. This allows the lowering code to avoid duplicated handling of AST nodes. Using a BLOCK construct containing multiple statements for an ATOMIC construct that requires multiple statements is now allowed. In fact, any nesting of such BLOCK constructs is allowed. This implementation will parse, and perform semantic checks for both conditional-update and conditional-update-capture, although no MLIR will be generated for those. Instead, a TODO error will be issues prior to lowering. The allowed forms of the ATOMIC construct were based on the OpenMP 6.0 spec.
78 lines
1.6 KiB
Fortran
78 lines
1.6 KiB
Fortran
!RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=60
|
|
|
|
subroutine f00
|
|
integer :: x, y, v
|
|
|
|
!ERROR: ATOMIC UPDATE operation with CAPTURE should contain two statements
|
|
!$omp atomic update capture
|
|
x = v
|
|
x = x + 1
|
|
y = x
|
|
!$omp end atomic
|
|
end
|
|
|
|
subroutine f01
|
|
integer :: x, y, v
|
|
|
|
!ERROR: ATOMIC UPDATE operation with CAPTURE should contain two assignments
|
|
!$omp atomic update capture
|
|
x = v
|
|
block
|
|
x = x + 1
|
|
y = x
|
|
end block
|
|
!$omp end atomic
|
|
end
|
|
|
|
subroutine f02
|
|
integer :: x, y
|
|
|
|
! The update and capture statements can be inside of a single BLOCK.
|
|
! The end-directive is then optional. Expect no diagnostics.
|
|
!$omp atomic update capture
|
|
block
|
|
x = x + 1
|
|
y = x
|
|
end block
|
|
end
|
|
|
|
subroutine f03
|
|
integer :: x
|
|
|
|
!ERROR: In ATOMIC UPDATE operation with CAPTURE neither statement could be the capture
|
|
!$omp atomic update capture
|
|
x = x + 1
|
|
x = x + 2
|
|
!$omp end atomic
|
|
end
|
|
|
|
subroutine f04
|
|
integer :: x, v
|
|
|
|
!$omp atomic update capture
|
|
!WARNING: In ATOMIC UPDATE operation with CAPTURE either statement could be the update and the capture, assuming the first one is the capture statement
|
|
v = x
|
|
x = v
|
|
!$omp end atomic
|
|
end
|
|
|
|
subroutine f05
|
|
integer :: x, v, z
|
|
|
|
!$omp atomic update capture
|
|
!ERROR: In ATOMIC UPDATE operation with CAPTURE the right-hand side of the capture assignment should read z
|
|
v = x
|
|
z = x + 1
|
|
!$omp end atomic
|
|
end
|
|
|
|
subroutine f06
|
|
integer :: x, v, z
|
|
|
|
!$omp atomic update capture
|
|
z = x + 1
|
|
!ERROR: In ATOMIC UPDATE operation with CAPTURE the right-hand side of the capture assignment should read z
|
|
v = x
|
|
!$omp end atomic
|
|
end
|