-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[AMDGPU] Enable atomic optimizer for 64 bit divergent values #96473
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 2 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b002711
[AMDGPU] Extend readlane, writelane and readfirstlane intrinsic lower…
vikramRH 881e116
[AMDGPU] Extend permlane16, permlanex16 and permlane64 intrinsic lowe…
vikramRH 827d209
fix builtin handling
vikramRH 6047848
Review comments
vikramRH 8a36f07
updated test cases, added new pointer/vector tests
vikramRH 5a4c4c4
Take over recent changes from original patch
vikramRH 12155f5
add hepler to emit N-ary builtins
vikramRH 6714741
Merge branch 'main' into permlane_generic
vikramRH 40381ca
update with latest changes from #89217
vikramRH 4e4cdd9
clang format
vikramRH fe9acb8
Merge branch 'main' into permlane_generic
vikramRH 0a0f93e
Merge branch 'main' into permlane_generic
vikramRH 2091436
[AMDGPU] Enable atomic optimizer for 64 bit values
vikramRH 0bf7890
Merge branch 'main' into atomicOpt_64
vikramRH b4f0198
review comments
vikramRH 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -178,6 +178,20 @@ bool AMDGPUAtomicOptimizerImpl::run(Function &F) { | |
| return Changed; | ||
| } | ||
|
|
||
| static bool shouldOptimize(Type *Ty) { | ||
| switch (Ty->getTypeID()) { | ||
| case Type::FloatTyID: | ||
| case Type::DoubleTyID: | ||
| return true; | ||
| case Type::IntegerTyID: { | ||
| if (Ty->getIntegerBitWidth() == 32 || Ty->getIntegerBitWidth() == 64) | ||
| return true; | ||
| } | ||
|
Contributor
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. Don't forget pointers |
||
| default: | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| void AMDGPUAtomicOptimizerImpl::visitAtomicRMWInst(AtomicRMWInst &I) { | ||
| // Early exit for unhandled address space atomic instructions. | ||
| switch (I.getPointerAddressSpace()) { | ||
|
|
@@ -227,12 +241,10 @@ void AMDGPUAtomicOptimizerImpl::visitAtomicRMWInst(AtomicRMWInst &I) { | |
| const bool ValDivergent = UA->isDivergentUse(I.getOperandUse(ValIdx)); | ||
|
|
||
| // If the value operand is divergent, each lane is contributing a different | ||
| // value to the atomic calculation. We can only optimize divergent values if | ||
| // we have DPP available on our subtarget, and the atomic operation is either | ||
| // 32 or 64 bits. | ||
| if (ValDivergent && | ||
| (!ST->hasDPP() || (DL->getTypeSizeInBits(I.getType()) != 32 && | ||
| DL->getTypeSizeInBits(I.getType()) != 64))) { | ||
| // value to the atomic calculation. We only optimize divergent values if | ||
| // we have DPP available on our subtarget, and the atomic operation is of | ||
| // 32/64 bit integer, float or double type. | ||
| if (ValDivergent && (!ST->hasDPP() || !shouldOptimize(I.getType()))) { | ||
| return; | ||
| } | ||
|
|
||
|
|
@@ -311,12 +323,10 @@ void AMDGPUAtomicOptimizerImpl::visitIntrinsicInst(IntrinsicInst &I) { | |
| const bool ValDivergent = UA->isDivergentUse(I.getOperandUse(ValIdx)); | ||
|
|
||
| // If the value operand is divergent, each lane is contributing a different | ||
| // value to the atomic calculation. We can only optimize divergent values if | ||
| // we have DPP available on our subtarget, and the atomic operation is 32 or | ||
| // 64 bits. | ||
| if (ValDivergent && | ||
| (!ST->hasDPP() || (DL->getTypeSizeInBits(I.getType()) != 32 && | ||
| DL->getTypeSizeInBits(I.getType()) != 64))) { | ||
| // value to the atomic calculation. We only optimize divergent values if | ||
| // we have DPP available on our subtarget, and the atomic operation is of | ||
| // 32/64 bit integer, float or double type. | ||
| if (ValDivergent && (!ST->hasDPP() || !shouldOptimize(I.getType()))) { | ||
| return; | ||
| } | ||
|
|
||
|
|
||
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
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.
Better name that expresses why this type is handleable.
Also in a follow up, really should cover the i16/half/bfloat and 2 x half, 2 x bfloat cases