Skip to content

compute: accept DPP16 on binary16 VOP2 add, sub, subrev and mul - #3188

Merged
pigalot merged 1 commit into
R0Y00:mainfrom
Leyukaka:f16-dpp
Nov 27, 2026
Merged

pigalot merged 1 commit into
R0Y00:mainfrom
Leyukaka:f16-dpp

Conversation

@Leyukaka

Copy link
Copy Markdown
Collaborator

Fixes #3167. Part of #2935. Target branch main.

Change (src/gfx1013_compute_native.cpp, src/gfx1013_direct_compute.inl): direct compute accepts DPP16 on the binary16 VOP2 ops v_add_f16, v_sub_f16, v_subrev_f16 and v_mul_f16.

  • src0 goes through the existing DPP16 lane permutation, and the f16 op reads the low half of the permuted word.
  • FI, BOUND_CTRL and inactive source lanes follow the 32-bit DPP rules.
  • For these four ops, the row and bank masks gate the destination write. Row r is lane / 16, and bank b covers lanes with (lane % 16) / 4 == b. Other DPP ops still require full masks, and their behaviour is unchanged.
  • DPP8, clamp and omod stay refused on these ops.

Tests. The setup was Windows 11 build 26300.9974 with an NVIDIA GeForce RTX 5080 (driver 32.0.16.2101) and DXC from the Windows SDK 10.0.26100, on main 80668b97 plus this commit.

  • native_f16_alu_hardware adds four DPP16 cases under a sparse EXEC, against the exact binary16 reference in tests/f16_packed_model.py:
    • quad_perm:[1,0,3,2] with FI;
    • row_shr:1 without FI;
    • a partial row mask;
    • a partial bank mask with BOUND_CTRL.
  • native_f16_alu_ir, the native_dpp* tests, native_sdwa_f16*, native_direct_container and native_permlane* pass.
  • Mutation checks, run by hand, each failing native_f16_alu_hardware:
    • ignoring the permutation;
    • ignoring the row mask;
    • ignoring the bank mask;
    • ignoring FI and inactive sources.

Measured on a local capture (counts and instruction shape only) with compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests on main 80668b97.

  • 2 of 2,689 requests stopped first at "unsupported v_add_f16 DPP form". Both use quad_perm:[1,0,3,2] row_mask:0xf bank_mask:0xf fi:1.
  • With this change, both pass and stop next at "SDWA binary16 source must be a VGPR". The compiled count does not change, and no request that compiled before stops compiling.
  • One of the two is dispatched 3,500 times in one start-up run.

AI-assisted.

@KelboLive

Copy link
Copy Markdown
Contributor

LGTM. The DPP16 support for binary16 VOP2 ops looks correct, particularly the handling of dpp_control vs permuted modes in the f16 path. Given the large scope of this PR (infrastructure + shader features), I've focused on the core compute logic which appears sound and consistent with previous changes.\n\nNote: This PR is quite large. Ensure CI passes fully before merging.

@Leyukaka

Copy link
Copy Markdown
Collaborator Author

Thanks. The size came from the old base (80668b97). The branch is now rebased on main 5b145ca9 (4e26c045), and the diff is the single f16 DPP16 change in 4 files: two in src/, the f16 test and a two-line doc update. On the rebased tree, the native_f16_alu*, native_dpp*, native_sdwa_f16*, native_direct_container and native_permlane* tests pass. native_cvt_f16_i16_hardware fails as it does on main; #3190 fixes it.

AI-assisted.

The direct compute path refused any DPP source on v_add_f16, v_sub_f16,
v_subrev_f16 and v_mul_f16. src0 now goes through the existing DPP16
lane permutation, and the f16 op reads the low half of the permuted word.
FI, BOUND_CTRL and inactive source lanes follow the 32-bit DPP rules.
For these ops the row and bank masks gate the destination write; other
DPP ops still require full masks. DPP8 and clamp/omod stay refused.

native_f16_alu_hardware adds four DPP16 cases under a sparse EXEC:
quad_perm with FI, row_shr:1 without FI, a partial row mask and a partial
bank mask with BOUND_CTRL, against the exact binary16 reference.

AI-assisted.

@pigalot pigalot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed ce002d89 merged over main 6d690968. The merge is clean (tree 97e61f4c) and git diff --cached --check is clean. The diff matches the four-file scope described in the last comment.

What I traced.

  • Opcodes: binary16_alu covers only v_add_f16, v_sub_f16, v_subrev_f16 and v_mul_f16. DPP16 decoding of these is limited to the direct profile; other paths still refuse.
  • Masks: partial row_mask and bank_mask are accepted only for this half-precision path. Lane L in wave32 uses row L >> 4 (plus 2 for the upper half in split wave64) and bank (L >> 2) & 3. That matches the GFX10 DPP definition of a row as 16 lanes and a bank as 4 lanes within a row.
  • Writes: a write needs a usable source lane and both mask bits. Without bound_ctrl, an out-of-row or inactive source keeps the destination. With BOUND_CTRL:0, the source reads 0.
  • Modifiers: the DPP neg/abs bits are decoded from their GFX10 DPP-word positions, and the high 16 bits of the destination are kept.

What I ran. I built compile_dxil native_store_replay native_compute_ir_dump in dev and release (plus offscreen_check in release), then ran

python .agentic\scripts\with_gpu_lock.py ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^(native_f16_alu_(ir|hardware)|native_dpp[a-z0-9_]*_hardware|native_sdwa_f16[a-z0-9_]*|native_direct_container|native_permlane[a-z0-9_]*)$'
  • Results: 8/8 pass in Debug and Release /O2, with no skips. native_f16_alu_hardware matched all 256 words of the DPP case, with the high halves kept.
  • Negative control: on main 886a5a28, the PR's native_f16_alu_check.py fails in both modes. ir and gpu stop at +0x60: unsupported v_add_f16 DPP form.

Mutants in src/gfx1013_direct_compute.inl. For each, I rebuilt in dev and ran native_f16_alu_(ir|hardware):

Mutant Result
DPP permutation ignored (own lane read) killed (word 8: 0xabcd3c00 vs 0xabcd3c02)
row_mask ignored killed (word 74)
bank_mask ignored killed (word 27)
bank computed from lane >> 3 killed (word 27)
inactive source lane still writes killed (word 9)
row computed from lane >> 3 killed (word 46)
bound_ctrl ignored killed (word 11)

Restored and rebuilt afterwards; git diff --quiet is clean.

Verdict: approve on ce002d89.

Environment: NVIDIA GeForce RTX 5090 driver 610.88, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Windows SDK 10.0.28000.0 DXC, Python 3.12.10, wave32, debug layer off.
CI: Build and test on Windows passes on ce002d89.

This reply was AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

direct compute: accept DPP16 on v_add_f16, v_sub_f16, v_subrev_f16 and v_mul_f16

3 participants