Skip to content

compute: copy descriptor words through VCC as a scalar temporary, wave64 SMEM loads and lane spills - #3329

Merged
tedin7 merged 2 commits into
R0Y00:mainfrom
Leyukaka:compute-vcc-descriptor-copy
Nov 28, 2026
Merged

tedin7 merged 2 commits into
R0Y00:mainfrom
Leyukaka:compute-vcc-descriptor-copy

Conversation

@Leyukaka

@Leyukaka Leyukaka commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #3224 (claimed there). Target branch main.

Some direct compute programs park descriptor words in VCC and move them back, for example s_mov_b64 vcc, s[18:19] while s[18:19] hold the upper words of a buffer descriptor. The move into s106/s107 refused at once with "descriptor used as mask", although VCC is only a scalar temporary there.

Change 1 (src/gfx1013_direct_compute.inl, first commit):

  • In compute, s_mov_b32 and aligned s_mov_b64 copy each word into or out of s106/s107 with its symbol, as for other SGPRs.
    • An indexed descriptor keeps its runtime slot index, and a heap offset keeps its byte offset.
    • transfer() in src/gfx1013_compute_native.cpp already copies both symbols, and VOPC and carry writes already make VCC numeric again (s106 only in wave32).
  • Every consumer that reads VCC as a mask or as numeric data checks that the VCC words reaching it are numeric, and refuses otherwise:
    • the operand reader (limit raised to s107 for VCC in compute);
    • carry-in and v_cndmask;
    • the scalar matches that bypass the operand reader;
    • DPP with a preserved destination;
    • SMEM offsets (already the case on main);
    • s_cbranch_vccz/vccnz, on s106 in wave32 and on both words in wave64.
  • EXEC and M0 stay refused as before.

Change 2 (src/gfx1013_direct_compute.inl, src/gfx1013_compute_native.cpp, second commit):

  • Wave64 table and heap-offset descriptor loads (s_load_dwordx4/x8) may end at s106/s107; the "symbolic scalar memory destination overlaps wave64 VCC" refusal is removed and the load writes the descriptor symbols there (shown for table loads; a heap-offset load into s[104:107] now reaches the heap contract check).
  • v_writelane_b32 and v_readlane_b32 spill and reload s106/s107 like other SGPRs (bound raised from s105 to s107 in both files); a symbolic reload into anything above s107 is still refused.
  • A later read of VCC as a mask still refuses with "unbound numeric SGPR s106".

Tests for change 1. The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, Release, on main 32dc3d7c plus the first commit.

  • The new native_vcc_descriptor_copy_controls:
    • loads a descriptor into s[16:19] and parks s[18:19] in VCC, with one pair move or two word moves;
    • clears s[18:19], moves VCC back and stores through s[16:19];
    • checks that each round trip, wave32 and wave64, gives the same single raw UAV store call as the program without it;
    • checks that the park followed by s_cbranch_vccz, by v_cndmask_b32 with VCC, or by s_mov_b64 exec, vcc is refused.
  • With main's compile_dxil the round trip is refused at the park with "descriptor used as mask", so the test fails there.
  • native_vcc_descriptor_copy_hardware passes on the RTX 5080: 320 output and guard words for each of the four round trips. native_vcc_descriptor_copy_warp reports a capability skip (77).
  • ctest -R "native_|startup_compute|compile_dxil|salu": 528 of 529 pass, plus one transient failure.
    • native_scalar_lds_hardware fails as on main.
    • cpu_native_exe_termination failed once during the parallel run and passes when run alone.
  • I measured my local set of 882 captured compute requests with compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests (counts only):

Tests for change 2. Same setup, on main 8ecd30fe plus both commits.

  • New native_vcc_descriptor_copy_{smem_store,smem_mask,smem_range,spill_image,spill_mask}: a wave64 x4 load into s[104:107] stored through directly; the same load followed by s_cbranch_vccnz (refused); an x8 load into s[104:111] (refused as a range); an x8 image descriptor in s[100:107] spilled to a VGPR with v_writelane_b32 (s100..s105, vcc_lo, vcc_hi), cleared, reloaded and used by image_store; the same spill followed by s_cbranch_vccnz (refused). native_direct_container and native_heap_offset_add now expect the accepted load or the heap contract instead of the overlap refusal.
  • ctest -R "^(native_vcc_descriptor_copy_.*|native_direct_container|native_heap_offset_add|native_lane_access.*)$": 10 pass, native_vcc_descriptor_copy_warp skips (77). ctest -R "native_|compile_dxil|salu" after a full build: all pass except native_fixed_mesh57_waterfall_fine_hardware and native_scalar_lds_hardware, which fail on main too.
  • Mutations: the v_writelane_b32 source bound back to <= 105 in gfx1013_direct_compute.inl makes spill_image and spill_mask fail; restoring the SMEM overlap refusal makes smem_store, smem_mask, native_direct_container and native_heap_offset_add fail.
  • On the 900 s census in direct compute: untranslated compute shaders of a start-up run ranked by dispatches, with first refusals on main #3224 (compile_dxil --jobs 4 gfx1013-direct-cs@0 --requests), four programs stopped at the SMEM overlap and then at the vcc_lo/vcc_hi spill; they now pass both. Three then stop at direct descriptor address outside bound table (native: bind a single directly indexed heap flag as a descriptor table #3221) and one at unbound numeric SGPR s61, so none compiles with this alone.

A direct compute program may park descriptor words in VCC with s_mov and
move them back. The move into s106/s107 used to refuse eagerly with
"descriptor used as mask". The words are now copied with their symbols,
and every consumer that reads VCC as a mask or as numeric data (carry-in,
cndmask, branches, SALU, DPP, readlane selectors, SMEM offsets) requires
numeric VCC words, so a real descriptor-as-mask use still refuses.
…oads and lane spills

A wave64 table or heap-offset descriptor load may end at s106/s107, and the program then spills
the descriptor with v_writelane_b32 (vcc_lo/vcc_hi included) and reloads it with v_readlane_b32.
Both refused before: "symbolic scalar memory destination overlaps wave64 VCC" for the load, then
"unbound numeric SGPR s106" for the spill. With the scalar-temporary VCC model of the previous
commit, the load writes the descriptor symbols into s106/s107, the spill and reload carry them
like other SGPRs, and a reload into M0, EXEC or above is still refused. A later read of VCC as a
mask still refuses with the existing reason.
@Leyukaka Leyukaka changed the title compute: copy descriptor words through VCC as a scalar temporary compute: copy descriptor words through VCC as a scalar temporary, wave64 SMEM loads and lane spills Nov 28, 2026
@Leyukaka
Leyukaka force-pushed the compute-vcc-descriptor-copy branch from 17595bd to 9541455 Compare November 28, 2026 20:21
@Leyukaka

Copy link
Copy Markdown
Collaborator Author

Rebased on main 8ecd30fe and added a second commit for the wave64 SMEM refusal claimed on #3224: table and heap-offset descriptor loads may end at s106/s107, and v_writelane_b32/v_readlane_b32 carry those words like other SGPRs. The body now covers both commits, with tests, mutations and the census result (the four programs get past both VCC refusals; none compiles with this alone).

@tedin7 tedin7 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.

Reviewed head 9541455.

Code read (gfx1013_direct_compute.inl, gfx1013_compute_native.cpp): s_mov_b32/s_mov_b64 now copy each word per identity into or out of s106/s107 in compute; every VCC consumer found in the diff (operand reader, carry-in and v_cndmask, scalar bypass matches, DPP with preserved destination, s_cbranch_vccz/vccnz, lane read/write) first requires the VCC words to be numeric and refuses otherwise. EXEC and M0 stay refused. The wave64 SMEM overlap refusal is removed only for table and heap-offset loads, with the new SMEM range and mask refusal tests behind it. No issue found.

Verification (Win2025, dev and release, this head):

  • x2w_pipe.py win2025 3329 --regex 'native_vcc_descriptor_copy|native_direct_container|native_heap_offset_add': 10/10 passed on dev and 10/10 on release, including native_vcc_descriptor_copy_warp and _hardware.
  • Required CI on the head is green; 1 commit behind main; no change requests.

AI-assisted; commands listed were executed locally.

@tedin7
tedin7 merged commit 0614f68 into R0Y00:main Nov 28, 2026
5 checks passed
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.

2 participants