Repository navigation
compute: accept SGPR and inline-constant sources in binary16 SDWA - #3240
Merged
Merged
Conversation
The binary16 SDWA VOP2 arithmetic (add, sub, subrev, mul) accepts an SGPR or an inline constant as src0/src1, as GFX10 SDWA allows (extension bits 23 and 31). The source selection applies to the 32-bit scalar word; an inline float is materialized as its binary16 value first. A WORD_1 selection of an inline constant stays refused because its other half is not modelled here. Literals stay refused (SDWA has none). New test native_sdwa_f16_scalar (IR and hardware): SGPR DWORD/WORD_1, inline 1.0 and integer 0, with distinct halves in every source and the preserved/padded destination half, plus refusal controls.
R0Y00
approved these changes
Nov 28, 2026
R0Y00
left a comment
Owner
There was a problem hiding this comment.
Reviewed ae208bb on main 8007a53. The integrated source tree is 6fa0888f63ccbe245925e1a5b03746f3d852e74e. Checked the direct compute path for SGPR DWORD/WORD_0/WORD_1 and inline DWORD/WORD_0 as well as the inline high-half, literal, sign extension and opcode refusal controls.
Debug 8/8 and Release /O2 8/8, no skips, using:
ctest --test-dir <build> --no-tests=error --output-on-failure -j 1 -R "^(native_sdwa_f16(_scalar)?_(ir|hardware)|native_f16_alu_(ir|hardware)|native_fma_f16_opsel_ir|native_direct_container)$"
RTX 4060 Laptop GPU, driver 32.0.16.1656, Windows 11 26200.9974, standalone replay without the debug layer. Hosted Windows (required), Linux Python, and gfx1013 assembly jobs passed. The hosted /O2 job was skipped.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #2935, claimed in #3224 (item 1 of my comment there). Target branch
main.Change (
src/gfx1013_compute_native.cpp,src/gfx1013_direct_compute.inl,docs/experiments/native-sdwa-f16.md): the binary16 SDWA VOP2 arithmetic (v_add_f16,v_sub_f16,v_subrev_f16,v_mul_f16) accepts an SGPR or an inline constant as src0 or src1. GFX10 SDWA allows this through extension bits 23 and 31, whichtools/disasm_rdna2.pydecodes the same way.packed_f16_inline_constant(shader: accept inline constants in packed binary16 arithmetic and min/max in direct DXIL #3230).v_min_f16/v_max_f16SDWA are untouched. They wait for shader: lower v_min_f16 and v_max_f16 in the direct compute path #3125.tests/native_sdwa_f16_check.pydrops its two controls that expected these legal encodings to be refused.Tests. The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, Release, on
main7364e6a9plus this commit.New
native_sdwa_f16_scalar_irand_hardwarecompare exact words againsttests/f16_packed_model.pyfor five cases:Every register source (SGPR and VGPR) has distinct halves, and the destination checks both UNUSED_PRESERVE (sentinel kept) and UNUSED_PAD (zero).
Refusal controls: a literal, an SGPR selection with a modifier, a WORD_1 inline constant, and two SDWA min/max forms (0x39, 0x3a), still refused as "unimplemented direct SDWA operand profile".
With
main'snative_compute_ir_dump, the new test fails on "SDWA binary16 source must be a VGPR".33 tests pass with
-R "native_sdwa|native_f16|native_fma_f16|native_packed|native_cvt_f16|native_direct_container".Mutation check by hand: ignoring the inline-constant conversion fails both new tests.
Measured with
compile_dxil --jobs 8 gfx1013-direct-cs@36 --requestsonmain7364e6a9, before and with this commit.v_rcp_f16, which compute: lower binary16 VOP1 rcp, sqrt, exp and rsq #3220 lowers.AI-assisted.