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
@github-actions

Copy link
Copy Markdown

Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

@github-actions github-actions Bot added the stale No activity for 3 days; closed 4 days later unless something happens label Nov 28, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Triage (#1607) – head f6a575b

No open PR adds the same tests; #1122 (closed, not merged) tested the same v_fma_mix family, and main only exercises V_FMA_MIX_F32 / V_FMA_MIXLO_F16 incidentally, with no V_FMA_MIXHI_F16 test.
The CPU reference matches the ISA (NEG_HI is abs for this family, OP_SEL ignored on f32 sources, MIXLO/MIXHI keep the other half), and the operands are exact in f16 so the expectations do not depend on rounding.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

@grathepic

Copy link
Copy Markdown

merge-check

  • base: 078358a
  • head: f6a575b
  • merge: clean (git diff --check exit 0)
  • build: cargo +1.98.1-x86_64-pc-windows-msvc build --offline --locked --workspace — exit 0 (36 pre-existing warnings in xcl lib)
  • tests: cargo +1.98.1-x86_64-pc-windows-msvc test --offline --locked --workspace --no-fail-fast -- --test-threads=4 (with XCL_DXC_DIR=C:\VulkanSDK\1.4.363.0\Bin) — 3007 passed, 0 failed, 52 ignored across 44 harnesses; 27 SKIPPED (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps, 1 no dxil.dll, 1 cannot disable the driver cache (Windows Developer Mode required)). New GPU test gpu::recomp::tests::gpu_fma_mix_halves_modifiers_clamp_and_preserved_half ran and passed with 0 skips.
  • title run: not required (Tier 0 test-only PR; adds one unit test in crates/xcl/src/gpu/recomp/tests.rs with zero production code or dependency changes)
  • review: Read full 101-line diff. Strictly test-only (+101/-0), placed in gpu::recomp::tests and guarded with gpu_ready(). Tests 12 ENC_VOP3P combinations across V_FMA_MIX_F32, V_FMA_MIXLO_F16, and V_FMA_MIXHI_F16 with exact dyadic f16/f32 operands: verifies OP_SEL_HI/OP_SEL_HI_2, OP_SEL (including ignored on f32), NEG_HI as abs before NEG, CLAMP (interior, >1, and <0 cases), and preservation of the untouched destination half (0xA5A5_5A5A sentinel). Disjoint VGPR allocations (v1..v6 inputs, v16..v59 outputs). Note: the PR body's opening line mentions #1122, which was closed unmerged; per PR triage: duplicate PRs and batch-tested PRs, each checked by two contributors #1607 triage, no other open PR covers V_FMA_MIXHI_F16 / this family.
  • performance: not applicable (test-only)
  • verdict: safe to merge
  • hardware / tool and model: NVIDIA GeForce RTX 3080 (driver 32.0.16.2140), AMD Ryzen 7 5800X3D, Windows 11 (10.0.26300.0), Rust 1.98.1-x86_64-pc-windows-msvc, DXC 1.9.0.5512 (VulkanSDK, no dxil.dll) / Antigravity, Gemini 4 Neon

@github-actions github-actions Bot added area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 area:tests Unit, integration, e2e tests, or testtitle gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) needs-1st-check Passes gates; needs first independent merge-check (#3041) labels Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 area:tests Unit, integration, e2e tests, or testtitle gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) needs-1st-check Passes gates; needs first independent merge-check (#3041) off-goal Does not bear on the current goal (world loading); waits until it is reached stale No activity for 3 days; closed 4 days later unless something happens

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants