-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[flang][OpenMP]Add parsing and semantics support for ATOMIC COMPARE #117032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
6fa6600
549e2e0
c551791
0b7c4db
c2c2ecf
62e7d53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
! RUN: not %flang_fc1 -fopenmp-version=51 -fopenmp %s 2>&1 | FileCheck %s | ||
! OpenMP version for documentation purposes only - it isn't used until Sema. | ||
! This is testing for Parser errors that bail out before Sema. | ||
program main | ||
implicit none | ||
integer :: i, j = 10 | ||
logical :: r | ||
|
||
!CHECK: error: expected OpenMP construct | ||
!$omp atomic compare write | ||
r = i .eq. j + 1 | ||
|
||
!CHECK: error: expected end of line | ||
!$omp atomic compare num_threads(4) | ||
r = i .eq. j | ||
end program main |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
program main | ||
implicit none | ||
integer :: i, j = 10 | ||
logical :: k | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: is this used? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it should have been "r", but given the below comments, we need another variable, I think. |
||
!READ | ||
!$omp atomic read | ||
i = j | ||
|
@@ -121,6 +122,30 @@ program main | |
i = j | ||
!$omp end atomic | ||
|
||
!COMPARE | ||
!$omp atomic compare | ||
r = i .eq. j | ||
!$omp atomic seq_cst compare | ||
r = i .eq. j | ||
!$omp atomic compare seq_cst | ||
r = i .eq. j | ||
!$omp atomic release compare | ||
r = i .eq. j | ||
!$omp atomic compare release | ||
r = i .eq. j | ||
!$omp atomic acq_rel compare | ||
r = i .eq. j | ||
!$omp atomic compare acq_rel | ||
r = i .eq. j | ||
!$omp atomic acquire compare | ||
r = i .eq. j | ||
!$omp atomic compare acquire | ||
r = i .eq. j | ||
!$omp atomic relaxed compare | ||
r = i .eq. j | ||
!$omp atomic compare relaxed | ||
r = i .eq. j | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The 5.1 standard specifies the format as follows. You will have to update the tests.
In 5.2 standard these are described as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
|
||
!ATOMIC | ||
!$omp atomic | ||
i = j | ||
|
@@ -205,6 +230,20 @@ end program main | |
!CHECK: !$OMP ATOMIC CAPTURE RELAXED | ||
!CHECK: !$OMP END ATOMIC | ||
|
||
!COMPARE | ||
|
||
!CHECK: !$OMP ATOMIC COMPARE | ||
!CHECK: !$OMP ATOMIC SEQ_CST COMPARE | ||
!CHECK: !$OMP ATOMIC COMPARE SEQ_CST | ||
!CHECK: !$OMP ATOMIC RELEASE COMPARE | ||
!CHECK: !$OMP ATOMIC COMPARE RELEASE | ||
!CHECK: !$OMP ATOMIC ACQ_REL COMPARE | ||
!CHECK: !$OMP ATOMIC COMPARE ACQ_REL | ||
!CHECK: !$OMP ATOMIC ACQUIRE COMPARE | ||
!CHECK: !$OMP ATOMIC COMPARE ACQUIRE | ||
!CHECK: !$OMP ATOMIC RELAXED COMPARE | ||
!CHECK: !$OMP ATOMIC COMPARE RELAXED | ||
|
||
!ATOMIC | ||
!CHECK: !$OMP ATOMIC | ||
!CHECK: !$OMP ATOMIC SEQ_CST | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
! RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=51 | ||
use omp_lib | ||
implicit none | ||
! Check atomic compare. This combines elements from multiple other "atomic*.f90", as | ||
! to avoid having several files with just a few lines in them. atomic compare needs | ||
! higher openmp version than the others, so need a separate file. | ||
|
||
|
||
real a, b | ||
logical r | ||
a = 1.0 | ||
b = 2.0 | ||
!$omp parallel num_threads(4) | ||
! First a few things that should compile without error. | ||
!$omp atomic seq_cst, compare | ||
r = b .ne. a | ||
|
||
!$omp atomic seq_cst compare | ||
r = a .ge. b | ||
!$omp end atomic | ||
|
||
!$omp atomic compare acquire hint(OMP_LOCK_HINT_CONTENDED) | ||
r = a .lt. b | ||
|
||
!$omp atomic release hint(OMP_LOCK_HINT_UNCONTENDED) compare | ||
r = a .gt. b | ||
|
||
!$omp atomic compare seq_cst | ||
r = b .ne. a | ||
|
||
!$omp atomic hint(1) acq_rel compare | ||
r = b .eq. a | ||
!$omp end atomic | ||
|
||
! Check for error conidtions: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: conidtions -> conditions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doh, just pushed a fix for the openmp_flags, missed this. Will update in a bit, but want to see if it passes tests first! :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, test didn't work, so needed a change anyway! :) Fingers crossed I figured out what is needed now... 🤞 |
||
!ERROR: More than one memory order clause not allowed on OpenMP Atomic construct | ||
!ERROR: At most one SEQ_CST clause can appear on the COMPARE directive | ||
!$omp atomic seq_cst seq_cst compare | ||
r = a .le. b | ||
!ERROR: More than one memory order clause not allowed on OpenMP Atomic construct | ||
!ERROR: At most one SEQ_CST clause can appear on the COMPARE directive | ||
!$omp atomic compare seq_cst seq_cst | ||
r = b .gt. a | ||
!ERROR: More than one memory order clause not allowed on OpenMP Atomic construct | ||
!ERROR: At most one SEQ_CST clause can appear on the COMPARE directive | ||
!$omp atomic seq_cst compare seq_cst | ||
r = b .ge. b | ||
|
||
!ERROR: More than one memory order clause not allowed on OpenMP Atomic construct | ||
!ERROR: At most one ACQUIRE clause can appear on the COMPARE directive | ||
!$omp atomic acquire acquire compare | ||
r = a .le. b | ||
!ERROR: More than one memory order clause not allowed on OpenMP Atomic construct | ||
!ERROR: At most one ACQUIRE clause can appear on the COMPARE directive | ||
!$omp atomic compare acquire acquire | ||
r = b .gt. a | ||
!ERROR: More than one memory order clause not allowed on OpenMP Atomic construct | ||
!ERROR: At most one ACQUIRE clause can appear on the COMPARE directive | ||
!$omp atomic acquire compare acquire | ||
r = b .ge. b | ||
|
||
!ERROR: More than one memory order clause not allowed on OpenMP Atomic construct | ||
!ERROR: At most one RELAXED clause can appear on the COMPARE directive | ||
!$omp atomic relaxed relaxed compare | ||
r = a .le. b | ||
!ERROR: More than one memory order clause not allowed on OpenMP Atomic construct | ||
!ERROR: At most one RELAXED clause can appear on the COMPARE directive | ||
!$omp atomic compare relaxed relaxed | ||
r = b .gt. a | ||
!ERROR: More than one memory order clause not allowed on OpenMP Atomic construct | ||
!ERROR: At most one RELAXED clause can appear on the COMPARE directive | ||
!$omp atomic relaxed compare relaxed | ||
r = b .ge. b | ||
|
||
!$omp end parallel | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.