Skip to content

Tests: cover the v_fma_mix family's halves, modifiers and clamp - #1570

Open
Rj45n wants to merge 1 commit into
xcl-dev:mainfrom
Rj45n:tests/fma-mix-gpu-coverage
Open

Rj45n wants to merge 1 commit into
xcl-dev:mainfrom
Rj45n:tests/fma-mix-gpu-coverage

Conversation

@Rj45n

@Rj45n Rj45n commented Nov 24, 2026

Copy link
Copy Markdown

Superseded by #1122, which came first and covers more. I wrote this before seeing that PR;
it also exercises SGPR operands, both wave32 and wave64, the dynamic S_ROUND_MODE rounding and
chained mixlo+mixhi, none of which are here. I ran #1122 on an RTX 5070 Ti and it catches eight
deliberate emit.rs regressions out of eight (report in that thread). Close this one in its favour.

The only thing this test reaches that #1122 does not: NEG = 0b111 and NEG_HI = 0b111, the
modifiers set on all three sources at once. If that is worth having, it belongs as two encodings
added to #1122, not as a second test.

What is in it

  • crates/xcl/src/gpu/recomp/tests.rs: gpu_fma_mix_halves_modifiers_clamp_and_preserved_half,
    12 encodings on each of the three MIX opcodes against a CPU reference — OP_SEL_HI, OP_SEL,
    OP_SEL on a non-f16 source (ignored), NEG, NEG_HI (which is abs here, applied before
    NEG), CLAMP above 1 and below 0, and the untouched half of the destination.

Tested

  • RTX 5070 Ti 16 GB (driver 621.01), Windows 11 Pro 10.0.26300, Rust 1.98.1
    stable-x86_64-pc-windows-msvc, DXC 1.9.2602.17, debug. No game data.
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 752 passed, 0 failed, 41 ignored
    over 18 test binaries.
  • SKIPPED, 2, both "no wave64": gpu_geometry_wave32_prefix_count_over_a_mask,
    gpu_wave32_program_in_wave64_hardware.
  • Eight deliberate regressions in the MIX arm of emit.rs (NEG/NEG_HI swapped; NEG_HI not doing
    abs; abs after neg; OP_SEL taking the other half; OP_SEL_HI ignored; MIXLO writing the high half;
    the other half not preserved; CLAMP ignored) are each caught. emit.rs is unchanged here.

Not tested

  • AMD and any other GPU, Linux / Wine, release profile, wave64 (this adapter is wave32).
  • No retail title, so no scripts/smoke.ps1; the diff touches only tests.rs, which
    pr_check.py exempts.
  • f16 rounding: out of scope by design — every expected result is exactly representable.

AI use

  • Claude Code with Claude Opus 5 wrote the test, ran the suite and the mutation check, and drafted
    this description. I checked the diff and every count against the logs.

`V_FMA_MIXHI_F16` had no test anywhere, `V_FMA_MIX_F32` had one case with no
modifier, and nothing locked the part of VOP3P MIX that is easiest to get
wrong: in this family `NEG_HI` is `abs`, not a negation of the high half, and
it applies before `NEG`. A change that "fixed" that pair, or that dropped the
preservation of the half a MIXLO/MIXHI destination does not write, would have
passed the suite and broken every mixed-f16 shader silently.

The test runs 12 encodings on each of the three opcodes against a CPU
reference: which sources are f16 (`OP_SEL_HI`), which half each one takes
(`OP_SEL`), `OP_SEL` on a source that is not f16 (ignored), `NEG`, `NEG_HI`,
the two together, `CLAMP` above 1 and below 0, and the untouched half of the
destination, which starts from a marker value. Operands differ between four
lane groups, so a reference that ignored them could not pass.

Every operand is a small dyadic value, so each product and sum is exact in f32
and each result is representable in f16: the expectations do not depend on the
f16 rounding mode, which has its own tests, nor on whether `mad()` fuses.

Measured on an RTX 5070 Ti (driver 621.01), Windows 11, Rust 1.98.1 MSVC,
debug: `cargo test --workspace --no-fail-fast -- --test-threads=4` gives 752
passed, 0 failed, 41 ignored over 19 test binaries. Eight deliberate
regressions in `emit.rs` (NEG/NEG_HI swapped, NEG_HI not doing abs, abs after
neg instead of before, OP_SEL taking the other half, OP_SEL_HI ignored, MIXLO
writing the high half, the other half not preserved, CLAMP ignored) are each
caught by this test; `emit.rs` is unchanged in this commit.

Assisted-by: Claude Code (Claude Opus 5)

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@DarkPanda69

Copy link
Copy Markdown

AMD run with 64-lane waves, which this PR lists as not tested.

Tested: pass, head f6a575b applied on its base main 9e3831e, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17.
cargo test -p xcl --lib -- gpu::recomp --test-threads=4:

  • AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010, native wave64: 193 passed, 0 failed, 18 ignored, 0 SKIPPED. gpu_fma_mix_halves_modifiers_clamp_and_preserved_half ok.
  • NVIDIA RTX 3060, driver 32.0.16.1088: 193 passed, 0 failed, 18 ignored, 2 SKIPPED (no wave64). Same test ok.

Not tested: release profile; Intel; the whole workspace suite.

AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored.

Thanks!

@ivall ivall added the off-goal Does not bear on the current goal (world loading); waits until it is reached label Nov 24, 2026
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.

4 participants