feat: v_fract_f16, v_frexp_mant_f16 and v_frexp_exp_i16_f16 in the RDNA 2 interpreter — 1,214/1,490 #247
No reviewers
Labels
No labels
accessibility
bloqué : binaire console
bug
chargeur
console-dll
cpu
documentation
duplicate
enhancement
good first issue
gpu
help wanted
invalid
performance
question
runtime-gdk
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LooperSalty--AnyXboxX!247
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/247/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?
@lcg007xd-c on GitHub · 2026-11-25 21:07 UTC · original
lcg007xd-c:feat/rdna2-f16-fract-frexp→main· +122 −18 · 11 files · 1 commits · merged 2026-11-26 00:15 UTCChange
The reference interpreter now runs three more f16 VOP1 ops, in VOP1 and VOP3, 6 encodings that raised
Untranslateduntil now. They mirror the interpreter's f32 forms (_fract,_frexp_mantissa,_frexp_exponent):v_fract_f16S0 + -floor(S0)(ISA), at most0x3BFF, the largest f16 under 1.0, asv_fract_f32stops at0x3F7FFFFF(#209). Sofract(-2^-24)is0x3BFF, not 1.0. NaN for ±inf and NaN;fract(-0) = +0; DX semantics,fract(-1.2) = 0.8v_frexp_mant_f16S0 = m × 2^e, 0.5 ≤ |m| < 1, sign kept. ±0, ±inf and NaN give S0 unchanged (ISA pseudo-code:D.f16 = S0.f16)v_frexp_exp_i16_f16A denormal is normalised:
0x0001= 0.5 × 2^-23 gives-23,0x03FFgives-14. That is whatmath.frexpdoes in the f32 forms here, and what LLVM does when it foldsamdgcn_frexp_mant/expwithAPFloatfrexp(AMDGPUInstCombineIntrinsic.cpp). It is not measured on hardware.The existing f16 rules apply: a low-half write keeps the high half,
op_selreads or writes the high half, andabs/negact on bit 15. One new refusal: VOP3clampon the integer result ofv_frexp_exp_i16_f16. The f16[0, 1]clamp would otherwise be applied to an integer; a newINTEGER_RESULTset marks it.Source: AMD, "RDNA 2" ISA, November 2020, §12.8 "VOP1 Instructions", opcodes 89, 90 and 95 (printed p. 147-148).
HLSL: not changed. The recompiler still refuses these ops (tested).
Coverage (
rdna2_exec.coverage()): 1,208 → 1,214 of 1,490. All 9 READMEs stay at 81%. Overlap: other open PRs change the same README number. Inemu/rdna2_exec_f16.pythis PR adds its lines at the end ofOPERATIONSand after_is_nan, away from where #245 and #246 add theirs, so the code parts merge cleanly.Linked issue: Refs #115 (f16).
Verification
Linux (Arch, Python 3.14.10), no C++ runtime, no GPU (runtime and GPU tests skip), rebased rebased on
main9a06443:The suite is green on this machine since #237 and #238 merged.
Not run: the Windows CI job and GPU/WARP (no HLSL change).
Oracle and test data
New
tests/test_rdna2_f16_fract_frexp.py(11 tests). A hand-written table gives the three results for each of 13 inputs:The tests:
op_selreading and writing the high half;neg, and inline 1.0;Failure case: 8 of the 11 fail on
main(the HLSL refusals pass).Checklist
E_NOTIMPL), never a fake success.test_readme_sync.pychecks it).Made with AI assistance (Claude Code).
🤖 Generated with Claude Code
@LooperSalty on GitHub · 2026-11-25 21:56 UTC · original
Thanks — this one is approved, but it now conflicts with main after #242, #244 and #248 were merged (mostly the README RDNA 2 line, plus shared rdna2 files for some). Could you merge or rebase onto main, recount the README line with
rdna2_exec.coverage()on the merged tree (all 9 languages), and push? I will merge it as soon as CI is green.@lcg007xd-c on GitHub · 2026-11-25 22:01 UTC · original
Rebased onto
main(9a06443), README line recounted withrdna2_exec.coverage()on the merged tree: 1,214 of 1,490 (81%), all 9 languages.