recomp: f64 abs / neg modifiers on the sign bit #72

Closed
github-bot wants to merge 2 commits from gh-pr/72/head into gh-pr/72/base
Owner

@⁠gefydev on GitHub · 2026-11-23 00:28 UTC · original
gefydev:recomp-f64-neg-sign-bit → main · +102 −43 · 4 files · 2 commits · closed without merging

On top of #71, which is what runs this test on NVIDIA. Only the last commit is new.

The f64 source modifiers are emitted as -x (NEG) and abs(x) (ABS). DXIL (LLVM 3.7) has no fneg, so DXC compiles -x as fsub double -0.0, x, and IEEE 754 doesn't define the sign of a NaN result there. AMD happens to flip it. On a GTX 1650, v_frexp_mant_f64 with NEG on 0x7FF8000000000001 returns 0x7FF8000000000001 instead of 0xFFF8000000000001:

assertion `left == right` failed: lane 8 v_frexp_mant_f64 neg
  left: 9221120237041090561
 right: 18444492273895866369

On RDNA the modifiers only flip or clear the sign bit, NaN included. f64v now applies them that way, to the high dword: asdouble(lo, hi ^ 0x80000000u) and asdouble(lo, hi & 0x7FFFFFFFu). For anything but NaN the value is the same as before.

f32 operands (fsrc) still use -x / abs(). I haven't seen a failing case there, so I left them alone.

Validation

GTX 1650, Windows 11, NVIDIA driver 32.0.16.2114 (and before that the same GPU on Linux with vkd3d-proton). On Windows, cargo test --workspace has 0 failures and gpu_frexp_f64_exp_and_mant runs and passes. The failure output above is from vkd3d-proton; on Windows I only ran it with the fix.

  • gpu_frexp_f64_exp_and_mant now uses gpu_ready_wave32. It fails without this commit (above) and passes with it.
  • f64_class_compare_vopc_and_vop3, frexp_f64_instructions and rndne_f64_instructions check the generated HLSL, so they now expect the new form.
  • cargo test -p xcl --lib: 0 failed on the GTX 1650 (19 SKIPPED) and without a GPU.
**@⁠gefydev** on GitHub · 2026-11-23 00:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/72) `gefydev:recomp-f64-neg-sign-bit` → `main` · +102 −43 · 4 files · 2 commits · closed without merging On top of #71, which is what runs this test on NVIDIA. Only the last commit is new. The f64 source modifiers are emitted as `-x` (NEG) and `abs(x)` (ABS). DXIL (LLVM 3.7) has no `fneg`, so DXC compiles `-x` as `fsub double -0.0, x`, and IEEE 754 doesn't define the sign of a NaN result there. AMD happens to flip it. On a GTX 1650, `v_frexp_mant_f64` with NEG on `0x7FF8000000000001` returns `0x7FF8000000000001` instead of `0xFFF8000000000001`: ``` assertion `left == right` failed: lane 8 v_frexp_mant_f64 neg left: 9221120237041090561 right: 18444492273895866369 ``` On RDNA the modifiers only flip or clear the sign bit, NaN included. `f64v` now applies them that way, to the high dword: `asdouble(lo, hi ^ 0x80000000u)` and `asdouble(lo, hi & 0x7FFFFFFFu)`. For anything but NaN the value is the same as before. f32 operands (`fsrc`) still use `-x` / `abs()`. I haven't seen a failing case there, so I left them alone. ## Validation GTX 1650, Windows 11, NVIDIA driver 32.0.16.2114 (and before that the same GPU on Linux with vkd3d-proton). On Windows, `cargo test --workspace` has 0 failures and `gpu_frexp_f64_exp_and_mant` runs and passes. The failure output above is from vkd3d-proton; on Windows I only ran it with the fix. - `gpu_frexp_f64_exp_and_mant` now uses `gpu_ready_wave32`. It fails without this commit (above) and passes with it. - `f64_class_compare_vopc_and_vop3`, `frexp_f64_instructions` and `rndne_f64_instructions` check the generated HLSL, so they now expect the new form. - `cargo test -p xcl --lib`: 0 failed on the GTX 1650 (19 `SKIPPED`) and without a GPU.
On an adapter without 64-lane waves (NVIDIA) every kernel test that
needs wave64 was skipped: 41 of them, most of which check instruction
semantics that do not depend on the wave size (f64, atomics, images,
typed buffers, scalar moves).

Options::hw_wave = 32 now runs a wave64 kernel as two native wave32
halves, as console mesh programs do there: lane_id covers both halves,
each half ORs its SGPRs into the zeroed result, so a lane mask gets
both words and a uniform value stays the same. runner::run_code and
run_code_with use it on such an adapter, and refuse a program that
needs both halves at once (geometry_wave32_hazards). The 22 tests
whose programs pass that check switch to gpu_ready_wave32.
The f64 NEG source modifier was emitted as -x and ABS as abs(x). DXIL
has no fneg: DXC writes -x as fsub -0.0, x, and IEEE leaves the sign
of a NaN result open, so a negated NaN kept its sign on NVIDIA
(v_frexp_mant_f64 with NEG on 0x7FF8000000000001). The hardware
modifiers only flip or clear the sign bit; they are now that, on the
high dword.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:08:01 +00:00
github-bot closed this pull request 2026-11-26 04:08:01 +00:00
Author
Owner

@⁠FZNull on GitHub · 2026-11-23 00:51 UTC · original

Validated on native Windows 11 (not Wine/vkd3d-proton): RTX 4060 (Ada, lane range 32..32), MSVC, DXC 1.8.2502.11 from SDK 10.0.26100.

  • base dd713e3 / PR head a7a2074 (this PR includes #71)
  • cargo test --workspace --no-fail-fast: 372 -> 373 passed, 0 failed, 34 ignored
  • SKIPPED ...: no wave64 drops from 41 to 19, so 22 GPU tests that never ran on this adapter now run and pass
  • cargo test -p xcl --lib: 343 -> 344 passed

No TDR, no device removal; mesh and e2e tests unaffected. Nothing from a game package was used.

AI-assisted.

**@⁠FZNull** on GitHub · 2026-11-23 00:51 UTC · [original](https://github.com/xcl-dev/xcl/pull/72#issuecomment-7088693467) Validated on native Windows 11 (not Wine/vkd3d-proton): RTX 4060 (Ada, lane range 32..32), MSVC, DXC 1.8.2502.11 from SDK 10.0.26100. - base `dd713e3` / PR head `a7a2074` (this PR includes #71) - `cargo test --workspace --no-fail-fast`: **372 -> 373 passed, 0 failed, 34 ignored** - `SKIPPED ...: no wave64` drops from **41 to 19**, so 22 GPU tests that never ran on this adapter now run and pass - `cargo test -p xcl --lib`: 343 -> 344 passed No TDR, no device removal; mesh and e2e tests unaffected. Nothing from a game package was used. _AI-assisted._
Author
Owner

@⁠ivall on GitHub · 2026-11-23 10:20 UTC · original

Landed as c2887bb (cherry-picked, authorship kept), without #71 – #67 already runs these kernels on 32-lane GPUs, so the test now gates on gpu_ready instead of gpu_ready_wave32. Passes on an RX 9070 natively and with XCL_SPLIT_WAVE64=1 (the 32-lane split form forced on RDNA). Closing here since the commit is on main. Thanks!

**@⁠ivall** on GitHub · 2026-11-23 10:20 UTC · [original](https://github.com/xcl-dev/xcl/pull/72#issuecomment-7097813370) Landed as c2887bb (cherry-picked, authorship kept), without #71 – #67 already runs these kernels on 32-lane GPUs, so the test now gates on `gpu_ready` instead of `gpu_ready_wave32`. Passes on an RX 9070 natively and with `XCL_SPLIT_WAVE64=1` (the 32-lane split form forced on RDNA). Closing here since the commit is on `main`. Thanks!

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.