cpp-migration: lower the SDWA forms of binary16 add, sub and mul in the direct C++ compute path #2963
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#2963
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Leyukaka on GitHub · 2026-11-26 23:52 UTC · original
Target branch
cpp-migration. Part of #2935 (instruction coverage). I am taking the SDWA forms of binary16 arithmetic. The plain forms are #2945 (claimed); this builds on that lowering and will rebase onto it once it lands.Gap: the direct compute decoder admits SDWA operand profiles for a list of integer and binary32 VOP1/VOP2 ops (
gfx1013_compute_native.cpp, "unimplemented direct SDWA operand profile"). The binary16 VOP2 arithmetic ops are not on it, sov_add_f16_sdwaandv_mul_f16_sdwaare refused, for example:v_add_f16_sdwa v16, v1, v12 dst_sel:WORD_0 dst_unused:UNUSED_PAD src0_sel:WORD_0 ...;v_mul_f16_sdwa v6, v25, v19 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_0 ....Measured on a local capture of 2,689 compute requests (counts and instruction shape only). The table counts every request that contains the form; occurrences are static counts up to each program's
s_endpgm.v_add_f16_sdwav_mul_f16_sdwaThe most common shapes write
dst_sel:WORD_0withUNUSED_PRESERVEorUNUSED_PAD, and selectWORD_0,WORD_1orDWORDsources.With
compile_dxil --jobs 8 gfx1013-direct-cs@36 --requestsbuilt fromcpp-migrationf934df52, 11 request keys stop first at this refusal: 9 withv_add_f16_sdwaand 2 withv_mul_f16_sdwa. In a 600 s start-up run, which used the Python translator, they were dispatched 16,828 times (6,723 + 10,105). I matched pipelines by request key.Plan: the SDWA forms of
v_add_f16,v_sub_f16,v_subrev_f16andv_mul_f16, followingtools/startup/gfx2hlsl.pysdwa_half(), which already lowers them on main.src0_sel/src1_selWORD_0orWORD_1pick the half, andDWORDreads the low half, as the 16-bit op does. abs/neg are allowed. Each source must be a single VGPR.packed_half_rne, asv_cvt_f16_f32does.sdwa_halfand #2945 do.dst_selWORD_0orWORD_1.UNUSED_PADzeroes the other half;UNUSED_PRESERVEkeeps the other half of the old register.sdwa_half()does:dst_sel:DWORD;sext(),clampand output modifiers;v_min_f16/v_max_f16SDWA, whichsdwa_halfdoes not lower, stay refused.Tests: a hardware readback against an independent binary16 CPU reference (Python
struct'e', round to nearest even).WORD_1sources,UNUSED_PRESERVE,UNUSED_PAD, and abs/neg.dst_sel:DWORD, a byte selection and an SGPR source stay refused.WORD_0/WORD_1, and ignoringUNUSED_PRESERVE.AI-assisted.
@MasterDomino on GitHub · 2026-11-27 01:01 UTC · original
Closed by #2973, merged into
cpp-migrationas7bcff286.native_sdwa_f16_{ir,hardware}pass on an RTX 5080 (author) and on an RX 9070 XT, and reading only the low half fails both. AI-assisted.