ISA sweep: run every case on RDNA2 silicon and pin the reference models to the record (stacked on #385) #387

Open
github-bot wants to merge 3 commits from github-bot/gh-387 into main AGit
Owner

@⁠SchmashinPrunes on GitHub · 2026-11-25 17:50 UTC · original
SchmashinPrunes:isa-sweep-rdna2-silicon → main · +2842 −31 · 10 files · 3 commits · open

@⁠omonkeyz, this is the silicon harness and record behind #385. It's stacked on #385: the first commit is #385's, so review the second and third. The record pins the corrected models.

The third commit adds TOMBOX_SWEEP_SILICON_MODE=host. It translates each pack with a given initial MODE (TOMBOX_SWEEP_RSRC1), runs it on the D3D12 host, and compares every lane with the silicon outputs, so translator and hardware can be compared under any MODE. That's how #388 and #389 were found.

What it adds

  • isa_sweep_silicon (CPU only; does nothing unless TOMBOX_SWEEP_SILICON is set) exports every sweep case as a raw gfx10 program, and later checks or records the hardware outputs.
    • Each program is the sweep's own code plus a small entry shim.
    • SGPRs are per wave on hardware, but the sweep's lane model gives every lane its own inputs. So each input row runs in its own wave: all 32 lanes load row w, and lane w % 32 stores.
    • One setup pattern is rewritten. exec_quarter writes EXEC with a VOP3 compare, and on gfx1036 a VOPC with SDST = EXEC leaves EXEC unchanged (checked separately). The silicon program compares into an SGPR and then does s_mov. The instruction under test is never touched.
  • tools/rdna2-hwprobe/sweep_silicon.py and sweep_silicon_runner.cpp run the packs on an RDNA2 Linux box (ROCm/HIP, clang-18/ld.lld-18):
    • sweep_silicon.py absent lists cases whose instruction gfx103x lacks, or decodes as something other than on gfx1013, by comparing LLVM's gfx1013 and gfx1036 disassembly. gfx10.3 removed v_mac/mad/madak/madmk(_legacy)_f32 and reuses two of the opcodes for fma_legacy, so running those would execute a different instruction. They are not run.
    • Each pack's disassembly is checked against a block list before it runs: DS (src2 ops hang gfx1036), scalar stores and atomics, s_sendmsg, s_trap, s_sethalt, memory other than the sweep's own MUBUF loads and stores, and exports.
    • Each pack runs in its own process with a timeout.
    • The README section has the full procedure.
  • tests/isa_sweep/rdna2_sweep_hw.rs (528 KB, text) is the gfx1036 record of all 2,196 cases that ran. Per case it stores an FNV-1a digest of every output word the model defines, plus only the words where the hardware differs from the model's bits (NaN payloads, ulp-tolerance results), each packed as lane << 34 | word << 32 | value.
  • sweep_models_match_rdna2_silicon (CPU only, about 0.2 s) rebuilds each case's hardware output from the model plus the recorded words, checks the digest, and runs the sweep's own comparison on every lane. Any model change that moves a recorded bit fails it.

Results (gfx1036 iGPU, Ryzen 5 9600X, ROCm/HIP 5.7.1)

  • 2,173 cases match the models under the sweep's comparison rules.
  • 8 mnemonics are recorded as known differences, each with its reason:
    • the 7 f32 omod ops (v_add/sub/subrev/mul/mul_legacy/min/max_f32): omod acts only with IEEE 0 and f32 output denormals flushed (#386);
    • v_mul_lo_i32: gfx103x doesn't have it; its low 32 bits equal v_mul_lo_u32's.
  • 22 cases aren't in the record: the removed multiply-add instructions above.

gfx1036 is RDNA2 but not gfx1013. Wherever an instruction could differ between them, the absent check uses LLVM's tables for both.

Tests

run result
sweep_models_match_rdna2_silicon (WARP box, CPU) ok: 2,173 checked, 8 known, 22 not recorded
same test with one cube rule reverted (v_cubema of a zero axis) fails on exactly the 2 affected cases
isa_sweep target on WARP 4/4; sweep 552 pass, the 4 existing WARP_KNOWN deviations
rerunning sweep_silicon.py on two packs byte-identical outputs to the recorded run

The PR gate is clean. No game or console files are involved.

🤖 Generated with Claude Code

**@⁠SchmashinPrunes** on GitHub · 2026-11-25 17:50 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/387) `SchmashinPrunes:isa-sweep-rdna2-silicon` → `main` · +2842 −31 · 10 files · 3 commits · open @⁠omonkeyz, this is the silicon harness and record behind #385. It's **stacked on #385**: the first commit is #385's, so review the second and third. The record pins the corrected models. The third commit adds `TOMBOX_SWEEP_SILICON_MODE=host`. It translates each pack with a given initial MODE (`TOMBOX_SWEEP_RSRC1`), runs it on the D3D12 host, and compares every lane with the silicon outputs, so translator and hardware can be compared under any MODE. That's how #388 and #389 were found. ### What it adds - **`isa_sweep_silicon`** (CPU only; does nothing unless `TOMBOX_SWEEP_SILICON` is set) exports every sweep case as a raw gfx10 program, and later checks or records the hardware outputs. - Each program is the sweep's own code plus a small entry shim. - SGPRs are per wave on hardware, but the sweep's lane model gives every lane its own inputs. So each input row runs in its own wave: all 32 lanes load row w, and lane w % 32 stores. - One setup pattern is rewritten. `exec_quarter` writes EXEC with a VOP3 compare, and on gfx1036 a VOPC with SDST = EXEC leaves EXEC unchanged (checked separately). The silicon program compares into an SGPR and then does `s_mov`. The instruction under test is never touched. - **`tools/rdna2-hwprobe/sweep_silicon.py` and `sweep_silicon_runner.cpp`** run the packs on an RDNA2 Linux box (ROCm/HIP, `clang-18`/`ld.lld-18`): - `sweep_silicon.py absent` lists cases whose instruction gfx103x lacks, or decodes as something other than on gfx1013, by comparing LLVM's gfx1013 and gfx1036 disassembly. gfx10.3 removed `v_mac/mad/madak/madmk(_legacy)_f32` and reuses two of the opcodes for `fma_legacy`, so running those would execute a different instruction. They are not run. - Each pack's disassembly is checked against a block list before it runs: DS (src2 ops hang gfx1036), scalar stores and atomics, `s_sendmsg`, `s_trap`, `s_sethalt`, memory other than the sweep's own MUBUF loads and stores, and exports. - Each pack runs in its own process with a timeout. - The README section has the full procedure. - **`tests/isa_sweep/rdna2_sweep_hw.rs`** (528 KB, text) is the gfx1036 record of all 2,196 cases that ran. Per case it stores an FNV-1a digest of every output word the model defines, plus only the words where the hardware differs from the model's bits (NaN payloads, ulp-tolerance results), each packed as `lane << 34 | word << 32 | value`. - **`sweep_models_match_rdna2_silicon`** (CPU only, about 0.2 s) rebuilds each case's hardware output from the model plus the recorded words, checks the digest, and runs the sweep's own comparison on every lane. Any model change that moves a recorded bit fails it. ### Results (gfx1036 iGPU, Ryzen 5 9600X, ROCm/HIP 5.7.1) - 2,173 cases match the models under the sweep's comparison rules. - 8 mnemonics are recorded as known differences, each with its reason: - the 7 f32 omod ops (`v_add/sub/subrev/mul/mul_legacy/min/max_f32`): omod acts only with IEEE 0 and f32 output denormals flushed (#386); - `v_mul_lo_i32`: gfx103x doesn't have it; its low 32 bits equal `v_mul_lo_u32`'s. - 22 cases aren't in the record: the removed multiply-add instructions above. gfx1036 is RDNA2 but not gfx1013. Wherever an instruction could differ between them, the absent check uses LLVM's tables for both. ### Tests | run | result | |---|---| | `sweep_models_match_rdna2_silicon` (WARP box, CPU) | ok: 2,173 checked, 8 known, 22 not recorded | | same test with one cube rule reverted (`v_cubema` of a zero axis) | fails on exactly the 2 affected cases | | `isa_sweep` target on WARP | 4/4; sweep 552 pass, the 4 existing `WARP_KNOWN` deviations | | rerunning `sweep_silicon.py` on two packs | byte-identical outputs to the recorded run | The PR gate is clean. No game or console files are involved. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Three translator rules disagreed with gfx1036 silicon (the ISA sweep's
own cases run as raw kernels):

- op_sel is honoured only by VOP3-native opcodes (0x140-0x17f,
  0x300-0x3ff). VOPC, VOP2 and VOP1 ops in the VOP3 encoding ignore the
  bits: they read the low source halves and write the low half (keeping
  the high half). LLVM rejects op_sel on those encodings for gfx1013 as
  well. vop3_opsel_ok() gates every op_sel read outside VOP3P/interp.
- v_cube{id,sc,tc,ma}_f32 pick the major axis with denormal inputs
  treated as zero and return raw coordinates; v_cubema of a zero axis is
  +0. 588 of 588 recorded non-NaN cases per op match.
- v_sat_pk_u8_i16 writes the full dword (D[31:16] = 0), so it is no
  longer merged as a 16-bit result.

The sweep reference models and three exec expectations follow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
isa_sweep_silicon (env TOMBOX_SWEEP_SILICON, CPU only) exports every sweep
case as a raw gfx10 program (the sweep's own code plus an entry shim, one
input row per wave so SGPR inputs match the per-lane model), and checks or
records the outputs that tools/rdna2-hwprobe/sweep_silicon.py collects on
an RDNA2 GPU. Cases whose instruction gfx103x lacks or decodes differently
are listed by sweep_silicon.py absent and not run.

tests/isa_sweep/rdna2_sweep_hw.rs is the gfx1036 record of all 2,196 run
cases: per case an FNV-1a digest of the output words the model defines and
only the words where the hardware differs from the model's bits.
sweep_models_match_rdna2_silicon rebuilds the hardware output from the
model plus those words, checks the digest and runs the sweep comparison:
2,173 cases match; 8 mnemonics are recorded as known differences (f32
omod under MODE 0xf0, issue #386; v_mul_lo_i32 absent on gfx103x).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TOMBOX_SWEEP_SILICON_MODE=host translates each pack with the initial MODE
from TOMBOX_SWEEP_RSRC1 (PGM_RSRC1 bits), runs it on the D3D12 host and
compares every lane with the silicon outputs in TOMBOX_SWEEP_SILICON_OUT,
using the sweep's comparison rules with silicon as the reference.
sweep_silicon.py takes SIL_DN16 for the f16/f64 denormal mode alongside
SIL_DN32 and SIL_IEEE, and hlsl_for honours TOMBOX_SWEEP_RSRC1.

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:08 +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/387/head:github-bot/gh-387'
git switch 'github-bot/gh-387'

Merge

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