Direct DXIL: truncate s instead of returning native on special values in round_exact #1898
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1898
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1898/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?
@emirduran707 on GitHub · 2026-11-24 22:39 UTC · original
emirduran707:dxil-round-denorm-inf-nan→main· +37 −17 · 2 files · 1 commits · merged 2026-11-24 23:55 UTCIn directed f32 rounding (
crates/xcl/src/gpu/dxil/lower_round.rs, #1679),round_exactreturned the native D3D12 f32 result (native) whenever the f64 valueswas±inforNaN(ex == 0x7FF). Becausenativeis computed with D3D12's default f32 denormal behaviour rather thanMODE's input denormal control (ext_exact),v_mul_f32(denormal, +inf)andv_fma_f32(denormal, +inf, 1.0)returnedNaN(0xffc00000) instead of+inf(0x7f800000) when input denormals are preserved (MODE_INIT), and can similarly disagree when input denormals are flushed.salready holds the exact f64±inf/NaNcomputed from theMODE-aware inputs:round_exactnow truncatessdirectly withFPTruncon thespecialpath, and the unusednativeparameter is removed fromround_exactandround_sum.What is in it
crates/xcl/src/gpu/dxil/lower_round.rs: truncatesviaFPTrunconex == 0x7FFinround_exactinstead of returningnative; drop unusednativeparameter fromround_exactandround_sum.crates/xcl/src/gpu/dxil/round_tests.rs: GPU testgpu_direct_f32_round_preserved_denormal_times_inf_is_infcheckingv_mul_f32(0x0000_0001, +inf)andv_fma_f32(0x0000_0001, +inf, 1.0)under directed rounding with preserved denormals.Tested
cargo test --workspace --no-fail-fast -- --test-threads=4one1217e7: 974 passed, 2 failed, 45 ignored; 8 SKIPPED (6 inlower_dxil::tests::{f16,f32}_programs_on_the_gpu;heap_window_out_of_memory_falls_back_to_the_switch_form;pso_measurement_compiles_an_exact_synthetic_record)gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1seed 722 andfuzz_validate_and_gpu_3seed 1599) fail identically on unmodifiedmain689f2dbon this GPU.cargo test -p xcl --lib round_tests -- --test-threads=4: 5 passed, 0 failedgpu_direct_f32_round_preserved_denormal_times_inf_is_infbefore the change failed (v_mul_f32(denorm, +inf) with preserve = 0xffc00000, expected +inf); passes afterRegression run
main:
this PR:
Not tested
AI use
sinstead of returningnativeon special values inround_exacte1217e762c@upipibi on GitHub · 2026-11-24 22:41 UTC · original
NVIDIA counterpart to the Radeon run: RTX 3070 8 GB, driver 616.56, Windows 11, debug,
e1217e7onmain689f2db.gpu_direct_f32_round_preserved_denormal_times_inf_is_inf: passes, 2 of 2 runs.round: 29 passed, 0 failed.AI-assisted (Claude Code). Synthetic tests only.
@DavidM1911 on GitHub · 2026-11-25 02:07 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!