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

Open
SchmashinPrunes wants to merge 3 commits from upstream-pr/387 into main
SchmashinPrunes commented 2026-11-25 17:50:37 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by SchmashinPrunes on 2026-11-25T17:50:37Z.


@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

<!-- greyfinch-sync:omonkeyz/xbox-emulator:issue:5496351982 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/387). Originally posted by [SchmashinPrunes](https://github.com/SchmashinPrunes) on 2026-11-25T17:50:37Z. --- @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)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/387:upstream-pr/387'
git switch 'upstream-pr/387'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/387'
git switch 'upstream-pr/387'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/387'
git switch 'upstream-pr/387'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/387'
git switch 'main'
git merge --squash 'upstream-pr/387'
git switch 'main'
git merge --ff-only 'upstream-pr/387'
git switch 'main'
git merge 'upstream-pr/387'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
omonkeyz/xbox-emulator!387
No description provided.