compute: lower ds_append in wave32 and converged wave64 compute shaders #3432
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!3432
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3430"
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?
@Ammmae0x on GitHub · 2026-11-29 02:07 UTC · original
Ammmae0x:compute/ds-append-non-virtual-waves→main· +373 −6 · 5 files · 12 commits · merged 2026-12-02 15:32 UTCRefs #3226, #2935
ds_append(0x3e) was lowered only whenvirtual_waveswas non-zero, so native wave32 and converged wave64 shaders fell through todecode_local_dataand were refused withunsupported local DS opcode 62.local_memory()now handlesds_appendin all modes under the existinginvalid local append counterguard (GDS bits, low words, unaligned or out-of-range offsets; no LDS allocation is still refused before lowering).Wave64 keeps the existing lowering: both EXEC words counted, half-0/lane-0 leader, workgroup barrier, atomic add, broadcast through the wave exchange.
Native wave32 (and narrow guest wave64) counts EXEC_LO only, takes the lane-0 leader, and broadcasts with
waveReadLaneAtfrom lane 0. It emits no workgroup barrier, so a divergent per-wave branch around the append cannot deadlock.ds_consume(0x3d) stays refused.M0 assumption: the lowering reads the counter address from the static instruction offset only (
shared_address("lds", words, offset / 4)inlocal_memory()), so it assumes M0 == 0 in every direct mode (virtual_waves, converged wave64, native wave32 / narrow wave64). A nonzero M0 is silently ignored, not refused. Not covered at runtime: narrow wave64 (compile-only incontrols), wave64 above 64 threads, nonzero M0. Stated in the test docstring anddocs/experiments.mdalongside the existing ds_append counter note.Tests:
tests/native_compute_ds_append_check.py+tests/cmake/native_compute_ds_append.cmake._controls: compile_dxil IR checks (wave32/narrow: oneunaryBits, onewaveReadLaneAt, no barrier; wave64: twounaryBits,waveExchange, barrier kept) and seven refusals (GDS bit 170x20000and bit 160x10000, lowi.bbit, unaligned offset, out-of-range offset,ds_consume, no LDS allocation)._warp/_hardware: native_store_replay --direct readback for native wave32 (partial EXEC with lane 0 masked off, multi-wave workgroup, divergent s_cbranch_execz, count==0 no-op, final LDS counter 94) and converged wave64 (asymmetric EXEC_LO/EXEC_HI, final counter 32); gated onoffscreen_check <adapter> --shader-wave32exiting 0.Review fixes (
6c3518ec, on merge oforigin/main8a30428a):main()validates argv and setssdk = argv[2] if mode == "controls" else argv[3]beforePath(sdk); wrong arity now prints usage instead of raisingNameErrorin all three modes (verified on Linux with fake paths: both modes reachdxc.exeunder the rightsdk).The
gdsrefusal now uses the real RDNA2 GDS bit 17 (0x20000;ds_append v24 offset:12 gdsis0xd8fa000c, confirmed against the disassembler), with bit 16 kept as a second case, so narrowing(i.a & 0x30000)to either single bit fails a refusal; the new low-i.brefusal pins(i.b & 0xffffff).The Python-only
expected_wave64()"reference mutants" are removed; translator spot-mutations on throwaway copies of the real source are killed by the offline harness instead (gating0x3eonvirtual_waves, dropping|| (i.b & 0xffffff), narrowing(i.a & 0x30000)to0x10000/0x20000, removingwaveReadLaneAt, re-addingbarrier()in the!wave64path — 6/6 killed, each by its intended check).PR CI now runs these tests:
native_compute_ds_append_(controls|warp|hardware)added to theprctest filter, withcompile_dxilandnative_store_replayadded to theprbuild targets.Linux checks (this host cannot run compile_dxil or Windows CTest):
Offline harness (source + decoded-program + reference-model checks): PASS
6/6 translator spot-mutations fail the harness, clean tree passes again
form_coverage_check.py,docs_links_check.py,bidi_controls_check.py: passpy_compileof the new check: passgit merge-tree --write-tree origin/main HEAD: exit 0Windows Verification (
1535cb9c2d67bb713343e299ccb677eaf14051fd)AI-assisted.
@Leyukaka on GitHub · 2026-11-29 03:27 UTC · original · reviewed
Comment on
c63e326(draft). Evidence is reading only: the diff, the head blobs and main212d4b5f. Nothing was built or run, so the mutations below are derived from the code, not executed.The lowering reads as correct for the modes it enables: popcount of EXEC_LO, lane 0 as leader regardless of EXEC, no atomic when the count is zero, old value broadcast with
waveReadLaneAt(.., 0). Wave64 keeps both counts, the barrier and the exchange.Blocking:
tests/native_compute_ds_append_check.py:290:main(*argv)evaluatesPath(sdk) / "dxc.exe", butsdkis not a parameter, a local, a module-level name or an import. All three modes (controls,warp,hardware) raise NameError before any check. Fix:sdk = argv[2] if mode == "controls" else argv[3]before that line.windows.ymlrunsctest --preset pr, and the include filter of that preset inCMakePresets.jsonhas no pattern matchingnative_compute_ds_append_*. The /O2 job was skipped.Test gaps once the script runs:
gdsrefusal case sets0x10000(bit 16). The GDS bit is 17:tools/disasm_rdna2.py:2124reads(w0 >> 17) & 1, andtests/rdna2_tools_check.py:470decodes0xD8FA000Casds_append v24 offset:12 gds. Narrowing(i.a & 0x30000)to(i.a & 0x10000)atsrc/gfx1013_direct_compute.inl:1322keeps the case refused while real GDS is accepted. Use0x20000.i.b == 1 << 24, so dropping|| (i.b & 0xffffff)at :1322 passes. Add a case with a lowi.bbit set.expected_wave64(**flags)withexpected_wave64(). They do not involve the translator.M0: the lowering uses the instruction offset only (
shared_address("lds", words, offset / 4)), before and after this change.docs/experiments.md:5715states the counter is "at LDS byte zero with zero M0". The assumption now applies to every direct mode. Either refuse when M0 is not known to be zero or state the limit.Not covered at runtime: narrow wave64 (compile-only in
controls), wave64 with more than 64 threads, non-zero M0.@Ammmae0x on GitHub · 2026-11-29 14:43 UTC · original
Addressed all items from
@Leyukaka's review across6c3518ec..b4ba7c20:argvNameErrorinmain(): Reordered validation and fixedsdk = argv[2] if mode == "controls" else argv[3].i.blow-bit refusals: Updated thegdsrefusal to RDNA2 GDS bit 17 (0x20000,0xd8fa000c), kept bit 16 (0x10000) asgds-bit16, and addedlow-ib((1 << 24) | 1), pinning both terms of(i.a & 0x30000) || (i.b & 0xffffff).M0 == 0scope: Replaced the Python-onlyexpected_wave64()claims with source-backed checks + 6 killed spot-mutations, documented theM0 == 0assumption honestly indocs/experiments.mdand test docstrings, and fixedcontrols()inb4ba7c20to count DXIL call lines (call i32 @dx.op.unaryBits.i32/call i32 @dx.op.waveReadLaneAt.i32) instead of moduledeclarelines.b4ba7c20): Passed in bothdev(2 passed, 1 skipped,2.55s) andrelease(2 passed, 1 skipped,2.54s) onNVIDIA GeForce RTX 4050 Laptop GPU (10de:28e1), driver 32.0.15.9186(warpskipped exit77on 4-lane WARP).AI-assisted.
@Leyukaka on GitHub · 2026-11-29 15:03 UTC · original · approved these changes
Re-review on
b4ba7c20. Evidence is reading only (diff against merge base8a30428a, head blobs, CI log of run 46274251467). Nothing was built or run here.Points from the review on
c63e3269:sdkNameError: fixed.tests/native_compute_ds_append_check.py:305setssdk = argv[2] if mode == "controls" else argv[3]after the arity checks at :291-302; this matches the arguments intests/cmake/native_compute_ds_append.cmake.0x20000, :198 keeps0x10000asgds-bit16, so narrowing(i.a & 0x30000)atsrc/gfx1013_direct_compute.inl:1384to either bit leaves one case accepted.i.b: fixed. :204low-ibuses(1 << 24) | 1; it is the only case that depends on(i.b & 0xffffff).compile_dxilandnative_store_replayare added to theprbuild targets andnative_compute_ds_append_(controls|warp|hardware)to theprtest filter; no other change inCMakePresets.json.Build and test on Windowsrannative_compute_ds_append_controls(Passed, 5.01 s); 85/85.docs/experiments.md:5725-5733and the test docstring, not enforced. The source hunk is unchanged fromc63e3269.Runtime evidence: in CI both
_warpand_hardwarewere skipped (exit 77), so only the compile-level_controlschecks ran there. The wave32 and wave64 readbacks (final counters 94 and 32) rest on the author's RTX 4050 run alone.Nits, not blocking:
hardwarein theprtest filter always skips on the hosted runner, and it is the only_hardwareentry in that filter.controls|warpwould be enough.docs/experiments.md:5725saysds_appendis lowered "the same way in every mode". That holds for the counter address only; the count, the barrier and the broadcast differ between wave64 and wave32 / narrow wave64.git merge-tree --write-treeof main5de0b114withb4ba7c20is clean.Not covered at runtime: narrow wave64, wave64 above 64 threads, nonzero M0, any adapter in CI.
@Leyukaka on GitHub · 2026-12-02 07:13 UTC · original
Friendly note: this is approved, but it currently conflicts with
mainafter the recent merges; a rebase should be all it needs.@Ammmae0x on GitHub · 2026-12-02 13:36 UTC · original
@Leyukaka Merge conflicts with
mainare resolved in1535cb9c(MERGEABLE), and Windowsdev(2 passed, 1 skipped,4.46s) +release(2 passed, 1 skipped,3.99s) verification passed onNVIDIA GeForce RTX 4050 Laptop GPU(10de:28e1, driver32.0.15.9186). Ready for re-review.AI-assisted.
@R0Y00 on GitHub · 2026-12-02 14:36 UTC · original · approved these changes
I checked the conflict resolution on
1535cb9cand a clean trial merge with current main. The partial-final-wave refusal and existing PR preset registrations are preserved. On the exact head I builtcompile_dxilandnative_store_replaywith MSVC Debug, then ranctest --preset dev --no-tests=error -j 1 -V -R '^native_compute_ds_append_'. The controls passed all seven refusal cases. RTX 4060 Laptop, driver 32.0.16.1656, matched wave32 and converged wave64 readback, including zero-count and divergent wave32 controls. Inbox WARP 10.0.26100.9818 skipped because it exposes four lanes. Hosted Windows CI failed in the sharednative_direct_meshfixture, tracked by #3853.