Skip to content

Tests: GPU tests of 64-bit atomics skip where those atomics write nothing - #983

Open
vakaobr wants to merge 1 commit into
xcl-dev:mainfrom
vakaobr:tests/int64-atomics-skip
Open

vakaobr wants to merge 1 commit into
xcl-dev:mainfrom
vakaobr:tests/int64-atomics-skip

Conversation

@vakaobr

@vakaobr vakaobr commented Nov 24, 2026 •

Copy link
Copy Markdown

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 / InterlockedMax64 on device memory. The adapter still reports Int64ShaderOps, AtomicInt64OnTypedResourceSupported, AtomicInt64OnGroupSharedSupported and AtomicInt64OnDescriptorHeapResourceSupported as 1, so a one-thread kernel checks it instead: a returning InterlockedAdd64 must 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 with no 64-bit atomics only when the probe kernel ran and its results are wrong.
  • Same file: gpu_atomic_fcmpswap_x2 and gpu_atomic_fmin_fmax_x2 return through it.
  • Same file: the three GLOBAL_ATOMIC_{ADD,INC,DEC}_X2 instructions and their asserts move unchanged from gpu_more_atomics_sub_dword_scratch_valu into a new gpu_global_atomic_add_inc_dec_x2, gated the same way, so the rest of the old test runs on such a host.

Tested

  • Apple M5 Pro (20-core GPU), macOS 27.2.1, CrossOver 26.3.0.39832 with D3DMetal 3.0 ("AMD Compatibility Mode", 32-lane waves only), Rosetta 2. Cross-built with mingw-w64 (GCC 16.2.0), Rust 1.100.0, debug, DXC 1.9.2609.
  • Each gpu::recomp::tests::gpu_*atomic* test in its own process (<lib test exe> --exact <test> --test-threads=1 --nocapture).
    • On main 6bac4b4: 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).
    • At this PR's head ab7ce43 (on main 9aec53d): 8 passed, 0 failed, of which 3 are SKIPPED …: 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_valu now passes.
  • Local probes (not in the PR), one thread, through the same mem binding: a 32-bit Store, a 32-bit InterlockedAdd, 64-bit arithmetic with Store2 and Store<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 *_X2 atomics behave the same in their buffer, flat and global forms, except UMIN / UMAX with GLC=0. Interlocked*64 memory-window accessors that a program never calls do not affect it.
  • Independent run: a second M5 Pro (x86_64-pc-windows-gnullvm, release), base 9aec53d and this head: the same three failures on the base; at this head the two gated tests skip and gpu_more_atomics_sub_dword_scratch_valu passes (@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-smoke blocks.

Not tested

AI use

  • Claude Code with Claude Opus 5.5 ran the probes and tests on this machine, wrote the change and this description.

…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)
@mikebuckets171

Copy link
Copy Markdown

Verified on a second Apple silicon host, on the gnullvm target: all three of the failures you name reproduce on the base, and at this head the two dedicated tests skip and the mixed one runs.

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, x86_64-pc-windows-gnullvm with LLVM-MinGW 20261117 (clang 23.1.6), --release --locked, test binaries run under Wine, one test per process (--exact <full test path> --nocapture --test-threads=1). Base is 9aec53d, head ab7ce43; the lib test binary reports 704 tests on the base and 705 at the head.

test 9aec53d ab7ce43
gpu::recomp::tests::gpu_atomic_fcmpswap_x2 FAILED, tests.rs:4737: assertion left == right failed: lane 0: buffer cell, left: 4609434218613702656 SKIPPED …gpu_atomic_fcmpswap_x2: no 64-bit atomics -> ok. 1 passed; 0 failed
gpu::recomp::tests::gpu_atomic_fmin_fmax_x2 FAILED, tests.rs:4868: assertion left == right failed: buffer: max of the lanes, left: -inf SKIPPED …gpu_atomic_fmin_fmax_x2: no 64-bit atomics -> ok. 1 passed; 0 failed
gpu::recomp::tests::gpu_more_atomics_sub_dword_scratch_valu FAILED, tests.rs:4632: assertion left == right failed: global_atomic_inc wraps at 10, left: 0 ok. 1 passed; 0 failed in 0.62 s

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 (global_atomic_inc came back 0), and after your change the test runs and passes - so taking the three 64-bit atomics out of it really does keep the rest of it working on a Mac host rather than trading one failure for a skip.

The left: 4609434218613702656 on the first row is what the cell holds when the atomic never writes: it is the value the test put there first, unchanged, which fits your "any 64-bit atomic writes nothing at all, other stores included" measurement. left: -inf on the second is the reduction over lanes that never got updated.

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 PR checks description job, which is main's own pull_request_target workflow, so the CI job still needs a maintainer's approval to start for a fork contribution.

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.

@shortside

Copy link
Copy Markdown

Test report from a second Mac, head ab7ce43 against its merge base 9aec53d.

Tested

  • MacBook Pro M5 Pro, macOS 27.2.1, Rosetta 2; CrossOver 26.3 (Wine 11.0), Windows 10 bottle, D3DMetal; DXC 1.9.2609. Cross-built for x86_64-pc-windows-msvc with clang-cl / lld-link 23.1.6 and an xwin SDK 10.0.26100, Rust 1.100.0, debug. The lib test binary run under Wine, one test per process (--exact --nocapture, 60 s cap).
  • Every lib test with atomic in its name (12 on base, 13 on head): base 9 passed, 3 failed (gpu_atomic_fcmpswap_x2, gpu_atomic_fmin_fmax_x2, gpu_more_atomics_sub_dword_scratch_valu); head 10 passed, 3 passed with SKIPPED … no 64-bit atomics (gpu_atomic_fcmpswap_x2, gpu_atomic_fmin_fmax_x2, and the new gpu_global_atomic_add_inc_dec_x2), 0 failed.
  • gpu_more_atomics_sub_dword_scratch_valu goes from failed to passed (it runs, it does not skip).

Not tested

  • Windows (where none of these should skip), the rest of the suite.

AI use

  • Claude Code with Claude Fable 5.2 built both commits, ran the tests and wrote this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

Independent verification, merged onto current main 384f7f7 locally (clean merge).

Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug.

  • cargo test -p xcl --lib atomic: 13 passed, 0 failed — the 64-bit atomic GPU tests still run and pass on this adapter (which does support them, so the new skip_test("no 64-bit atomics") guard is correctly not taken). The skip is gated on an actual probe, not assumed.

AI use: test runs by Devin (Cognition, SWE-2); no code changes.

@jesuarchive

Copy link
Copy Markdown

Native Windows + NVIDIA check that the new skip does not fire where 64-bit atomics work. Head ab7ce43, merged locally onto main 47efa2e (clean merge, nothing pushed).

Tested

  • NVIDIA GeForce RTX 3060 12 GB (Ampere, 32-lane waves only), driver 32.0.16.1088; AMD Ryzen 7 5800XT; Windows 11 Pro build 26300; rustc 1.95.0 stable-x86_64-pc-windows-msvc; DXC 1.9.2602.17 from the Windows SDK; debug.
  • cargo test -p xcl --lib atomic -- --test-threads=1 --nocapture: 13 passed, 0 failed, 0 ignored. The InterlockedAdd64 probe did not report a failure and no test printed skipping or SKIPPED: gpu_atomic_fcmpswap_x2, gpu_atomic_fmin_fmax_x2, gpu_atomic_fmin_fmax_negative_zero, gpu_more_atomics_sub_dword_scratch_valu, gpu_global_atomics_and_sub_dword_access and the new gpu_global_atomic_add_inc_dec_x2 all ran on the GPU and passed. Same filter on main 47efa2e: 12 passed (without the new test).
  • cargo test --workspace -- --test-threads=4: 742 passed, 0 failed, 41 ignored (main: 741 / 0 / 41).
  • SKIPPED on this adapter, the same two on main: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64).

Not tested

  • A host where the skip should fire (no CrossOver / D3DMetal here); AMD and Intel GPUs; the head on its own base 9aec53d; release build.

AI use

  • Claude Code with Claude Opus 5.5: merged the branch, ran the commands above on this machine and wrote this report.

@bjarngard

Copy link
Copy Markdown

Test report for head ab7ce43 (AMD, native wave64, and RTX 5080)

Tested

  • AMD Radeon(TM) Graphics (Ryzen 9 9950X iGPU, RDNA2, native wave64), driver 32.0.21043.5001; Windows 11 build 26300; Rust 1.99.1 MSVC; DXC 1.9.2602.17; debug
  • XCL_ADAPTER=radeon cargo test --workspace --no-fail-fast -- --test-threads=4: 725 passed, 0 failed, 41 ignored, no SKIPPED
  • With XCL_REQUIRE_GPU=wave64: gpu_global_atomic_add_inc_dec_x2, gpu_more_atomics_sub_dword_scratch_valu passed
  • RTX 5080 (Blackwell, wave32), driver 621.24: full suite 725 passed, 0 failed, 41 ignored; SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware
  • gpu_global_atomic_add_inc_dec_x2 and gpu_more_atomics_sub_dword_scratch_valu ran and passed on both adapters; the new no 64-bit atomics skip did not fire on either

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.

@JoaoPauluu

Copy link
Copy Markdown

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 main on this stack.

Tested

  • RTX 3060 12 GB (NVIDIA 620.70.06, 32-lane waves), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #257, DXC 1.9.2609.5. Release, cross-built for x86_64-pc-windows-gnu. ab7ce43 as it is (merge base 9aec53d) and main 47efa2e, no uncommitted changes. The lib test binary runs under Wine, one test per process (--exact, 90 s cap).
  • ab7ce43, every lib test with atomic in its name: 13 passed, 0 failed. 3 of them SKIPPED no 64-bit atomics: gpu_atomic_fcmpswap_x2, gpu_atomic_fmin_fmax_x2, gpu_global_atomic_add_inc_dec_x2.
  • The probe printed InterlockedAdd64 probe: [0, 3, 0, 0]. So the add itself lands, carry included ([0, 3]), but the old value InterlockedAdd64 returns comes back as 0 ([0, 0] where [0xffffffff, 1] is expected). D3DMetal writes nothing at all.
  • The same tests on main 47efa2e:
test main this PR
gpu_atomic_fcmpswap_x2 ok SKIPPED
gpu_atomic_fmin_fmax_x2 ok SKIPPED
gpu_atomic_fmin_fmax_negative_zero ok ok
gpu_more_atomics_sub_dword_scratch_valu fails: kernel dispatch: GPU fence still pending after 10000 ms ok
gpu_global_atomic_add_inc_dec_x2 not on main SKIPPED
  • So on this stack the probe finds a real fault: a 64-bit atomic's returned value is lost. That would also explain the GPU hang main has had here in gpu_more_atomics_sub_dword_scratch_valu (the inc / dec x2 CAS loop never sees the old value), but I have not checked which instruction hangs.
  • But fcmpswap_x2 and fmin_fmax_x2 work on main here and are skipped with this PR, so on vkd3d-proton the skip also covers 64-bit atomics that work.

Not tested

  • whether the lost return value is in vkd3d-proton (dxil-spirv) or the NVIDIA driver; the other lib tests; native Windows.

AI use

  • Claude Code (Claude Opus 5.5) built the commits, ran the tests and runs and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.

@ivall ivall added the off-goal Does not bear on the current goal (world loading); waits until it is reached label Nov 24, 2026
CalvyPZ pushed a commit to CalvyPZ/xcl that referenced this pull request Nov 24, 2026
…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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

off-goal Does not bear on the current goal (world loading); waits until it is reached

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants