shader: lower ds_append, ds_consume and the addtid LDS accesses #134
No reviewers
Labels
No labels
accessibility
bug
claimed
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
tester report
urgent
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LakshanSivakumar--Native-Victory-macOS!134
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-134"
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?
@Olima34 on GitHub · 2026-11-26 18:25 UTC · original
Olima34:fix/shader-lds-address-causes→main· +284 −1 · 4 files · 1 commits · merged 2026-11-26 19:01 UTC"an LDS address" refused 3 unique compute shaders in tester log #123. It covers the DS instructions that take their address from M0 rather than from a VGPR. They are now lowered, from AMD's RDNA2 ISA (the PDF on docs.amd.com) and LLVM.
Sources.
DS_APPEND(62) /DS_CONSUME(61): "addr = M0.base + offset; rtnval = LDS(addr); LDS(addr) = LDS(addr) ± countbits(valid mask); GPR[VDST] = rtnval; // return to all valid threads", done as "one atomic add for first valid lane and broadcast result to all valid lanes".AMDGPUDAGToDAGISel::SelectDSAppendConsumecopies the pointer into M0 and puts the constant in the offset field.ADDTID:LDS_BASE + {OFFSET1,OFFSET0} + M0[15:0] + TID*4.Lowering (
lower.rs,ds_by_m0, inside the instruction's guard):ds_append/ds_consume:atomicrmw add/subof it atM0 + offset, done bywaveIsFirstLane;waveReadLaneFirst.ds_read_addtid_b32/ds_write_addtid_b32read or write the dword at(M0 & 0xFFFF) + offset + 4 × the console lane. With a 32-lane host the lane isconsole_flat & 63, so a console wave64 split into two host waves still addresses by console lane.console_lanes. An append or consume where the host splits a console wave stays refused, as "ds_append or ds_consume in a console wave the host splits": the console makes one atomic for the whole wave, and two host waves would make two.ds_gwsstays refused by name. Addresses are taken as aligned and in bounds, like the other LDS accesses. This is a markedshortcut:: the ISA clamps append/consume by M0's size.Tests.
gfx_refusal_tests::lds_instructions_addressed_by_m0_translate: wave32 append, consume and read_addtid; a wave64 program of 32 threads on a 32-lane host lowers; wave64 with 64 threads on a 32-lane host is refused.addr_tests::lds_append_consume_and_addtid_follow_m0_on_the_gpu, run on Metal:read_addtid;Without the change it fails with the refusal.
victory-shader and victory-gpu tests (arm64, Metal), Windows clippy and
cargo xtask policypass.(This PR first only split the refusal by opcode; with the ISA in hand it now lowers them.)
shader: name the LDS instruction without an address when it is refusedto shader: lower ds_append, ds_consume and the addtid LDS accesses33a3a61be8to6d535ab275@LakshanSivakumar on GitHub · 2026-11-26 18:56 UTC · original · approved these changes
Reviewed and tested together with the other open PRs on main (macOS x86_64 tests for shader, hle, loader and gpu, the setup shell tests, and Windows clippy). Thanks!