Repository navigation
shader: lower v_floor_f16, v_ceil_f16, v_trunc_f16 and v_rndne_f16 in the direct compute path - #3135
Conversation
… the direct compute path
|
Thanks for this slice. The integer rounding is careful work. I transcribed the emitted IR into Python and
Note: the PR CI job runs the This comment was AI-assisted. |
KelboLive
left a comment
There was a problem hiding this comment.
Correct and thorough lowering of v_floor_f16, v_ceil_f16, v_trunc_f16, and v_rndne_f16. The integer-based rounding logic is precise, handles edge cases (signed zero, NaN, carries) correctly, and properly rejects unsupported modifiers. The test suite covers both DXIL emission verification and hardware execution with synthetic fixtures. Approved.
|
I've reviewed this lowering for v_floor_f16, v_ceil_f16, v_trunc_f16, and v_rndne_f16. The integer-based approach is sound in principle, but several issues need addressing before merge: 1. Inline float constants (P0) constexpr unsigned halves[]{0x3800, 0xb800, 0x3c00, 0xbc00, 0x4000,
0xc000, 0x4400, 0xc400, 0x3118};
bits = to_string(halves[r - 240]);The f16 lowering should do the same -- either map inline constants to their binary16 representations or refuse them. In my model, ~92% of constant*op results would be wrong without this fix. Please add at least one inline-constant source to the fixture. 2. +/-Inf and NaN not tested (P0)
Please add +/-Inf and at least one NaN to 3. Modifier/encoding coverage incomplete (P1)
Either test every op in both VOP1 and VOP3A with abs/neg/clamp cases, or narrow the PR description to match what's actually tested. 4. CMake guard (P0) if(X2W_HAVE_DXCAPI AND EXISTS INTAKE_PYTHON)But other native fragments use: if(TARGET compile_dxil AND TARGET native_store_replay AND EXISTS ...)When 5. Controls test fragility (P1) 6. Missing graphics guard (P0) if (graphics_input) return false;Your new block lacks this guard, so direct compute lowering now applies to vertex/fragment shaders too. Was that intended? If not, add the same guard. If yes, a graphics fixture is needed. 7. Documentation gaps (P1)
|
|
For |
Fixes #3127. Refs #2935.
What this changes
v_floor_f16(VOP10x5b/ VOP3A0x1db),v_ceil_f16(VOP10x5c/ VOP3A0x1dc),v_trunc_f16(VOP10x5d/ VOP3A0x1dd), andv_rndne_f16(VOP10x5e/ VOP3A0x1de) insrc/gfx1013_direct_compute.inlusing exact 32-bit integer IEEE-754 binary16 rounding while preservingD[31:16].±Inf, andNaN, handles mantissa-to-exponent carries, supports VOP3Aabs/neg/clamp, and refuses unsupported modifiers (omod,op_sel, unused VOP3 sources).Tests & docs added
tests/native_round_f16_check.py&tests/cmake/native_round_f16.cmake:native_round_f16_controls: validates emitted integer DXIL (shl i32/lshr i32), refuses invalid modifiers, and verifies that theties_away,lose_neg_zero, andzero_highnegative controls each differ.native_round_f16_hardware: dispatches 8 binary16 edge cases (-0.0h,±min_sub,0.5h,1.5h,2.5h,-1.5h,1023.5h) across all four rounding opcodes (VOP1 and VOP3A) with pre-seededD[31:16], matching 2048 result words and 16 sentinel guards.docs/experiments/native-round-f16.md: experiment note and reproduction commands.Verification
fbb9aef710.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_round_f16_|^native_ldexp_' -V: 4/4 passed (0 skipped).ctest --preset release --no-tests=error -R '^native_round_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_floor_f16,v_ceil_f16,v_trunc_f16, andv_rndne_f16only; does not establish full-game execution.