-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[AMDGPU] Handle unset/max flat workgroup size in waves/EU #139955
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
Closed
Closed
Changes from all commits
Commits
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
35 changes: 35 additions & 0 deletions
35
llvm/test/CodeGen/AMDGPU/amdgpu-attributor-max-flat-wgs.ll
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,35 @@ | ||
; RUN: opt -S -mtriple=amdgcn-unknown-amdhsa -mcpu=gfx942 -passes=amdgpu-attributor %s | FileCheck %s | ||
|
||
; CHECK-LABEL: define internal fastcc void @call1( | ||
; CHECK-SAME: ) #[[ATTR0:[0-9]+]] | ||
define internal fastcc void @call1() #0 { | ||
tail call fastcc void @call2() | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: define internal fastcc void @call2( | ||
; CHECK-SAME: ) #[[ATTR0]] | ||
define internal fastcc void @call2() #1 { | ||
tail call fastcc void @call5() | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: define { ptr addrspace(1), ptr } @call3( | ||
; CHECK-SAME:) #[[ATTR0]] | ||
define { ptr addrspace(1), ptr } @call3() #2 { | ||
tail call fastcc void @call5() | ||
ret { ptr addrspace(1), ptr } zeroinitializer | ||
} | ||
|
||
; CHECK-LABEL: define internal fastcc void @call5( | ||
; CHECK-SAME: ) #[[ATTR0]] | ||
define internal fastcc void @call5() { | ||
tail call fastcc void @call1() | ||
ret void | ||
} | ||
|
||
attributes #0 = {"amdgpu-flat-work-group-size"="1, 1024" "target-cpu"="gfx942" } | ||
attributes #1 = {"amdgpu-flat-work-group-size"="1, 1024" "target-cpu"="gfx942" } | ||
attributes #2 = {"amdgpu-flat-work-group-size"="1, 256" "target-cpu"="gfx942" } | ||
|
||
; CHECK: attributes #[[ATTR0]] = { "amdgpu-agpr-alloc"="0" "amdgpu-flat-work-group-size"="1,256" "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-flat-scratch-init" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "target-cpu"="gfx942" "uniform-work-group-size"="false" } |
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.
And it is also wrong to use default flat work group size 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.
can you elaborate why ? Isn't it always safe (correctness-wise) to use max that function allows ?
Uh oh!
There was an error while loading. Please reload this page.
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.
If both of them are zero, it means the flat workgroup size AA still doesn't reach fixed point since its state is still valid here.
Yes, it is always safe to use max, but then there is no point to have this waves per eu AA. Using the default/max value here basically pushes waves per eu to its worst state, and it can't be optimized later on, even if a more optimal flat work group size is encountered. That is because the growth of flat workgroup size and waves per eu is in different direction, and the value gets from waves per eu always dominates the values propagated here.
To fix this properly, we should not use flat workgroup size here at all, which is exactly what #123995 is doing. The intermediate value of work group size should not be used to define waves per eu.
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.
Thanks for explanation.
That's what I sort-of get from the comment in
AAAMDFlatWorkGroupSize
. However, the issue we're seeing is internal compiler error, so compiling with bad perf is always better than having crashing compiler.@arsenm can #123995 be merged ?