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

Open
upipibi wants to merge 1 commit from upstream-pr/1301 into main
upipibi commented 2026-11-24 14:30:49 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by upipibi on 2026-11-24T14:30:49Z.


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

At the current head 88bbc77 (rebased onto main e99b0bd on 2026-12-03): NVIDIA GeForce RTX 3070, driver 621.40, Windows 11 Pro, rustc 1.100.0, debug.

  • cargo test -p xcl --lib -- --test-threads=4 (default, direct backend): 2864 passed, 0 failed, 37 ignored
  • gpu_min_max_order_minus_zero_below_plus_zero, 3 runs each with XCL_DIRECT_DXIL=0 and =1: 1 passed, 0 failed every run.

Earlier, at b4819a3:

  • 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

The pair below is for the earlier head b4819a3, before the 2026-12-03 rebase; a pair on 88bbc77 is needed.

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

<!-- greyfinch-sync:ivall/xcl:issue:5474121921 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1301). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-24T14:30:49Z. --- 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** At the current head 88bbc77 (rebased onto `main` e99b0bd on 2026-12-03): NVIDIA GeForce RTX 3070, driver 621.40, Windows 11 Pro, rustc 1.100.0, debug. - `cargo test -p xcl --lib -- --test-threads=4` (default, direct backend): 2864 passed, 0 failed, 37 ignored - `gpu_min_max_order_minus_zero_below_plus_zero`, 3 runs each with `XCL_DIRECT_DXIL=0` and `=1`: 1 passed, 0 failed every run. Earlier, at b4819a3: - 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** The pair below is for the earlier head b4819a3, before the 2026-12-03 rebase; a pair on 88bbc77 is needed. 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)
DarkPanda69 commented 2026-11-24 15:06:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-24T14:39:39Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7134738677 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1301#issuecomment-7134738677). Originally posted by [DarkPanda69](https://github.com/DarkPanda69) on 2026-11-24T14:39:39Z. --- 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.
futurepro62 commented 2026-11-24 15:06:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T14:33:16Z.


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.
<!-- greyfinch-sync:ivall/xcl:comment:7134565473 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1301#issuecomment-7134565473). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T14:33:16Z. --- 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.
ersinhf commented 2026-11-24 15:06:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ersinhf on 2026-11-24T14:42:14Z.


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.
<!-- greyfinch-sync:ivall/xcl:comment:7134810300 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1301#issuecomment-7134810300). Originally posted by [ersinhf](https://github.com/ersinhf) on 2026-11-24T14:42:14Z. --- 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.
DavidM1911 commented 2026-11-24 16:07:19 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T15:52:46Z.


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!

<!-- greyfinch-sync:ivall/xcl:comment:7136765449 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1301#issuecomment-7136765449). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T15:52:46Z. --- 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!
github-actions[bot] commented 2026-11-28 20:18:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-28T20:18:39Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7245192029 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1301#issuecomment-7245192029). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T20:18:39Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 05:22:34 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:22:34Z.


Triage (#1607) – head b4819a3

#1577 targets the same issue (#1282) differently: it wraps every f16/f32 min/max/min3/max3/pk_min/pk_max in new fmin_ieee / fmax_ieee helpers. This PR adds only a GPU test that pins the ISA's -0 < +0 ordering (f64 included) and reports that the current lowering already passes on NVIDIA and AMD. The two are different approaches, not duplicates.
No problems found in the diff. The PR conflicts with main.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7301704820 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1301#issuecomment-7301704820). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:22:34Z. --- **Triage (#1607)** – head b4819a3 #1577 targets the same issue (#1282) differently: it wraps every f16/f32 min/max/min3/max3/pk_min/pk_max in new `fmin_ieee` / `fmax_ieee` helpers. This PR adds only a GPU test that pins the ISA's -0 < +0 ordering (f64 included) and reports that the current lowering already passes on NVIDIA and AMD. The two are different approaches, not duplicates. No problems found in the diff. The PR conflicts with main. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
upipibi commented 2026-12-03 17:10:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by upipibi on 2026-12-03T17:10:18Z.


Rebased onto main e99b0bd (head 88bbc77, test-only). It still pins min/max ordering −0 below +0 on the GPU across drivers. RTX 3070, driver 621.40, debug:

  • gpu_min_max_order_minus_zero_below_plus_zero, 3 runs each with XCL_DIRECT_DXIL=0 and =1: 1 passed, 0 failed every run
  • cargo test -p xcl --lib -- --test-threads=4: 2864 passed, 0 failed, 37 ignored

Tested with the help of Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7386078089 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1301#issuecomment-7386078089). Originally posted by [upipibi](https://github.com/upipibi) on 2026-12-03T17:10:18Z. --- Rebased onto `main` `e99b0bd` (head `88bbc77`, test-only). It still pins min/max ordering −0 below +0 on the GPU across drivers. RTX 3070, driver 621.40, debug: - `gpu_min_max_order_minus_zero_below_plus_zero`, 3 runs each with `XCL_DIRECT_DXIL=0` and `=1`: 1 passed, 0 failed every run - `cargo test -p xcl --lib -- --test-threads=4`: 2864 passed, 0 failed, 37 ignored *Tested with the help of Claude Code (Claude Opus 5.5).*
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1301:upstream-pr/1301'
git switch 'upstream-pr/1301'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/1301'
git switch 'upstream-pr/1301'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1301'
git switch 'upstream-pr/1301'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1301'
git switch 'main'
git merge --squash 'upstream-pr/1301'
git switch 'main'
git merge --ff-only 'upstream-pr/1301'
git switch 'main'
git merge 'upstream-pr/1301'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1291
No description provided.