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.
122 lines
3.5 KiB
Fortran
122 lines
3.5 KiB
Fortran
! REQUIRES: openmp_runtime
|
|
|
|
! RUN: %python %S/../test_errors.py %s %flang_fc1 %openmp_flags
|
|
! Semantic checks on hint clauses, as they appear on critical construct
|
|
|
|
program sample
|
|
use omp_lib
|
|
integer :: y
|
|
logical :: z
|
|
real :: k
|
|
integer :: p(1)
|
|
|
|
!$omp critical (name) hint(1)
|
|
y = 2
|
|
!$omp end critical (name)
|
|
|
|
!$omp critical (name) hint(2)
|
|
y = 2
|
|
!$omp end critical (name)
|
|
|
|
!ERROR: The synchronization hint is not valid
|
|
!$omp critical (name) hint(3)
|
|
y = 2
|
|
!$omp end critical (name)
|
|
|
|
!$omp critical (name) hint(5)
|
|
y = 2
|
|
!$omp end critical (name)
|
|
|
|
!ERROR: The synchronization hint is not valid
|
|
!$omp critical (name) hint(7)
|
|
y = 2
|
|
!$omp end critical (name)
|
|
|
|
!ERROR: Synchronization hint must be a constant integer value
|
|
!ERROR: Must be a constant value
|
|
!$omp critical (name) hint(x)
|
|
y = 2
|
|
!$omp end critical (name)
|
|
|
|
!$omp critical (name) hint(4)
|
|
y = 2
|
|
!$omp end critical (name)
|
|
|
|
!$omp critical (name) hint(8)
|
|
y = 2
|
|
!$omp end critical (name)
|
|
|
|
!$omp critical (name) hint(omp_sync_hint_uncontended)
|
|
y = 2
|
|
!$omp end critical (name)
|
|
|
|
!$omp critical (name) hint(omp_lock_hint_speculative)
|
|
y = 2
|
|
!$omp end critical (name)
|
|
|
|
!ERROR: Synchronization hint must be a constant integer value
|
|
!ERROR: Must be a constant value
|
|
!$omp critical (name) hint(omp_sync_hint_uncontended + omp_sync_hint)
|
|
y = 2
|
|
!$omp end critical (name)
|
|
|
|
!$omp critical (name) hint(omp_sync_hint_nonspeculative)
|
|
y = 2
|
|
!$omp end critical (name)
|
|
|
|
!$omp critical (name) hint(omp_sync_hint_none)
|
|
y = 2
|
|
!$omp end critical (name)
|
|
|
|
!$omp critical (name) hint(omp_sync_hint_uncontended + omp_lock_hint_speculative)
|
|
y = 2
|
|
!$omp end critical (name)
|
|
|
|
!$omp critical (name) hint(omp_lock_hint_nonspeculative + omp_lock_hint_uncontended)
|
|
y = 2
|
|
!$omp end critical (name)
|
|
|
|
!$omp critical (name) hint(omp_lock_hint_contended + omp_sync_hint_speculative)
|
|
y = 2
|
|
!$omp end critical (name)
|
|
|
|
!$omp critical (name) hint(omp_lock_hint_contended + omp_sync_hint_nonspeculative)
|
|
y = 2
|
|
!$omp end critical (name)
|
|
|
|
!ERROR: The synchronization hint is not valid
|
|
!$omp critical (name) hint(omp_sync_hint_uncontended + omp_sync_hint_contended)
|
|
y = 2
|
|
!$omp end critical (name)
|
|
|
|
!ERROR: The synchronization hint is not valid
|
|
!$omp critical (name) hint(omp_sync_hint_nonspeculative + omp_lock_hint_speculative)
|
|
y = 2
|
|
!$omp end critical (name)
|
|
|
|
!ERROR: Synchronization hint must be a constant integer value
|
|
!ERROR: Must have INTEGER type, but is REAL(4)
|
|
!$omp critical (name) hint(1.0)
|
|
y = 2
|
|
!$omp end critical (name)
|
|
|
|
!ERROR: Synchronization hint must be a constant integer value
|
|
!ERROR: Operands of + must be numeric; have LOGICAL(4) and INTEGER(4)
|
|
!$omp critical (name) hint(z + omp_sync_hint_nonspeculative)
|
|
y = 2
|
|
!$omp end critical (name)
|
|
|
|
!ERROR: Synchronization hint must be a constant integer value
|
|
!ERROR: Must be a constant value
|
|
!$omp critical (name) hint(k + omp_sync_hint_speculative)
|
|
y = 2
|
|
!$omp end critical (name)
|
|
|
|
!ERROR: Synchronization hint must be a constant integer value
|
|
!ERROR: Must be a constant value
|
|
!$omp critical (name) hint(p(1) + omp_sync_hint_uncontended)
|
|
y = 2
|
|
!$omp end critical (name)
|
|
end program
|
|
|