test: cover direct compute 32-bit integer min3 max3 and med3 #3185

Merged
xiaoqi72665 merged 1 commit from upstream-pr/3185 into main 2026-11-27 22:06:15 +00:00
xiaoqi72665 commented 2026-11-27 20:41:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by xiaoqi72665 on 2026-11-27T20:41:15Z.


Fixes #3184. Refs #2935, #1546.

Change

Add a focused direct-native regression for v_min3/max3/med3 in u32 and i32. The native compare/select lowering already exists (4036577); no production compiler change is needed. The prior Python/AOT implementations and tests are #1992, #1574, #1577 and #308.

  • Six individually compiled canonical forms; six clamp-refusal controls.
  • 11 source-built cases: all permutations of INT_MIN, INT_MAX and 0xffffffff, repeated values, equality, sparse guest EXEC, and an S0/destination alias. Two physical 32-thread groups. Compare the full 2,064-DWORD readback against a sorting-based independent CPU oracle, including all untouched guards and masked destination preservation.
  • Oracle checks distinguish wrong signedness (independently for every opcode), dropped S2, wrong rank and ignored EXEC.
  • Register native_int32_minmax3_controls and native_int32_minmax3_hardware following the existing native_sad pattern.

Verification

Clean builds on main 5fc9f6ff (includes #3155 and #3081), with only this test fixture/registration added. Both Debug and Release:

  • Registered focused CTest: controls PASS; stock native_store_replay hardware test capability SKIP (77, system SM6.5). Exit 0; not two executed passes.
  • Actual GPU execution with the same native compiler and fixture via an ignored local replay copy using the previously verified app-local Agility/WARP device setup (#3160): RX 7900 XT 11/11, WARP 1.0.22 11/11 per configuration. All 44 cases, 90,816 DWORD comparisons exact. The local device setup is not part of this patch.
  • Earlier verification on 671d2f46 also passed 44/44 cases; not added to final revision totals.

Environment: Windows 10 22H2 build 19045, RX7900XT driver 32.0.32029.2010, WARP 1.0.22.0, Agility 1.620.2 DLL-only, Windows SDK 10.0.26100.0, MSVC 19.44. Debug layer unavailable. Full physical waves deliberately avoid the independently reproduced WARP partial-wave ballot anomaly (#3160); sparse guest EXEC remains covered. No claim that the known WARP failure is fixed.

Standard commands:

cmake --build --preset dev --target compile_dxil native_store_replay
ctest --preset dev --no-tests=error -j 1 -R '^native_int32_minmax3_' -V
cmake --build --preset release --target compile_dxil native_store_replay
ctest --preset release --no-tests=error -j 1 -R '^native_int32_minmax3_' -V

On this Win10 machine, the actual readback additionally used the locally built replay copy with explicit device-factory/Agility exports, not a capability bypass.

Public source-generated fixtures only. AI-assisted; tested locally by Buhe (@xiaoqi72665).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5532829036 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3185). Originally posted by [xiaoqi72665](https://github.com/xiaoqi72665) on 2026-11-27T20:41:15Z. --- Fixes #3184. Refs #2935, #1546. ## Change Add a focused direct-native regression for v_min3/max3/med3 in u32 and i32. The native compare/select lowering already exists (4036577); no production compiler change is needed. The prior Python/AOT implementations and tests are #1992, #1574, #1577 and #308. - Six individually compiled canonical forms; six clamp-refusal controls. - 11 source-built cases: all permutations of INT_MIN, INT_MAX and 0xffffffff, repeated values, equality, sparse guest EXEC, and an S0/destination alias. Two physical 32-thread groups. Compare the full 2,064-DWORD readback against a sorting-based independent CPU oracle, including all untouched guards and masked destination preservation. - Oracle checks distinguish wrong signedness (independently for every opcode), dropped S2, wrong rank and ignored EXEC. - Register native_int32_minmax3_controls and native_int32_minmax3_hardware following the existing native_sad pattern. ## Verification Clean builds on main 5fc9f6ff (includes #3155 and #3081), with only this test fixture/registration added. Both Debug and Release: - Registered focused CTest: controls PASS; stock native_store_replay hardware test capability SKIP (77, system SM6.5). Exit 0; not two executed passes. - Actual GPU execution with the same native compiler and fixture via an ignored local replay copy using the previously verified app-local Agility/WARP device setup (#3160): RX 7900 XT 11/11, WARP 1.0.22 11/11 per configuration. All 44 cases, 90,816 DWORD comparisons exact. The local device setup is not part of this patch. - Earlier verification on 671d2f46 also passed 44/44 cases; not added to final revision totals. Environment: Windows 10 22H2 build 19045, RX7900XT driver 32.0.32029.2010, WARP 1.0.22.0, Agility 1.620.2 DLL-only, Windows SDK 10.0.26100.0, MSVC 19.44. Debug layer unavailable. Full physical waves deliberately avoid the independently reproduced WARP partial-wave ballot anomaly (#3160); sparse guest EXEC remains covered. No claim that the known WARP failure is fixed. Standard commands: ```powershell cmake --build --preset dev --target compile_dxil native_store_replay ctest --preset dev --no-tests=error -j 1 -R '^native_int32_minmax3_' -V cmake --build --preset release --target compile_dxil native_store_replay ctest --preset release --no-tests=error -j 1 -R '^native_int32_minmax3_' -V ``` On this Win10 machine, the actual readback additionally used the locally built replay copy with explicit device-factory/Agility exports, not a capability bypass. Public source-generated fixtures only. AI-assisted; tested locally by Buhe (@xiaoqi72665).
KelboLive commented 2026-11-27 21:16:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T21:16:45Z.


LGTM on the min3/max3/med3 test coverage.\n\nNote: Like #3187, this PR removes v_cvt_f16_* conversions from the direct compute path. Please clarify if these are being moved to a different code path or deprecated.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7228299410 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3185#issuecomment-7228299410). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-27T21:16:45Z. --- LGTM on the min3/max3/med3 test coverage.\n\n**Note:** Like #3187, this PR **removes** `v_cvt_f16_*` conversions from the direct compute path. Please clarify if these are being moved to a different code path or deprecated.
xiaoqi72665 commented 2026-11-27 21:25:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by xiaoqi72665 on 2026-11-27T21:25:29Z.


Thanks for checking! #3159 merged at 20:43:02 UTC, 107 seconds after this PR was opened. The old branch lacked that newer commit; our three-dot diff never removed the conversions. Rebased onto 5b145ca as 81693c1; range-diff is identical and the Files changed are still only two added test files (+139/-0). All of src/ and the #3159 test files match upstream byte-for-byte.

Fresh Debug/Release: conversion IR (82 cases, 38 refusals), DXIL controls, and min/max/median controls passed in both builds. Stock GPU tests skip 77 on this Win10 machine. With the local Agility replay, min/max/median passed 44/44 cases on RX 7900 XT and WARP. The conversion GPU fixture reaches its final guard check but hits an existing F.SENTINEL AttributeError; a local diagnostic copy using an exact full-buffer sentinel comparison passed all 82 conversions across two groups on both adapters in both builds. No conversion code or tests were changed in this PR.

AI-assisted; locally verified by Buhe.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7228431656 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3185#issuecomment-7228431656). Originally posted by [xiaoqi72665](https://github.com/xiaoqi72665) on 2026-11-27T21:25:29Z. --- Thanks for checking! #3159 merged at 20:43:02 UTC, 107 seconds after this PR was opened. The old branch lacked that newer commit; our three-dot diff never removed the conversions. Rebased onto `5b145ca` as `81693c1`; range-diff is identical and the [Files changed](https://github.com/R0Y00/Xbox2Windows/pull/3185/files) are still only two added test files (+139/-0). All of `src/` and the #3159 test files match upstream byte-for-byte. Fresh Debug/Release: conversion IR (82 cases, 38 refusals), DXIL controls, and min/max/median controls passed in both builds. Stock GPU tests skip 77 on this Win10 machine. With the local Agility replay, min/max/median passed 44/44 cases on RX 7900 XT and WARP. The conversion GPU fixture reaches its final guard check but hits an existing `F.SENTINEL` AttributeError; a local diagnostic copy using an exact full-buffer sentinel comparison passed all 82 conversions across two groups on both adapters in both builds. No conversion code or tests were changed in this PR. AI-assisted; locally verified by Buhe.
pigalot commented 2026-11-27 22:05:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T22:05:41Z.

Review: APPROVED


I reviewed 81693c16 merged over main 5612e924. The merge is clean (tree 9fdc4f0b) and git diff --cached --check is clean. The PR only adds a test and its registration.

What I traced.

  • Coverage: on main, no tests/native_*.py exercises VOP3 opcodes 0x152..0x159, so this is the first direct-native fixture for the six integer min3/max3/med3 forms.
  • Encodings: the fixture's encodings match the GFX10 VOP3 opcodes for v_{min,max,med}3_{i,u}32.
  • Oracle: the reference sorts the three operands with a signed or unsigned key and picks rank 0, 1 or 2. That is an independent model of the lowering's bound(...) select chain at gfx1013_direct_compute.inl.
  • EXEC: under sparse EXEC, inactive lanes keep SEED, and the aliased signed-median destination keeps S0.

What I ran. I built compile_dxil native_store_replay in dev and release, then ran

python .agentic\scripts\with_gpu_lock.py ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^(native_int32_minmax3_(controls|hardware)|native_direct_container)$'
  • Results: 3/3 pass in Debug and Release /O2, with no skips. native_int32_minmax3_hardware executed all 11 cases on the GPU, and each matched all 2,064 words.
  • Not a skip here: the PR body reports a 77 skip for the registered hardware test on its machine. On this one it ran.

Negative controls. The production lowering is unchanged, so I mutated it in src/gfx1013_direct_compute.inl. For each, I rebuilt in dev and ran both tests:

Mutant Result
signed_order = false (i32 compared unsigned) killed (first triple: 0x7fffffff vs 0x80000000 at word 11)
min3/max3 drop the S2 bound killed (word 9: 0x80000000 vs 0xffffffff)
med3 inner max(a, b) replaced with min(a, b) killed (word 10)

Restored and rebuilt afterwards; git diff --quiet is clean.

Verdict: approve on 81693c16.

Environment: NVIDIA GeForce RTX 5090 driver 610.88, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Windows SDK 10.0.28000.0 DXC, Python 3.12.10, wave32, debug layer off.
CI: Build and test on Windows passes on 81693c16.

This reply was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6093796068 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3185#pullrequestreview-6093796068). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-27T22:05:41Z. **Review:** APPROVED --- I reviewed `81693c16` merged over `main` `5612e924`. The merge is clean (tree `9fdc4f0b`) and `git diff --cached --check` is clean. The PR only adds a test and its registration. **What I traced.** - **Coverage:** on `main`, no `tests/native_*.py` exercises VOP3 opcodes `0x152`..`0x159`, so this is the first direct-native fixture for the six integer min3/max3/med3 forms. - **Encodings:** the fixture's encodings match the GFX10 VOP3 opcodes for `v_{min,max,med}3_{i,u}32`. - **Oracle:** the reference sorts the three operands with a signed or unsigned key and picks rank 0, 1 or 2. That is an independent model of the lowering's `bound(...)` select chain at `gfx1013_direct_compute.inl`. - **EXEC:** under sparse EXEC, inactive lanes keep `SEED`, and the aliased signed-median destination keeps S0. **What I ran.** I built `compile_dxil native_store_replay` in `dev` and `release`, then ran ```powershell python .agentic\scripts\with_gpu_lock.py ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^(native_int32_minmax3_(controls|hardware)|native_direct_container)$' ``` - **Results:** 3/3 pass in Debug and Release `/O2`, with no skips. `native_int32_minmax3_hardware` executed all 11 cases on the GPU, and each matched all 2,064 words. - **Not a skip here:** the PR body reports a 77 skip for the registered hardware test on its machine. On this one it ran. **Negative controls.** The production lowering is unchanged, so I mutated it in `src/gfx1013_direct_compute.inl`. For each, I rebuilt in `dev` and ran both tests: | Mutant | Result | |---|---| | `signed_order = false` (i32 compared unsigned) | killed (first triple: `0x7fffffff` vs `0x80000000` at word 11) | | min3/max3 drop the S2 bound | killed (word 9: `0x80000000` vs `0xffffffff`) | | med3 inner `max(a, b)` replaced with `min(a, b)` | killed (word 10) | Restored and rebuilt afterwards; `git diff --quiet` is clean. **Verdict:** approve on `81693c16`. Environment: NVIDIA GeForce RTX 5090 driver 610.88, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Windows SDK 10.0.28000.0 DXC, Python 3.12.10, wave32, debug layer off. CI: `Build and test on Windows` passes on `81693c16`. This reply was AI-assisted.
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
R0Y00/Xbox2Windows!3185
No description provided.