Recompiler: folded wave64 instruction driver and kernel entry (tests only) #3543
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3543"
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 throny on 2026-11-30T19:16:11Z.
Stacked on #3530 (which is stacked on #3529); only the top commit belongs here. Part of #3011 (C57, step 3 of the design note).
The instruction driver of the folded wave64 form: a wave64 kernel runs in one hardware wave of 32 lanes, hardware lane t carrying console lanes t and t + 32.
Lw::inst_foldedlowers the program's instructions through the half context (step 1) and the lane primitives (step 2). Nothing in the runtime asks for the form yet (kernel::translate_foldediscfg(test)), so nothing a title runs changes.What is in it
crates/xcl/src/gpu/dxil/lower_fold.rs(new):Lw::inst_folded. Scalar instructions are lowered once; VALU once per half, with the mask writes of both halves collected and written once;v_readlane,v_readfirstlane,v_writelane,v_mbcntthrough the folded lane primitives; everything else (vector memory, LDS, images,ds_bpermute, DPP, relative moves,s_barrier, mode writes) is refused with the translator's usual error, so a caller falls back to another form.crates/xcl/src/gpu/dxil/kernel.rs:translate_folded(tests only), thefoldflag throughtranslate_entry_with/translate_on_this_thread, the kernel entry (setup_lanes_folded([64,1,1]),vgpr_base/vgpr_base_hi), the epilogue storing the second bank. A program whose two banks would not fit a hardware lane (2N + 16 > 255 registers) is refused (review fix C77).crates/xcl/src/gpu/dxil/lower.rs:fold_masks,vgpr_base_hiinInit. Because both halves' mask writes are collected and written once, a mask read through a loop join is the same for both halves;MASK_JOIN_LOOPinfold_tests.rsis a regression test for that case (C76, the fault fixed in another project b8f365ad), no separate code change.crates/xcl/src/gpu/dxil/lanes.rs:ballotandrlarefuse in the folded form (not_folded);write_lane_foldedmasks the lane to 0..63. These are small fixes to step 2 code, kept in this commit.crates/xcl/src/gpu/dxil/fold_tests.rs(new),core_tests.rs,mod.rs: tests comparing folded kernels with the 64-lane result.773 changed lines, of which 454 are tests (
fold_tests.rs); the code is about 320 lines.Tested
cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4on 5868686a (same tree as the head, only the commit message changed): 2892 passed, 1 failed, 51 ignored.gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, is the one #3530 reports failing onorigin/maintoo (not from this PR).SKIPPEDon this adapter: the wave64 variants of thegpu::recomp::lower/lower_dxiltests anddispatch_chain_native_wave64_builds_whole(no wave64), two heap-window tests (no heap windows),shaders::tests::pso_measurement_compiles_an_exact_synthetic_record(driver cache cannot be disabled).Regression run
ff0c364b(scripts/smoke.ps1 -Game <title>, 60 s):-Xcl). The PR branch is based on main9dfbe3ea(via #3529 / #3530), the main run is on the currentorigin/main.Not tested
fold_tests.rscovers.AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by KDenKC on 2026-11-30T19:44:40Z.
AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 3.8 Flash.
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T01:41:25Z.
Measurement of the folded form in the world, as promised on #3011: the full local stack (steps 1–8 on
main0fe06eb0), RTX 4080 16 GB (621.40), two 900 s runs of the same save and inputs withXCL_GPU_PROFILE=1,XCL_WAVE64_FOLDunset vs=1, each with its own DXIL cache. No device removal in either.So the stack stays as it is: steps 1–3 are correct and tested, but I won't push steps 4+ without a reason. A note for whoever picks it up: the profiler's form label still says "split in halves" for folded programs; it should name the folded form.
AI use: Claude Code (Claude Opus 5.5), runs and aggregation by a Claude Sonnet 5.5 sub-agent.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T02:57:03Z.
merge-check
base:
d0832e614fhead:
6597afd4e0merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2897 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 top commit (91bc7718..6597afd4) in full. No behaviour change for titles:
foldis only set through the test-onlytranslate_folded, and the new code inInit::first/store_registersonly runs withvgpr_base_hi. Minor: (1) theandc(l, 63)added towrite_lane_folded(lanes.rs ~1175) changes nothing, since the loop already masks the lane and bit 5 is unchanged, so it is not a fix and should be squashed into #3530 with the other lanes.rs change; (2) no test reaches thenot_foldedguards inballot/rla(class() refuses those first) or the refusals in lower_fold.rs ~130/~140; (3) counting NSA address registers in kernel.rs ~335 is dead while every image instruction is refused. No GPU path a title takes is changed, so no smoke run.performance: none by default (test-only entry point); not measured
verdict: safe to merge (after #3529 and #3530, which it is stacked on; this run tested the three together)
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 brainhay5 on 2026-12-01T03:09:58Z.
merge-check claim
head:
6597afd4e0Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T03:16:11Z.
merge-check claim
head:
6597afd4e0Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T03:17:29Z.
merge-check
base:
d0832e614fhead:
6597afd4e0merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2896 passed, 1 failed, 51 ignored; 29 SKIPPED lines
failing: test_title_runs_and_game_folder_is_untouched
review: automated overnight check — diff inspected for safety only (no build/CI/toolchain/script changes, no process/network/runtime-loading code); no duplicate search performed; no line-by-line code review.
performance: not assessed beyond the suite.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 610.88 (32.0.16.1088); Ryzen 7 5800X3D, 64 GB; Windows 11 22631; OpenCode agent, DeepSeek V4.1 Flash 1017
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T06:46:56Z.
Closing our own PR to keep the queue small: measured in the world (see #3543), the folded wave64 form brings no gain on an RTX 4080 (folded programs ran at a median 1.27× their split time, within run-to-run noise), so this code would sit unused in the tree. The branch stays on throny/xcl; reopen if a later measurement (e.g. on another GPU) shows a gain.
AI use: Claude Code (Claude Opus 5.5).
Pull request closed