-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6fa6600
[flang][OpenMP]Add parsing and semantics support for ATOMIC COMPARE
Leporacanthicus 549e2e0
Update based on review comments, consisting of:
Leporacanthicus c551791
Use opnemp_flags to get directory location of omp_lib
Leporacanthicus 0b7c4db
Change order of flags
Leporacanthicus c2c2ecf
Add requires openmp_runtime to test
Leporacanthicus 62e7d53
Remove unused include
Leporacanthicus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| ! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -fopenmp-version=51 -o - %s 2>&1 | FileCheck %s | ||
|
|
||
| ! CHECK: not yet implemented: OpenMP atomic compare | ||
| program p | ||
| integer :: x | ||
| logical :: r | ||
| !$omp atomic compare | ||
| if (x .eq. 0) then | ||
| x = 2 | ||
| end if | ||
| end program p |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| ! REQUIRES: openmp_runtime | ||
| ! RUN: %python %S/../test_errors.py %s %flang_fc1 %openmp_flags -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, c | ||
| a = 1.0 | ||
| b = 2.0 | ||
| c = 3.0 | ||
| !$omp parallel num_threads(4) | ||
| ! First a few things that should compile without error. | ||
| !$omp atomic seq_cst, compare | ||
| if (b .eq. a) then | ||
| b = c | ||
| end if | ||
|
|
||
| !$omp atomic seq_cst compare | ||
| if (a .eq. b) a = c | ||
| !$omp end atomic | ||
|
|
||
| !$omp atomic compare acquire hint(OMP_LOCK_HINT_CONTENDED) | ||
| if (b .eq. a) b = c | ||
|
|
||
| !$omp atomic release hint(OMP_LOCK_HINT_UNCONTENDED) compare | ||
| if (b .eq. a) b = c | ||
|
|
||
| !$omp atomic compare seq_cst | ||
| if (b .eq. c) b = a | ||
|
|
||
| !$omp atomic hint(1) acq_rel compare | ||
| if (b .eq. a) b = c | ||
| !$omp end atomic | ||
|
|
||
| ! Check for error conditions: | ||
| !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 | ||
| if (b .eq. c) b = 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 compare seq_cst seq_cst | ||
| if (b .eq. c) b = 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 | ||
| if (b .eq. c) b = 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 acquire compare | ||
| if (b .eq. c) b = 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 compare acquire acquire | ||
| if (b .eq. c) b = 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 | ||
| if (b .eq. c) b = 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 relaxed compare | ||
| if (b .eq. c) b = 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 compare relaxed relaxed | ||
| if (b .eq. c) b = 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 | ||
| if (b .eq. c) b = a | ||
|
|
||
| !$omp end parallel | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is this needed here?
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.
No, it's a leftover from debugging. Fixed now.