Recompiler: folded wave64 lane primitives (thread hand-out, two-ballot masks, lane reads, v_mbcnt) #3530
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3530"
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-30T14:59:51Z.
Stacked on #3529; only the top commit belongs here. Part of #3011 (C57, step 2/2 of the design note).
The lane primitives of the folded form (one hardware wave of 32 lanes carries a console wave of
64: hardware lane t is console lanes t and t + 32, the second in the VGPR bank of step 1). They
work when
Lw::foldis set; no program selects the form yet, so nothing a title runs changes.What is in it
crates/xcl/src/gpu/dxil/lanes.rs, a secondimpl Lwafter the split primitives:folded_numthreads,setup_lanes_folded(->FoldedThreads): the hardware group is[ceil(T / 64) * 32, 1, 1]; hardware thread f is console threads(f >> 5) * 64 + (f & 31)and that + 32, console lanes
WaveGetLaneIndex()and that + 32; thread id components of bothhalves; the launch EXEC, all ones or, for a partial last wave, two ballots of
thread < T. Setsfold. No group barrier and no groupshared counter.ballot_folded,write_mask_folded:lo = WaveActiveBallot(cond of half 0).x,hi = WaveActiveBallot(cond of half 1).x; both halves' conditions (each under its own EXECbit) are made before the register pair is written, once.
read_lane_folded,read_first_lane_folded:WaveReadLaneAt(v of the half, l & 31), the halffrom bit 5 of
l(one read whenlis known while translating, else both and a select).write_lane_folded: the VGPR of the bank bit 5 oflnames, where the lane isl.mbcnt_folded: the countv_mbcnt_lo/_hiadds, for the half selected (half 1 counts thewhole low dword).
crates/xcl/src/gpu/dxil/lower.rs:Lw::each_half(runs a closure for half 0, then half 1, andrestores the half selected). No line of step 1 changed.
THIRD_PARTY.md: a row for another project'sfold.rs(GPL-3.0-or-later), whose thread mapping,lane read / write and
v_mbcntrecipes these follow; the note is above theimplinlanes.rs.Nothing was copied: theirs rewrites machine code, this builds DXIL values.
gpu_folded_wave64_cross_half_operations(lanes.rs,fold_tests).About 170 lines of code and 250 of test.
Tested
cargo test -p xcl --lib -j 12 -- half_tests gpu::dxil folded --test-threads=4: 313 passed, 1 failed (theresinfo_d16test below), 3 ignored;gpu_folded_wave64_cross_half_operationsran on the GPU (not skipped)cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 2888 passed, 1 failed, 51 ignoredgpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16("2D D16 resinfo clobbered v2/v3"), fails the same way onorigin/main9dfbe3ea(cargo test -p xcl --lib -- gpu_direct_image_get_resinfo_d16: 0 passed, 1 failed), so it is not from this PR. Not looked into further.SKIPPEDon this adapter (32-lane waves only): the wave64 variants ofgpu::recomp::lower/lower_dxiltests (no wave64),gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole, two heap-window tests (no heap windows),shaders::tests::pso_measurement_compiles_an_exact_synthetic_record(driver cache cannot be disabled: Developer Mode)driver before step 3, so the test builds a compute entry by hand from the primitives (and
set_half,act,write32,first_lane,lanemask_ltof the existing lowering) and runs itwith
runner::dispatchin groups of[128,1,1],[104,1,1],[80,1,1]and[8,8,2]consolethreads (64 hardware threads each). Every console thread stores 19 words, each compared with the
64-lane result: its thread id and components, lane, launch EXEC (full, 40 and 16 threads of a last
wave), a mask over lanes 0..39 and its count, lane reads of lanes 5, 45 (known when translating)
and 37 (from a register),
mbcnt_foldedand the unfoldedlanemask_ltcount, the first lane ofan EXEC with upper bits only and a write under it, lane writes of lanes 9 and 41, a mask with
lane 50 only, a compare that writes EXEC. Nothing is stored past the group's threads. Wave 0 of
the first group is also compared with the same program as console code in the kernel form
(
runner::direct_kernel, split on this adapter).mbcnt_foldedbroken on purpose (half 1 not counting the low dword) the test fails atthread 32.
Regression run
9dfbe3ea(scripts/smoke.ps1 -Game <title>, 60 s):scripts/smoke.ps1setsXCL_NETWORK,XCL_RUN_SECONDSandXCL_ACTIVITYbefore it startsxcl.exe, so the child process gets them (the run ended after 60 s with exit 0). The runs used-Xclwith a release build of each commit in its own target directory.Not tested
either: memory and LDS, control flow, more than one thread group per dispatch, a lane read or
write under a
guard_override, the thread limits of a dispatch (compute_gate).threads (as the 1-D native form does); a driver that forms them otherwise is not handled.
[WaveSize(32)]waves full for this entry.AI use
main9dfbe3ea, ran the suite and prepared this PR.🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by KDenKC on 2026-11-30T17:03:49Z.
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 Foniass on 2026-12-01T03:16:36Z.
merge-check
base:
d0832e614fhead:
91bc77189fmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2893 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 #3530's own commit (against #3529's head
cc606cc1). Nothing a title runs changes: the new functions are only called from fold_tests. RDNA2 semantics check out (v_mbcnt lo/hi, v_readlane / v_writelane lane select on bits 5:0, v_writelane ignoring EXEC, v_readfirstlane of an empty EXEC reading lane 0, the EXEC of a partial last wave). The test's expected values are computed on the CPU, it checks nothing is stored past the group, and it uses skip_test. Findings, all low: (1) THIRD_PARTY.md says ported logic carries "a note in their header" (GPL-3.0 §5a), but the VIctory-NVIDIA note sits above the secondimpl Lw(lanes.rs ~1070), not in the file's header doc. (2)write_mask_folded(~1138) is simpler thanwrite_mask: no per-lane bit record, no batched-ballot path, and with a VGPR destination it writes only the selected half. That is fine while nothing calls it that way, but step 3 will. (3) The thread hand-out takes the wave fromflat >> 5and the lane fromWaveGetLaneIndex, which assumes hardware waves of 32 consecutive threads (the same assumption as the existing 1-D native form; the description says so). No smoke run: no GPU path a title takes changes.performance: none expected (nothing a title runs calls the new code); not measured
verdict: safe to merge (after #3529, which it is stacked on; this run tested both 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-01T06:32:22Z.
merge-check claim
head:
91bc77189fImported from ivall/xcl. Originally posted by throny on 2026-12-01T06:46:59Z.
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).
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T11:48:12Z.
merge-check claim withdrawn
Our automated merge-check loop claimed this PR and then stopped before posting a check — two loops were running at once and both are now shut down. No check from us is coming, so this claim is void and the head is free for someone else to take.
AI use: an agent posted this withdrawal.
Pull request closed