Files
mandy/tests/semantic/fixtures/wave64_single_wave_barrier.asm
Jan Trencansky a02a5ef7a9 rdna2spirv: no round-loop fallback for single-wave emulated programs
translate() re-translated every emulated wave64 program whose inline
structured form has an OpControlBarrier under a selection or loop as the
round loop (barriers_under_control_flow), for NVIDIA, which hangs on a
barrier only part of the workgroup reaches. A single-wave workgroup
(plan mode inline_all) is one wave: its barriers sit at the top level or
under %pc-only guards, which every invocation takes alike, so the
fallback only applies to multi-wave plans now.

The round form keeps nearly the whole register file live across the
loop and drove RADV/ACO's spiller past 12 GiB (53 GB uncapped) on large
single-wave programs, and made programs with long loops 10-100 times
slower. 666 main-set compute shaders return to the structured form;
translated and spirv-val counts are unchanged.

Restores the single-wave expectations in test_wave64_emulate_opt.py,
test_loop_ballot_barrier.py and test_loop_iteration_guard.py (its round
scheduler check now uses --dispatch-loop), adds
test_wave64_single_wave_barrier.py with a hand-written fixture, and a
docs/design.md contract row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 09:07:28 -05:00

23 lines
647 B
NASM

; One wave64 workgroup: a uniform loop and a uniform branch, each with a read of another wave32 half's lane, which
; the emulation exchanges through %x_buf behind a workgroup barrier. s4 is a push constant: 0 skips the branch.
v_lshlrev_b32_e32 v2, 2, v0
v_mov_b32_e32 v1, v0
s_mov_b32 s8, 0
s_mov_b32 s9, 0
again:
v_add_nc_u32_e32 v1, 1, v1
v_readlane_b32 s10, v1, 40
s_add_u32 s9, s9, s10
s_add_u32 s8, s8, 1
s_cmp_eq_u32 s8, 3
s_cbranch_scc0 again
s_cmp_eq_u32 s4, 0
s_cbranch_scc1 done
v_add_nc_u32_e32 v1, 100, v1
v_readlane_b32 s11, v1, 41
s_add_u32 s9, s9, s11
done:
v_mov_b32_e32 v3, s9
buffer_store_dword v3, v2, s[0:3], 0 offen
s_endpgm