Repository navigation
Translator: ds_permute_b32, the forward (scatter) cross-lane permute (SHADER-90) - #628
Conversation
…(SHADER-90) Each source lane on in EXEC sends its data to lane ((addr + offset) >> 2) mod 32 of its own half (like ds_bpermute_b32); a destination nobody targets gets 0, an off destination keeps its VDST. Highest-numbered source wins a collision. Native: per-source shuffles with a ballot guard for missing lanes; wave64 emulation: two buffer rounds and a %x_perm variable. Tests: tests/semantic/test_ds_permute.py, GPU tests cs_w32_permute and cs_w64x_permute. Contract row in docs/design.md. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
IAmNotSiob
left a comment
There was a problem hiding this comment.
read through both paths. native: a ballot guard for missing lanes, then 32 shuffles of target and data, last match wins, which is the highest source as in the pseudocode. emulated: two rounds plus %x_perm. the per-half mod 32 is backed by the gpu runs. semantic tests pass merged with main (810).
the ds_bpermute thing u mention (wave32 returns an inactive source lane's value instead of 0) sounds like it should get its own issue if #253 is stuck.
TL;DR: looks right and is tested on two gpus, approved. ds_bpermute might need its own issue. AI-assisted review (Claude Code).
|
Thanks for the review. The wave32 |
|
AMD + 32-wide check of #628, tested at the merged head 0726e3f, on one machine. Setup: Windows 11. AMD Radeon Graphics (Ryzen 7 7800X3D iGPU, RDNA2), driver 32.0.21043.5001, subgroup 32..64. RTX 4070 Ti SUPER, driver 610.88, subgroup 32. Test programs from main c432cdc (llvm-mingw clang), llvm-mc 23.1.6.
(AI-assisted run, counts only.) |
SHADER-90 (claimed in #374):
ds_permute_b32, the forward (scatter) cross-lane permute, which the translator still rejected. Unblocks FUZZ-10 (@FreddyxS).Semantics (RDNA2 ISA, DS_PERMUTE_B32 opcode 178 and §10.4.4)
iwritesdata0[i]into destination lanefloor((addr[i] + offset) / 4) mod 32; a destination nobody targets gets 0 (tmp[] = 0in the pseudocode, not its old VDST); a source lane that is off in EXEC does not propagate; a destination lane that is off in EXEC keeps its VDST.mod 32within the lane's own half (mirrorsds_bpermute_b32), not the literalmod 64of the pseudocode. Confirmed on a GPU (below).What
tools/rdna2spirv.py: each source lane publishes its target lane plus one (0 = off in EXEC); each destination lane scans the 32 sources of its half in order and keeps the last match. Native wave32/wave64: a shuffle of target and data per source, with a ballot guard for lanes missing from a partial wave.--wave64-emulate: two buffer rounds and a Function variable%x_perm. Code size is about 90 lines per instance (wave32) and about 330 under emulation; I accepted that for a rare instruction.ds_permuteis also added to the two LDS-size scans that skipds_swizzle/ds_bpermute.tests/semantic/test_ds_permute.py(+ two fixtures viaregen_fixtures.py, one line intest_lds_basic_alloc.py): identity, rotation, reversal, collisions (any writer), unwritten lanes, inactive sources, non-zerooffset:. On the unchanged translator:Unsupported: ds_permute_b32(21 errors); making inactive sources propagate their data also fails 9 cases.runtime/test/shaders/cs_w32_permute.asmandcs_w64x_permute.asm(the wave64 one because the wave32 test never reaches the emulated path or the per-half behaviour, lane 32 gets lane 63's data), registered incheck.py(WAVE32_LANE_DUMPStoo: it needs 32 lanes, so it is skipped on llvmpipe) andrun_gpu_tests.py.docs/design.md(LDS row, the "rejected" note removed) anddocs/shader_validation.md.tools/lds_fuzz.pyis untouched on purpose: its "rejected" comment is FUZZ-10's (@FreddyxS) and Translator: ds_read_u8/i8_d16[_hi] 8-bit LDS reads into a 16-bit half (SHADER-85) #592 edits the same lines.shader_validation.mdnow says the translator supports it and the fuzzer does not generate it yet.Tested
Linux 7.3.5 (CachyOS),
python -I scripts/run_gpu_tests.py --build runtime/build/linux, each GPU pinned withVK_LOADER_DRIVERS_SELECT(device line checked),VK_LOADER_LAYERS_DISABLE=~implicit~, on currentmain+ this commit:LEONIDA_W64_EMULATE=1: 87/87cs_w32_permute=218 29 8 211 0 15 99 15on all three runs;cs_w64x_permute=218 442 435 239 0 99 239 232on emulation and RADVunittest discover -s tests/semantic810 OK;regen_fixtures.py --checkclean;spirv-valclean for wave32, wave64, emulated and emulated with a partial waveNot covered: the partial-wave guard in native mode has only
spirv-val, not a value test, and--wave64-emulatehas no CPU test (the interpreter rejects Workgroup memory), only the GPU test. Also: plain wave32ds_bpermute_b32onmainstill returns an inactive source lane's value instead of 0 (shader_validation.mdcites #253 for that fix, which is not onmain); I did not touchds_bpermute. No game files used. AI-assisted (Claude Code).🤖 Generated with Claude Code