-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[AMDGPU][SIInsertWaitcnts] Wait on all LDS DMA operations when no aliasing store is found #170660
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1086,13 +1086,17 @@ void WaitcntBrackets::updateByEvent(WaitEventType E, MachineInstr &Inst) { | |
| } | ||
| } | ||
| } | ||
| if (Slot || LDSDMAStores.size() == NUM_LDS_VGPRS - 1) | ||
| if (Slot) | ||
| break; | ||
| // The slot may not be valid because it can be >= NUM_LDS_VGPRS which | ||
| // means the scoreboard cannot track it. We still want to preserve the | ||
| // MI in order to check alias information, though. | ||
| LDSDMAStores.push_back(&Inst); | ||
| Slot = LDSDMAStores.size(); | ||
| break; | ||
| } | ||
| setRegScore(FIRST_LDS_VGPR + Slot, T, CurrScore); | ||
| if (Slot < NUM_LDS_VGPRS) | ||
| setRegScore(FIRST_LDS_VGPR + Slot, T, CurrScore); | ||
| if (Slot) | ||
| setRegScore(FIRST_LDS_VGPR, T, CurrScore); | ||
| } | ||
|
|
@@ -2010,15 +2014,23 @@ bool SIInsertWaitcnts::generateWaitcntInstBefore(MachineInstr &MI, | |
| if (Ptr && Memop->getAAInfo()) { | ||
| const auto &LDSDMAStores = ScoreBrackets.getLDSDMAStores(); | ||
| for (unsigned I = 0, E = LDSDMAStores.size(); I != E; ++I) { | ||
| if (MI.mayAlias(AA, *LDSDMAStores[I], true)) | ||
| if (MI.mayAlias(AA, *LDSDMAStores[I], true)) { | ||
| if ((I + 1) >= NUM_LDS_VGPRS) { | ||
|
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. Can you move this up to avoid the AA check if it the limit
Contributor
Author
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. We still need to do the AA check if we hit the limit. If we don't alias with any LDSDMAStore, even those above the limit, we don't need to wait |
||
| // We didn't have enough slot to track this LDS DMA store, it | ||
| // has been tracked using the common RegNo (FIRST_LDS_VGPR). | ||
| ScoreBrackets.determineWait(LOAD_CNT, RegNo, Wait); | ||
| break; | ||
| } | ||
|
|
||
| ScoreBrackets.determineWait(LOAD_CNT, RegNo + I + 1, Wait); | ||
| } | ||
| } | ||
| } else { | ||
| ScoreBrackets.determineWait(LOAD_CNT, RegNo, Wait); | ||
| } | ||
| if (Memop->isStore()) { | ||
|
|
||
| if (Memop->isStore()) | ||
| ScoreBrackets.determineWait(EXP_CNT, RegNo, Wait); | ||
| } | ||
| } | ||
|
|
||
| // Loop over use and def operands. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -223,6 +223,7 @@ define amdgpu_kernel void @buffer_load_lds_dword_10_arrays(<4 x i32> %rsrc, i32 | |
| ; GFX9-NEXT: s_waitcnt vmcnt(2) | ||
| ; GFX9-NEXT: ds_read_b32 v7, v9 offset:1792 | ||
| ; GFX9-NEXT: ; wave barrier | ||
| ; GFX9-NEXT: s_waitcnt vmcnt(0) | ||
|
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. Is this wait needed? Or is the test deliberately using more slots than SIInsertWaitcnts can track, so we have to be conservative?
Contributor
Author
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. Yes that's precisely what I was trying to fix. The wait is required here because we ran out of tracking slots. |
||
| ; GFX9-NEXT: ds_read_b32 v8, v9 offset:2048 | ||
| ; GFX9-NEXT: ; wave barrier | ||
| ; GFX9-NEXT: ds_read_b32 v9, v9 offset:2304 | ||
|
|
@@ -288,6 +289,7 @@ define amdgpu_kernel void @buffer_load_lds_dword_10_arrays(<4 x i32> %rsrc, i32 | |
| ; GFX10-NEXT: s_waitcnt vmcnt(2) | ||
| ; GFX10-NEXT: ds_read_b32 v7, v9 offset:1792 | ||
| ; GFX10-NEXT: ; wave barrier | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) | ||
| ; GFX10-NEXT: ds_read_b32 v8, v9 offset:2048 | ||
| ; GFX10-NEXT: ; wave barrier | ||
| ; GFX10-NEXT: ds_read_b32 v9, v9 offset:2304 | ||
|
|
||
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.
Just curious: can Slot ever be 0 when we exit the loop above? It's not clear to me if these "if"s handle that case correctly, if it can ever happen.
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.
I think so. Worst case we'll call
setRegScoretwice. This will be fixed in #162077