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

Open
github-bot wants to merge 1 commit from github-bot/gh-1570 into main AGit
Owner

@⁠Rj45n on GitHub · 2026-11-24 17:46 UTC · original
Rj45n:tests/fma-mix-gpu-coverage → main · +101 −0 · 1 files · 1 commits · open

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.
**@⁠Rj45n** on GitHub · 2026-11-24 17:46 UTC · [original](https://github.com/xcl-dev/xcl/pull/1570) `Rj45n:tests/fma-mix-gpu-coverage` → `main` · +101 −0 · 1 files · 1 commits · open **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 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:57:49 +00:00
Author
Owner

@⁠DarkPanda69 on GitHub · 2026-11-24 18:11 UTC · original

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.

**@⁠DarkPanda69** on GitHub · 2026-11-24 18:11 UTC · [original](https://github.com/xcl-dev/xcl/pull/1570#issuecomment-7140294037) 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.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 19:41 UTC · original

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

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

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 19:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/1570#issuecomment-7142453792) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~22 ignored. Thanks!
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1570/head:github-bot/gh-1570'
git switch 'github-bot/gh-1570'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1570'
git switch 'github-bot/gh-1570'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1570'
git switch 'github-bot/gh-1570'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1570'
git switch 'main'
git merge --squash 'github-bot/gh-1570'
git switch 'main'
git merge --ff-only 'github-bot/gh-1570'
git switch 'main'
git merge 'github-bot/gh-1570'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.