Repository navigation
Recompiler: split wave64 halves skip the exchange at local votes and uniform first-lane reads - #3563
Royalflamejlh wants to merge 3 commits into
Conversation
|
Review (head edc0e4e, diff read, not a merge-check; draft with
Fine: the fixed-point retraction of non-local votes, the EXEC-within-branch tracking, the AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
edc0e4e to
f0e1c97
Compare
|
Thanks. The
Still true: the votes apply to mesh programs and the GPU tests are compute only (now said under Tested). I can open the three commits as three pull requests if that is wanted. AI use: Claude Code. Claude Opus 5.5 checked the point and wrote the change; Claude Fable 5.2 ran the tests on the card and wrote this reply. |
|
Re-review (head f0e1c97, diff read, not a merge-check:
AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
No open or merged PR makes the same change on the direct DXIL path. #1193 skips uniform v_readfirstlane exchanges on the HLSL path (recomp/x64_uniform.rs), and #2343 batches consecutive v_readfirstlane/v_readlane exchanges in dxil/lower_valu.rs instead of skipping them; both are different changes, though #2343 touches the same lowering and may conflict. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
|
Test report on head Setup: release builds of
hardware / tool and model: NVIDIA GeForce RTX 3090 24 GB (driver 621.24, wave32 only), Intel Core i5-10600K, 32 GB, Windows 11 Home build 26300, rustc 1.100.0 / Claude Code (Claude Opus 5.5), numbers from the logs checked by me |
bmjask
left a comment
There was a problem hiding this comment.
Review of f0e1c97f: 3 finding(s). 1 are inline. These are on lines outside the diff:
crates/xcl/src/shaders.rs:35: XCL_WAVE64_IDIOMS isn't in semantic_pipeline_setting, and on the HLSL backend pso.rs:379 also leaves the tag out of the translated identity. A run with XCL_WAVE64_IDIOMS=0 keeps the same warm_settings_key() / translation_cache_identity(), so a warm pipeline library built with the idioms on is reused for a run that turns them off.
crates/xcl/src/gpu/dxil/mask_exchange.rs:65: s_cmpk_* and s_addk_i32 write SCC when lowered (lower.rs ~1278-1297), but uses() only kills SCC demand for names starting with S_CMP_, and S_CMPK_EQ_I32 doesn't match. In v_cmp vcc; s_and_saveexec_b64 s4, vcc; ...; s_cmpk_eq_i32 s5, 7; s_cbranch_scc1, the branch's SCC demand passes the S_CMPK, reaches the saveexec, and vcc gets exchanged even with the idioms on. Adding S_CMPK_ and S_ADDK_I32 to the SCC-kill list fixes it.
These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
| } | ||
|
|
||
| /// SOPK instructions that read and write what their operands say, no more. | ||
| pub(super) fn plain_sopk(name: &str) -> bool { |
There was a problem hiding this comment.
plain_sopk leaves out S_WAITCNT_VSCNT, S_WAITCNT_VMCNT/LGKMCNT/EXPCNT and S_VERSION. They lower to no-ops but uses() still treats them as reading every register (read: !0). s_waitcnt_vscnt null, 0 is very common after stores, so any local vote whose skipped side contains one is taken back. Separately, lane_work lists S_WAITCNT_VSCNT under ENC_SOPP, where it can never match because it's SOPK.
A forward s_cbranch_execz over per-lane work reads each half's own word of EXEC, so the compare behind it is not exchanged (gpu/dxil/idioms.rs, the conditions in docs/wave64-on-wave32.md, "Idioms"); s_or_b64 exec, exec, s at its target gives the saved EXEC without asking for EXEC whole. XCL_WAVE64_IDIOMS=0 turns it off and tags the translated cache and the warm pipeline library's settings. Kernel::exchange_sites counts where the halves meet in a translation. On a retail pack's 9 442 distinct wave64 compute and mesh programs (retail_wave64_compute_exchange_census): 157 393 exchanged compares before, 114 214 with the votes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… value v_readfirstlane of a value every lane of EXEC holds (scalar arithmetic the compiler does in a VGPR) is the same in each half's first running lane of EXEC: the halves exchange it only when one of them has no such lane (idioms::uniform_reads, Lw::read_first_lane_uniform; the rule in docs/wave64-on-wave32.md). Kernel::exchange_sites leaves that exchange out. A lane mask an instruction reads (v_cndmask_b32's, a carry in, v_div_fmas' VCC) has to have one bit for all of EXEC's lanes, and the destination an accumulator or a 16-bit result keeps part of counts as an operand. In the same pack's programs 38 702 of 57 884 v_readfirstlane are such reads. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
s_movk_i32, s_cmovk_i32, s_addk_i32, s_mulk_i32 and s_cmpk_* read and write the registers they name, s_waitcnt_*cnt and s_version none; s_cmpk_* and s_addk_i32 replace SCC. The split form's mask demand took every SOPK instruction for one that may read any register, so a compare before any of them was exchanged: 114 214 exchanged compares in the pack's wave64 compute and mesh programs, 90 743 without that. Under XCL_WAVE64_IDIOMS as the other idioms. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f0e1c97 to
8a02160
Compare
|
@bmjask thank you, all three hold; fixed at
The same check found AI use: Claude Code (Claude Opus 5.5) checked each point, wrote the fixes and tests, and drafted this reply. |
|
Follow-up review (head 8a02160, since f0e1c97, diff read, not a merge-check; checks red):
New: none. Fine: AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
merge-check verdict: safe to merge |
…hanges Build on #3563's split-wave64 idioms to eliminate redundant inter-half spin exchanges and startup barriers in direct DXIL compute shaders (all gated under XCL_WAVE64_IDIOMS): - Local EXEC skips (S_CBRANCH_EXECZ/NZ) on each half's own EXEC word, including s_endpgm tails, LDS compute programs (with explicit LDS store ordering), all *_SAVEEXEC_B64 forms, scalar-only compares, half-overwritten pairs, and #3563's s_or_b64 exec restore joins. - Lazy meets: ballots and v_readlane/v_readfirstlane defer until the first whole read and batch stale pairs and lane values into one rendezvous. - Local lowering for one-value VGPR first-lane reads, thread-0 EXEC first-lane reads, and lane-number equality compares. - Deferred cross-half wave reductions (or/and/xor/add/min/max) folded when the halves next meet. - Hardware waves that need nothing of one another run apart without the startup atomic or group barrier (for programs up to 256 guest instructions without LDS). - Local loop exits when a half has no active lane left in an s_andn2_b64 loop mask. Assisted-by: Codex (GPT-6) Assisted-by: Gemini 4 Neon
|
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any. |
|
Closing: this landed through #3655, which was stacked on it. AI use: Claude Code (Claude Opus 5.5) checked the commits and wrote this comment. |
…hanges Build on xcl-dev#3563's split-wave64 idioms to eliminate redundant inter-half spin exchanges and startup barriers in direct DXIL compute shaders (all gated under XCL_WAVE64_IDIOMS): - Local EXEC skips (S_CBRANCH_EXECZ/NZ) on each half's own EXEC word, including s_endpgm tails, LDS compute programs (with explicit LDS store ordering), all *_SAVEEXEC_B64 forms, scalar-only compares, half-overwritten pairs, and xcl-dev#3563's s_or_b64 exec restore joins. - Lazy meets: ballots and v_readlane/v_readfirstlane defer until the first whole read and batch stale pairs and lane values into one rendezvous. - Local lowering for one-value VGPR first-lane reads, thread-0 EXEC first-lane reads, and lane-number equality compares. - Deferred cross-half wave reductions (or/and/xor/add/min/max) folded when the halves next meet. - Hardware waves that need nothing of one another run apart without the startup atomic or group barrier (for programs up to 256 guest instructions without LDS). - Local loop exits when a half has no active lane left in an s_andn2_b64 loop mask. Assisted-by: Codex (GPT-6) Assisted-by: Gemini 4 Neon
A split wave64 compute or mesh program on a GPU with 32-lane waves only meets its other half at every mask read whole and every
v_readfirstlane. Three recognised cases now need no meeting. Over the wave64 compute and mesh programs of one retail pack without LDS (9,074 programs), the places where the halves meet went from 217,578 to 112,237. That is a static count of sites, not GPU time, and it was taken on a tree that carries this change beside other unmerged pull requests, not on this branch. #3114 measures the exchange at 2.6x a program's GPU time.The three commits can be three pull requests (the first stands alone, the other two need it) if that is easier to review.
What is in it (
crates/xcl/src/gpu/dxil/idioms.rs, new, 677 lines with tests; direct translator only)s_cbranch_execzthat only skips per-lane work reads each half's own word of EXEC, so the compare behind it stays in its half. It holds when the skipped side has only per-lane work under EXEC, scalar arithmetic, non-coherent scalar loads or mesh exports; no lane read or write, LDS, barrier or message; no exchanged mask; forward branches that stay inside; EXEC within the EXEC at the branch; and no SGPR written there that is read after it.v_readfirstlaneof a value made, in the same block and after the last EXEC write, by plain VALU on scalars: each half reads its own first running lane when both halves have one; otherwise the exchange runs as before.s_movk_i32,s_cmovk_i32,s_addk_i32,s_mulk_i32ands_cmpk_*were taken to read every register, which forced an exchange on any compare before them.XCL_WAVE64_IDIOMS=0turns all three off and is part of the translated cache's identity.Kernel::exchange_sitescounts the sites.848 changed lines (825 added) in three commits of 528, 242 and 57 added lines, each a form of its own that the others do not need; about a third of each is tests.
Tested
x86_64-pc-windows-gnu, release. Head8a02160af(bmjask's three review points fixed;idioms mask_exchange shaders:: pso::151 passed, 0 failed, 2 ignored, 17 SKIPPED;gpu::dxil316 passed, 1 failed (directed_reference_basics, which fails onmainunder Wine), 4 ignored; the GPU tests not rerun on this head). The results below are off0e1c97f3, onmain493dbd3d.cargo test -p xcl --release --lib gpu::dxil -- --test-threads=2: 314 passed, 1 failed, 4 ignored. SKIPPED:dispatch_chain_native_wave64_builds_whole(no wave64). The failure isround_tests::directed_reference_basics, which fails the same way onmain.gpu_split_wave64_local_votes_leave_what_the_exchange_leavesandgpu_split_wave64_uniform_first_lanes_read_what_the_exchange_readspassed (groups of 32, 48, 64, 96 and 128 threads; idioms on against off, and against the console's values). Both are compute programs: the votes also apply to mesh programs, which no GPU test here covers.v_div_fmas, a carry-in whose carry-out goes nowhere,v_dot2c/v_dot4c, a 16-bit result).XCL_GPU_PROFILE=1, which makes a queue run its draws and dispatches one after the other; on a later head of that tree the title lost its device at the world start without the switch (2 of 2 runs, with folding on and with it off) and ran 600 s with it (1 of 1), so the run says nothing about this change with the GPU's work overlapping.main493dbd3d, a retail title in its world, 2 measured runs of 420 s each): no device removal, and no change in presents, draws or dispatches per 2 s outside the spread of two runs of one build. The suite was not run there.Regression run
RTX 5070 Ti 16 GB (driver 621.24), Ryzen 7 9800X3D, Windows 11 Pro 26300, release builds by
scripts/smoke.ps1, the same retail title for 60 s each.main:this PR's head:
Not tested
bench_split_wave64.docs/wave64-on-wave32.md, "What is not exact").AI use
25590d0ee).