feat: v_cvt_pkrtz_f16_f32 in the RDNA 2 interpreter — 1,210/1,490 #246
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!246
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/246/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:04 UTC · original
lcg007xd-c:feat/rdna2-cvt-pkrtz→main· +109 −19 · 11 files · 1 commits · merged 2026-11-26 00:15 UTCChange
The reference interpreter now runs
v_cvt_pkrtz_f16_f32in VOP2 (opcode 47) and VOP3. Both encodings raisedUntranslateduntil now.Source: AMD, "RDNA 2" ISA, November 2020, §12.7 "VOP2 Instructions" (printed p. 135): "D.f16_lo = f32_to_f16(S0.f32); D.f16_hi = f32_to_f16(S1.f32). // Round-toward-zero regardless of current round mode setting in hardware." The ISA notes it is meant for 16-bit compressed exports, so pixel shaders that export f16 colours use it.
It joins
rdna2_exec_f16.OPERATIONS(#218) with a small helper,half_toward_zero:half_bits) and steps one ulp back toward zero when that value lies farther from zero than the exact one. This is exact, because the nearest and toward-zero results are at most one ulp apart.0x7BFF), never infinity; ±inf stay ±inf; f32 denormals and values under 2^-24 give ±0.0x7E00, the module's rule for every f16 result.abs/negact on bit 31 and an inline float is the f32 value.WORD_RESULT).op_selon these 32-bit sources,clampandomod(the existing f16 checks); SDWA/DPP as for every f16 op.HLSL: not changed. The recompiler still refuses the instruction (tested); its translation can follow with GPU parity tests.
Coverage (
rdna2_exec.coverage()): 1,208 → 1,210 of 1,490. All 9 READMEs stay at 81%. Overlap: other open PRs (#230, #232, #241, #244, #245) change the same README number; whichever merges later adds its own delta.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_pkrtz.py(7 tests). It uses a hand-written table of 19 f32 inputs and their toward-zero binary16:1 + 3·2^-11→0x3C01(nearest0x3C02); 65520 →0x7BFF(nearest inf);1.5·2^-24→0x0001(nearest0x0002);0xFBFF;Lane i packs inputs i and i + 7. The tests check:
neg/abswork;Failure case: 6 of the 7 fail on
main(the HLSL refusal passes).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,210 of 1,490 (81%), all 9 languages.