Skip to content

Float atomic min/max: handle -0.0 and f64 operands - #38

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
grooving6:fix/float-atomic-minmax
Nov 22, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
grooving6:fix/float-atomic-minmax

Conversation

@grooving6

Copy link
Copy Markdown
Contributor

Summary

  • Route f32 and f64 memory min/max atomics through sign-aware integer atomics so -0.0 takes the negative-value path.
  • Add translation and GPU coverage for f64 atomics across buffer, flat, and global memory, including -0.0 results and GLC return values.

Testing

  • Added translation checks for native 64-bit atomic generation and memory-window accessors.
  • Added GPU tests for f32 -0.0 operands and f64 min/max across buffer, flat, and global memory.
  • DXC compilation runs in the translation test when DXC is available; GPU tests return early when no GPU is available.

The translator turns buffer / flat / global atomic fmin / fmax into one
integer atomic, chosen by the operand's sign. It tested the sign with
asfloat(v) >= 0.0f, which is true for -0.0, so -0.0 took the signed
path, where its bits (0x80000000) are the smallest int. On an RX 7900
XTX, global_atomic_fmin on -5.0 with -0.0 stored -0.0, and fmax left
-5.0 in place.

The choice now compares the bits with +inf's (0x7F800000): the signed
path for +0.0 to +inf, the unsigned path for -0.0, negative values and
NaNs. Only -0.0 changes path. One helper, float_minmax_mem, replaces the
two copies (FLAT / GLOBAL and rmw32).

The same helper gives buffer / flat / global_atomic_fmin_x2 / fmax_x2
with InterlockedMin64 / Max64, without a CAS loop like the f32 forms.
ISA coverage: 1034 -> 1040 of 1157; FLAT, FLAT_GLBL and MUBUF complete.

Tests: gpu_atomic_fmin_fmax_negative_zero (fails before the fix on
global and buffer), atomic_fmin_fmax_x2_are_native_64_bit_atomics
(HLSL shape, DXC with one and two memory windows), gpu_atomic_fmin_fmax_x2
(all three families on the GPU: 64 lanes racing, the -0.0 cases, GLC).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivall
ivall merged commit cf08a50 into xcl-dev:main Nov 22, 2026
@grooving6
grooving6 deleted the fix/float-atomic-minmax branch November 22, 2026 19:25
CalvyPZ pushed a commit to CalvyPZ/xcl that referenced this pull request Nov 24, 2026
Add standalone host-driver parity and contract tests for D3D12.X's
memory-layout and copy-footprint query hooks (Part of xcl-dev#480):
GetResourceAllocationInfo (xcl-dev#25), GetResourceAllocationInfo2 (console
xcl-dev#108 vs PC ID3D12Device8 xcl-dev#68), GetCustomHeapProperties (xcl-dev#26), and
GetCopyableFootprints (xcl-dev#38).

No runtime files outside crates/xcl/tests/ are modified. Full suite
(.\scripts\test.ps1) passed 895 passed, 0 failed, 42 ignored (1 GPU
test skipped: heap_window_out_of_memory_falls_back_to_the_switch_form).

Part of xcl-dev#480
Assisted-by: Antigravity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants