Recompiler: on a macOS host, s_barrier is the native group barrier by default #2353
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from ivall/xcl. Originally posted by vakaobr on 2026-11-25T16:41:05Z.
Stacked 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.The default goes into
main'ssafe_barrier_wanted(), soXCL_SAFE_BARRIERstill decides the same way for both translators. The refusal of the split form's geometry ES phase (#1727's pattern) is unchanged on a Mac: onlyXCL_SAFE_BARRIER=0lifts it, as onmain.Part of #258.
What is in it
crates/xcl/src/gpu/recomp/emit.rs:safe_barrier_wanted().XCL_SAFE_BARRIER=0/1decides; by default the spin barrier everywhere except on a macOS host (util::mac_host, #2361). Newsafe_barrier_set_off(): whetherXCL_SAFE_BARRIER=0is set.crates/xcl/src/gpu/recomp/pso.rs: the compute build key'ssafe_barriercomes fromsafe_barrier_wanted(). It read the variable on its own, so on a Mac a default run and anXCL_SAFE_BARRIER=1run would have shared keys.crates/xcl/src/gpu/dxil/kernel.rs:translate_geometryrefuses the split ES phase unlesssafe_barrier_set_off(), which ismain's behaviour. Its two tests (lower_mem.rs,geometry_tests.rs) ask the same.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). Two tests that read the variable themselves now asksafe_barrier_wanted().Tested
x86_64-pc-windows-gnu, debug, DXC 1.9.2609; heade69da9don #2361's69c0b04onmain9dfbe3e. Base:69c0b04with only this PR'stests.rs.barrierin its name, all ofgpu::dxil::geometry_testsandgpu::dxil::robustness_tests,geometry_export_rejected, the compute build key tests, and the two that look forxcl_s_barrier()in the HLSL. Each ran in its own process (<lib test exe> --exact <test> --test-threads=1):XCL_SAFE_BARRIER=1XCL_SAFE_BARRIER=0XCL_SAFE_BARRIER=0gpu_s_barrier_1024_threads_waits_for_working_waves: fails on the base (128 threads read their partner's LDS word before it was written); passes with this PR, and withXCL_SAFE_BARRIER=0on either; fails withXCL_SAFE_BARRIER=1(128 threads).gpu::dxil::ops_tests::groupshared_barrier_and_atomics_runfails in all five runs on the same assertion (ops_tests.rs:398); this switch does not reach it.programs_left_to_the_hlsl_path_for_their_barrier_translate_and_compile(XCL_SAMPLE_BARRIER). No SKIPPED tests.Regression run
scripts/smoke.ps1on. On Windowsmac_host()is false, so the default there is unchanged.Not tested
XCL_SAFE_BARRIER(#1409); #1413 turns it off only while the variable is set. So on a Mac, switching between the default andXCL_SAFE_BARRIER=1can reuse the other's translations until one of them lands.AI use
main, ran the tests above and wrote this description. I checked it before posting.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T18:50:17Z.
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!
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-30T08:39:16Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by vakaobr on 2026-11-30T13:22:03Z.
Please keep this open:
mainnow usessafe_barrier_wantedin the direct translator too, so changing its default on a Mac reaches further than this PR tested. I'll rework and re-test it on currentmain.Imported from ivall/xcl. Originally posted by vakaobr on 2026-11-30T14:44:10Z.
Reworked on current
main(e69da9d): the default now goes throughsafe_barrier_wanted(), so it reaches both translators and the build key; the split-geometry refusal stays as onmain. Description updated with the test runs.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:56:04Z.
Triage (#1607) – head
e69da9dStacked on #2361 (
mac_host). Only the top commit,e69da9d, belongs to this PR. No other open or merged PR changes thes_barrierdefault on a Mac. #1793 and #1413 touch the safe barrier but do not change its default.The PR routes the compute build key (
pso.rs) throughsafe_barrier_wanted(), which fixes a key that would otherwise not see the Mac default. A newsafe_barrier_set_off()keepstranslate_geometry's refusal of the split ES phase unchanged, and on Windows nothing changes.XCL_MAC_HOSTnow changes the translated HLSL but is not incache_allowed(pso.rs) or theshaders.rsenv-var list, unlikeXCL_SAFE_BARRIER.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.