compute: lower the discarded-cache and wave-id SMEM forms #3638
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3638
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3636"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@lambirou on GitHub · 2026-11-30 19:00 UTC · original
lambirou:compute/smem-misc→main· +592 −7 · 6 files · 9 commits · merged 2026-12-02 05:42 UTCStacked on #3634 (
compute/smem-cache-noops): the diff includes that commit until #3634 lands. Rebase after it merges. The branch also mergesorigin/mainatd5970858without conflicts.Part of the SMEM slice (P2). This adds
s_dcache_discard,s_dcache_discard_x2ands_get_waveid_in_workgroup.s_dcache_discardand_x2are cacheless no-ops like the other SMEM cache controls, but their operands are still parsed and bounded. LLVM 15.0.7's gfx1013 assembler establishes the spelling: both take an aligned SGPR pair (not a quad); a quad, an odd pair or a modifier is rejected.s_get_waveid_in_workgroupreturns the wave index within the workgroup (tid.x / wave width), which is 0 for the one-wave model; a group whose width is not statically known is refused. Its SGPR result arrives through LGKM like a scalar load: the destination stays pending untils_waitcnt lgkmcnt(0), and a read before that wait is refused asUnresolved scalar move source.Tests
Head
1479e86aon Windows 11 build 26300 (AMD Radeon RX 9060 XT1002:7590, driver32.0.32029.2010; Microsoft Basic Render Driver1414:008c, driver10.0.26100.10068), after mergingorigin/mainatd5970858:ctest --preset dev --no-tests=error -R '^(compute_store_aot_smem_wide_loads|compute_store_aot_smem_stores|compute_store_aot_(warp|hardware)|compute_store_aot_smem_stores_(warp|hardware)|compute_store_aot_smem_cache_(controls|cli)|compute_store_aot_smem_misc_(controls|cli))$' -j 1passed 10/10 in 131.8 s: the wide-load and store text modes, the two WARP draws, the two hardware draws, the cache controls/CLI and the misc controls/CLI. No skips. The misc controls now put the LGKM wait before the read, check the one-wave and declared-wave32 wave-ID values, and require a read before the wait to fail with
Unresolved scalar move source; the discard spellings and their refusals are unchanged.tests/compute_store_check.py smem-misc-controlspassed (7.4 s) andsmem-misc-clipassed (21.2 s; LLVM 15.0.7's clang integrated assembler andLLVM-C.dll, fourteen containers).tests/compute_store_check.py smem-cache-controlsandsmem-cache-clipassed;smem-wide-loadsandsmem-storespassed.tests/form_coverage_check.pypassed;tests/docs_links_check.pypassed (192 Markdown files, 745 links).The Linux
compute_store_check.py binarymode needsllvm-mc, which this Windows host does not have; it was not run locally. CI's Linux LLVM step still runs it.Limits
The discard is a no-op property of the cacheless compute model, not a measurement of the native cache; the wave-id value is verified in the emitted HLSL and the LLVM/CLI round-trip, not by a GPU draw. No console measurement was made.
AI-assisted.
@lukaslw-lab on GitHub · 2026-11-30 19:52 UTC · original · reviewed
Reviewed
7e92b4caby reading the delta over #3634 (83b60bd3); not built or run.Verdict: comment. No MUST. One SHOULD that also changes the fixture, so worth fixing before merge.
s_get_waveid_in_workgroupis an SMEM instruction, and its SGPR result arrives through the LGKM counter like any scalar load, so the guest musts_waitcnt lgkmcnt(0)before reading it. The scalar loads put their destinations inpending(tools/compute_store_aot.py:1833,:1849), andalu_wordrefuses a pending SGPR until the wait. The wave-ID branch writesscalar[dst]withoutpending.add(dst)(:1481-1495), so a read straight after it is accepted. The fixture is exactly that shape:smem_misc_waveid_programemitss_get_waveid_in_workgroup s4thenv_mov_b32_e32 v15, s4(tests/compute_store_check.py,smem_misc_waveid_program). Suggest: adddsttopending, puts_waitcnt lgkmcnt(0)in the fixture, and add a refusal case for the read before the wait.local.x >> 5is the guest wave index for a 1D wave32 group (also for a partial last wave). It folds to 0 for ≤ 32 threads and for the declared one-wave wave64 LDS group. 2D/3D groups and an undeclared width stay refused. Same rules as thes_bcnt1_i32_b32 exec_lolowering.s0-s105, signed 21-bit immediate orsN [offset:], everything else refused. As a no-op after ans_store_*it keeps the stored data, which is one outcome hardware also allows (the line may already be written back).Tests:
smem-misc-controlschecks the HLSL text and every refusal, and records the three forms.smem-misc-cliround-trips them through LLVM 15 and the CLI. Neither is in the Windowsprpreset filter, and the Linux LLVM step runs onlycompute_store_check.py binary. So CI ran onlyform_coverage_check.py, and the new modes have only the author's local run. The wave-ID value is not checked on a device.@lambirou on GitHub · 2026-11-30 20:24 UTC · original
Thanks for the review. Fixed in
1479e86a:s_get_waveid_in_workgroupnow adds its SGPR destination topending, so the result is unreadable untils_waitcnt lgkmcnt(0)clears it, like the scalar loads.smem_misc_waveid_programnow emitss_waitcnt lgkmcnt(0)beforev_mov_b32_e32 v15, s4.s4before the wait and expects the exact messageUnresolved scalar move source. The discard forms and their refusals are unchanged.I merged
origin/mainatd5970858without conflicts. The targeted entries passed 10/10 (131.8 s), including the two WARP and two hardware draws, with no skips:ctest --preset dev --no-tests=error -R '^(compute_store_aot_smem_wide_loads|compute_store_aot_smem_stores|compute_store_aot_(warp|hardware)|compute_store_aot_smem_stores_(warp|hardware)|compute_store_aot_smem_cache_(controls|cli)|compute_store_aot_smem_misc_(controls|cli))$' -j 1.tests/form_coverage_check.pyandtests/docs_links_check.pyalso pass. The PR body records the commands and results; CI is running on the new head.@lukaslw-lab on GitHub · 2026-12-01 01:35 UTC · original · reviewed
Reviewed
0db3e0b9by reading the diff; not built or run. Our point was at7e92b4ca. The PR's own fix since then is1479e86a; the rest is #3634's commits and merges of main.Verdict: comment. The wave-ID fix is right. No MUST. One SHOULD: at this head the evidence in
docs/experiments.mdcontradicts itself about LLVM 15 on the same host.docs/experiments.md:4672-4675) says the cache CLI entry "returned 77 (skipped) on that host because LLVM 15's clang integrated assembler andLLVM-C.dllwere not installed; no LLVM 15 round trip has been run". This PR's paragraph (:4730) says "the four entries passed with LLVM 15.0.7's clang integrated assembler andLLVM-C.dll", and those four includecompute_store_aot_smem_cache_cli. The PR body and your 20:24 comment report 10/10 with "no skips", also includingsmem_cache_cli, 13 minutes after the 20:11 correction on #3634. If LLVM 15 was installed in between, #3634's paragraph should say the cache round trip ran. If not, the misc CLI result here is not established either. Please make the two agree with what actually ran.1479e86a: the wave-ID destination goes intopendingafter the range and already-pending checks, so a read needss_waitcnt lgkmcnt(0), like the scalar loads. The fixture now has the wait. The new refusal (wait=False→Unresolved scalar move source) reaches the read-before-wait path.7e92b4caare otherwise unchanged. #3634's commits match what we approved there.Tests: CI passed at this head.
smem-misc-controlsandsmem-misc-cliare still outside theprfilter and the Linux check list, so the wave-ID refusal has only your local run.github-bot referenced this pull request2026-12-01 11:17:12 +00:00
@R0Y00 on GitHub · 2026-12-02 05:41 UTC · original · approved these changes
Confirmed #3634 is already on main and the remaining diff keeps the validated cache controls. Exact head
0db3e0b9:python -B tests/compute_store_check.pypassed insmem-misc-controls,smem-cache-controls,smem-wide-loads, andsmem-storesmodes.python -B tests/form_coverage_check.pypassed. Locally changing the generatedlocal.x >> 5uto>> 6umade the 64-thread control fail at the expected wave-ID assertion; the source was restored. This run validates lowering and refusal behavior.