[CK_TILE] FMHA Reduce register spilling in fwd with dropout (workaround for CI failures with clang-22) #3221
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.
Proposed changes
There are test failures in CI on gfx90a with mainline and staging compilers (clang-22):
My investigation shows that the failures are caused by this code:
The inline assembly is
buffer_load_iffromcomposable_kernel/include/ck_tile/core/arch/amd_buffer_addressing_builtins.hpp
Line 148 in 1e77695
The compiler doesn't know that
v[6:9]may have no values yet because the memory load is still in progress so it spills these registers right after the inline asm without addings_waitcnt vmcnt(...).So there are two kind of incorrect values:
buffer_load_dwordx4is likely not finished whenbuffer_store_dwordstarts);v6..v9, if they are used in other operations, will be eventually rewritten when the load finishes.Usually, without spilling, there is
s_waitcnt vmcnt(...)added bybuffer_load_fencebefore results (v[6:9]here) are used. But in this case spilling happens right after loading.This problem was encountered before, here are PR that addressed it in other places:
This PR tries to WORK AROUND this issue by reducing its probability to happen with less register spilling in the kernels with dropout. See commit messages for more details. The failing kernel (hdim = 64) has no spilling on gfx90a at all with these changes.
The real fix will be to replace inline assembly with builtins (so the compiler knows that it needs to add waits). But this is a separate task due to a need of evaluating performance and making the high level implementation as effective as this inline assembly fragment.
Checklist
Please put an
xinto the boxes that apply. You can also fill these out after creating the PR. If you're not sure, please don't hesitate to ask.clang-formaton all changed filesDiscussion
If this is a relatively large or complex change, feel free to start a discussion by explaining why you chose the solution you did and what alternatives you considered