Recompiler: bounded split-wave64 spin default and early-exit-safe s_barrier #798
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!798
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/798/head"
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?
@gsucristo on GitHub · 2026-11-24 05:33 UTC · original
gsucristo:recomp/safe-s-barrier-and-x64-spin→main· +244 −17 · 2 files · 2 commits · merged 2026-11-24 05:57 UTCPrevent GPU SM deadlocks in translated Compute and Mesh shaders on 32-lane GPUs (and under early wave exits) by defaulting split-wave64 exchanges to bounded arrival counters (
XCL_X_SPIN 1) and emitting an early-exit-safe, bounded LDS arrival barrier (xcl_s_barrier) for multi-warps_barrier.On RDNA2,
s_endpgmdecrements the active workgroup wave count so surviving waves reachings_barrierdo not wait for already-exited waves. On PC D3D12/NVIDIA,GroupMemoryBarrierWithGroupSync()compiles tobar.sync 0, which hangs the SM permanently if any hardware warp exits early (s_endpgm), exhaustsxcl_budget(LOOP_GUARD), or diverges in split-wave64 mode.What is in it
crates/xcl/src/gpu/recomp/emit.rs,tests.rs): defaultx64_spin()totrue(XCL_X_SPIN 1, opt-out viaXCL_WAVE64_SPIN=0) and updategpu_split_wave64_waves_diverge.crates/xcl/src/gpu/recomp/emit.rs,tests.rs): pre-scan fors_barrierin multi-warp Compute/Mesh shaders (compute_or_mesh_hw_waves() > 1) and emitxcl_s_barrier_init/xcl_s_barrier/xcl_s_barrier_exitbacked byXCL_BAR_ALIVE+ packed(gen: 20, arrived: 12)XCL_BAR_STATEbounded at1 << 20iterations (opt-out viaXCL_SAFE_BARRIER=0); emitGroupMemoryBarrier()for single-warp Compute/Meshs_barrier; addgpu_safe_s_barrier_multi_warp_and_early_endpgmtesting 4-warp 2-gen LDS exchange (wave64 and wave32) and upper-wave earlys_endpgmbefore twos_barriers.Tested
rustc 1.98.1(x86_64-pc-windows-msvccross-compile), debug.cargo test --workspace --no-fail-fast --target x86_64-pc-windows-msvc -- --test-threads=4 --skip a_freed_block_is_decommitted_before_its_address_is_reused: 700 passed, 4 failed (pre-existing Wine-only failures:hle::xaudio2::tests::xma2_source_voice_decodes_and_manages_lifetime,test_title_runs_and_game_folder_is_untouched,disk_free_space_ex_reports_pls_quota,set_predication_buffer_state_and_kickoff), 41 ignored, 1 filtered (a_freed_block_is_decommitted_before_its_address_is_reused).SKIPPEDGPU tests:gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64).gpu_split_wave64_waves_diverge,gpu_safe_s_barrier_multi_warp_and_early_endpgm.Regression run
scripts/smoke.ps1runs on a retail title (Linux/Proton environment only).Not tested
xcl_s_barrierdispatch on hardware (Compute path tested),scripts/smoke.ps1retail regression run.AI use
@MesshM on GitHub · 2026-11-24 05:46 UTC · original
Test run of
0c02b87b267142801e6843563988bf7ac5f6a2e7on AMD RDNA4. I merged it onto currentmaine50836blocally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 705 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 664 passed, 0 failed, 21 ignoredSKIPPED;gpu_safe_s_barrier_multi_warp_and_early_endpgmpasses, natively in wave64 on this adapter.Review: A question about the bounded barrier: it lets waves go on after a bounded wait instead of hanging the SM when a wave has exited early. If the bound can also be reached by a wave that is merely slow (a long divergent path before its
s_barrier), the others would continue unsynchronised and read LDS that is not written yet, giving wrong results rather than a hang. Is the bound tied only to waves that have executeds_endpgm(counted), or is it a spin count? If it is a spin count, a log or counter when it expires would make such a case visible. The change also alters how multi-waves_barrieris emitted on 64-lane GPUs like this one; the suite passes here.Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
@upipibi on GitHub · 2026-11-24 05:52 UTC · original
On
0c02b87, from reading the code (not run):When
xcl_s_barrierhits the1 << 20poll bound (emit.rs:5410-5416), the waiting wave decrementsXCL_BAR_ALIVEforitself while it keeps running, advances the generation (which releases every wave waiting at this barrier before the slow
wave has arrived), and turns its own later barriers off. The slow wave's eventual arrival is counted in the next
generation, so every later barrier in the group releases one arrival early. The result is silently wrong LDS data with no
host-side signal, where main would wait or hang visibly. A wave stuck in a long but legitimate loop (
LOOP_GUARDallows65 536 iterations) can plausibly exceed 2^20 LDS-atomic polls. Could the timeout raise a sticky flag the runtime logs,
and keep the waiter counted? The same applies to the now default-on
XCL_X_SPINpath (xcl_x_dead).AI-assisted (Claude Code), read-only review.
@eizispark on GitHub · 2026-11-24 05:53 UTC · original
Hardware check of
0c02b87b267142801e6843563988bf7ac5f6a2e7(verified clean merge withmaine50836b): pass.Tested
rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profilecargo test --workspace -- --test-threads=4:702 passed, 3 failed, 41 ignored(GPU tests skipped on this adapter:none; unfiltered native Windows run — the 3hle::d3d12xfailures were shared-VRAM contention inplaced_title_textures_share_vram_and_preserve_pixelsplus 2 downstream mutexPoisonErrors;cargo test -p xcl --lib hle::d3d12x:: -- --test-threads=1:105 passed, 0 failed, 1 ignored)gpu::recomp::tests(gpu_split_wave64_waves_diverge,gpu_safe_s_barrier_multi_warp_and_early_endpgm):2 passed, 0 failedon native RDNA4 wave64Regression run
main(f4ce27c):PR (
0c02b87):Not tested
xcl_s_barrierhardware dispatch; gameplay past the menusAI use
scripts/smoke.ps1harness on this machine and formatted this report.@mastrr9 on GitHub · 2026-11-24 05:57 UTC · original
Independent native Windows NVIDIA RTX 5080 (wave32) + D3D12 debug layer build/test run and code review at head
0c02b87b267142801e6843563988bf7ac5f6a2e7.Code Review
x64_lds+safe_barrier_prelude:XCL_XS+XCL_XCend at8189,XCL_BAR_ALIVE=8189,XCL_BAR_STATE=8190,XCL_XW=8191(no slot overlap), and in the non-x64LDS caseXCL_LDS_TOP = 8188ukeeps title LDS accesses below8189..8190.Flow::Endlowering inrecomp/mod.rs: setspc = 0xFFFFFFFFu;rather thanreturn;, so earlys_endpgmfalls cleanly intoxcl_s_barrier_exit()at the end ofmain().gpu_safe_s_barrier_multi_warp_and_early_endpgmandgpu_split_wave64_waves_divergepassed cleanly on wave32 NVIDIA hardware (wheresplit_wave64+XCL_X_SPIN 1+xcl_s_barrier()actually exercise the multi-warp wave32 path).Tested
617.42/32.0.16.1742), Windows 11 Pro 25H2 (26200.9974), D3D12 debug layer installed (d3d12SDKLayers.dll),rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC from Windows SDK10.0.26100.0, debug build.cargo build --workspace && cargo test --workspace -- --test-threads=4ok, executed on RTX 5080, not skipped):gpu::recomp::tests::gpu_safe_s_barrier_multi_warp_and_early_endpgmgpu::recomp::tests::gpu_split_wave64_waves_divergegpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask(no wave64)gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64)Not tested
AI use: Antigravity (Gemini 4 Neon reviewed the diff; Gemini 4 Hydrogen ran the RTX 5080 workspace tests) drafted this report.