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

Manually merged
github merged 1 commit from gh-pr/38/head into gh-pr/38/base 2026-11-26 04:05:38 +00:00
Owner

@⁠grooving6 on GitHub · 2026-11-22 18:10 UTC · original
grooving6:fix/float-atomic-minmax → main · +176 −17 · 2 files · 1 commits · merged 2026-11-22 19:22 UTC

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.
**@⁠grooving6** on GitHub · 2026-11-22 18:10 UTC · [original](https://github.com/xcl-dev/xcl/pull/38) `grooving6:fix/float-atomic-minmax` → `main` · +176 −17 · 2 files · 1 commits · merged 2026-11-22 19:22 UTC ## 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]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:05:37 +00:00
github manually merged commit 145bc56ae3 into gh-pr/38/base 2026-11-26 04:05:38 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.