Recompiler: add exact wave-local eligibility analysis for wave64 compute #3040
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3040"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by coolpersonnn on 2026-11-27T16:47:20Z.
Adds eligibility analysis for executing a wave64 compute program as independent wave32 halves. Part of #3011.
Adapted from Vice-Tay
1f69d67(GPL-3.0-or-later), with upstream VIctory63bcca4, victory-fork9a9091d, and VIctory-NVIDIA-RT0fae809e360acredited in the source andTHIRD_PARTY.md.What is in it
gpu/recomp/wave_local.rsimplements the eligibility proof and its fixtures. It rejects DPP16 masks whose rows differ across the halves, and tracks the SGPR pair selected by SDWA compare destinations.rejects_vcc_clobbered_before_a_loop_backedge) that accepts a preservedVCCand a scalar overwrite after its final use, and rejects at byte PC 8 when a backward branch makes the header consume the overwrittenVCC_LO. Review feedbackTested
cargo test -p xcl --lib wave_local -- --test-threads=1on stackeda92f307d(samewave_local.rs): 28 passed, 0 failed, 0 ignored.7a572ab2rebase,cargo test --workspace --no-fail-fast -- --test-threads=4one5e87e6e(identical patch): 2,687 passed, 4 failed, 49 ignored, and 30SKIPPEDlines (21 no wave64, 3 per-lane f16/f32-to-f16 refusals, 2 no heap windows, 2 mesh pipeline PC skips, 1 cannot disable driver cache, 1gpu::recompskip line). The 4 failures weregpu::dxil::fuzz_tests::fuzz_validate_and_gpu_{0..3}.cargo test --release -p xcl --lib retail_wave_local_census -- --nocapture --test-threads=1on5e470d3ewithXCL_SAMPLE_RPF: 26,503 records, 2,689 compute shaders (1,535 wave32, 1,154 wave64); 359 accepted (340NoCrossHalf, 19SingleWave).cargo test --release -p xcl --lib retail_wave_local_buffer_differential -- --nocapture --test-threads=1on5e470d3ewithXCL_SAMPLE_RPFandXCL_SAMPLE_WAVE_LOCAL_DIFF=1: 1 passed, 0 failed, 0 ignored. Out of 359 accepted shaders, all 31 that wrote to the seeded buffers matched split-wave64 HLSL (0 mismatches), 105 produced no observable writes with those inputs, and 223 required image bindings.Regression run
60 seconds per run on the same retail title with fresh per-run
XCL_DATA_ROOTdirectories,XCL_PREPARE=0, andXCL_ADAPTER=RTX 5090.Main
Analyzer head
Not tested
7a572ab2rebase (f197cb2d).f197cb2d.AI use
gemini-pro-orchestrator-neon) and Codex (gpt-6.2-sol) assisted the original adaptation. Codex (gpt-6.2-sol) handled the earlier review fixes, loop regression, and initial rebase.Gemini 4 Hydrogen) in T3 Code rebased onto7a572ab2, ran the workspace/census/differential tests and 60 s smoke runs, pushedf197cb2d, and updated this report.Imported from ivall/xcl. Originally posted by Gevroska on 2026-11-27T18:39:17Z.
I tested how WaveLocal handles a mask value that changes between loop iterations at
962cdca8. The 17 CPU fixtures I ran all passed, but none contained a backward branch. I added a local CPU test with a two-iteration uniform loop whose header readsVCCas a 64-bit mask at byte PC 8.VCCand branch back to the headerNoCrossHalfVCC_LOafter its last use and remove the backward branchNoCrossHalfmask op with non-mask sourceThe rejection occurs at the header where the next iteration would consume the overwritten value. The test also checked that the header had both expected incoming edges. It passed on Windows with zero skips. This verifies the static eligibility decision for this loop. I didn’t test shader lowering or GPU execution.
I used OpenAI Codex with GPT-6.2 Sol to write and run the test. A separate GPT-6.2 Sol agent verified the fixture and logs. GPT-6.2 Astra drafted this comment.
I reviewed and approved this comment before posting.
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-27T19:51:37Z.
Tested
Clean detached
962cdca84c402e0254cc1c6909bb82393164cd21on Windows 11 25H2 build 26200.9974, Ryzen 7 3800X, and Rust 1.100.0 MSVC. I verified the fixture source, executable, and exact-head production library hashes, then ran the existing CPU harness withdiamond.exe --test-threads=1 --nocapture.Three synthetic RDNA2 programs use a uniform scalar branch, a
[64, 1, 1]thread group, and a scalar read ofVCC_LOafter the two paths join.VCC_LO:Ok(NoCrossHalf).VCC_HIinstead: rejected at byte 24 withmask read as data. Each predecessor was tested separately.3 passed, 0 failed, 0 ignored, 0 skipped. Process exit 0.
Not tested
GPU execution, lowering, retail shaders, and the stock suite.
AI use
T3 Code / Codex (
gpt-6.2-sol) wrote the synthetic fixture, independently reran it, and wrote this report.Imported from ivall/xcl. Originally posted by razormontana on 2026-11-28T00:49:41Z.
Independent check of the eligibility analyzer at
962cdca84c402e0254cc1c6909bb82393164cd21, as included in the clean #3042 stack atbecdecfe8895548fc6329e572b44cba010757acc. Windows 11 Pro build 22631, Core i7-10700K, RTX 3070 8 GB with NVIDIA 617.42, Rust 1.100.0 x64 MSVC.Tested
cargo test --offline --locked -j 1 -p xcl --lib --no-run --message-format=json-render-diagnosticsbuilt the test executable. The run selected the 17 published CPU analyzer fixtures by exact name with--exact --test-threads=1 --nocapture. All 17 passed, with 0 failed, 0 ignored and 0 explicit skips. The fixtures cover eligibility and rejection at mask, branch, LDS, lane operation and workgroup boundaries.Not tested
A detached #3040-only build, the game-data census, or retail behavior.
AI use
Codex GPT-6.2 ran the focused validation, checked the results, and prepared this report.
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-28T02:29:30Z.
Source review of #3040 at
962cdca8: I found two eligibility cases to resolve before #3042 uses this analyzer for wave-local lowering. These are source-traced cases; I have not run their GPU regressions.DPP16 row mask across two 32-lane waves.
analyzeallows DPP16 without examiningROW_MASK(scan). For a 64-thread group, identity quad permutation0xE4,ROW_MASK=0xC,BANK_MASK=0xF, the console instruction writes rows 2–3 (lanes 32–63); the existing partition fixture uses that encoding. Wave-local HLSL setslane_id = WaveGetLaneIndex()for each 32-lane wave, while DPP16 write enable selectsROW_MASK >> (lane_id >> 4). Both waves then select bits 0–1 and skip writes intended for the upper half. The direct and per-lane emitters also use their local lane index for this row selection. A conservative eligibility fix is to reject DPP16 for groups over 32 threads when(ROW_MASK & 3) != ((ROW_MASK >> 2) & 3), reading the field from the DPP extension encoding. Please add an analyzer rejection for0xC, an eligible symmetric-mask control such as0xA, and a split-vs-wave-local GPU comparison.SDWA compare destination.
mask_op_destchecksd.enc.nameand readsSD/SDSTfrom the base encoding. For SDWA VOPC, those fields are in the extension:vopc_writecorrectly writess[22:23]whenSD=1, SDST=22, while the analyzer marks VCC instead. A later scalar read ofs23can pass eligibility even though the full-wave ballot's upper word differs from the local-wave value. An existing encoded fixture verifies the actual destination. Please resolve the SDWA destination from the extension and add an analyzer regression in which readings23as ordinary data rejects the 64-thread shader.AI use: OpenAI Codex (GPT-6.2 Sol) checked the paths; OpenAI Codex (GPT-6.2 Astra) independently traced the low-level cases. No runtime result is claimed.
Imported from ivall/xcl. Originally posted by bmjask on 2026-11-28T22:04:17Z.
Review: COMMENTED
Critical-review result: I did not find a concrete unsound acceptance in the eligibility analysis. The rejection set covers the principal cross-half hazards I checked: lane exchange, wave-wide counts, mask/SCC use, large-group LDS, divergent barriers, and scalar writes live across lane joins.
This remains a large proof surface. Before depending on it beyond the experimental path, please report differential GPU results comparing accepted shaders against split-wave64 over the available retail corpus, including acceptance counts and output mismatches. That evidence is more useful here than additional hand-selected positive tests.
Reviewed at
962cdca84cwith Codex (GPT-5).Imported from ivall/xcl. Originally posted by coolpersonnn on 2026-11-28T23:41:30Z.
@bmjask Thanks for the review. The branch has been updated to
c56cfcdd(rebased ontomain10373744, also addressing the DPP16ROW_MASKand SDWASD/SDSTanalyzer fixes), and the requested retail corpus differential check was run against the stacked lowering head (43d0c866):retail_wave_local_buffer_differential, RTX 5090, release): Out of 1,154 wave64 compute shaders in the retail pack, the analyzer accepted 359 (340NoCrossHalf, 19SingleWave).1d7d9f365982e397initially differed due to overlapping synthetic buffer views in the test harness and matched once each view was given a disjoint range).Full workspace/smoke numbers are in the updated PR description.
AI use: Codex (
gpt-6.2-sol) implemented the review fixes, rebased the branch, ran the tests and retail corpus comparison, and updated the PR description. Antigravity (Gemini 4 Hydrogen) drafted and posted this reply from that session's recorded results.Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T00:14:12Z.
merge-check
base:
929854811bhead:
c56cfcdd3bmerge: clean (trial merge aeabe8bdc8edd20dfa098c0657dccd087d2c65db, local, not pushed;
git diff --checkclean)build: cargo build --workspace -> ok (no new warnings from
wave_local.rs)tests: cargo test --workspace --no-fail-fast -- --test-threads=4 (XCL_DXC_DIR = DXC 1.9.2609) -> 2628 passed, 0 failed, 49 ignored; SKIPPED: 26 (21 no wave64 on this 32-lane GPU, 3 per-lane f16/f32 forms refused (#1426 semantics), 2 no heap windows); failing: none. All 20
wave_local::testsran and passed, including the two new ones,rejects_asymmetric_dpp16_rows_in_split_groupsandrejects_sdwa_compare_destination_read_as_data.retail_wave_local_censusreturns early withoutXCL_SAMPLE_RPF; no sample pack here, so it checked nothing. In the first full run thexcllib binary stopped itself duringuma_driver::tests("coherent window could not be restored ... Windows error 487 ... Map gave 0x20349c10000, wanted 0x2035e040000"): another test thread took the address between unmap and remap. Those tests come from main (2fc61b64), and this PR touches no UMA code. A rerun ofcargo test -p xcl --libon the same merge: 2489 passed, 0 failed; the count above uses that rerun plus the other targets of the first run.review: none blocking; whole new-head diff read (
wave_local.rs+914, thepub modline, the THIRD_PARTY.md row, and a provenance header that matches it). Both findings from thehollowedone's source review at962cdca8are addressed in this head. (1) DPP16 is rejected for groups over 32 threads whenROW_MASK & 3 != ROW_MASK >> 2; the field is read from the DPP extension; the test covers0xC(rejected) against the symmetric control0xA(accepted), and 32 threads (accepted). (2) SDWA VOPCSD/SDSTcome from the extension encoding; the test coversSD=1, SDST=22then a read ofs23(rejected as mask read as data) againstSD=0(accepted). Notes, none blocking:analyzeyet (onlypub mod wave_local), so this PR has no runtime effect. The split-vs-wave-local GPU comparison thehollowedone asked for can only run once #3042 wires the analyzer into lowering, and should be checked there.962cdca8(a mask overwritten after its last use, then a branch back to the header, rejected at the header) would be a cheap regression test to add.performance: none at runtime (analysis code nobody calls yet). No title run: Recompiler / Tier 1.
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti 16 GB (driver 610.74, wave32 only), AMD Ryzen 9 9950X, Windows 11 build 26200; rustc 1.99.0, debug test profile, DXC 1.9.2609 via XCL_DXC_DIR. Claude Code, Claude Opus 5.5: merge, build, suite and full-diff review; this report.
Imported from ivall/xcl. Originally posted by coolpersonnn on 2026-11-29T13:32:31Z.
@Kalmarv Thanks for the review. Both notes have been addressed:
e5e87e6e): Addedrejects_vcc_clobbered_before_a_loop_backedge, which accepts a uniform loop preservingVCCand an overwrite after final use without a backedge, and rejects at byte PC 8 when a backward branch makes the header consume the overwrittenVCC_LO.5e470d3e): Rebased ontomain(7a649b0e) atop#3040with the conflict resolved;retail_wave_local_buffer_differentialpassed (359accepted of1,154wave64 compute shaders; all31with observable buffer writes matched split-wave64 HLSL with0mismatches;105no observable write;223requiring image bindings).Full test counts and 60 s smoke results are in both updated PR descriptions.
AI use: Codex (
gpt-6.2-sol) in T3 Code added the loop regression and rebased both branches onto7a649b0e. Antigravity (Gemini 4 Hydrogen) in T3 Code ran the workspace tests, retail census/differential, and 60 s smoke runs, pushed both branches, updated the PR descriptions, and posted this reply.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:24:27Z.
Triage (#1607) – head
f197cb2#3042 is stacked on this PR (it contains this commit plus the lowering that uses it), so that overlap is a stack, not a duplicate. No other open or merged PR adds a wave-local eligibility analysis. No problems found in the parts of
wave_local.rsI read; the analysis is conservative (it rejects any cross-half op it cannot prove safe) and nothing calls it yet.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T12:08:54Z.
merge-check
base:
493dbd3dd0head:
f197cb2dc5merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2921 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (+948). It adds
wave_local::analyze, which decides whether a wave64 compute program's two 32-lane halves never depend on each other. Nothing calls it yet, so there's no runtime effect. Findings: (1) Size. About 370 lines of code (wave_local.rs~1-370) and 575 of tests; that fits "new code with its tests", but CONTRIBUTING asks for the reason in the description past 800. (2) Hard to check by hand. The dataflow is written as dense one-liners (~87, ~358, ~361), and soundness rests entirely on it; a few named steps would make review of the turn-on PR easier. (3)partial_blocks(~103) copieslower.rs~1116 ("matching lower::partial_blocks"); reusing or extending that one keeps the two from drifting. (4)retail_wave_local_census(~888) only prints. Lanes of one console wave that talk through UAV memory aren't modelled, but the split form doesn't order that between halves either, so it's no regression (unverified). Fine: it conservatively rejects cross-lane reads (readlane / writelane, (b)permute,s_getreg, TG_SIZE), thes_bcnt1/s_ff1/v_mbcnt/ readfirstlane family in groups over 32 threads, masks read as data, inverting mask ops, VCCZ / EXECZ reads, SCC set by a mask op, LDS and GDS in groups over 32 threads, barriers inside lane branches, scalar writes in a lane branch live at the join (back-edges included), indirect jumps, and asymmetric DPP16ROW_MASK. The SDWA compare-destination fix is in. The PR's red CI is thepipeline_librarylock-poisoning flake (the same commit passed in #3042's run). No smoke run: nothing calls it.performance: no smoke run (the default path doesn't reach this change); not measured. Analysis only, not called: no runtime path changes. Its 21
wave_localtests passed here.verdict: safe to merge (not called yet; the size reason belongs in the description, and reusing
lower::partial_blockswould keep the two from drifting)hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by coolpersonnn on 2026-12-01T14:27:14Z.
Closing: prerequisite for #3042, which is being closed after world testing showed no measurable speedup.
Pull request closed