-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[flang][openacc] Add support for force clause for loop collapse #162534
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
11 commits
Select commit
Hold shift + click to select a range
65b02a4
add initial implementation
SusanTan 64d0110
tweak
SusanTan c7e7321
tweak
SusanTan 48733f4
code cleanup
SusanTan 32b5f71
add a test
SusanTan fa52cbb
cleanup code
SusanTan e2141ff
refactor code to parse in OpenACC.cpp
SusanTan c27d440
use collapseLoopCount in calculating tile loopcount
SusanTan d92e115
Merge remote-tracking branch 'origin/main' into susant/collapse-force
SusanTan 8c11d6f
format
SusanTan 7cca8e4
refactor
SusanTan 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
41 changes: 41 additions & 0 deletions
41
flang/test/Lower/OpenACC/acc-loop-collapse-force-lowering.f90
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,41 @@ | ||
! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s | ||
|
||
! Verify collapse(force:2) sinks prologue (between loops) and epilogue (after inner loop) | ||
! into the acc.loop region body. | ||
|
||
subroutine collapse_force_sink(n, m) | ||
integer, intent(in) :: n, m | ||
real, dimension(n,m) :: a | ||
real, dimension(n) :: bb, cc | ||
integer :: i, j | ||
|
||
!$acc parallel loop collapse(force:2) | ||
do i = 1, n | ||
bb(i) = 4.2 ! prologue (between loops) | ||
do j = 1, m | ||
a(i,j) = a(i,j) + 2.0 | ||
end do | ||
cc(i) = 7.3 ! epilogue (after inner loop) | ||
end do | ||
!$acc end parallel loop | ||
end subroutine | ||
|
||
! CHECK: func.func @_QPcollapse_force_sink( | ||
! CHECK: acc.parallel | ||
! Ensure outer acc.loop is combined(parallel) | ||
! CHECK: acc.loop combined(parallel) | ||
! Prologue: constant 4.2 and an assign before inner loop | ||
! CHECK: arith.constant 4.200000e+00 | ||
! CHECK: hlfir.assign | ||
! Inner loop and its body include 2.0 add and an assign | ||
! CHECK: acc.loop | ||
! CHECK: arith.constant 2.000000e+00 | ||
! CHECK: arith.addf | ||
! CHECK: hlfir.assign | ||
! Epilogue: constant 7.3 and an assign after inner loop | ||
! CHECK: arith.constant 7.300000e+00 | ||
! CHECK: hlfir.assign | ||
! And the outer acc.loop has collapse = [2] | ||
! CHECK: } attributes {collapse = [2] | ||
|
||
|
Oops, something went wrong.
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.
Having collapse clause parsing in a single place would be ideal. We currently have
getLoopCountForCollapseAndTile
in OpenACC.cpp. Any chance to make something similar - like getLoopCountForCollapse - and then use it both here and in getLoopCountForCollapseAndTile.