Repository navigation
shader: lower v_cvt_f16_u16, v_cvt_f16_i16, v_cvt_u16_f16 and v_cvt_i16_f16 in the direct compute path - #3159
Conversation
…16_f16 in direct compute Lower VOP1 and VOP3A v_cvt_f16_u16, v_cvt_f16_i16, v_cvt_u16_f16 and v_cvt_i16_f16 in DirectCompute::float_alu() preserving D[31:16] on gfx10. Int16/u16 -> f16 converts via sitofp/uitofp and packed_half_rne() round-to-nearest-even (with optional VOP3 clamp to [0.0, 1.0]); f16 -> i16/u16 widens via legacyF16ToF32, truncates toward zero, saturates to [-32768, 32767] / [0, 65535], maps NaN to 0, and supports VOP3 abs/neg. Also add all four conversions to half_binary in DirectCompute::lower() so the default binary16 rounding/denormal MODE contract is enforced. Fixes R0Y00#3148 Refs R0Y00#2935 AI-assisted.
tedin7
left a comment
There was a problem hiding this comment.
Review of 7adec5b (updated with main). Comment only.
The four conversions read inline float sources 240-248 as their binary16 values (the same nine constants as inline_half_words, which #3147 just made a shared member; the local halves[] copy here could use it in a follow-up), and literal and inline integer sources as their low 16 bits. f16 -> i16/u16 truncates through fptosi/fptoui only on an in-range value, saturates out-of-range values to the type bounds and maps NaN to 0; i16/u16 -> f16 goes through f32 and packed_half_rne, which is exact because every 16-bit integer is exact in f32. Unsupported forms (DPP, SDWA, omod, op_sel high half, modifiers on the integer source, an unknown rounding or denormal mode) are refused. native_cvt_f16_i16_ir checks 82 cases at the IR level without a GPU, so the semantics are covered on WARP hosts and in CI even though the _hardware leg skips.
src/gfx1013_direct_compute.inl is also changed on cpp-migration; this merges cleanly there and the native sweep passes on that merge (comment below).
Commands: git diff origin/main...pull/3159/head (read), git merge-tree --write-tree origin/cpp-migration pull/3159/head, plus the Windows commands in the comment below.
AI-assisted; commands listed were executed locally.
|
Windows Server 2025 verification of
AI-assisted; commands listed were executed locally. |
|
@legacy-code-archaeologist Thanks for #3159. During #3185's rebase regression on 5b145ca, the stock conversion hardware fixture reached its last guard assertion and raised |
Lowers
v_cvt_f16_u16,v_cvt_f16_i16,v_cvt_u16_f16, andv_cvt_i16_f16(VOP1 and VOP3A) in the direct C++ compute path (src/gfx1013_direct_compute.inl), preservingD[31:16]and enforcing the binary16 MODE contract viahalf_binary.Verification
Measured on Windows 10.0.26100 (
devpreset) atupstream/main429f11d5+6772a597:ctest --preset dev --no-tests=error -R '^native_cvt_f16_i16_' -V:native_cvt_f16_i16_ir(passed,1.09s): evaluates DXIL IR vianative_compute_ir_dumpacross 82 conversion cases (VGPR, SGPR, literal, inline ints/floats, VOP3clamp/abs/neg/-|x|, RNE ties, saturation, subnormals, infinities, NaNs, non-zero upper halves) and 38 refusals (DPP, SDWA,omod,op_sel, illegalabs/neg/clamp,src1, and MODE writes).native_cvt_f16_i16_controls(passed,3.84s): compiles all 82 conversions to DXIL viacompile_dxiland verifies all 38 refusals.native_cvt_f16_i16_hardware(skipped, exit77): Quadro M1000M does not support shader model 6.6 with wave32, so GPU readback is not measured.ctest --preset dev --no-tests=error -R '^native_.*_(controls|ir)$' --output-on-failure: 47/47 passed (54.43s).python -B tests/docs_links_check.py: passed (101 Markdown files, 589 links).zero_high_half,drop_ordered_nan,swap_signed,drop_clamp,wrong_inline_float) each failednative_cvt_f16_i16_ir(exit1).Fixes #3148
Refs #2935
AI-assisted.