-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[AMDGPU] Consider FLAT instructions for VMEM hazard detection #137170
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 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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.
Without having a deep understanding of the hazard, it is not clear to me why you would exclude isLDSDMA here. I.e. why shouldn't an instruction like GLOBAL_LOAD_LDS_DWORD satisfy both the HasLds and HasVmem conditions?
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.
Hm, I currently don't have a deep understanding either. While working on the other PR, I just noticed that the current implementation only considers FLAT instruction targeting Global/Scratch memory and I thought that it might make more sense to exclude LDS DMA instead.
However, I'm not sure what is actually supported by the ISA. I mean, we have an LDS bit in the FLAT instruction encoding which is described as "0 = normal, 1 = transfer data between LDS and memory instead of VGPRs and memory", which would suggest that no vgprs are touched. On the other hand,
FLAT_Global_Load_LDS_Pseudostill usesVM_CNTand hasSchedRW = [WriteVMEM, WriteLDS].(Note, though, that this change introduces more synchronization in the current tests)
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.
isDS covers the encoding, it's not a hasLds test. GLOBAL_LOAD_LDS_DWORD is definitively a FLAT encoded instruction
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.
That is, the HasLds part makes sense. I don't understand the exemption on HasVmem
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.
In case a VMEM instruction does LDS DMA, it doesn't actually access the vector memory anymore, or is this assumption wrong?
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.
Do actually flat FLAT instructions support the LDS bit? I thought the bit only applied to GLOBAL_* instructions (or in some ISAs the dedicated LDS opcodes), but I can't seem to find this as a documented restriction.
I'd guess they don't really support LDS->LDS copy, so I would assume they implicitly assume a global memory source address if the bit isn't just ignored. In any case I don't think we ever codegen a FLAT_* instruction with the LDS bit.
I think the intent here was to check for GLOBAL_* or SCRATCH_* instructions, excluding FLAT_* instructions (but all 3 sets are FLAT encoded instructions)
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.
Agreed, that matches the GFX9/GFX10 docs that I have found. Only MUBUF, GLOBAL_* and SCRATCH_* instructions support 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.
So what we actually want for
HasVmemis just plainSIInstrInfo::isVMEM(MI)?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.
That seems trivially correct to me. Anything different would be weird and would need justification.
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.
ok, done