-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[AMDGPU] Optimize LDS DMA soft waitcnt #138802
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
Open
kerbowa
wants to merge
1
commit into
main
Choose a base branch
from
users/kerbowa/direct-lds-load-memory-model-waits
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+185
−0
Open
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
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 | ||||
---|---|---|---|---|---|---|
|
@@ -117,3 +117,173 @@ body: | | |||||
S_ENDPGM 0 | ||||||
|
||||||
... | ||||||
|
||||||
# Soft waitcnt should be honored here. | ||||||
# GCN-LABEL: name: buffer_load_dword_lds_ds_read_soft_wait | ||||||
# GCN: BUFFER_LOAD_DWORD_LDS_IDXEN | ||||||
# GCN-NEXT: S_WAITCNT 3952 | ||||||
# vmcnt(0) | ||||||
# GCN-NEXT: S_BARRIER | ||||||
--- | ||||||
name: buffer_load_dword_lds_ds_read_soft_wait | ||||||
body: | | ||||||
bb.0: | ||||||
$m0 = S_MOV_B32 0 | ||||||
BUFFER_LOAD_DWORD_LDS_IDXEN $vgpr0, $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr4, 4, 0, 0, implicit $exec, implicit $m0 :: (load (s32) from `ptr addrspace(1) poison` + 4), (store (s32) into `ptr addrspace(3) poison` + 4) | ||||||
S_WAITCNT_VMCNT_LDS_DMA_soft 3952 | ||||||
S_BARRIER | ||||||
$vgpr0 = DS_READ_B32_gfx9 $vgpr1, 0, 0, implicit $m0, implicit $exec :: (load (s32) from `ptr addrspace(3) poison`) | ||||||
S_ENDPGM 0 | ||||||
|
||||||
... | ||||||
|
||||||
# No need for waitcnt. | ||||||
# GCN-LABEL: name: buffer_store_lds_dword_ds_read_soft_wait | ||||||
# GCN: BUFFER_STORE_LDS_DWORD | ||||||
# GCN-NEXT: S_BARRIER | ||||||
--- | ||||||
name: buffer_store_lds_dword_ds_read_soft_wait | ||||||
body: | | ||||||
bb.0: | ||||||
$m0 = S_MOV_B32 0 | ||||||
BUFFER_STORE_LDS_DWORD $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr4, 4, 0, 0, implicit $exec, implicit $m0 :: (load (s32) from `ptr addrspace(3) poison` + 4), (store (s32) into `ptr addrspace(1) poison` + 4) | ||||||
S_WAITCNT_VMCNT_LDS_DMA_soft 3952 | ||||||
S_BARRIER | ||||||
$vgpr0 = DS_READ_B32_gfx9 $vgpr1, 0, 0, implicit $m0, implicit $exec :: (load (s32) from `ptr addrspace(3) poison`) | ||||||
S_ENDPGM 0 | ||||||
|
||||||
... | ||||||
|
||||||
# Soft waitcnt should mean vmcnt(1) before the barrier and vmcnt(0) after. | ||||||
# GCN-LABEL: name: series_of_buffer_load_dword_lds_ds_read_soft_wait | ||||||
# GCN: BUFFER_LOAD_DWORD_LDS_IDXEN | ||||||
# GCN-NEXT: BUFFER_LOAD_DWORD_LDS_IDXEN | ||||||
# GCN-NEXT: BUFFER_LOAD_DWORD_LDS_IDXEN | ||||||
# GCN-NEXT: S_WAITCNT 3953 | ||||||
# vmcnt(1) | ||||||
# GCN-NEXT: S_BARRIER | ||||||
# GCN-NEXT: S_WAITCNT 3952 | ||||||
# vmcnt(0) | ||||||
# GCN-NEXT: DS_READ_B32_gfx9 | ||||||
--- | ||||||
name: series_of_buffer_load_dword_lds_ds_read_soft_wait | ||||||
body: | | ||||||
bb.0: | ||||||
$m0 = S_MOV_B32 0 | ||||||
BUFFER_LOAD_DWORD_LDS_IDXEN $vgpr0, $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr4, 0, 0, 0, implicit $exec, implicit $m0 :: (load (s32) from `ptr addrspace(1) poison`), (store (s32) into `ptr addrspace(3) poison`) | ||||||
BUFFER_LOAD_DWORD_LDS_IDXEN $vgpr0, $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr4, 4, 0, 0, implicit $exec, implicit $m0 :: (load (s32) from `ptr addrspace(1) poison` + 4), (store (s32) into `ptr addrspace(3) poison` + 4) | ||||||
BUFFER_LOAD_DWORD_LDS_IDXEN $vgpr0, $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr4, 8, 0, 0, implicit $exec, implicit $m0 :: (load (s32) from `ptr addrspace(1) poison` + 8), (store (s32) into `ptr addrspace(3) poison` + 8) | ||||||
S_WAITCNT_VMCNT_LDS_DMA_soft 3953 | ||||||
S_BARRIER | ||||||
$vgpr0 = DS_READ_B32_gfx9 $vgpr1, 0, 0, implicit $m0, implicit $exec :: (load (s32) from `ptr addrspace(3) poison`) | ||||||
S_ENDPGM 0 | ||||||
|
||||||
... | ||||||
|
||||||
# No waitcnt before the barrier because counter is too high | ||||||
# GCN-LABEL: name: buffer_load_dword_lds_ds_read_soft_wait_redundant | ||||||
# GCN: BUFFER_LOAD_DWORD_LDS_IDXEN | ||||||
# GCN-NEXT: S_BARRIER | ||||||
# GCN-NEXT: S_WAITCNT 3952 | ||||||
# vmcnt(0) | ||||||
# GCN-NEXT: DS_READ_B32_gfx9 | ||||||
--- | ||||||
name: buffer_load_dword_lds_ds_read_soft_wait_redundant | ||||||
body: | | ||||||
bb.0: | ||||||
$m0 = S_MOV_B32 0 | ||||||
BUFFER_LOAD_DWORD_LDS_IDXEN $vgpr0, $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr4, 4, 0, 0, implicit $exec, implicit $m0 :: (load (s32) from `ptr addrspace(1) poison` + 4), (store (s32) into `ptr addrspace(3) poison` + 4) | ||||||
S_WAITCNT_VMCNT_LDS_DMA_soft 3953 | ||||||
S_BARRIER | ||||||
$vgpr0 = DS_READ_B32_gfx9 $vgpr1, 0, 0, implicit $m0, implicit $exec :: (load (s32) from `ptr addrspace(3) poison`) | ||||||
S_ENDPGM 0 | ||||||
|
||||||
... | ||||||
|
||||||
# Combine waitcnt. | ||||||
# GCN-LABEL: name: series_of_buffer_load_dword_lds_ds_read_soft_wait_repeat | ||||||
# GCN: BUFFER_LOAD_DWORD_LDS_IDXEN | ||||||
# GCN-NEXT: BUFFER_LOAD_DWORD_LDS_IDXEN | ||||||
# GCN-NEXT: BUFFER_LOAD_DWORD_LDS_IDXEN | ||||||
# GCN-NEXT: S_WAITCNT 3953 | ||||||
# vmcnt(1) | ||||||
# GCN-NEXT: S_BARRIER | ||||||
# GCN-NEXT: S_WAITCNT 3952 | ||||||
# vmcnt(0) | ||||||
# GCN-NEXT: DS_READ_B32_gfx9 | ||||||
--- | ||||||
name: series_of_buffer_load_dword_lds_ds_read_soft_wait_repeat | ||||||
body: | | ||||||
bb.0: | ||||||
$m0 = S_MOV_B32 0 | ||||||
BUFFER_LOAD_DWORD_LDS_IDXEN $vgpr0, $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr4, 0, 0, 0, implicit $exec, implicit $m0 :: (load (s32) from `ptr addrspace(1) poison`), (store (s32) into `ptr addrspace(3) poison`) | ||||||
BUFFER_LOAD_DWORD_LDS_IDXEN $vgpr0, $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr4, 4, 0, 0, implicit $exec, implicit $m0 :: (load (s32) from `ptr addrspace(1) poison` + 4), (store (s32) into `ptr addrspace(3) poison` + 4) | ||||||
BUFFER_LOAD_DWORD_LDS_IDXEN $vgpr0, $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr4, 8, 0, 0, implicit $exec, implicit $m0 :: (load (s32) from `ptr addrspace(1) poison` + 8), (store (s32) into `ptr addrspace(3) poison` + 8) | ||||||
S_WAITCNT_VMCNT_LDS_DMA_soft 3953 | ||||||
S_WAITCNT_VMCNT_LDS_DMA_soft 3953 | ||||||
S_BARRIER | ||||||
S_WAITCNT_VMCNT_LDS_DMA_soft 3953 | ||||||
S_WAITCNT_VMCNT_LDS_DMA_soft 3953 | ||||||
$vgpr0 = DS_READ_B32_gfx9 $vgpr1, 0, 0, implicit $m0, implicit $exec :: (load (s32) from `ptr addrspace(3) poison`) | ||||||
S_ENDPGM 0 | ||||||
|
||||||
... | ||||||
|
||||||
# Merge waitcnt. | ||||||
# GCN-LABEL: name: series_of_buffer_load_dword_lds_ds_read_soft_wait_merge | ||||||
# GCN: BUFFER_LOAD_DWORD_LDS_IDXEN | ||||||
# GCN-NEXT: BUFFER_LOAD_DWORD_LDS_IDXEN | ||||||
# GCN-NEXT: BUFFER_LOAD_DWORD_LDS_IDXEN | ||||||
# GCN-NEXT: S_WAITCNT 3953 | ||||||
# vmcnt(1) | ||||||
# GCN-NEXT: S_BARRIER | ||||||
# GCN-NEXT: S_WAITCNT 3952 | ||||||
# vmcnt(0) | ||||||
# GCN-NEXT: DS_READ_B32_gfx9 | ||||||
--- | ||||||
name: series_of_buffer_load_dword_lds_ds_read_soft_wait_merge | ||||||
body: | | ||||||
bb.0: | ||||||
$m0 = S_MOV_B32 0 | ||||||
BUFFER_LOAD_DWORD_LDS_IDXEN $vgpr0, $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr4, 0, 0, 0, implicit $exec, implicit $m0 :: (load (s32) from `ptr addrspace(1) poison`), (store (s32) into `ptr addrspace(3) poison`) | ||||||
BUFFER_LOAD_DWORD_LDS_IDXEN $vgpr0, $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr4, 4, 0, 0, implicit $exec, implicit $m0 :: (load (s32) from `ptr addrspace(1) poison` + 4), (store (s32) into `ptr addrspace(3) poison` + 4) | ||||||
BUFFER_LOAD_DWORD_LDS_IDXEN $vgpr0, $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr4, 8, 0, 0, implicit $exec, implicit $m0 :: (load (s32) from `ptr addrspace(1) poison` + 8), (store (s32) into `ptr addrspace(3) poison` + 8) | ||||||
S_WAITCNT_VMCNT_LDS_DMA_soft 3954 | ||||||
S_WAITCNT_VMCNT_LDS_DMA_soft 3953 | ||||||
S_BARRIER | ||||||
S_WAITCNT_VMCNT_LDS_DMA_soft 3952 | ||||||
S_WAITCNT_VMCNT_LDS_DMA_soft 3952 | ||||||
$vgpr0 = DS_READ_B32_gfx9 $vgpr1, 0, 0, implicit $m0, implicit $exec :: (load (s32) from `ptr addrspace(3) poison`) | ||||||
S_ENDPGM 0 | ||||||
|
||||||
... | ||||||
|
||||||
|
||||||
# Handle the preexisting waitcnt. | ||||||
# GCN-LABEL: name: series_of_buffer_load_dword_lds_ds_read_soft_wait_preexisting | ||||||
# GCN: BUFFER_LOAD_DWORD_LDS_IDXEN | ||||||
# GCN-NEXT: BUFFER_LOAD_DWORD_LDS_IDXEN | ||||||
# GCN-NEXT: S_WAITCNT 0 | ||||||
# GCN-NEXT: BUFFER_LOAD_DWORD_LDS_IDXEN | ||||||
# GCN-NEXT: S_BARRIER | ||||||
# GCN-NEXT: S_WAITCNT 3952 | ||||||
# vmcnt(0) | ||||||
# GCN-NEXT: DS_READ_B32_gfx9 | ||||||
--- | ||||||
name: series_of_buffer_load_dword_lds_ds_read_soft_wait_preexisting | ||||||
body: | | ||||||
bb.0: | ||||||
$m0 = S_MOV_B32 0 | ||||||
BUFFER_LOAD_DWORD_LDS_IDXEN $vgpr0, $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr4, 0, 0, 0, implicit $exec, implicit $m0 :: (load (s32) from `ptr addrspace(1) poison`), (store (s32) into `ptr addrspace(3) poison`) | ||||||
BUFFER_LOAD_DWORD_LDS_IDXEN $vgpr0, $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr4, 4, 0, 0, implicit $exec, implicit $m0 :: (load (s32) from `ptr addrspace(1) poison` + 4), (store (s32) into `ptr addrspace(3) poison` + 4) | ||||||
S_WAITCNT 0 | ||||||
BUFFER_LOAD_DWORD_LDS_IDXEN $vgpr0, $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr4, 8, 0, 0, implicit $exec, implicit $m0 :: (load (s32) from `ptr addrspace(1) poison` + 8), (store (s32) into `ptr addrspace(3) poison` + 8) | ||||||
S_WAITCNT_VMCNT_LDS_DMA_soft 3953 | ||||||
S_WAITCNT_VMCNT_LDS_DMA_soft 3953 | ||||||
S_BARRIER | ||||||
S_WAITCNT_VMCNT_LDS_DMA_soft 3953 | ||||||
S_WAITCNT_VMCNT_LDS_DMA_soft 3953 | ||||||
$vgpr0 = DS_READ_B32_gfx9 $vgpr1, 0, 0, implicit $m0, implicit $exec :: (load (s32) from `ptr addrspace(3) poison`) | ||||||
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.
Suggested change
Should fix all the MMOs to have address space directly and drop the filler poison values |
||||||
S_ENDPGM 0 | ||||||
|
||||||
... |
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.
Document this
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.
Yes please! What is it? How does it interact with S_WAITCNT_VMCNT? Why does SIMemoryLegalizer want to start emitting it?
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 we avoid baking "DMA" into the name? I don't think that terminology has been used since GFX9. Later documents just talk about "load to LDS".
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 would like to see the follow-up patch in which SIMemoryLegalizer emits those before this lands, can you create a stacked PR with the MemoryLegalizer changes @kerbowa ?
I don't understand why we need these now, and why it's needed for correctness