feat: v_floor/ceil/trunc/rndne_f16 in the HLSL recompiler #251
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!251
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/251/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:33 UTC · original
lcg007xd-c:feat/hlsl-f16-rounding→main· +162 −18 · 12 files · 2 commits · merged 2026-11-26 00:15 UTCDraft, stacked on #245. The first commit is #245 (f16 rounding in the interpreter); only the second commit,
feat: v_floor/ceil/trunc/rndne_f16 in the HLSL recompiler, is new here. I will rebase ontomainonce #245 merges, and mark it ready then.Change
The HLSL recompiler now translates
v_floor_f16,v_ceil_f16,v_trunc_f16andv_rndne_f16, in VOP1 and VOP3, which #245 adds to the interpreter. They are four new entries inrdna2_hlsl_f16.TEMPLATES:F16ToF32widens the half exactly. floor, ceil and trunc use the same HLSL functions as the f32 forms already checked on GPU (v_floor/ceil/trunc_f32inrdna2_hlsl_ops).v_rndne_f16does not useround()(DXILRound_ne). #260 measured the NVIDIA 621.xx driver foldingRound_ne(2.5)to 3.0 (#227), so a newF16Rndnehelper rounds to nearest even on the binary16 bits:0x7E00) are returned unchanged;A Python model of the helper matches the interpreter's
v_rndne_f16on all 65,536 inputs.F32ToF16is exact for an integer value, keeps the sign of zero, and gives0x7E00for a NaN, matching the interpreter's rule.The module's VOP1/VOP3 handling applies unchanged: the low or high half (
op_sel),abs/negon bit 15, andclampthroughF16Clamp.Linked issue: Refs #115 (f16), #227.
Verification
Linux (Arch, Python 3.14), no C++ runtime, no GPU:
Ruff: left to the CI lint job for this push.
GPU parity: Windows CI only (WARP), not run on an AMD or NVIDIA card. The first version (with
round()) passed the GPU test on WARP, but WARP does not show the NVIDIA folding. Locally the GPU test's program translates and, with the GPU runner stubbed to return the interpreter's memory, builds and passes its own checks.Oracle and test data
In
tests/test_rdna2_f16_rounding.py(from #245), the HLSL refusal tests are replaced by:coverage_names(); forv_rndne_f16, that the shader body has noround(;test_rounding_matches_the_interpreter_on_gpu: each op in VOP1 on three sources, VOP3 withop_selhigh half in and out,neg, andabs+clamp, plus a literal (0xDEAD4100, 2.5), compared byte for byte with the interpreter. It reuses the inputs oftests/test_rdna2_hlsl_f16.py(ROWS: ties, denormals, ±0, ±inf, NaNs, random halves).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 the updated #245 (itself on
main9a06443). No README change in this one; it stays a draft until #245 merges.@lcg007xd-c on GitHub · 2026-11-25 22:38 UTC · original
Switched
v_rndne_f16to an integer-only helper (F16Rndne) so it does not hit the NVIDIARound_ne(2.5)folding from #227/#260; checked against the interpreter on all 65,536 f16 inputs.