Skip to content

Recompiler tests: GPU checks for f32 ceil/trunc/rndne, f32/i32 min/max - #739

Open
13hourstilliland wants to merge 1 commit into
xcl-dev:mainfrom
13hourstilliland:recomp-tests-round-min-max
Open

13hourstilliland wants to merge 1 commit into
xcl-dev:mainfrom
13hourstilliland:recomp-tests-round-min-max

Conversation

@13hourstilliland

Copy link
Copy Markdown
Contributor

Adds a GPU test for nine RDNA2 instructions that emit.rs translates but no test runs: v_ceil_f32, v_trunc_f32, v_rndne_f32, v_max_f32, v_min_f32, v_max3_f32, v_min3_f32, v_max_i32 and v_min_i32. Test only, no runtime change.

What is in it

  • gpu_valu_round_and_min_max_f32_i32 in crates/xcl/src/gpu/recomp/tests.rs, after f32_compares_with_nan (away from the lines open PRs add to): one kernel with all 9 instructions, run as wave64 where the adapter has it and as wave32 everywhere (gpu_waves), 32 batches of operands: edge values (±0, ±0.5, ±1.5, ±2.5, 0.49999997, ±8388607.5, ±1e30, ±inf, NaN), values on 1/256 steps up to 2^23 and random bit patterns, with denormals flushed to a signed zero and NaNs quieted, each lane compared with the RDNA2 definition computed on the CPU: rounding keeps the sign of a zero; a quiet NaN operand of an f32 min/max gives the other operand (minNum/maxNum), and min/max zero results are compared without their sign.
  • A failure lists the lane, instruction, operands, result and expected value, and counts the wrong results per instruction.
  • Checked that it catches bugs, on a local copy, measured on 3db536e (before the rebase onto main 91f9a5e; the test code did not change): with the reference changed (reference round_ties_even replaced by round: wave32, 188 wrong (V_RNDNE_F32: 188), no other instruction) the test fails; with ceil as floor, trunc as round, rndne as trunc, max and min swapped, max3 and min3 with the inner op swapped, signed i32 min and max made unsigned applied to emit.rs all at once it fails and names every instruction (wave32, 5199 wrong (V_CEIL_F32: 634, V_TRUNC_F32: 217, V_RNDNE_F32: 217, V_MAX_F32: 956, V_MIN_F32: 956, V_MAX3_F32: 628, V_MIN3_F32: 629, V_MAX_I32: 481, V_MIN_I32: 481), 217 to 956 wrong per instruction). Those edits are not in the PR.
  • v_min_f32 also appears in the open Recompiler: image_sample_b/d/cd/c_o offsets move by the mip they read #247, inside an image-sample test; that PR does not test it on its own.

Tested

  • NVIDIA GeForce RTX 3070 8 GB, driver 610.88; Intel Core i5-12600K; Windows 11 Home build 26200
  • Rust 1.100.0 stable-x86_64-pc-windows-gnu (MinGW linker), DXC 1.9.2609.5, debug build, commit 586edba (on main 91f9a5e)
  • cargo test --workspace --no-fail-fast -- --test-threads=4, run in the interactive desktop session: 693 passed, 0 failed, 41 ignored (lib: 653 passed, 0 failed, 21 ignored; e2e 3 of 3; gpu_valu_round_and_min_max_f32_i32 ok). main 91f9a5e on the same machine: 692 passed, 0 failed, 41 ignored (lib: 652 passed, 0 failed, 21 ignored)
  • SKIPPED (no wave64 on this GPU): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware

Not tested

  • The wave64 path: the RTX 3070 has 32-lane waves only, so the test ran as wave32. Not run on AMD.
  • The MSVC toolchain (stable-x86_64-pc-windows-msvc): built with the GNU toolchain only.
  • A release build.
  • A retail title: not needed for a test-only change (no crates/xcl/src runtime file changes).
  • A hang I could not explain: the first two full-suite runs of this branch after a rebuild hung with four tests stuck at zero CPU (gpu_typed_buffer_loads_and_stores, gpu_uma_import_check_at_init, gpu_valu_16_and_64_bit and this test) and were killed. The same four tests together passed twice, the lib suite alone passed 4 of 4, main passed 4 of 4, and the full-suite run counted above passed. I did not find the cause.

AI use

  • Hermes Agent with Claude Opus 5.5: wrote the test, ran the tests and the mutation check on the hardware above, and wrote this description.

emit.rs translates v_ceil_f32, v_trunc_f32, v_rndne_f32, v_max_f32,
v_min_f32, v_max3_f32, v_min3_f32, v_max_i32 and v_min_i32, but no test
ran any of them.

gpu_valu_round_and_min_max_f32_i32 runs all nine as VOP3 in one kernel
(wave64 and wave32 through gpu_waves) on 32 batches of operands: edge
values (+-0, +-0.5, +-1.5, +-2.5, 0.49999997, +-8388607.5, +-1e30,
+-inf, NaN), values on 1/256 steps up to 2^23 and random bit patterns,
with denormals flushed to a signed zero and NaNs quieted. The reference
is computed on the CPU: rounding keeps the sign of a zero; a quiet NaN
operand of an f32 min/max gives the other operand (minNum/maxNum), and
min/max zero results are compared without their sign.

Measured on an RTX 3070 (wave32 only; NVIDIA has no wave64, so that
half did not run):
- GREEN against the real emitter: 1 passed.
- RED, reference round_ties_even replaced by round: fails with
  "wave32, 188 wrong (V_RNDNE_F32: 188)", no other op.
- MUTANT, all nine emit.rs expressions broken at once (ceil->floor,
  trunc->round, round->trunc, max<->min, max3/min3 inner op swapped,
  signed i32 min/max made unsigned): "wave32, 5199 wrong (V_CEIL_F32:
  634, V_TRUNC_F32: 217, V_RNDNE_F32: 217, V_MAX_F32: 956, V_MIN_F32:
  956, V_MAX3_F32: 628, V_MIN3_F32: 629, V_MAX_I32: 481, V_MIN_I32:
  481)"; emit.rs restored afterwards.

Assisted-by: Hermes Agent (Claude Opus 5.5)
@13hourstilliland
13hourstilliland marked this pull request as ready for review November 24, 2026 04:22
@MesshM

MesshM commented Nov 24, 2026

Copy link
Copy Markdown

Test run of 586edbac69ebec057acaa9927957683036958dce on AMD RDNA4. I merged it onto current main 64b3f35 locally (clean merge) and tested that tree.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, mesh shaders), 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: 702 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 661 passed, 0 failed, 21 ignored
  • 0 SKIPPED; the new rounding / min-max GPU test passes.

Review: Overlap: v_ceil_f32, v_trunc_f32 and v_rndne_f32 are also covered by #655 (gpu_float_rounding_ops), and v_min_f32 / v_max_f32 by #719; new here are v_max3_f32, v_min3_f32 and the i32 min / max. If those land first, this could keep only the new ones. The references are right (ceil(−0.5) = −0, min / max zero results compared without the sign, as D3D allows).

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.

@futurepro62

Copy link
Copy Markdown

An NVIDIA run, since the report above is on RDNA4 (native wave64). Tested exact head 586edba (on its base 91f9a5e).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 693 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new test ran and passed (not skipped): gpu::recomp::tests::gpu_valu_round_and_min_max_f32_i32 ... ok.
    Not tested
  • AMD (covered above), a release build.

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@ItsMrDubey

Copy link
Copy Markdown

Test report for 586edbac69ebec057acaa9927957683036958dce (this PR's head)

Tested

  • NVIDIA GeForce RTX 4070 Ti 12 GB (Ada), driver 617.14; Intel Core i9-10900K, 32 GB RAM; Windows 11 Pro build 26300
  • Rust 1.88.0 (stable-x86_64-pc-windows-msvc), debug; DXC 1.9.2602.17 from Windows SDK 10.0.26100
cargo build --workspace
cargo test --workspace --no-fail-fast -- --test-threads=4

16 test binaries: 692 passed, 1 failed, 41 ignored. Same machine, main 64b3f3559: 700 passed, 1 failed, 41 ignored.

This PR's tests:

  • gpu::recomp::tests::gpu_valu_round_and_min_max_f32_i32: ok

Failures:

16 test binaries instead of main's 17 because this branch predates tests/sparse_reinit.rs; nothing crashed.

SKIPPED (no wave64 on this GPU): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.

AI use: Claude Code (Claude Opus 5.5) ran the builds and tests and wrote this report from their output.

@JJAutoCompare

Copy link
Copy Markdown

Empirical test report (586edba)

Verified PR #739 at commit 586edbac69ebec057acaa9927957683036958dce in a clean detached checkout.

Hardware / environment

  • Intel Arc A770 selected with XCL_ADAPTER=A770, on Windows x64 build 26200 with an AMD Family 23 Model 113 CPU.
  • Rust 1.100.0 (0ef1bc386 2026-11-09). The test ran in the unoptimized Cargo test profile with incremental compilation and debug info disabled.
  • DXC 1.9.2609.5 (01b62ad47 in dxc.exe --version). The fixture reported loading dxcompiler and dxil version 1.9.2609.5.

Commands and results

  • cargo test -p xcl --lib --no-run completed with exit code 0 before acquiring the GPU lock.
  • Under Invoke-ArcTest.ps1, with RUST_TEST_NOCAPTURE=1, ran xcl-00e28da3621caf64.exe gpu::recomp::tests::gpu_valu_round_and_min_max_f32_i32 --exact --nocapture --test-threads=1 using the executable from that build. Exit code 0. The log showed 1 passed, 0 failed, 0 ignored, 0 skipped and 673 filtered out. The fixture completed in 0.73 seconds.

Observed behavior

The fixture compiled its recompiled shader with DXC and completed its GPU comparisons against the CPU reference. It checked nine VOP3 instructions over 32 batches per executed wave mode. Coverage included f32 ceil, truncation and nearest-even rounding, two- and three-operand f32 min/max, and signed i32 min/max. The fixture checked signed zero for rounding and numeric results for min/max with a single quiet NaN. The result confirms wave32 coverage. The log does not enumerate the wave modes, so native wave64 coverage was not established by this run.

Not tested

The full GPU workspace suite and game smoke runs were omitted. No other GPU was tested.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr739-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.

7 participants