Recompiler: on a macOS host, s_barrier is the native group barrier by default #2363
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!2363
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2363"
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?
@vakaobr on GitHub · 2026-11-25 16:41 UTC · original
vakaobr:recompiler/mac-native-barrier→main· +110 −4 · 3 files · 2 commits · draftStacked on #2361; only the top commit belongs here.
On a macOS host (CrossOver / D3DMetal), multi-wave Compute and Mesh
s_barriers now use the nativeGroupMemoryBarrierWithGroupSyncby default instead of the emulated spin barrierxcl_s_barrier. On D3DMetal, in a 1024-thread group in the split form, the waves spinning inxcl_s_barrierstarve the one wave still working (its loop ran about 1000 times slower) until the spin's 2^20-poll bound gives up and threads read LDS before it is written: wrong output, or the hang at world entry reported in #258. The native barrier was correct in every case I tried, including waves that already rans_endpgm, LDS exchange across the split-wave64 halves, barriers in loops and partial console waves. Windows keeps the spin barrier.Part of #258.
What is in it
crates/xcl/src/gpu/recomp/emit.rs:safe_barrier_enabled().XCL_SAFE_BARRIER=0/1decides; by default the spin barrier everywhere except on a macOS host (util::mac_host, #2361).crates/xcl/src/gpu/recomp/tests.rs: new GPU testgpu_s_barrier_1024_threads_waits_for_working_waves(1024 threads, every wave runs 1000v_readfirstlanes, then reads the LDS word of the farthest wave after the barrier);gpu_safe_s_barrier_multi_warp_and_early_endpgmaskssafe_barrier_enabled()whether to expectxcl_s_barrier().Tested
x86_64-pc-windows-gnu, debug, DXC 1.9.2609, atc917219(on #2361's6d6a3e3, onmain65fc114).cargo test -p xcl --lib --target x86_64-pc-windows-gnu --no-run; each test in its own process:wine --bottle xcl-test <exe> --exact <test> --test-threads=1 --nocapture.barrierin their name, on the base commit (with only the new test added) and on this commit:gpu_s_barrier_1024_threads_waits_for_working_waves: base fails (64 threads read their partner's LDS word before it was written), this commit passes. WithXCL_SAFE_BARRIER=1on this commit it fails again (128 threads).gpu_safe_s_barrier_multi_warp_and_early_endpgm: passes on both, and withXCL_SAFE_BARRIER=1.split_wave64_dead_scc_skips_exchange_barrier: passes on both.gpu::dxil::ops_tests::groupshared_barrier_and_atomics_run: fails on both, with the same assertion (ops_tests.rs:398); it does not go through the HLSL emitter.Regression run
scripts/smoke.ps1on.Not tested
mac_host()is false), but I did not run it.XCL_SAFE_BARRIER(#1409; #1413 turns it off while the variable is set).emit.rsis in the translator's source hash, so this commit itself does not reuse old entries.AI use
main, checked open PRs for overlap, ran the tests above and wrote this description.@DavidM1911 on GitHub · 2026-11-25 18:50 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.