Skip to content

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

Merged
pigalot merged 1 commit into
R0Y00:mainfrom
xiaoqi72665:native/int32-minmax3
Nov 27, 2026
Merged

pigalot merged 1 commit into
R0Y00:mainfrom
xiaoqi72665:native/int32-minmax3

Conversation

@xiaoqi72665

Copy link
Copy Markdown
Contributor

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 5fc9f6f (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 (native compute: run wave32 direct modules on WARP (proposal, stage 1 claimed) #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 671d2f4 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).

@KelboLive

Copy link
Copy Markdown
Contributor

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.

@xiaoqi72665

Copy link
Copy Markdown
Contributor Author

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.

@pigalot pigalot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@pigalot
pigalot merged commit 6d69096 into R0Y00:main Nov 27, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tests: cover signed and unsigned 32-bit min3/max3/med3 in direct compute

3 participants