Repository navigation
Translator: barrier rounds for wave32 compute shaders whose s_barrier isn't in uniform control flow (SHADER-91 follow-up) - #930
Conversation
4f09756 to
3c9e14f
Compare
|
Tested
No game files were used. |
quackottu
left a comment
There was a problem hiding this comment.
Tested 3c9e14f on NVIDIA GeForce RTX 5070 (subgroup 32), driver 621.24, Windows 11 Pro (26300), Vulkan SDK 1.4.363.0, llvm-mc 21.1.8 (built with scripts/build_llvm_mc.ps1), scripts/run_gpu_tests.py:
- native: 76/103 passed, 27 skipped (
main8df277f here: 64/91 passed, 27 skipped, all wave64 tests needing a 64-wide subgroup) LEONIDA_W64_EMULATE=1: 103/103 passed (mainhere: 91/91)python -m unittest discover -s tests/semantic: Ran 1018 tests in 163.609s OK
3c9e14f to
7dc3a7d
Compare
|
Tested 7dc3a7d on two GPUs: pass, native and emulated. Windows 11 Home 10.0.26300, llvm-mc 21.1.8 (AMDGPU, native), Vulkan SDK 1.4.363.0, MSVC 14.44.35207, Python 3.14.7,
ctest with AI-assisted (Claude Code). No game files. |
|
AI-assisted. No game files used. Additional AMD/NVIDIA test evidence for PR #930: an old-translator control, repeated fixture launches, and a comparison of the synthetic suite's compiled modules. Tested head 7dc3a7d against its parent dcd8ecf on Windows 11: AMD Radeon iGPU (AMD proprietary 26.10.1, subgroup 32..64) and RTX 5080 (616.92, subgroup 32), selected with VK_LOADER_DRIVERS_SELECT. Test programs were built from the parent with MSVC 19.50 / Ninja Release; llvm-mc 23.1.6.
Caveat: the AMD runner repeat reported missing words in 2/30 PR fixture executions versus 0/30 controls. An earlier batch of direct launches (its log was later overwritten, so it isn't counted here) showed the same empty-output symptom with both the PR and control modules. The 3,800 later direct launches whose results are recorded all passed: 1,800 across the three fixtures, plus 2,000 interleaved PR/control launches of cs_barrier_divergent with subgroup size 32 requested and with the default setting (500 per translator per setting). Its cause remains unresolved; these results do not establish either a PR defect or a harness defect. |
… isn't in uniform control flow (SHADER-91) On RDNA every s_barrier counts against the same workgroup barrier and a wave that has ended no longer counts; SPIR-V needs every OpControlBarrier reached by the whole workgroup in uniform control flow. A native wave32 compute shader whose s_barrier sits anywhere but a top-level block of the structured tree now runs in rounds, the emulated wave64 loop without its cross-lane part: s_barrier ends a segment, each invocation runs until its next s_barrier or the end, and the workgroup meets at one OpControlBarrier at the end of the round. A per-round count of the invocations not done (three Workgroup words) ends the loop. Native wave64 cs and ms are unchanged. Intel Arrow Lake Xe-LPG iGPU (32.0.101.8132): cs_barrier_divergent and the new cs_barrier_early_end and cs_barrier_loop lose the device with the plain translation and pass with barrier rounds; all three pass on an RTX 5070 Ti (617.42) either way. docs/design.md's Workgroup barriers row describes it. AI-assisted (Claude Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7dc3a7d to
c774f25
Compare
…arge Native wave32 barrier rounds counted the invocations not done in %x_buf, three Workgroup dwords (#930). With a full 32 KiB LDS that made 32,780 B, 12 bytes over the 32,768 B maxComputeSharedMemorySize of the AMD Windows and Intel drivers, so the SHADER-309 runtime check refused the pipeline. When the shader uses its LDS and the array plus 12 bytes is over 16,384 B (the Vulkan minimum), the count now borrows LDS word 0 between rounds: invocation 0 saves and clears it, the invocations not done add 1, all read it, invocation 0 restores it, each step behind a workgroup barrier while no shader code runs. Smaller shaders keep %x_buf and one barrier per round. A 32 KiB LDS round shader is now exactly 32,768 B. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claimed in the coordination issue as: SHADER-91 follow-up, barrier rounds (#634 (comment))
What and why
On RDNA every
s_barriercounts against the same workgroup barrier, and a wave that has ended no longer counts. In SPIR-V anOpControlBarrierhas to be reached by the whole workgroup in uniform control flow. On the native path the translator left the barrier wheres_barrieris, anddocs/design.md(SHADER-91, #708) noted that this isn't proven and named the fix: "a barrier-only round scheduler (the emulated loop without its cross-lane part) is the fix if a hang shows up."A hang has shown up on Intel. On an Arrow Lake Xe-LPG iGPU (Windows driver 32.0.101.8132),
cs_barrier_divergentloses the device on every run (vkQueueWaitIdle -> -4,VK_ERROR_DEVICE_LOST). On @kapitche's UHD 770 (101.6129) it hangs or writes nothing (#634).needs_barrier_rounds: a native wave32 compute shader runs in rounds when ans_barriersits anywhere but a top-level block of the structured tree. That means under a guard, in a loop, or anywhere in the dispatch loop. A top-level block is one every invocation runs, so a barrier there keeps the plain translation. Native wave64 cs and ms (AMD only) are unchanged.--wave64-emulateis unchanged too: it already has its own round loop.bar_scheduleris the emulated loop without its cross-lane part:s_barriersets%x_barand ends a segment (x_split). The rest of the block is a continuation segment, and SSA values cross it throughx_spill, as under--wave64-emulate.%pcuntil it reaches ans_barrieror the end.OpControlBarrier, at the end of the round loop, withs_barrier's own semantics (workgroup, acquire-release, workgroup memory).Workgroupwords, by round mod 3: invocation 0 clears the next round's word, which was last read two rounds earlier.s_barrierhave one nested (@Spaghetih's count in Coordinating who works on what (3) (moved to #1006) #634), so those 43 now run in rounds. I don't have the game files to rerun the corpus. Under--wave64-emulatethe same splitting and spilling already runs on every wave64 cs and ms shader, at more points than barriers.docs/design.md: the "Workgroup barriers" row describes this, the GPU results, and what is still unproven (native wave64, AMD only).Tested
Windows 11 26200, llvm-mc 23.1.6, Vulkan SDK 1.4.363, MSVC 19.44,
main4a36bb1. Two new fixtures, registered incheck.pyandrun_gpu_tests.pylikecs_barrier_divergent:cs_barrier_early_end.asm: waves 1-3 end without ans_barrierwhile wave 0 waits at one, then reads what wave 3 wrote.cs_barrier_loop.asm: wave w runs w + 1 iterations of add-to-LDS /s_barrier/ read. The k-th barrier has to wait for every wave still running, so each read is 32 × (4 − k).mainmaincs_barrier_divergentcs_barrier_early_endcs_barrier_loopWhole
run_gpu_tests.pywith this PR: the GPU test shaders all translate and passspirv-val(103/103;main101/101). No test changes result except the three barrier fixtures:maincs_barrier_divergentloses the device)LEONIDA_W64_EMULATE=1The Intel failures left on this branch are the ones #820 fixes (
cs_exec64,cs_w32_permute,cs_wqm_w32, plus the emulated wave64 mask tests) andps_bitmask_perm(#618). The same list fails onmain.lds_fuzz --seed 1 --programs 50 --wave bothmatchesmainon both GPUs (Intel 39/50, RTX 43/50, the same programs).Rebased onto
mainc63773d (which has #820; runtime rebuilt), with this PR: 114/114 shaders translate and passspirv-val.ps_bitmask_perm(GPU test ps_bitmask_perm: ds_swizzle BITMASK_PERM 10p0i wrong on Intel Xe iGPU #618); rdna2spirv: constant EXEC lane bits with shift and mask (Intel took 16-bit constants mod 16) #820's list is gone onmainnow.cs_w64x_partialonce with no dump. It passed alone 3 of 3 with this PR and 3 of 3 withmain's translator, and in a second full run. It's a wave64 emulated test, a path this PR doesn't touch.cs_barrier_divergent.spvchanges among the suite's compiled modules.CPU:
python -m pytest tests3327 passed, 21 skipped, 1 xfailed, 0 failed on 4a36bb1, and 3867 passed, 30 skipped, 0 failed on c63773d.compileallis clean. New tests intests/test_translate.py:OpControlBarrieramong the blocks and the two that remain outside the round loop's body;OpControlBarrier, no rounds);cs_barrier_divergentstays structured natively, and under--wave64-emulateuses the emulated rounds.Negative control: with
main'srdna2spirv.pythe four new rounds tests fail, the top-level one passes, and on the Intel iGPU each of the three fixtures loses the device (table above).AI-assisted (Claude Code).
Checklist
docs/design.md, with how it was confirmed (GPU tests on an Intel Xe-LPG iGPU and an RTX 5070 Ti).🤖 Generated with Claude Code