Recompiler: batch consecutive v_readfirstlane/v_readlane exchanges in direct DXIL split-wave64 #2071
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2071
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2071/head"
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?
@zondy1i on GitHub · 2026-11-25 02:52 UTC · original
zondy1i:dxil/split-readlane-batch→main· +358 −8 · 5 files · 1 commits · closed without mergingPart of #1269.
Brings the split-wave64
v_readfirstlane_b32/v_readlane_b32exchange batching idea (similar to #944 for HLSL) to the direct DXIL backend (crates/xcl/src/gpu/dxil/).In split-wave64 mode (wave64 console shaders running on 32-lane hardware such as NVIDIA/Intel GPUs), every
v_readfirstlane_b32/v_readlane_b32previously emitted its own single-wordexchange_n(&[m])— 2 group barriers per instruction inPartner::Present(64-thread groups) and a full 4-block spin-wait loop with 2TGSM_FENCEbarriers and 2 groupsharedatomicrmwops per instruction inPartner::Spin(>64-thread groups). Consecutive independent runs now share a singleexchange_ncall. Native wave64 and wave32 lowering is untouched.What changed
crates/xcl/src/gpu/dxil/lanes.rs:Lw::read_lane_uniform_batch(&[(Value, Value)])to perform one cross-halfexchange_nacross a run of independent lane reads (reusingl & 31andlh == self.halfwhen consecutive items share the same lane index).crates/xcl/src/gpu/dxil/lower_valu.rs:Lw::lower_block_inststo greedily batch consecutiveVariant::Plainv_readfirstlane_b32/v_readlane_b32instructions within a basic block up toself.xslot, stopping at any SGPR read-after-write hazard (includingEXEC,VCCZ,EXECZ,M0, orEXECwrites).max_readlane_batch(stopping at CFG blockleaders) to size split-wave64 exchange slots inLw::new.crates/xcl/src/gpu/dxil/kernel.rs&crates/xcl/src/gpu/dxil/compact.rs:Lw::lower_block_instsin both the standard and compact forms.slotinLw::newwhensplitandmax_readlane_batch >= 2(up to 16 words without LDS; bounded to at most 256 total dwords = 1 KiB when sharing LDS).crates/xcl/src/gpu/dxil/core_tests.rs:split_readlane_batch_merges_present_and_spin_exchanges: verifies 6 consecutivev_readfirstlane_b32/v_readlane_b32collapse from 13 to 3 barriers (Partner::Present) and from 13 to 3atomicrmw addspin ops (Partner::Spin).split_readlane_batch_respects_sgpr_hazards: verifies lane-selector RAW dependencies andEXECwrites break the batch.gpu_split_readlane_batch_executes_correctly: GPU execution check on lower-half, upper-half, masked-lower-half, and dependent-chain cases.Tested
rustc 1.100.0, DXC /dxil.dll1.9.2602.17, NVIDIA GeForce RTX 3060 Ti 8 GB (driver621.01).cargo test -p xcl --lib -- gpu::dxil --skip fuzz_tests: 155 passed, 0 failed, 1 ignored (includessplit_readlane_batch_merges_present_and_spin_exchanges,split_readlane_batch_respects_sgpr_hazards,gpu_split_readlane_batch_executes_correctly, andcompact_tests).xcl shaders <corpus> --direct --sample 500 --seed 1 --max-bytes 262144 --split 1 --validate --threads 8: 500/500 translated and validated (0 unsupported, 0 validator failures, 0 panics).Not tested
gpu::dxil::fuzz_tests, AMD / Intel GPUs, Linux / Wine / vkd3d-proton.Regression run
main:PR:
AI use
Antigravity (Gemini 4 Neon) assisted with implementation, IR/hazard/GPU tests, and validation; all changes were reviewed and verified locally.
@JJAutoCompare on GitHub · 2026-11-25 03:05 UTC · original
XCL #2071 — Intel Arc A770 split-wave64 compatibility
Tested
Clean PR head
c270670b7b82aab8b3f805a3cd438d46642fbeeaon Windows 11 Enterprise Evaluation 26200.9974 x64, AMD Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust 1.100.0 (0ef1bc386,x86_64-pc-windows-msvc) and the unoptimized test profile. Each process logged dxcompiler and dxil 1.9.2609.5 (DXC build01b62ad4). The local checkout was clean before and after execution. GitHub showed the PR open at the tested SHA before and after the run. The final public conversation check at 2026-11-25 03:03:23 UTC showed no matching report or review.The process environment used
CARGO_BUILD_JOBS=2,CARGO_INCREMENTAL=0,CARGO_PROFILE_DEV_DEBUG=0,CARGO_PROFILE_TEST_DEBUG=0,CARGO_TARGET_DIR=L:/XclTooling/pr1947-1831ec4-t3-97236edf/target,TEMP=TMP=L:/XclTooling/pr2071/run-20261125T030121836Z/temp,XCL_ADAPTER=A770andXCL_DXC_DIR=$env:LOCALAPPDATA/XclTooling/dxc-1.9.2609/bin/x64.The prebuild exited 0 outside the Arc mutex and Cargo reported a newly built test executable (
fresh: false). The GPU test acquired and released the Arc mutex.split_readlane_batch_merges_present_and_spin_exchangessplit_readlane_batch_respects_sgpr_hazardsgpu_split_readlane_batch_executes_correctly3 passed, 0 failed, 0 ignored, 0 skipped. All three exited 0. Disassembly matched three barriers for the 64-thread group and three
atomicrmw addoperations for the 128-thread group. The lane-selector dependency and EXEC write cases each retained five barriers. The GPU fixture validated the signed direct DXIL container and dispatched it on the A770. All eight expected SGPR values matched, covering reads from both halves, first-active-lane selection with the lower half masked, and a dependent lane-selector chain.Not tested
GPU execution of the 128-thread spin path, native wave64, standalone wave32 lowering, HLSL execution, other adapters, the full workspace suite, stress, throughput, retail titles and smoke runs.
The Cargo JSON and stderr, each fixture's stdout and stderr, and all exit codes are preserved in
L:/XclTooling/pr2071/run-20261125T030121836Z.AI use
T3 Code / Codex (
gpt-6.2-sol) ran the three checked-in fixtures and prepared this report.@WebIdentity1 on GitHub · 2026-11-25 03:05 UTC · original · edited 2026-11-25 03:08 UTC
RTX 3090: actual multi-wave compute execution and cost
The new fixture below closes the GPU-execution gap for
Partner::Spin(also explicitly untested in the new Arc report). No runtime changes: parentcbc296ab65a2661a61e3e2da109134bcd5319f60versus headc270670b7b82aab8b3f805a3cd438d46642fbeea, each with the identical test-only addition tocore_tests.rs.Tested: Windows 10 Home 19045, Ryzen 7 7800X3D, RTX 3090 driver 591.74, Rust/Cargo 1.98.1 MSVC, DXC/DXIL 1.8.2502.11, debug. Each process printed the actual NVIDIA adapter.
All four invocations: 1 passed / 0 failed / 0 ignored, zero SKIPPED notices. Each executes both 64-thread
Presentand 128-threadSpincompute shaders, 16 groups, 64 loop iterations, six independent reads per iteration (lanes 0/7/31/32/41/63). Values evolve each iteration and differ by console wave. Every 1,024/2,048 output word agrees with the independent CPU sum and all 16 tail guards remain unchanged. This checks normal and forced-compact translation, repeated exchanges and cross-wave isolation. Both parent and head are correct; this is optimization coverage, not a newly fixed semantic failure.Emitted barrier calls fall 13 → 3 in all four forms;
atomicrmw addfalls 13 → 3 for the 128-thread spin case (64-thread remains one setup atomic). The spin form gets smaller and translates faster in this fixture. The 64-thread normal form instead grows by 36 bytes and has a slightly higher measured translation cost; there is no universal compile-time improvement claim.Method: one untimed warm translation then five timed
translate_computecalls, each byte-identical to that reference; explicit final DXIL validation outside the timer. GPU timings are ten samples after discarding the first of eleven timestamped dispatches; they exclude PSO creation, resources, upload/readback, submission, CPU wait and the barriers between dispatches. Correctness was checked on a separate untimed dispatch: the timed API discards its readback. One process per form/revision, parent before head, no randomized order/clock control; these short synthetic timings are descriptive, not retail speedup or cold-PSO evidence. Both 322-file source snapshots match before/after Windows execution and locally; Cargo rebuilt XCL for each revision.Not tested: full workspace, retail smoke, native wave64, AMD, LDS-carved exchange storage, divergent/partial EXEC in this new fixture, or memory consumption. The existing author hazard tests cover different cases and were not rerun here. The fixture is offered for adoption alongside those tests; no competing PR.
AI use: Codex (GPT-6) wrote the synthetic test, performed the native Windows comparison and prepared this report.
Portable test-only patch (same addition on parent and head)
@JoaoPauluu on GitHub · 2026-11-25 03:14 UTC · original
A run with vkd3d-proton as the host D3D12. The DXIL goes through dxil-spirv and then the NVIDIA Vulkan driver, a different compiler from a native-Windows run: this PR's 3 new tests pass.
Tested
x86_64-pc-windows-gnu.c270670as it is (merge base withmaincbc296a), no uncommitted changes. The lib test binary runs under Wine, one test per process.gpu_split_readlane_batch_executes_correctly: ok, not skippedsplit_readlane_batch_merges_present_and_spin_exchanges: ok, not skippedsplit_readlane_batch_respects_sgpr_hazards: ok, not skippedNot tested
AI use
@DavidM1911 on GitHub · 2026-11-25 05:09 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@DarkPanda69 on GitHub · 2026-11-25 03:29 UTC · original · edited 2026-11-25 12:35 UTC
Update for head
3b7dbf5: same result. Tested as is (it no longer applies on currentmain),gpu_split_readlane_batch_executes_correctlypasses on the RX 9070 XT and the RTX 3060. Wholegpu::filter: RTX 3060 632 passed, 0 failed; RX 9070 XT 629 passed, 3 failed, all three also failing on this head's base426a5a7without the PR (the #2115 fuzz seeds andgpu_image_get_resinfo_past_last_level, since fixed onmain).AMD run, with
gpu::dxil::fuzz_tests, both of which this PR lists as not tested.Tested: head
c270670applied on its basemaincbc296a, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17.cargo test -p xcl --lib -- gpu:: --test-threads=4:gpu_split_readlane_batch_executes_correctlyok. The 2 failures aregpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1and_3(seeds 722 and 1599, a wrong result word on this card). They fail the same way onmaincbc296awithout this PR, so this change neither causes nor fixes them;fuzz_validate_and_gpu_0and_2pass with it.Not tested: Linux / Wine / vkd3d-proton.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@zondy1i on GitHub · 2026-11-25 16:10 UTC · original
Continued in #2343 (rebased cleanly onto current
main; this PR was auto-closed when the fork branch was briefly deleted during a GitHub sync glitch and cannot be reopened).@DavidM1911 on GitHub · 2026-11-26 07:14 UTC · original
Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current
mainon the new head — needs another rebase before it can be tested.Pull request closed