Skip to content

Recompiler tests: GPU checks for v_fmac_f32, v_fmamk_f32 and v_fmaak_f32 - #737

Open
13hourstilliland wants to merge 1 commit into
xcl-dev:mainfrom
13hourstilliland:recomp-tests-fmac-fmamk-fmaak
Open

13hourstilliland wants to merge 1 commit into
xcl-dev:mainfrom
13hourstilliland:recomp-tests-fmac-fmamk-fmaak

Conversation

@13hourstilliland

Copy link
Copy Markdown
Contributor

Adds a GPU test for three RDNA2 instructions that emit.rs translates but no test runs: v_fmac_f32 (the destination is the addend), v_fmamk_f32 (a * K + b) and v_fmaak_f32 (a * b + K). Test only, no runtime change.

What is in it

  • gpu_valu_fmac_fmamk_fmaak in crates/xcl/src/gpu/recomp/tests.rs, after gpu_nonfused_mad_and_mac_prevent_fma_contraction (away from the lines open PRs add to): one kernel with all 3 instructions, run as wave64 where the adapter has it and as wave32 everywhere (gpu_waves), a 12 x 12 x 8 grid (±0, ±1, 2, 0.5, -3, 1.5, 0.25, ±inf and NaN for the factors; ±0, 1, -2.5, 100, 0.75, inf and NaN for the addend), 1152 triples per wave size, each lane compared with the RDNA2 definition computed on the CPU with f32::mul_add and the literal K in its place, bit for bit (any NaN for NaN); the products on this grid are exact, so fused and unfused multiply-adds agree.
  • 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 (wrong reference for v_fmamk_f32 (K_AK instead of K_MK): wave32, 696 wrong (V_FMAMK_F32: 696), no other instruction) the test fails; with the fmac addend replaced by 0, and the literal moved to the other operand in fmamk and in fmaak applied to emit.rs all at once it fails and names every instruction (wave32, 2034 wrong (V_FMAC_F32: 550, V_FMAMK_F32: 708, V_FMAAK_F32: 776), 550 to 776 wrong per instruction). Those edits are not in the PR.
  • The legacy FMA forms are not in this PR; Recompiler: legacy FMA zero product adds c; XAsync waits cover the callback #670 covers them.

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 9b5e344 (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_fmac_fmamk_fmaak 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).

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_fmac_f32 (the destination is the addend), v_fmamk_f32
(a * K + b) and v_fmaak_f32 (a * b + K), but no test ran them.

gpu_valu_fmac_fmamk_fmaak runs all three in one kernel over a 12 x 12 x 8
grid (+-0, +-1, 2, 0.5, -3, 1.5, 0.25, +-inf and NaN for the factors; +-0,
1, -2.5, 100, 0.75, inf and NaN for the addend), 1152 triples per wave size,
and compares each lane bit for bit (any NaN for NaN) with f32::mul_add,
with the literal K in its place. The products are exact, so fused and
unfused multiply-adds agree on this grid.

Measured on an RTX 3070 (wave32 only; NVIDIA has no wave64):
- with a wrong reference for v_fmamk_f32 (K_AK instead of K_MK) the test
  fails with "wave32, 696 wrong (V_FMAMK_F32: 696)" and no other op;
- with all three emitter lines broken at once (fmac addend replaced by 0,
  fmamk and fmaak literal moved to the other operand) it fails with
  "wave32, 2034 wrong (V_FMAC_F32: 550, V_FMAMK_F32: 708,
  V_FMAAK_F32: 776)";
- against the real emitter it passes.

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 9b5e3442686c2c1878b63bca3254667d466573f5 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; gpu_valu_fmac_fmamk_fmaak passes.

Review: fmac uses the destination as the addend, fmamk is a·K + b and fmaak a·b + K, compared against mul_add (one rounding), and the literal K is placed as the encoding expects. 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.

@futurepro62

Copy link
Copy Markdown

An NVIDIA run, since the report above is on RDNA4 (native wave64). Tested exact head 9b5e344 (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_fmac_fmamk_fmaak ... 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 9b5e3442686c2c1878b63bca3254667d466573f5 (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_fmac_fmamk_fmaak: 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.

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.

5 participants