-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[flang][openmp] Add parser/semantic support for workdistribute #154377
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 all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| !RUN: %flang_fc1 -fdebug-unparse -fopenmp -fopenmp-version=60 %s | FileCheck --ignore-case --check-prefix="UNPARSE" %s | ||
| !RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp -fopenmp-version=60 %s | FileCheck --check-prefix="PARSE-TREE" %s | ||
|
|
||
| !UNPARSE: SUBROUTINE teams_workdistribute | ||
| !UNPARSE: USE :: iso_fortran_env | ||
| !UNPARSE: REAL(KIND=4_4) a | ||
| !UNPARSE: REAL(KIND=4_4), DIMENSION(10_4) :: x | ||
| !UNPARSE: REAL(KIND=4_4), DIMENSION(10_4) :: y | ||
| !UNPARSE: !$OMP TEAMS WORKDISTRIBUTE | ||
| !UNPARSE: y=a*x+y | ||
| !UNPARSE: !$OMP END TEAMS WORKDISTRIBUTE | ||
| !UNPARSE: END SUBROUTINE teams_workdistribute | ||
|
|
||
| !PARSE-TREE: | | | OmpBeginDirective | ||
| !PARSE-TREE: | | | | OmpDirectiveName -> llvm::omp::Directive = teams workdistribute | ||
| !PARSE-TREE: | | | OmpEndDirective | ||
| !PARSE-TREE: | | | | OmpDirectiveName -> llvm::omp::Directive = teams workdistribute | ||
|
|
||
| subroutine teams_workdistribute() | ||
| use iso_fortran_env | ||
| real(kind=real32) :: a | ||
| real(kind=real32), dimension(10) :: x | ||
| real(kind=real32), dimension(10) :: y | ||
| !$omp teams workdistribute | ||
| y = a * x + y | ||
| !$omp end teams workdistribute | ||
| end subroutine teams_workdistribute |
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: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=60 | ||
| ! OpenMP Version 6.0 | ||
| ! workdistribute Construct | ||
| ! Invalid do construct inside !$omp workdistribute | ||
|
|
||
| subroutine workdistribute() | ||
| integer n, i | ||
| !ERROR: A WORKDISTRIBUTE region must be nested inside TEAMS region only. | ||
| !ERROR: The structured block in a WORKDISTRIBUTE construct may consist of only SCALAR or ARRAY assignments | ||
| !$omp workdistribute | ||
| do i = 1, n | ||
| print *, "omp workdistribute" | ||
| end do | ||
| !$omp end workdistribute | ||
|
|
||
| end subroutine workdistribute |
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,34 @@ | ||
| ! RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=60 | ||
| ! OpenMP Version 6.0 | ||
| ! workdistribute Construct | ||
| ! The !omp workdistribute construct must not contain any user defined | ||
| ! function calls unless the function is ELEMENTAL. | ||
|
|
||
| module my_mod | ||
| contains | ||
| integer function my_func() | ||
| my_func = 10 | ||
| end function my_func | ||
|
|
||
| impure integer function impure_my_func() | ||
| impure_my_func = 20 | ||
| end function impure_my_func | ||
|
|
||
| impure elemental integer function impure_ele_my_func() | ||
| impure_ele_my_func = 20 | ||
| end function impure_ele_my_func | ||
| end module my_mod | ||
|
|
||
| subroutine workdistribute(aa, bb, cc, n) | ||
| use my_mod | ||
| integer n | ||
| real aa(n), bb(n), cc(n) | ||
| !$omp teams | ||
| !$omp workdistribute | ||
| !ERROR: User defined non-ELEMENTAL function 'my_func' is not allowed in a WORKDISTRIBUTE construct | ||
| aa = my_func() | ||
| aa = bb * cc | ||
| !$omp end workdistribute | ||
| !$omp end teams | ||
|
|
||
| end subroutine workdistribute |
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,34 @@ | ||
| ! RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=60 | ||
| ! OpenMP Version 6.0 | ||
| ! workdistribute Construct | ||
| ! All array assignments, scalar assignments, and masked array assignments | ||
| ! must be intrinsic assignments. | ||
|
|
||
| module defined_assign | ||
| interface assignment(=) | ||
| module procedure work_assign | ||
| end interface | ||
|
|
||
| contains | ||
| subroutine work_assign(a,b) | ||
| integer, intent(out) :: a | ||
| logical, intent(in) :: b(:) | ||
| end subroutine work_assign | ||
| end module defined_assign | ||
|
|
||
| program omp_workdistribute | ||
| use defined_assign | ||
|
|
||
| integer :: a, aa(10), bb(10) | ||
| logical :: l(10) | ||
| l = .TRUE. | ||
|
|
||
| !$omp teams | ||
| !$omp workdistribute | ||
| !ERROR: Defined assignment statement is not allowed in a WORKDISTRIBUTE construct | ||
| a = l | ||
| aa = bb | ||
| !$omp end workdistribute | ||
| !$omp end teams | ||
|
|
||
| end program omp_workdistribute |
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,15 @@ | ||
| ! RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=50 | ||
| ! OpenMP Version 6.0 | ||
| ! workdistribute Construct | ||
| ! Unsuported OpenMP version | ||
|
|
||
| subroutine teams_workdistribute() | ||
| use iso_fortran_env | ||
| real(kind=real32) :: a | ||
| real(kind=real32), dimension(10) :: x | ||
| real(kind=real32), dimension(10) :: y | ||
| !ERROR: WORKDISTRIBUTE construct is not allowed in OpenMP v5.0, try -fopenmp-version=60 | ||
| !$omp teams workdistribute | ||
| y = a * x + y | ||
| !$omp end teams workdistribute | ||
| end subroutine teams_workdistribute |
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.
Consider an early return if
eis nullptr.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 it in latest patch.