Repository navigation
Conversation
util::mac_host(): the process runs under Wine on a Mac (CrossOver or the Game Porting Toolkit), where D3D12 is Apple's D3DMetal and the title's code runs through Rosetta 2. ntdll's wine_get_host_version names the host's system; "Darwin" is a Mac. XCL_MAC_HOST=1 / 0 overrides it. Nothing calls it yet. The Mac changes that need to know they run there (the barrier default, title textures on shared pages) build on it; until now only Ahmet-Dedeler's mac7 branch had it. Part of xcl-dev#258.
… default xcl_s_barrier (the LDS spin barrier for multi-wave Compute / Mesh groups) starves the waves it waits for on D3DMetal: in a 1024-thread group in the split form, the one wave still working ran about 1000 times slower while the others spun, until the 2^20-poll bound gave up and the barrier let threads read LDS early (wrong output; a hang at world entry was reported in xcl-dev#258). D3DMetal's GroupMemoryBarrierWithGroupSync is correct in every case tried, including waves that already ran s_endpgm, LDS exchange across the two halves, barriers in loops and partial console waves. safe_barrier_enabled(): XCL_SAFE_BARRIER=0 / 1 decides; by default the spin barrier everywhere but on a macOS host (util::mac_host). Windows is unchanged. gpu_s_barrier_1024_threads_waits_for_working_waves fails without this on the Mac (64 of 1024 threads read their partner's LDS word before it was written) and passes with it; with XCL_SAFE_BARRIER=1 it fails again. Part of xcl-dev#258.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.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, Memory: detect a macOS host under Wine (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 Memory: detect a macOS host under Wine (mac_host) #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(Shaders: translations made with XCL_SAFE_BARRIER=0 are cached and reused by later runs #1409; Shaders: XCL_SAFE_BARRIER turns the translation caches off (#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.