Repository navigation
Split wave64: masks read only lane by lane stay in their half - #94
Merged
Merged
Conversation
In the split wave64 form (xcl-dev#67) every mask write exchanges the two wave32 halves' ballots. A mask whose readers take only the reading lane's own bit (v_cndmask_b32's selector, the carry-in of v_add_co_ci / v_sub(rev)_co_ci) needs no exchange: xcl_x_ballot_local gives the half's own word. x64_masks.rs finds them with a backward liveness pass over the SGPRs. A register is whole-live when some path may read its whole value before it is written again. The rules follow the emitter, not only the operand tables: s_cmov*, s_addk, s_mulk, s_bitset*, s_movreld and SDWA compares into their SDST are not overwrites; s_movrels reads every register from its base; SDWA scalar sources and SMEM register offsets are reads; EXEC, indirect jumps, the kernel runner's end and loop exits through LOOP_GUARD count as whole reads (loop ranges from the translator's loop_ranges, now shared). Masks into NULL or constant false are never exchanged. Geometry mode keeps its exchanges. XCL_X64_ALL_MASKS=1 exchanges every mask, for comparison. bench_split_wave64 now counts each iteration's exchanges and times GPU work only (runner::dispatch_timed: timestamps, median of 9; before, the wall time of a whole dispatch with pipeline creation and copies). RTX 3090, all masks (3 runs) vs default (5 runs), split / wave32: - mask only: 1.64-1.68x -> 1.04-1.11x (one console wave per group), 3.90-4.14x -> 1.07-1.16x (four, counter-paired) - with a v_readfirstlane: 1.99-2.02x -> 1.74-1.81x, 6.45-6.64x -> 4.09-4.34x The benchmark's mask is exactly the kind the pass keeps local: it shows the exchange gone, not how much real shaders gain. Tests: 16 for the analysis, gpu_split_wave64_lane_local_masks, gpu_split_wave64_masks_read_whole_after_partial_writes (one kernel per rule; the halves' SGPRs differ without it) and gpu_split_wave64_local_and_exchanged_masks_in_diverging_waves (counter-paired, waves on different paths). Workspace, release, RTX 3090: 459 passed, 0 failed; XCL_WAVE64_SPIN=1: 224 passed. Not checked: real compute shaders (Minecraft's 273 wave64 programs as compute have 38 mask writes, all local), AMD. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ivall
added a commit
that referenced
this pull request
Nov 23, 2026
Collaborator
|
Merged – thanks, this is the step #67 named. Checked on AMD, which you couldn't: Checked on Windows 11 with an RX 9070 (RDNA4, MSVC build): Real compute shaders in the split form: XDefiant run on the RX 9070 with |
BBareth
pushed a commit
to BBareth/xcl
that referenced
this pull request
Nov 23, 2026
KickoffX (xcl-dev#93), Wait32/64BitValueX (xcl-dev#71/xcl-dev#72), RSSetDepthBiasX (xcl-dev#94). Conflicts with main resolved (console slots and PC overrides united; ExecuteCommandLists keeps the per-queue title-memory refresh). KickoffX resets the PC list mid-recording: it now also restores what the Reset clears and console code had set (descriptor heaps, topology, viewports, scissors, blend factor, stencil ref, vertex buffers, render targets) - on the console a kickoff leaves the list's state as it was; without the heaps a translated draw after it would read garbage descriptors.
Michael-Glaser
added a commit
to Michael-Glaser/xcl
that referenced
this pull request
Nov 24, 2026
…cl-dev#104) On newer GDK runtimes (QUEUE_SHIFTED), 20 command list console methods shift up by +2 via NEWER_LIST_SLOTS, leaving 11 older slots (xcl-dev#59, xcl-dev#60, xcl-dev#68, xcl-dev#69, xcl-dev#78, xcl-dev#81, xcl-dev#84, xcl-dev#88, xcl-dev#89, xcl-dev#93, xcl-dev#94) without another shifted method taking their old index. Those slots remained wired directly to the older layout's handlers, so a newer-layout call hit the wrong method. Wrap those orphaned slots in make_layout_split so newer-layout title calls go to a logged stub while older-layout titles keep the handler and non-title callers keep their PC target (including cl_execute_indirect at xcl-dev#59 and the original base-table stub for slots >= scanned). Slot xcl-dev#10 (Reset) stays Reset on both layouts and is not orphaned. Assisted-by: Antigravity (Gemini 4 Neon)
Michael-Glaser
added a commit
to Michael-Glaser/xcl
that referenced
this pull request
Nov 24, 2026
…vall#104) On newer GDK runtimes (QUEUE_SHIFTED), 20 command list console methods shift up by +2 via NEWER_LIST_SLOTS, leaving 11 older slots (ivall#59, ivall#60, ivall#68, ivall#69, ivall#78, ivall#81, ivall#84, ivall#88, ivall#89, ivall#93, ivall#94) without another shifted method taking their old index. Those slots remained wired directly to the older layout's handlers, so a newer-layout call hit the wrong method. Wrap those orphaned slots in make_layout_split so newer-layout title calls go to a logged stub while older-layout titles keep the handler and non-title callers keep their PC target (including cl_execute_indirect at ivall#59 and the original base-table stub for slots >= scanned). Slot ivall#10 (Reset) stays Reset on both layouts and is not orphaned. Assisted-by: Antigravity (Gemini 4 Neon)
This was referenced Nov 25, 2026
This was referenced Nov 25, 2026
rootw0rm
pushed a commit
to rootw0rm/xcl
that referenced
this pull request
Nov 27, 2026
… copies at once VA-vs-Map, headroom and ring-uploads title legs go green (Vulkan 9 -> 6 FAILs, null e2e 10 -> 7): buffer heaps come from the high-VA graphics pool (window 0, real committable host addresses), so placed buffers report VA == Map address with title-side aliasing offsets, and PC slot 15 runs the same immediate host memcpy as the console DMA copy (the single queue is already coherent). Evidence: new lib test heap_backed_placed_buffers_share_va_and_map_and_copy fails pre-slice (fake VAs, detached Map, slot-15 stub) and passes post; title fresh-root Vulkan run: done, failures: 6 (triangle, desc-heaps, committed-tex, bias-xcl-dev#94, title-mem tex, streaming tex remain); retail HOLDS (exit 139 @ exe+0x2237320, SIGSEGV rbx NULL, 20 stubs, 0 d3d12). Full lib shows the usual environment flakes (a different unrelated test fails each run, identical on the pristine tree); d3d12x_linux 14/14 green.
rootw0rm
pushed a commit
to rootw0rm/xcl
that referenced
this pull request
Nov 27, 2026
…nd struct Device xcl-dev#60/xcl-dev#55 + PC10 stash the PSO's draw bytes (VS/PS ptr+len, RTV formats/DSV format, rasterizer + blend, PC graphics-desc layout) into PsoRecord at creation; derived blend PSOs (xcl-dev#55) inherit the base record (patch bytes for S3). List slot 25 SetPipelineState binds the record into ListDrawRecord. Store-only: no draw, no validation, no execute; triangle/bias FAILs stay failing. Linux reads title pointers directly like the other null shims (shader::readable is no-op false here); Windows capture path unchanged. Evidence: new draw_s1_pso_record_populated_pre_draw fails pre-change (9 unresolved record symbols) and passes post; full lib 805 passed, 0 failed, 1 ignored (one known parallel VFS flake, green serially + on rerun); both cargo checks clean; title null 3 FAILs (triangle, present, bias-xcl-dev#94) / Vulkan 2 (triangle, bias-xcl-dev#94), all D3D12.X GPU-only, 0 non-GPU, delta 0; retail HOLDS (exit 139 @ exe+0x2237320, SIGSEGV fault 0, 20 stubs, xgr XAsync/XNetworking/XUser, 0 d3d12).
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.
Split wave64: masks read only lane by lane are not exchanged
In the split wave64 form (#67), every mask write (
v_cmp*, carry-outs) exchanges the two wave32 halves' ballots so that both hold the whole 64-bit mask. Many masks are never read whole: av_cndmask_b32selector or the carry-in ofv_add_co_ci/v_sub(rev)_co_cionly reads the reading lane's own bit, which its own half already has. This PR finds those masks and gives them the half's own ballot word (xcl_x_ballot_local) instead of an exchange. That covers every 64-bit address add and every select. #67 lists this as its next step.How it works
gpu/recomp/x64_masks.rsis a backward liveness pass over the SGPRs. A register is whole-live after an instruction when some path may read its whole value before it is written again. A mask written to registers that are not whole-live stays in its half. Both halves make the same static choice, so their exchange counts stay in step.After a local mask the halves hold different values in those registers, so a missed whole read lets them diverge: wrong results, or exchanges that no longer pair up. For that reason the rules follow what the emitter does, not only the ISA operand tables:
s_cmov*ands_cmovkdon't: they write only when a condition holds.s_addk,s_mulkands_bitset*don't: they read the old value first.s_movreldands_movrelsd_2don't: they writes[dst + m0].s_movrels*: reads every register from its base up to s123, VCC included.src_vccz/src_execz;s_getpc/s_add/s_setpc) counts as a plain branch.LOOP_GUARD): a loop can be left where its budget is checked. That is at its top, or, in thepcdispatcher form, before every block, which ends the program. Whatever is live after the loop, or at the end, therefore counts as live before each instruction in the loop. The loop ranges come from the translator's own merge, now one function:loop_ranges()inrecomp/mod.rs.falsemask ofv_div_scale). Either way both halves hold the same value.s_setpc) has no liveness pass and exchanges every other mask as before.XCL_X64_ALL_MASKS=1exchanges every mask, for comparison. On RDNA,XCL_SPLIT_WAVE64=1(ba905cf) runs the split form there too.Cost
bench_split_wave64(#67's benchmark) now does two things differently:runner::dispatch_timed). Before, it took the wall-clock time of a wholerunner::dispatch: pipeline creation, buffer creation, uploads, submission and the CPU's wait. That overhead is the same for wave32 and wave64, so it pulled every ratio towards 1; Wave64 console programs on GPUs with 32-lane waves only (NVIDIA) #67's 5070 Ti figures were measured that way.Measured on an RTX 3090 (driver 617.14): three runs with
XCL_X64_ALL_MASKS=1and five with the default. Each figure is wave64 split GPU time ÷ wave32 GPU time:v_readfirstlaneThe wave32 baseline is 11.4–14.1 ms. The 4–16 % that remains with no exchange at all is the rest of the split form (64-bit masks, assigning console threads at the start); I haven't measured it further.
What the benchmark does and doesn't show: its loop mask is exactly the kind this pass keeps local, so the result is close to guaranteed by construction. It shows that the exchange is gone and what an exchange costs, which matters most in the counter-paired form. It doesn't show how much real shaders gain: that depends on how many of their masks are read only lane by lane (see Not checked). It is also one synthetic loop on one GPU.
Still exchanged: readlane / readfirstlane,
ds_bpermute, coherent scalar loads, and masks read whole.Tests
x64_masks::tests, 16 unit tests:s_movrels/s_movreld/s_movrelsd_2, SMEM offset, SDWA S0 / S1);gpu_split_wave64_lane_local_masks: a select and a 64-bit carry chain whose masks have bits in both halves, checked lane by lane, plus a check that all four masks are emitted local. Putting the local word in the wrong half makes it fail.gpu_split_wave64_masks_read_whole_after_partial_writes:Without the rules it fails with "the halves ended with different SGPRs".
gpu_split_wave64_local_and_exchanged_masks_in_diverging_waves: four console waves per group (256 and 8 × 8 × 4), so the counter-paired form.The new unit tests for the partial-write rules and for the loop exits fail without their fixes. I checked this by running them against earlier versions of the pass.
Workspace, release, RTX 3090 on Windows 10 with the D3D12 Agility SDK 1.616.1, on
697dbb1:no wave64:gpu_wave32_program_in_wave64_hardwareand the native half ofgpu_geometry_wave32_prefix_count_over_a_mask.XCL_WAVE64_SPIN=1, thegputests give 224 passed, 0 failed.Other open PRs
s_round_mode/s_setreg*, now onmain): itss_setreg_b32only reads its SGPR, and the pass counts that read as whole, so a mask feeding it is still exchanged.recomp/mod.rsnext toloop_ranges(). It is textual only; Expand bounded GPU compatibility coverage #83 already conflicts withmainin three other files.mainin five files; this PR adds none.Not checked
XCL_X64_ALL_MASKS=1: 38 exchanged).XCL_SPLIT_WAVE64=1.cur_pc(emits nothing) andxcl_x_ballot_localonly take effect in the split form. It was not dumped and compared.🤖 Generated with Claude Code