ISA sweep: s_bfe and v_cvt_(pk)norm reference models checked against RDNA2 hardware (resubmits #78) #383

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

@⁠SchmashinPrunes on GitHub · 2026-11-25 15:39 UTC · original
SchmashinPrunes:rdna2-hw-refs-v3 → main · +899 −2 · 5 files · 1 commits · open

@⁠omonkeyz, this is the resubmission of #78, which the 11-22 history rewrite closed. You asked for it to come after #41 and #72. Both are on main now (#133, and valu_probe.py through #208), so here it is, rebuilt on a618736 as you asked: only the test, the hardware record and the generator. It has no docs/ or tools/progress edits and no comment lines.

It covers exactly the 10 mnemonics that tools/progress/progress.json still lists under rdna2_pending ("awaiting independent verification"): s_bfe_{i,u}{32,64}, v_cvt_norm_{i,u}16_f16 and v_cvt_pknorm_{i,u}16_{f16,f32}. Moving them is yours to do in a sync if you take this.

Library / area: tombox-xshader tests (ISA sweep). No translator change.

Exports changed (exports.txt rows): none

Source of the behaviour: results recorded on RDNA2 hardware with the sbfe and norm probes of valu_probe.py (@⁠QuentinDanblon's, from #72), first posted in the #41 thread.

  • The hardware is the gfx1036 iGPU of a Ryzen 5 9600X, on Linux Mint with ROCm/HIP 5.7.1. That's RDNA2, but not the console's GPU (gfx1013). The record says so in rdna2_hw::SOURCE, which the test prints.
  • The raw probe outputs are attached to #78. With main's valu_probe.py, tools/rdna2-hwprobe/sweep_vectors.py regenerates rdna2_hw.rs from them byte for byte (rechecked today).
  • No game or console files are involved.

What RDNA2 does

  • s_bfe_{u,i}{32,64}:

    • the width is the full 7-bit field;
    • a signed field that reaches the top bit is sign-filled;
    • junk in the unused S1 bits is ignored;
    • SCC = (result != 0).

    All 152 measured cases match ops_s::bfe64.

  • v_cvt_norm_* / v_cvt_pknorm_*:

    • the exact value is rounded to nearest, and NaN gives 0;
    • the only exact ties are ±0.5, where ties-to-even and ties-away agree;
    • v_cvt_norm_* keeps the upper half of D.

    This matches ops_v::norm16 (and so tb_nrm) everywhere.

Change

  • tests/isa_sweep/rdna2_hw.rs is the hardware record, generated by sweep_vectors.py:
    • all 152 s_bfe cases as literals;
    • an FNV-1a digest over all 65,536 f16 inputs for each of the four f16 conversions (the test regenerates the inputs), plus 54 literal edge inputs;
    • a digest over the sweep's 26×26 NRM_F32 edge grid for the two f32 pknorm forms, plus 512 literal random pairs.
  • tests/isa_sweep.rs gets a new CPU-only test, sweep_references_match_rdna2, that checks bfe64 and norm16 against the record. bfe64 and NRM_F32 become pub for it.
  • The one conflict with today's main was WARP_KNOWN, which I kept as main has it.

Tests

Windows 11, WARP, this branch on a618736:

sweep references vs RDNA2 (gfx1036, Ryzen 5 9600X iGPU, ROCm/HIP 5.7.1, 2026-11-21): 152 s_bfe cases, 4 f16 digests (54 literal inputs), 2 f32 grid digests, 512 f32 literal inputs; 0 mismatches
  • The full tombox-xshader suite passes: isa_sweep 3/3, tests/exec.rs 189/189, and every other target.
  • The PR gate is clean.

Mutation check (from the first submission): each of these planted model changes makes the new test fail:

planted change mismatches
zero-fill past the top bit 26
width modulo the operand size 52
truncate 590
round half up 6
NaN → 1 18
u16 not clamped at 0 432

Independent cross-check by @⁠QuentinDanblon on #78: the record's inputs equal the probe's case lists, and #72's Python models, which share no code with bfe64 / norm16, reproduce every digest and literal.

  • cargo test -p tombox-xshader passes
  • No game or console files and no binaries included
  • No fake success

🤖 Generated with Claude Code

**@⁠SchmashinPrunes** on GitHub · 2026-11-25 15:39 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/383) `SchmashinPrunes:rdna2-hw-refs-v3` → `main` · +899 −2 · 5 files · 1 commits · open @⁠omonkeyz, this is the resubmission of #78, which the 11-22 history rewrite closed. You asked for it to come after #41 and #72. Both are on main now (#133, and `valu_probe.py` through #208), so here it is, rebuilt on `a618736` as you asked: only the test, the hardware record and the generator. It has no `docs/` or `tools/progress` edits and no comment lines. It covers exactly the 10 mnemonics that `tools/progress/progress.json` still lists under `rdna2_pending` ("awaiting independent verification"): `s_bfe_{i,u}{32,64}`, `v_cvt_norm_{i,u}16_f16` and `v_cvt_pknorm_{i,u}16_{f16,f32}`. Moving them is yours to do in a sync if you take this. **Library / area:** tombox-xshader tests (ISA sweep). No translator change. **Exports changed (exports.txt rows):** none **Source of the behaviour:** results recorded on RDNA2 hardware with the `sbfe` and `norm` probes of `valu_probe.py` (@⁠QuentinDanblon's, from #72), first posted in the #41 thread. - The hardware is the gfx1036 iGPU of a Ryzen 5 9600X, on Linux Mint with ROCm/HIP 5.7.1. That's RDNA2, but not the console's GPU (gfx1013). The record says so in `rdna2_hw::SOURCE`, which the test prints. - The raw probe outputs are attached to #78. With main's `valu_probe.py`, `tools/rdna2-hwprobe/sweep_vectors.py` regenerates `rdna2_hw.rs` from them byte for byte (rechecked today). - No game or console files are involved. ### What RDNA2 does - **`s_bfe_{u,i}{32,64}`:** - the width is the full 7-bit field; - a signed field that reaches the top bit is sign-filled; - junk in the unused S1 bits is ignored; - SCC = (result != 0). All 152 measured cases match `ops_s::bfe64`. - **`v_cvt_norm_*` / `v_cvt_pknorm_*`:** - the exact value is rounded to nearest, and NaN gives 0; - the only exact ties are ±0.5, where ties-to-even and ties-away agree; - `v_cvt_norm_*` keeps the upper half of D. This matches `ops_v::norm16` (and so `tb_nrm`) everywhere. ### Change - `tests/isa_sweep/rdna2_hw.rs` is the hardware record, generated by `sweep_vectors.py`: - all 152 `s_bfe` cases as literals; - an FNV-1a digest over all 65,536 f16 inputs for each of the four f16 conversions (the test regenerates the inputs), plus 54 literal edge inputs; - a digest over the sweep's 26×26 `NRM_F32` edge grid for the two f32 pknorm forms, plus 512 literal random pairs. - `tests/isa_sweep.rs` gets a new CPU-only test, `sweep_references_match_rdna2`, that checks `bfe64` and `norm16` against the record. `bfe64` and `NRM_F32` become `pub` for it. - The one conflict with today's main was `WARP_KNOWN`, which I kept as main has it. ### Tests Windows 11, WARP, this branch on `a618736`: ``` sweep references vs RDNA2 (gfx1036, Ryzen 5 9600X iGPU, ROCm/HIP 5.7.1, 2026-11-21): 152 s_bfe cases, 4 f16 digests (54 literal inputs), 2 f32 grid digests, 512 f32 literal inputs; 0 mismatches ``` - The full `tombox-xshader` suite passes: `isa_sweep` 3/3, `tests/exec.rs` 189/189, and every other target. - The PR gate is clean. **Mutation check** (from the first submission): each of these planted model changes makes the new test fail: | planted change | mismatches | |---|---| | zero-fill past the top bit | 26 | | width modulo the operand size | 52 | | truncate | 590 | | round half up | 6 | | NaN → 1 | 18 | | u16 not clamped at 0 | 432 | **Independent cross-check** by @⁠QuentinDanblon on #78: the record's inputs equal the probe's case lists, and #72's Python models, which share no code with `bfe64` / `norm16`, reproduce every digest and literal. - [x] `cargo test -p tombox-xshader` passes - [x] No game or console files and no binaries included - [x] No fake success 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The ISA sweep held s_bfe_* and v_cvt_norm / v_cvt_pknorm at yellow
because their rules (s_bfe width >= 32, norm rounding) were not confirmed
against silicon. The sweep already passes them on WARP against
ops_s::bfe64 and ops_v::norm16; this adds the missing link from those
models to hardware.

tests/isa_sweep/rdna2_hw.rs records what an RDNA2 GPU (gfx1036 iGPU of a
Ryzen 5 9600X, ROCm/HIP 5.7.1; rdna2_hw::SOURCE) returned for the sbfe
and norm probes of tools/rdna2-hwprobe/valu_probe.py:
- all 152 s_bfe cases, literal;
- every f16 input of the four f16 conversions, as an FNV-1a digest over
  the 65536 inputs (regenerated in Rust) plus 54 literal edge inputs;
- the 26x26 f32 edge grid (the sweep's NRM_F32) as a digest, plus 512
  literal random f32 pairs.

sweep_references_match_rdna2 (CPU only) checks the sweep models against
it: 0 mismatches. Planted model changes (zero-fill, width modulo the
operand size, truncate, half-up, NaN -> 1, unclamped u16) each fail it
with 6 to 590 mismatches. tools/rdna2-hwprobe/sweep_vectors.py
regenerates the record from a probe directory; it needs valu_probe.py.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:21:01 +00:00
This pull request can be merged automatically.
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/383/head:github-bot/gh-383'
git switch 'github-bot/gh-383'

Merge

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