Repository navigation
Conversation
…hing
On Apple's D3DMetal 3.0 (macOS, CrossOver) a compute program with a
64-bit atomic writes nothing at all: not the atomic, not its other
stores, not even stores issued before it. Only non-returning unsigned
InterlockedMin64 / InterlockedMax64 on device memory work. The adapter
still reports Int64ShaderOps and every AtomicInt64On*Supported cap, so
no_int64_atomics() runs one small kernel instead: a returning
InterlockedAdd64 must carry into the high dword and give back the old
value. It skips only when that kernel ran and its results are wrong.
gpu_atomic_fcmpswap_x2 and gpu_atomic_fmin_fmax_x2 return through it.
The three GLOBAL_ATOMIC_{ADD,INC,DEC}_X2 instructions and their asserts
move unchanged from gpu_more_atomics_sub_dword_scratch_valu into
gpu_global_atomic_add_inc_dec_x2, gated the same way, so the rest of
the old test runs on such a host. (xcl-dev#258)
Assisted-by: Claude Code (Claude Opus 5.5)
|
Verified on a second Apple silicon host, on the Host: MacBook Pro M5 Pro (48 GB), macOS 27.2.1, CrossOver 26 with D3DMetal (adapter reports "AMD Compatibility Mode"), Rosetta 2, Rust 1.100.0,
The third row is the part worth having in the record: on this host the mixed test's own failure was the 64-bit atomic ( The Not tested here: Windows (no Windows machine on this bench), and this PR's CI has not run on GitHub - every head of mine on this repo shows only the Host: macOS 27.2.1 (Apple silicon, M5 Pro), CrossOver 26, D3DMetal; local inference unloaded and the bottle's wineserver stopped for each run. AI use: GPT-6 Luna built both trees, ran the tests and drafted this comment; the codes, line numbers and assertion values are from those runs. |
|
Test report from a second Mac, head Tested
Not tested
AI use
|
|
Independent verification, merged onto current Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug.
AI use: test runs by Devin (Cognition, SWE-2); no code changes. |
|
Native Windows + NVIDIA check that the new skip does not fire where 64-bit atomics work. Head Tested
Not tested
AI use
|
|
Test report for head Tested
Not tested: Intel. AI use: the tests were run and this report was written by an AI agent, Claude Code (Claude Opus 5.5), on the hardware above. The numbers are copied from the actual test output. |
|
A run on Linux with vkd3d-proton, NVIDIA: the probe fires here too, but for a different fault than D3DMetal's. And it skips two tests that pass on Tested
Not tested
AI use
|
…s them On Apple's D3DMetal (CrossOver), a program with a 64-bit atomic other than a non-returning unsigned min / max writes nothing at all, its other stores included, though the device reports 64-bit atomics (xcl-dev#983, xcl-dev#258). A title shader with a global / buffer `*_x2` atomic then computes or draws nothing. Where 32-bit atomics leave the same memory, emit those (`Options::split_int64_atomics`): - add_x2 / sub_x2: the low dword's InterlockedAdd, then the high dword's with the carry (or borrow) its old value shows. Adds commute, so the end state is exact. - and_x2 / or_x2 / xor_x2: one 32-bit op per dword. - umin_x2 / umax_x2 without GLC: the 64-bit atomic without a returned value, which D3DMetal runs. With GLC the returned old value is the two dwords' old values, which another lane's update can come between. swap, cmpswap, signed min / max, inc / dec, the float ones and umin / umax with GLC keep the 64-bit form. The option is set once per process by a probe on the title's device (InterlockedAdd64 plus a plain store; under Wine only), or by XCL_SPLIT_INT64_ATOMICS=1 / =0. It keys the translated-shader disk cache. Off (Windows drivers), the HLSL is unchanged. The window accessors get the non-returning 64-bit min / max overloads the split forms call. Tests: split_int64_atomics_emit_32_bit_atomics (the HLSL, with and without the option and with two memory windows; DXC-compiled) and gpu_split_int64_atomics (64 lanes on one cell per op: carries, borrows, one bit per lane through and / or / xor, the largest of 64 values).
On Apple's D3DMetal 3.0 (macOS, CrossOver 26.3), a compute program that contains a 64-bit atomic writes nothing at all: not the atomic, not its other stores, not even stores issued before it. The only exception is non-returning unsigned
InterlockedMin64/InterlockedMax64on device memory. The adapter still reportsInt64ShaderOps,AtomicInt64OnTypedResourceSupported,AtomicInt64OnGroupSharedSupportedandAtomicInt64OnDescriptorHeapResourceSupportedas 1, so a one-thread kernel checks it instead: a returningInterlockedAdd64must carry into the high dword and give back the old value. Part of #258.What is in it
crates/xcl/src/gpu/recomp/tests.rs:no_int64_atomics(), the one-time probe (OnceLock). It skips withno 64-bit atomicsonly when the probe kernel ran and its results are wrong.gpu_atomic_fcmpswap_x2andgpu_atomic_fmin_fmax_x2return through it.GLOBAL_ATOMIC_{ADD,INC,DEC}_X2instructions and their asserts move unchanged fromgpu_more_atomics_sub_dword_scratch_valuinto a newgpu_global_atomic_add_inc_dec_x2, gated the same way, so the rest of the old test runs on such a host.Tested
gpu::recomp::tests::gpu_*atomic*test in its own process (<lib test exe> --exact <test> --test-threads=1 --nocapture).main6bac4b4: 4 passed, 3 failed (gpu_atomic_fcmpswap_x2,gpu_atomic_fmin_fmax_x2,gpu_more_atomics_sub_dword_scratch_valu: "global_atomic_inc wraps at 10", 0 where 9 is expected).ab7ce43(onmain9aec53d): 8 passed, 0 failed, of which 3 areSKIPPED …: no 64-bit atomics(gpu_atomic_fcmpswap_x2,gpu_atomic_fmin_fmax_x2,gpu_global_atomic_add_inc_dec_x2).gpu_more_atomics_sub_dword_scratch_valunow passes.membinding: a 32-bitStore, a 32-bitInterlockedAdd, 64-bit arithmetic withStore2andStore<uint64_t>all land. Add64, And64, Or64, Xor64, Exchange64, CompareExchange64, CompareStore64, signed Min64 / Max64 and returning unsigned Min64 / Max64 each leave the whole program's writes out, and so does any 64-bit atomic on groupshared. The translated*_X2atomics behave the same in their buffer, flat and global forms, except UMIN / UMAX with GLC=0.Interlocked*64memory-window accessors that a program never calls do not affect it.x86_64-pc-windows-gnullvm, release), base9aec53dand this head: the same three failures on the base; at this head the two gated tests skip andgpu_more_atomics_sub_dword_scratch_valupasses (@mikebuckets171, Tests: GPU tests of 64-bit atomics skip where those atomics write nothing #983 (comment)).Regression run
Test-only change: no runtime file changed, no
xcl-smokeblocks.Not tested
cargo test --workspaceas a whole.XCL_REQUIRE_GPU=wave64/meshturns this skip into a failure, becauserunner::skip_testis unchanged.gpu_atomic_fcmpswap_x2andgpu_atomic_fmin_fmax_x2onno_doubles(), so the two PRs touch the sameiflines. Those two tests use no doubles (see Tests: GPU tests of f64 instructions skip on an adapter without doubles #787 (comment)).AI use