Tests: float min / max order -0 below +0 on the GPU #1301

Open
github-bot wants to merge 1 commit from github-bot/gh-1301 into main AGit
Owner

@⁠upipibi on GitHub · 2026-11-24 14:30 UTC · original
upipibi:fix/minmax-signed-zero → main · +77 −0 · 1 files · 1 commits · open

The RDNA2 ISA defines min(+0, -0) = min(-0, +0) = -0 and max(+0, -0) = max(-0, +0) = +0 for V_MIN/MAX_F32, _F16 and _F64, ahead of the IEEE_MODE branch. min3 / max3 are nested min / max. XCL emits HLSL min / max, whose DXIL FMin / FMax leave the sign of a zero result to the driver. #1282 proposes bit-level helpers around every min / max. This PR adds the GPU test instead. On the driver below the current lowering already gives the ISA's results, so the test pins that behaviour and fails on any driver that does not, without adding HLSL to every min / max (#1269).

Test-only. Part of #1282.

What is in it

  • crates/xcl/src/gpu/recomp/tests.rs: gpu_min_max_order_minus_zero_below_plus_zero. It covers v_min/max_f32, v_min3/max3_f32, v_min/max_f16, v_pk_min/max_f16 and v_min/max_f64 with (+0, -0) and (-0, +0), and compares result bits, in wave32 and wave64 (the split form on this GPU).

Tested

  • NVIDIA GeForce RTX 3070, driver 616.56; Windows 11 Pro 26100; Rust 1.100.0 MSVC; debug.
  • The new test passes on main's emitter.
  • cargo build --workspace + cargo test --workspace --no-fail-fast -- --test-threads=4 at b4819a3: 751 passed, 1 failed, 41 ignored.
    • The failure is hle::xaudio2::tests::opus_source_voice_decodes_and_manages_lifetime (the voice never starts: STARTED 0). It failed the same way on main 930e8b4 while a parallel 24-thread C++ build had the CPU, and passed in a later full suite on this PC once that build was done: it gives the voice 3 s to start, so it is load-sensitive here, not affected by this change.
    • SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • XCL_ADAPTER=warp: the test skips, because WARP has neither 32- nor 64-lane waves. So WARP is not covered.

Regression run
Not needed: test-only change.

Not tested

  • AMD (native v_min / v_max, which order the zeros themselves), Intel, WARP.

AI use

  • Claude Code (Claude Opus 5.5) wrote the test and this description, and ran it.

🤖 Generated with Claude Code

**@⁠upipibi** on GitHub · 2026-11-24 14:30 UTC · [original](https://github.com/xcl-dev/xcl/pull/1301) `upipibi:fix/minmax-signed-zero` → `main` · +77 −0 · 1 files · 1 commits · open The RDNA2 ISA defines `min(+0, -0) = min(-0, +0) = -0` and `max(+0, -0) = max(-0, +0) = +0` for `V_MIN/MAX_F32`, `_F16` and `_F64`, ahead of the IEEE_MODE branch. `min3` / `max3` are nested min / max. XCL emits HLSL `min` / `max`, whose DXIL `FMin` / `FMax` leave the sign of a zero result to the driver. #1282 proposes bit-level helpers around every min / max. This PR adds the GPU test instead. On the driver below the current lowering already gives the ISA's results, so the test pins that behaviour and fails on any driver that does not, without adding HLSL to every min / max (#1269). Test-only. Part of #1282. **What is in it** - `crates/xcl/src/gpu/recomp/tests.rs`: `gpu_min_max_order_minus_zero_below_plus_zero`. It covers `v_min/max_f32`, `v_min3/max3_f32`, `v_min/max_f16`, `v_pk_min/max_f16` and `v_min/max_f64` with `(+0, -0)` and `(-0, +0)`, and compares result bits, in wave32 and wave64 (the split form on this GPU). **Tested** - NVIDIA GeForce RTX 3070, driver 616.56; Windows 11 Pro 26100; Rust 1.100.0 MSVC; debug. - The new test passes on `main`'s emitter. - `cargo build --workspace` + `cargo test --workspace --no-fail-fast -- --test-threads=4` at `b4819a3`: 751 passed, 1 failed, 41 ignored. - The failure is `hle::xaudio2::tests::opus_source_voice_decodes_and_manages_lifetime` (the voice never starts: `STARTED` 0). It failed the same way on `main` `930e8b4` while a parallel 24-thread C++ build had the CPU, and passed in a later full suite on this PC once that build was done: it gives the voice 3 s to start, so it is load-sensitive here, not affected by this change. - SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - `XCL_ADAPTER=warp`: the test skips, because WARP has neither 32- nor 64-lane waves. So WARP is not covered. **Regression run** Not needed: test-only change. **Not tested** - AMD (native `v_min` / `v_max`, which order the zeros themselves), Intel, WARP. **AI use** - Claude Code (Claude Opus 5.5) wrote the test and this description, and ran it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The RDNA 2 ISA defines min(+0, -0) = min(-0, +0) = -0 and
max(+0, -0) = max(-0, +0) = +0 for V_MIN/MAX_F32, _F16 and _F64, ahead
of the IEEE_MODE branch, and min3 / max3 are nested min / max. XCL
emits HLSL min / max, whose DXIL FMin / FMax leave the sign of a zero
result to the driver.

gpu_min_max_order_minus_zero_below_plus_zero checks the ISA result for
v_min/max_f32, v_min3/max3_f32, v_min/max_f16, v_pk_min/max_f16 and
v_min/max_f64, comparing bits. It passes on an RTX 3070 (616.56) on
main, so it pins the behaviour for other drivers rather than fixing a
bug.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:50:02 +00:00
Author
Owner

@⁠DarkPanda69 on GitHub · 2026-11-24 14:39 UTC · original

AMD result, which this PR lists as not tested.

Tested: pass, head b4819a3 applied on main 930e8b4, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17.
cargo test -p xcl --lib -- gpu::recomp --test-threads=4:

  • AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010, native wave64: 190 passed, 0 failed, 18 ignored, 0 SKIPPED. gpu_min_max_order_minus_zero_below_plus_zero ok.
  • NVIDIA RTX 3060, driver 32.0.16.1088: 190 passed, 0 failed, 18 ignored, 2 SKIPPED (no wave64). gpu_min_max_order_minus_zero_below_plus_zero ok.

Not tested: Intel, WARP; the whole workspace suite.

AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

**@⁠DarkPanda69** on GitHub · 2026-11-24 14:39 UTC · [original](https://github.com/xcl-dev/xcl/pull/1301#issuecomment-7134738677) AMD result, which this PR lists as not tested. **Tested:** pass, head `b4819a3` applied on `main` `930e8b4`, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17. `cargo test -p xcl --lib -- gpu::recomp --test-threads=4`: - AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010, native wave64: 190 passed, 0 failed, 18 ignored, 0 SKIPPED. `gpu_min_max_order_minus_zero_below_plus_zero` ok. - NVIDIA RTX 3060, driver 32.0.16.1088: 190 passed, 0 failed, 18 ignored, 2 SKIPPED (no wave64). `gpu_min_max_order_minus_zero_below_plus_zero` ok. **Not tested:** Intel, WARP; the whole workspace suite. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-24 14:33 UTC · original · edited 2026-11-24 14:40 UTC

Full-suite run, since this PR has no test report yet. Tested exact head b4819a3 (on its base 930e8b4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: gpu_min_max_order_minus_zero_below_plus_zero.
  • Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, no skips.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-24 14:33 UTC · [original](https://github.com/xcl-dev/xcl/pull/1301#issuecomment-7134565473) · edited 2026-11-24 14:40 UTC Full-suite run, since this PR has no test report yet. Tested exact head `b4819a3` (on its base `930e8b4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4`: **752 passed, 0 failed, 41 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - The new tests ran and passed: `gpu_min_max_order_minus_zero_below_plus_zero`. - Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4`: **752 passed, 0 failed, 41 ignored**, no skips. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠ersinhf on GitHub · 2026-11-24 14:42 UTC · original

Ada and a newer NVIDIA driver (the reports so far are a 3070 on 616.56 and a 5070 Ti on 616.64). Exact head b4819a3, clean tree, on its base 930e8b4.

Tested

  • NVIDIA GeForce RTX 4070 (Ada, 32-lane waves), driver 621.14 (32.0.16.2114); AMD Ryzen 5 7500F, 32 GB; Windows 11 build 26200; rustc 1.100.0 stable-x86_64-pc-windows-msvc; DXC 1.9.2602.17 (SDK 10.0.26100.0); no XCL_SAMPLE_* set
  • cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4 (debug): 752 passed, 0 failed, 41 ignored; the same in release: 752 passed, 0 failed, 41 ignored
  • SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware
  • gpu_min_max_order_minus_zero_below_plus_zero ran (no skip) and passed, three more runs on its own as well: this driver gives the ISA's signed zeros for every form the test covers
  • hle::xaudio2::tests::opus_source_voice_decodes_and_manages_lifetime passes here in both builds, so the failure in the description does look local to that PC
  • XCL_ADAPTER=warp: the test skips (no wave64), as the description says

Does the test catch a wrong lowering? Two local edits of emit.rs's v_min_f32 line, reverted after:

  • the result replaced by a constant: the test fails and lists every v_min_f32 case (v_min_f32(-0.0, 0.0) = 0x12345678, want 0x80000000, …), so that line is the one it exercises
  • min(a, b) replaced by (a < b ? a : b), which returns +0 for (-0, +0) as written: the test still passes. My reading (not verified in the DXIL) is that DXC turns the compare-and-select back into FMin, since its default float model ignores the sign of zero. If that is right, it bears on #1282's suggestion: a fix written as HLSL compares could be folded away in the same way, while the bit operations it proposes (asuint(a) | asuint(b)) would not be. It also means this test checks the driver's FMin / FMax, which is what the PR says it pins.

Not tested

  • Intel, and WARP (skipped for lack of 32- / 64-lane waves)
  • the DXIL of the compare-and-select variant (the FMin reading above is inferred from the result only)

AI use

  • Claude Code with Claude Opus 5.5 ran the builds, the suites and the two local edits on this machine and wrote this comment; the person posting it checked each point.
**@⁠ersinhf** on GitHub · 2026-11-24 14:42 UTC · [original](https://github.com/xcl-dev/xcl/pull/1301#issuecomment-7134810300) Ada and a newer NVIDIA driver (the reports so far are a 3070 on 616.56 and a 5070 Ti on 616.64). Exact head `b4819a3`, clean tree, on its base `930e8b4`. **Tested** - NVIDIA GeForce RTX 4070 (Ada, 32-lane waves), driver 621.14 (32.0.16.2114); AMD Ryzen 5 7500F, 32 GB; Windows 11 build 26200; rustc 1.100.0 `stable-x86_64-pc-windows-msvc`; DXC 1.9.2602.17 (SDK 10.0.26100.0); no `XCL_SAMPLE_*` set - `cargo build --workspace`, then `cargo test --workspace --no-fail-fast -- --test-threads=4` (debug): **752 passed, 0 failed, 41 ignored**; the same in release: **752 passed, 0 failed, 41 ignored** - SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware` - `gpu_min_max_order_minus_zero_below_plus_zero` ran (no skip) and passed, three more runs on its own as well: this driver gives the ISA's signed zeros for every form the test covers - `hle::xaudio2::tests::opus_source_voice_decodes_and_manages_lifetime` passes here in both builds, so the failure in the description does look local to that PC - `XCL_ADAPTER=warp`: the test skips (`no wave64`), as the description says **Does the test catch a wrong lowering?** Two local edits of `emit.rs`'s `v_min_f32` line, reverted after: - the result replaced by a constant: the test fails and lists every `v_min_f32` case (`v_min_f32(-0.0, 0.0) = 0x12345678, want 0x80000000`, …), so that line is the one it exercises - `min(a, b)` replaced by `(a < b ? a : b)`, which returns `+0` for `(-0, +0)` as written: the test still **passes**. My reading (not verified in the DXIL) is that DXC turns the compare-and-select back into `FMin`, since its default float model ignores the sign of zero. If that is right, it bears on #1282's suggestion: a fix written as HLSL compares could be folded away in the same way, while the bit operations it proposes (`asuint(a) | asuint(b)`) would not be. It also means this test checks the driver's `FMin` / `FMax`, which is what the PR says it pins. **Not tested** - Intel, and WARP (skipped for lack of 32- / 64-lane waves) - the DXIL of the compare-and-select variant (the `FMin` reading above is inferred from the result only) **AI use** - Claude Code with Claude Opus 5.5 ran the builds, the suites and the two local edits on this machine and wrote this comment; the person posting it checked each point.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 15:52 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib -- --test-threads=1: all passed, 0 failed, 21 ignored. (Parallel runs intermittently abort with 0xc0000005 — same harness flake seen on unmodified main.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 15:52 UTC · [original](https://github.com/xcl-dev/xcl/pull/1301#issuecomment-7136765449) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib -- --test-threads=1`: all passed, 0 failed, 21 ignored. (Parallel runs intermittently abort with 0xc0000005 — same harness flake seen on unmodified `main`.) Thanks!
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1301/head:github-bot/gh-1301'
git switch 'github-bot/gh-1301'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1301'
git switch 'github-bot/gh-1301'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1301'
git switch 'github-bot/gh-1301'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1301'
git switch 'main'
git merge --squash 'github-bot/gh-1301'
git switch 'main'
git merge --ff-only 'github-bot/gh-1301'
git switch 'main'
git merge 'github-bot/gh-1301'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.