Repository navigation
shader: lower v_min_f16 and v_max_f16 in the direct compute path - #3125
Conversation
tedin7
left a comment
There was a problem hiding this comment.
Review of eeaa3d7 (comment only, no Windows run yet).
The ordering key (negative values mapped below -0, then a signed compare), the NaN handling and the kept D[31:16] read correctly to me.
One thing should change before merge: inline float constants. half_src takes operand32(i, i.src[j]) and keeps the low 16 bits, but for sources 240-248 operand32 returns the f32 bit pattern. For 0.5, 1.0, 2.0, 4.0 and their negatives that low half is 0, so v_max_f16 v4, 1.0, v3 compares against +0 instead of 1.0h. The v_add_f16 block in the same file maps these sources through halves[]. Could you do the same, or refuse 240-248, and add an inline-constant case to the fixture? The same point was raised on #3135 and applies to #3123 and the merged #3120, so one follow-up could cover all of them.
Command: git diff origin/main...pull/3125/head -- src/ (read), compared with the v_add_f16 operand path in src/gfx1013_direct_compute.inl.
AI-assisted; commands listed were executed locally.
KelboLive
left a comment
There was a problem hiding this comment.
Correct lowering of v_min_f16 and v_max_f16 using exact integer-based IEEE-754 binary16 ordering. The key function correctly handles signed zero ordering, NaN semantics (minNum/maxNum with canonical dual-NaN), VOP3A abs/neg/clamp, and properly rejects unsupported modifiers. Test suite covers all edge cases including ±0 ordering, subnormals, Inf, single/dual NaN, and negative controls. Approved.
|
This PR shares the same inline float constant bug that tedin7 already flagged on this PR and on #3135: Missing graphics guard. The v_add_f16 block has CMake guard. Same issue as #3135: uses NaN vs Inf test coverage. The NaN check VOP2 abs/neg not tested. The lowering supports |
|
I tried merging The conflict was textual only, in The failure:
A possible direction (unconfirmed): point that refusal control at a binary16 op that is still unlowered, so it keeps checking the refusal path. That is your call, since it edits an existing test. Other results on the merged tree:
Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; DXC 1.9.2602.17; Python 3.12.10; wave32; debug layer off. This reply was AI-assisted. |
|
Thanks for the min/max lowering. I reviewed
Two earlier requests need no work. ±Inf is already a case ( On the conflict: This was a static review: code reading plus This comment was AI-assisted. |
|
Merged current
Verified on NVIDIA GeForce RTX 5080 (
Ready for re-review! Commit: 1442d8e |
|
Thanks for the quick turnaround. I re-reviewed Fixed from round 1
Still needs a change
Minor: 248 (1/2π → CI run 46130052346 passed on this head, but This comment was AI-assisted. |
|
Thanks for the thorough re-review @JohnConnorNPC! Addressed both points and the minor notes in
Verified on NVIDIA GeForce RTX 5080 (
|
Leyukaka
left a comment
There was a problem hiding this comment.
GPU review of 58468b35.
- The two review rounds' requests are all addressed except the minor FP16 MODE check (below), and there are no open threads.
- Semantics match the merged
v_pk_min_f16rules: one NaN returns the other operand, two NaNs return0x7E00,-0orders below+0, clamp as before; SDWA, DPP, omod, op_sel and src2 are refused. - Run here in Windows Sandbox, network off, vGPU, Windows 11 build 26300 host, release build of
maind418f70ewith this PR and 11 other open PRs merged locally:native_minmax_f16_ir,_controls,_hardware,native_f16_alu_irandnative_f16_alu_hardwarepass. Changing the one-NaN select (select(a_nan, b, ...)→select(a_nan, a, ...)) makesnative_minmax_f16_irandnative_minmax_f16_hardwarefail.
Not covered: no FP16 denorm/MODE refusal as v_pk_min_f16 has; no input reaches it today because accepted MODE writes are forced to the default.
Approve.
Fixes #3124. Refs #2935.
What this changes
v_min_f16(VOP20x3a/ VOP3A0x13a) andv_max_f16(VOP20x39/ VOP3A0x139) insrc/gfx1013_direct_compute.inlusing exact 32-bit integer IEEE-754 binary16 ordering while preservingD[31:16].-0.0h < +0.0h, implements IEEE-754minNum/maxNum(returning the non-NaN operand if one is NaN and canonical0x7e00if both are NaN), supports VOP3Aabs/negandclamp, and refuses unsupported modifiers (omod,op_sel, unusedsrc2).Tests & docs added
tests/native_minmax_f16_check.py&tests/cmake/native_minmax_f16.cmake:native_minmax_f16_controls: validates emitted integer DXIL (icmp slt i32/icmp sgt i32), refuses invalid modifiers, and verifies that theignore_signed_zero,propagate_nan,no_clamp, andzero_highnegative controls each differ.native_minmax_f16_hardware: dispatches 8 binary16 pairs (±0.0hin both orders, normals, subnormals,±Inf, single/dual NaN) across VOP2 and VOP3A with pre-seededD[31:16], matching 2048 result words and 16 sentinel guards.docs/experiments/native-minmax-f16.md: experiment note and reproduction commands.Verification
eeaa3d7810.0.26300.9974), MSVC19.44.35230, Windows SDK / DXC10.0.26100.0, NVIDIA GeForce RTX 5080 (10de:2c02, driver32.0.16.2124).ctest --preset dev --no-tests=error -R '^native_minmax_f16_|^native_ldexp_' -V: 4/4 passed (0 skipped).ctest --preset release --no-tests=error -R '^native_minmax_f16_|^native_ldexp_': 4/4 passed (0 skipped).tests/docs_links_check.py&tests/bidi_controls_check.py: passed.Scope: covers synthetic direct-DXIL compute fixtures for
v_min_f16andv_max_f16only; does not establish full-game execution.