shader: lower ds_append and ds_consume in wave64 compute shaders split across 32-lane host waves #414
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-27T17:22:23Z.
Problem
In world runs on
main(#4 refusal table:3 | 3 | 0 | ds_append or ds_consume in a console wave the host splits), wave64 compute shaders with more than 32 threads per group that executeds_appendords_consumeare refused underOptions::wave32_host(Lower::ds_gds,crates/victory-shader/src/emit/lower.rs:5319).On RDNA2,
ds_append/ds_consumeperforms one atomic add/subtract ofpopcount(EXEC)atLDS[M0 + offset]for the 64-lane console wave and returns that wave-wideoldvalue to every active lane in the console wave (after which the shader typically adds its 64-lanev_mbcntprefix). Issuing an independent atomic per 32-lane host half would either double-count the lower half's prefix or interleave waves non-contiguously.Plan
lower/halves.rswithLower::wide_append:exchange_site(self.cur_ir)?(returnsDIVERGENT_EXCHANGEwhen the halves may diverge, which automatically enablesir::keep_lanes_to_endand single-wavelockstepretries, while keeping genuinely divergent multi-wave sites refused).(lo, hi)viawide_ballot(zeroing missing upper halves when the group size is not a multiple of 64) and computen = popcount(lo) + popcount(hi).firstbitlow(lo), or32 + firstbitlow(hi)whenlo == 0, gated onn != 0) perform the singleRmw::Add/Rmw::SubonLDS[M0 + offset]and writeoldtoxchg[wave], framed byxchg_barriers so every active lane in both 32-lane host halves readsoldwhile inactive lanes keepoutside.gfx_refusal_tests.rs(64-lane uniform,s_cbranch_execzearly-exit, single-wave divergent lockstep, 128-lane uniform, and 128-lane divergent refusal) plus a Metal GPU test insplit_wave_tests.rsverifyingds_append+v_mbcntandds_consumeacross split 64-lane and 128-lane groups.Refs #4, #258
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-27T17:22:24Z.
/claim
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-27T17:22:36Z.
Claimed by @Sheffy007. Open a draft pull request with
Refs #414in its description within 24 hours, or the claim expires.