Repository navigation
Recompiler: v_frexp_mant_f32 / _f16 keep the input's sign (#580) - #587
requiemsnkrp wants to merge 1 commit into
Conversation
`frexp_mant` returned HLSL frexp()'s mantissa, which is unsigned: a negative input gave a positive mantissa (-10.125 -> +0.6328125) and -0 gave +0. The ISA keeps the sign, as XCL's f64 path (`frexp_mant_d`) already does. The helper now ORs the input's sign bit back in; v_frexp_mant_f16 goes through the same helper. Fix and diagnosis by joeypercia in xcl-dev#580. The test runs v_frexp_mant_f32 (also with the NEG modifier), v_frexp_exp_i32_f32 and v_frexp_mant_f16 on negative inputs, -0, +0 and -inf: before, it failed on the first negative input (+0.6328125 for -10.125); after, it passes. Fixes xcl-dev#580 Co-authored-by: joeypercia <81598667+joeypercia@users.noreply.github.com> Assisted-by: Claude Code (Claude Opus 5.5)
|
I checked the f16 negative control listed under Not tested. On the RTX 4080, the same
Tested
Not tested
AI use
|
|
Test run of Tested
Review: ORing the input's sign bit into HLSL Not tested: no retail title or regression run (I have no unpacked game), no Run and report by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code. |
|
Independent check of the f16 before-fix case listed under Not tested. RTX 3060 12 GB (driver 610.88), Core i5-8400, Windows 11 Home 26200.9974, Rust 1.100.0 x86_64-pc-windows-msvc, SDK DXC 1.9.2602.17, debug;
Not tested: full workspace or retail titles. AI use: OpenAI Codex (GPT-6) ran both checks and drafted this report. |
Independent RTX 5070 verification of XCL PR #587Tested on Windows 10 build 19045, Intel i7-12700KF, NVIDIA RTX 5070 driver 591.86, Rust 1.100.0 MSVC debug build and DXC 1.8.2502.11 with a local D3D12 Agility SDK. Base implementation: 9ce2070. Used the PR regression harness on the parent emitter. For the separate half-precision run, only the preceding f32 assertions were gated; the program and GPU input state were identical.
Head: d6d7906. With the original, unmodified test and emitter restored, the combined bitwise GPU regression passed (1 passed, 0 failed, no skip). No tracked source differences from HEAD after verification. Workspace: cargo build --locked --workspace succeeded. cargo test --locked --workspace -- --test-threads=4 --nocapture reported 685 passed, 0 failed, 41 ignored. The harness counts runtime skips among passes. Two wave64 tests and two D3D12 debug-layer tests explicitly reported SKIPPED. Optional sample-dependent tests lacked retail inputs. No retail game smoke run was performed. This evidence covers instruction semantics on this GPU. Logs: base-f32.log, base-f16.log, head-frexp.log, head-build.log, head-suite.log. Local harness: verify.py. AI assistance: Codex (GPT-6.2 Astra) prepared the local assertion gate, executed the comparison and summarized the logs. Additional edge observations on the same RTX 5070 and PR head. A synthetic kernel executed the unmodified VOP1 f32 and f16 mantissa paths on eight input pairs repeated over 64 lanes. Every repeated lane agreed. Hex digits below are raw bits.
These are observations of this build. No comparison with native guest instructions or alternate denormal modes was performed, so this alone does not establish a regression or an ISA mismatch. Parent-emitter control for the edge table: same synthetic kernel and inputs on the same adapter, with only emit.rs switched between 9ce2070 and d6d7906. Both runs executed. For each precision, only the three negative finite inputs changed (smallest and largest subnormal, smallest normal), and each output changed by exactly the sign bit. Both f16 quiet NaNs already returned 0x7fff on the parent. The f32 subnormal magnitudes were already zero there. This isolates the PR effect on these inputs. |
|
The direct DXIL backend counterpart of this fix, from @regiumlepidi's parity sweep on #1269:
How to take it: this PR predates the direct backend on patch (1 commit, for
|
|
Holding merge on |
|
RTX 5070 reproduction of the Direct DXIL sign issue, using a modern tree. Base tree: Windows x64, RTX 5070 driver 591.86, Rust 1.100.0 MSVC debug, DXC/DXIL 1.8.2502.11, local Agility SDK, explicit Command:
All three failing runs stop at lane 0, The failing assertion precedes the f16 assertions, so these failing runs do not establish f16 behavior. No proposed Direct DXIL fix, full suite, Release, native RDNA2 or retail validation in this experiment. All temporary source edits were restored and Local logs: AI assistance: OpenAI Codex moved the existing regression test temporarily, applied the existing HLSL expression as a control, ran the tests, restored source and drafted this report. |
frexp_mantreturned HLSLfrexp()'s mantissa, which is unsigned, sov_frexp_mant_f32gave a positive mantissa for a negative input (−10.125 → +0.6328125) and +0 for −0. The ISA keeps the sign, as XCL's f64 path (frexp_mant_d) already does. The helper now ORs the input's sign bit back in;v_frexp_mant_f16goes through the same helper. The diagnosis and the one-line fix are @joeypercia's (#580), who has no title for the regression run; they are credited with aCo-authored-bytrailer. Fixes #580.What is in it
crates/xcl/src/gpu/recomp/emit.rs:frexp_mantkeeps the input's signcrates/xcl/src/gpu/recomp/tests.rs:gpu_frexp_mant_f32_f16_keep_the_signrunsv_frexp_mant_f32(VOP1, and VOP3 with NEG),v_frexp_exp_i32_f32andv_frexp_mant_f16on negative inputs, −0, +0 and −inf, bit for bitTested
main9ce2070 without the fix: fails on the first negative input (v_frexp_mant_f32 0xc1220000: got0x3f220000, want0xbf220000); with the fix: 3 of 3 passed. The threefrexptests passcargo test --workspace -- --test-threads=4on d6d7906: 685 passed, 0 failed, 41 ignoredgpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardwareRegression run
main:
PR:
Not tested
v_frexp_mant_f32/_f16on negative inputs in those 60 sgpu_f32_math_and_bit_scans_random(21 more instructions) is not included; it belongs in its own test PRAI use