Skip to content

Tests: check 64-bit shifts, v_mad_i64_i32 and f64 fma/min/max on the GPU - #682

Open
lemosss wants to merge 1 commit into
xcl-dev:mainfrom
lemosss:tests/gpu-64bit-int-and-f64-ops
Open

lemosss wants to merge 1 commit into
xcl-dev:mainfrom
lemosss:tests/gpu-64bit-int-and-f64-ops

Conversation

@lemosss

@lemosss lemosss commented Nov 24, 2026

Copy link
Copy Markdown

v_lshrrev_b64, v_ashrrev_i64, v_mad_i64_i32, v_fma_f64, v_min_f64 and v_max_f64 are translated (emit.rs, the 64-bit block after the VOPC compares) but no test names them; the existing 64-bit checks cover v_lshlrev_b64, v_mad_u64_u32 and the f64 unary ops. This adds a randomized GPU test of the six against the CPU, bit for bit. Test only: no runtime change. I found no issue or open PR for these ops (searched the open PRs' titles and descriptions for each op name).

What is in it

  • crates/xcl/src/gpu/recomp/tests.rs: gpu_64bit_int_and_f64_ops_random, one wave per dispatch in 50 dispatches (XCL_FUZZ_ITERS=n for more), as wave64 where the GPU has it and as wave32:
    • shifts: any u32 shift amount (the ISA takes S0[5:0], so amounts ≥ 64 check the mask), values with and without the sign bit;
    • v_mad_i64_i32: the 64-bit result of i32 × i32 + i64, factors and addend including i32::MIN / MAX, −1, i64::MIN / MAX;
    • v_fma_f64 against f64::mul_add (one rounding), also with VOP3 NEG on SRC2; inputs from the existing rand_f64 (denormals, infinities and NaNs included; a NaN result matches any NaN);
    • v_min_f64 / v_max_f64, also max with ABS on SRC0; b is often a, −a or a's neighbour, so ties and adjacent values are common. Pairs with a NaN and ±0 pairs of opposite signs are skipped: IEEE minNum / maxNum leave those open.

Tested

  • NVIDIA GeForce RTX 4060 8 GB (32-lane waves only), driver 610.88 (32.0.16.1088); Intel Core i7-10700K, 16 GB; Windows 11 Pro 26H2, build 26300.9974
  • Rust 1.100.0 stable-x86_64-pc-windows-msvc, VS 2022 Build Tools (MSVC 14.44), DXC 1.9.2609.5 (GitHub release, XCL_DXC_DIR); debug build
  • cargo test -p xcl --lib gpu_64bit_int_and_f64_ops_random -- --nocapture: passed, wave32: lanes 1600, min / max checked 1491 (545 with |a| = |b|), 0 distinct failures
  • Negative controls (not committed), with XCL_TRANSLATED_CACHE=0:
    • v_ashrrev_i64 cast to uint64_t instead of int64_t (a logical shift): 817 distinct failures, e.g. ashrrev_i64(amt 0x1, s 0x8abdb23003926697) = 0x455ed91801c9334b, want 0xc55ed91801c9334b
    • v_min_f64 translated as max: 1226 distinct failures
  • cargo build --workspace + cargo test --workspace --no-fail-fast -- --test-threads=4 on this branch (main 91f9a5e + this commit): 692 passed, 1 failed, 41 ignored. The failure is hle::d3d12x::real::readback_routing_tests::coherent_buffer_sanitizes_console_flags_and_state at real.rs:5355 (VirtualFree of its 64 KB block returned 0), a test this PR does not touch. It passed 3 of 3 alone on this branch and 3 of 3 alone on main 91f9a5e, and four more cargo test -p xcl --lib -- --test-threads=4 runs on this branch passed in full (653 passed, 0 failed), as did two on main (652 passed). So it looks intermittent when it runs beside other tests.
  • SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware

Regression run

  • not needed: the PR changes only tests.rs, no runtime file

Not tested

  • wave64 / AMD hardware: this adapter has 32-lane waves only, so the wave64 pass did not run
  • v_mad_i64_i32's SDST. It is translated as the unsigned carry of the 64-bit add (w < c, the same as v_mad_u64_u32). The ISA describes the op as {vcc_out, D.i64} = S0.i32 * S1.i32 + S2.i64; if that is read as one signed 65-bit result, the carry-out is bit 64 of the signed sum, which differs from the unsigned carry when an operand is negative. I could not check which the console hardware gives (no AMD GPU here), so the test leaves the SDST out. Mentioning it in case it matters.
  • min / max on NaNs and on ±0 pairs (left out on purpose, see above)
  • the full suite on main 91f9a5e without this commit (not run separately)
  • release build

AI use

  • Claude Code with Claude Opus 5.5: chose the untested ops, wrote the test and the CPU reference, ran the test, the negative controls and the full suite, and drafted this description.

v_lshrrev_b64, v_ashrrev_i64, v_mad_i64_i32, v_fma_f64, v_min_f64 and
v_max_f64 are translated in emit.rs's 64-bit block, but no test names
them: the existing 64-bit checks cover v_lshlrev_b64, v_mad_u64_u32 and
the f64 unary ops.

gpu_64bit_int_and_f64_ops_random runs the six against the CPU on random
inputs, bit for bit, as wave64 and as wave32: any u32 shift amount (the
ISA takes S0[5:0]), mad factors and addend with their extremes, fma
against f64::mul_add, also with NEG on SRC2, and min / max with ties and
neighbours, also max with ABS on SRC0. min / max skip pairs with a NaN
and +-0 pairs of opposite signs, which minNum / maxNum leave open.
v_mad_i64_i32's SDST is not checked.

Measured on an RTX 4060 (wave32 only): 1600 lanes, 1491 min / max pairs
checked (545 with |a| = |b|), 0 failures. A logical shift for
v_ashrrev_i64 gives 817 distinct failures; max in place of v_min_f64
gives 1226.
@joeypercia

Copy link
Copy Markdown

AMD / native wave64 run (the Not tested item): bfb6c4e merged onto main 91f9a5e (clean merge).

Tested

  • AMD Radeon iGPU (Ryzen 7 7800X3D, RDNA2, 32–64 lanes, no mesh shaders), driver 26.11.2 (32.0.21045.29003); RTX 4070 Ti (616.56, 32 lanes); Windows 11 Pro 26200; Rust 1.100.0 MSVC; DXC 1.8.2502.11; debug
  • gpu_64bit_int_and_f64_ops_random: passes on the RDNA2 iGPU, both passes ran (wave64: 3200 lanes, min / max checked 2948; wave32: 1600 lanes), and on the RTX 4070 Ti (wave32)
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on the RDNA2 iGPU: 689 passed, 4 failed, 41 ignored. The 4 are outside this PR: placed_title_textures_share_vram_and_preserve_pixels and the two lock-poison followers (D3D12.X: back kept-in-step title textures by shared VRAM pages (#248) #288 / Tests: check cubemap tile reuse independently of idle page reclamation #447), and fine_timer_makes_short_sleeps_short, all under load; the same 4 pass alone on this merge, 2 runs of 2. SKIPPED: gpu_geometry_mode_es_gs_strip, gpu_mesh_mode_two_passes (no mesh shaders)

Not tested

  • v_mad_i64_i32's SDST (as in the description); release build

Run and report by Claude Code (Claude Opus 5.5).

@MesshM

MesshM commented Nov 24, 2026

Copy link
Copy Markdown

Test run of bfb6c4ef1ad5ac7f87c3f41ca4a692baf47193aa on AMD RDNA4. I merged it onto current main 91f9a5e locally (clean merge) and tested that tree.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 693 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 653 passed, 0 failed, 21 ignored
  • 0 SKIPPED; gpu_64bit_int_and_f64_ops_random passes.

Review: The 64-bit shifts take their count from S0[5:0] and the test feeds counts with high bits set; v_mad_i64_i32 is checked as the wrapping i64 result; min / max leave out NaN pairs and ±0 pairs, where IEEE minNum / maxNum allow either result, and fma runs with NEG on SRC2 and max with ABS on SRC0. I found nothing to change.

Not tested: no retail title or regression run (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's head on its old base was not run, only its merge onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

@towiice towiice left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested:

  • Hardware: NVIDIA GeForce GTX 1650 SUPER (Turing TU116, 4 GB VRAM, 32-wide subgroups / wave32, driver 610.88), Windows 11 x64 (26H2 / 10.0.26300), DXC v1.9.2609 (01b62ad4), toolchain stable-x86_64-pc-windows-gnullvm (llvm-mingw 23.1.6).
  • Recompiler GPU unit tests: cargo test -p xcl --lib gpu::recomp::tests
    • Result: 116 passed, 0 failed, 17 ignored (including new 64-bit int and f64 tests: gpu_64bit_int_and_f64_ops_random, gpu_f64_math_random).
  • E2E compute tests: cargo test -p xcl --test gpu_compute_e2e -- --test-threads=1
    • Result: 2 passed, 0 failed, 0 ignored (async_compute_pso_registers_real_pso_and_not_standin, console_wave64_compute_through_the_pso_hook_dispatch_and_read_back).
      All tests pass cleanly on Turing hardware with zero regressions.

@lordon1a

Copy link
Copy Markdown

Independent test report on bfb6c4e:

Tested

  • Hardware: NVIDIA GeForce RTX 3070 Ti Laptop GPU (driver 616.64, wave32, SM 6.6), Intel i7-12700H, Windows 11 Home 26H2 (build 26200), rustc 1.100.0 (x86_64-pc-windows-gnullvm), debug build, DXC 1.9.2609.5 (01b62ad4)
  • Command: cargo test -p xcl --lib gpu_64bit_int_and_f64_ops_random -- --nocapture
  • Result: 1 passed, 0 failed, 0 ignored in 0.95s (wave32: lanes 1600, min / max checked 1491 (545 with |a| = |b|), 0 distinct failures)

Not tested

  • AMD / wave64, Intel GPU, retail title

AI use

  • Antigravity (Google DeepMind agent) — fetched bfb6c4e in a detached worktree, audited the diff, ran the test, and posted this report.

@JJAutoCompare

Copy link
Copy Markdown

Empirical test report (bfb6c4e)

Hardware / environment

  • Tested detached commit bfb6c4ef1ad5ac7f87c3f41ca4a692baf47193aa in a clean worktree.
  • Intel Arc A770 Graphics, driver 32.0.101.9175. Windows 11 Enterprise Evaluation, version 10.0.26200 (build 26200). AMD Ryzen 7 3800X.
  • Rust 1.100.0 (0ef1bc386, x86_64-pc-windows-msvc), unoptimized test profile with debug info and incremental compilation disabled. DXC 1.9.2609.5 (01b62ad4), DXIL 1.9.2609.5.

Commands and results

  • cargo test -p xcl --lib --no-run outside the Arc lock exited 0. Cargo built the library test executable with one deprecation warning.
  • With XCL_ADAPTER=A770 and RUST_TEST_NOCAPTURE=1, ran xcl-00e28da3621caf64.exe gpu::recomp::tests::gpu_64bit_int_and_f64_ops_random --exact --nocapture --test-threads=1 under Invoke-ArcTest.ps1. Exit 101. The harness reported 0 passed, 1 failed, 0 ignored and 673 filtered out. The UTF-8 log contained 0 case-sensitive lines starting with SKIPPED .

Observed behavior

The PR adds one test whose shader combines 64-bit integer shifts, the vector result of v_mad_i64_i32, and f64 FMA, min, and max. DXC loaded and the test reached pipeline creation. CreateComputePipelineState returned The parameter is incorrect. (0x80070057), and the test panicked on the returned error. The failure is consistent with the A770's reported DoublePrecisionFloatShaderOps=0. The shader never dispatched, so the run yielded no GPU comparison coverage for either the integer or the f64 operations.

Not tested

Full GPU workspace suite, adapters with f64 support, and game smoke runs.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr682-focused.log and published.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

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