Repository navigation
Conversation
A wave32 compute or mesh lane is LocalInvocationIndex mod 32, so the reduction for lanes 32-63 in Gen.wave_mask was always 0. Emit one OpGroupNonUniformBitwiseOr and a constant 0 high word, as the wave32 fragment path already does. 0.426 -> 0.387 ms per dispatch on a mask-heavy kernel (RTX 5080), same output bytes.
|
Tested 7dda9b4 on NVIDIA GeForce RTX 5090 (32-wide subgroups), driver 617.42, Windows 11 (26200), native MSVC 2022 RelWithDebInfo, llvm-mc 21.1.8 and SPIRV-Tools: pass.
AI-assisted (Claude Code). |
|
Tested 7dda9b4 on Intel Iris Xe Graphics (TGL GT2, Xe-LP, variable subgroup 8..32), Mesa ANV 26.3.1, Vulkan 1.4.363, Linux 6.12 (Arch container on Debian 13), llvm-mc 23.1.5, SPIRV-Tools v2026.4, GCC: pass. Branch and its merge-base
So the single-reduction mask read holds on a driver whose subgroup size is not fixed at 32, not only on NVIDIA. No timing measured here. Synthetic fixtures only, no game files. AI-assisted (Claude Code). |
|
Tested AMD Radeon RX 6700 XT (gfx1031, RDNA2), RADV Mesa 26.3.1, CachyOS, Linux 7.3.5. Each run done on
Per-test results are identical between On AMD the subgroup could be 64 wide. Every wave32 AI-assisted (Claude Code). |
|
Tested 7dda9b4 (merged onto main 86a7807) on NVIDIA GeForce RTX 2060 (Turing), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 (10.0.26300), subgroup size 32: pass (no regression) What I ran:
No GPU test changed status against main. This PR adds no GPU fixture of its own, so the run checks that the translator change breaks none of the existing GPU tests; it does not exercise the new rule directly. Unit tests changed by the PR: The one failure on both sides is AI-assisted run (Claude Code); the numbers are from my machine. |
Claimed in #7049 (comment)
rdna2spirv: a wave32 compute mask read uses one subgroup reduction, not two
Gen.wave_maskbuilds the whole wave's mask (fors_bcnt1,s_ff1,v_mbcntand similar) with twoOpGroupNonUniformBitwiseOrreductions: one for lanes 0-31 and one for lanes 32-63. In a wave32 compute or mesh shader the lane isLocalInvocationIndex & 31(wave_lane), so it is always below 32. The second reduction always gave 0. Now these shaders emit one reduction and use the constant 0 for the high word, as the wave32 fragment path already does. Wave64, emulated and fragment shaders are unchanged. Each subgroup reduction costs several shuffles on a 32-wide NVIDIA subgroup.Measured
v_readlane,v_cmp,s_bcnt1andv_mbcnt): 0.426 ms becomes 0.387 ms per dispatch (-9%). A hand-written GLSL version runs 0.373 ms. The output buffer is byte-identical: FNV-1a over the whole buffer matchesmainand GLSL.spirv-val.Tests
tests/semantic/test_wave32_mask_reduction.py: a two-wave wave32 group withs_bcnt1andv_mbcntof a VCC mask. It expects one reduction per read and checks the counts per lane withrun_compute_workgroup. It fails onmain(4 != 2) and passes here.tests/semantic: every file passes excepttest_float_nan_fract.py, which fails the same way onmain(3 NaN-payload failures).tests/test_translate.py: 638 passed.scripts/run_gpu_tests.pyon an RTX 3090 (NVIDIA 580.105.08, 32-wide subgroups): the result of every test matchesmain. Native: 183/235 passed, 51 skipped. WithLEONIDA_W64_EMULATE=1: 214/235 passed, 20 skipped. The one failure (ms_wave_info_s3) fails onmaintoo.mainside by side:crosslane_fuzz: 451 match, 32 mismatch, 17 hypothesis-only on both, with the same failing programs. These mismatches are already onmain.lds_fuzz,valu_fuzz --family f16andvalu_fuzz --family mem: 500/500 match on both.