Direct DXIL: guard NaN operands in 32-bit and 64-bit float_minmax_mem #3283
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3283"
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?
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T04:40:17Z.
What is in it
Guards NaN operands in Direct DXIL 32-bit and 64-bit memory float min/max atomics (
buffer_atomic_fmin,buffer_atomic_fmax,global_atomic_fmin,global_atomic_fmax,flat_atomic_fmin,flat_atomic_fmax, and their_x264-bit variants) incrates/xcl/src/gpu/dxil/lower_mem.rs:float_minmax_mem(32-bit) andatomic64"fmin" | "fmax"(64-bit), checks whether the incoming operand is NaN ((v & 0x7FFF_FFFF) > 0x7F80_0000for f32,(v & 0x7FFF_FFFF_FFFF_FFFF) > 0x7FF0_0000_0000_0000for f64).AtomicOp::Orwith0instead of comparing and exchanging, preserving IEEE-754 / RDNA2minNum/maxNumsemantics (neither+qNaNnor-qNaNoverwrites finite memory) while still returning the prior memory value whenGLC=1.direct_atomic_fmin_fmax_nan_preserves_memoryincrates/xcl/src/gpu/dxil/core_tests.rs(guarded byrunner::wave32_supported()for headless/no-GPU runners) verifying 32-bit and 64-bit global/bufferfmin/fmaxwith+qNaNand-qNaNagainst positive and negative finite values, includingGLC=1return values.recomp/emit.rsandrecomp/tests.rs); this PR targets the default Direct DXIL backend (dxil/lower_mem.rsanddxil/core_tests.rs) with zero file overlap.Tested
Hardware:
NVIDIA GeForce RTX 5070 Ti(driver32.0.16.1074),AMD Ryzen 9 9950X,Windows 11 Pro (Build 26200),rustc 1.99.0 (b940084d7),XCL_DXC_DIRwith DXC1.9.2609.5.cargo check --workspace --all-targets: 0 errors.cargo test --lib direct_atomic_fmin_fmax_nan_preserves_memory gpu_atomic_fmin_fmax_x2 gpu_atomic_fmin_fmax -- --test-threads=1): 3 passed, 0 failed.cargo test --workspace -- --test-threads=4): 2609 passed, 0 failed, 49 ignored (26SKIPPED: 21no wave64on NVIDIA wave32, 3 pre-existing#1426f16 refusals, 2no heap windows).Regression run
main-ancestor baseline (f0e8fdd5c3942ddd399d5ee11384c8595c5aacff):This branch (
de4ebbb23ac84689501e59709cf6149e7a390ba9, 0 minidumps, 0 System display events):Not tested
fmin/fmaxwith a finite operand (this PR guards NaN source operands only).AI use
Written, verified, and tested with an AI coding assistant (
Antigravity), with all targeted GPU tests, full workspace tests, and 150 sxcl-smokeruns executed on local hardware.Imported from ivall/xcl. Originally posted by Foniass on 2026-11-29T14:57:26Z.
Note: since this run the PR conflicts with main (
3b6a91ed). The result above is for this head merged onto the base named above.Merge-check run and written with Claude Code (Claude Opus 5.5): a test merge onto the base above, the full suite, and a 60 s
scripts/smoke.ps1run of a retail title against main on the same machine. The 4fuzz_validate_and_gpu_*failures happen on main on this machine too.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-01T21:12:35Z.
Code review location:
crates/xcl/src/gpu/dxil/lower_mem.rs; line 1803The operand-NaN guard looks right, but a NaN already in memory still isn't replaced. The signed/unsigned integer-atomic trick only follows minNum/maxNum when memory is finite. fmin with mem=-qNaN (0xFFC00000), v=1.0: pp is true, and IMin(-4194304, 0x3F800000) keeps 0xFFC00000, while minNum (and the LDS CAS+fmin path) gives 1.0. fmin mem=-qNaN, v=-1.0: UMax keeps the NaN. fmax mem=+qNaN (0x7FC00000), v=2.0: IMax keeps the NaN. Once a NaN gets into memory, every later fmin/fmax of that sign class sticks to it. The 64-bit copy (~1871) has the same problem. Sending NaN-involved cases through the existing CAS path, as rmw32 does for LDS, would cover both sides.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-01T21:12:35Z.
Review: COMMENTED
Review of
de4ebbb2: 1 finding(s). 1 are inline.These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.