rdna2-hwprobe: probe kernels for f16 FMA, s_bfe widths, NaN rules and norm conversions, with gfx1036 results (stacked on #41) #72
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!72
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/72/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@QuentinDanblon on GitHub · 2026-11-21 23:16 UTC · original
QuentinDanblon:probe/valu-open-questions→main· +65 −25 · 2 files · 87 commits · closed without mergingLibrary / area:
tools/rdna2-hwprobe(the hardware probe added by #41). No runtime or translator change.Exports changed (exports.txt rows): none
Source of the behaviour: the kernels were run on RDNA2 hardware (gfx1036) by @SchmashinPrunes, results below. Mnemonics and encodings are LLVM's AMDGPU GFX10 ones (Apache-2.0 WITH LLVM-exception); the harness (runner, kernel preamble, metadata) is @SchmashinPrunes' from #41.
Stacked on #41. This branch is #41's head
2515839plus one commit, so the diff shows #41's files too. Onlytools/rdna2-hwprobe/valu_probe.pyand a README section are new (commitsefffbc0andae3a658). If #41 lands first I'll rebase and the diff shrinks to that commit.Why
Four questions in open PRs and on main come down to "what does RDNA2 return", and #41 showed the only reliable way to answer that: run it.
valu_probe.pyreuses that harness for non-MTBUF instructions and generates 33 kernels:fma16v_fmac/fmamk/fmaak_f16, LLVM's GFX10 names) or multiply-then-add (v_mac/madmk/madak_f16, what main implements)? Each kernel also runsv_fma_f16andv_mul_f16+v_add_f16on the same inputs, so both references come from the hardware. About 28,000 of 65,536 inputs per kernel separate the two.sbfes_bfe_{u,i}{32,64}with a width field of 32 or more (64 or more for the 64-bit forms): 7-bit width with sign-fill past the top bit (main since8491769), 7-bit width with the literal ISA formula (zero-fill), or width modulo the operand size. 152 cases, with junk in the unused bits of S1.nanv_fma_f32,v_mul_f32,v_add_f32,v_sub_f32,v_fmac_f32,v_min_f32,v_max_f32return, IEEE mode off and on, over every combination of quiet/signalling NaN, infinity, zero and denormal.tb_fmaon main, #61normv_cvt_pknorm_{i,u}16_{f32,f16}andv_cvt_norm_{i,u}16_f16(the f16 forms are exhaustive over 16 bits).tb_nrm, #63valu_probe.py show <dir>prints, per question, how many recorded outputs match each candidate rule.Results (gfx1036, measured by @SchmashinPrunes)
Run with the generator unmodified on the gfx1036 iGPU of a Ryzen 5 9600X (ROCm/HIP 5.7.1), all 33 kernels: #41. Recorded in the README by
ae3a658.fma16v_fma_f16, none match multiply-then-add. Supports #49.sbfe8491769is right; supports #70.normnanshowdoes not fit. He fitted rules with 0 mismatches (default NaN0xffc00000, no quieting in IEEE mode 0,0 * inf + NaNgives the default NaN,v_sub_f32negates src1 first). They are written in the README;showis not updated to check them.This is RDNA2, not the console's gfx1013.
What was checked, and what was not
clang-18,ld.lld-18) and disassemble identically forgfx1036andgfx1013.showwas run against simulated outputs for each possible answer (fused and unfused, each of the threes_bfemodels, first-NaN and reversed, nearest and half-up) and reports the right one each time.To run it (needs the ROCm setup described in the tool's README):
cargo test -p <crate>: not applicable, no crate is touched by the new commit (#41's own tests:--test exec exec_mem::mtbuf8 / 8 on WARP and on an RTX 5090 with #41 merged onto8491769)missingwith a note🤖 Generated with Claude Code
@SchmashinPrunes on GitHub · 2026-11-22 00:15 UTC · original
Thanks for recording the results! Following up on the fitting script: I put the fitted NaN rules into
show, as one commit on top ofae3a658. If you want it in #72, cherry-pick:0acea8aon SchmashinPrunes:valu-nan-rulesnan_arith()/nan_minmax()encode the rules.show_nanchecks every NaN-related output against them and prints how many differ per instruction and IEEE mode, with a few examples. That replaces the old candidate line and the raw min/max tables, and the README is updated to match.showstill runs end to end. The other sections are unchanged.@QuentinDanblon on GitHub · 2026-11-22 00:20 UTC · original
Taken, thank you:
0acea8ais on this PR asHEAD, with you as the author. One change: I left out the three__pycache__/*.pycfiles the commit carried, since the repository takes no binaries (I made the same mistake on my first probe commit).Checked on my side, on simulated outputs only (no AMD GPU here):
showruns end to end, reports 0 differing results in both IEEE modes when the outputs follownan_arith/nan_minmax(same case counts as yours: 65,265 fma, 43,824 mul, 43,886 add and sub, 43,736 min and max), and flags 104 / 88 / 22 results when I change the default NaN to0x7fc00000.@omonkeyz on GitHub · 2026-11-22 13:12 UTC · original
Main's history was rewritten, which auto-closed this PR (sorry for the noise). This is stacked on #41. Resubmit it after #41, with only valu_probe.py and the probe notes. Put the notes in the PR description or a .txt, because .md files under tools/ are not published. Strip comment lines. To resubmit:
git fetchthis repo, branch from the currentmain, cherry-pick only your own commits (the old branch is based on the previous history and cannot be merged), and open a new PR.Pull request closed