Recompiler: split wave64 exchanges every mask by default #3748
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3748"
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-12-03T00:37:59Z.
On 32-lane GPUs (NVIDIA) a 64-lane console wave runs as two halves that exchange their masks at set points. Two analyses leave out exchanges they find unneeded: the lazy planner (
gpu/dxil/kernel.rs) and the half-local mask analysis (gpu/recomp/x64_masks.rs). In some programs that is wrong. The halves fall out of step, the next exchange gives up after its spin limit, and the wave reads zeros from then on, without an error. This makes every exchange the default;XCL_X64_PRECISE_MASKS=1turns the analyses back on. Part of #505.Found by @theaustinayers (#505). With a longer spin limit the silent zeros became 37-40 ms GPU calls; with every exchange kept (
XCL_X64_ALL_MASKS=1, on main) they were back to about 0.5 ms, and the cell's lighting and final colour pass came out right. KDenKC's RTX 5090 data (#505): seven split programs had a longest call of 31.4-31.9 ms on main and none with all masks; frame GPU time went from 144 to 131 ms, and the cell was lit.What is in it
v_readlaneof lane 32 or above that holds a constant reads that constant, as the console does in its whole-wave reduction idiom (identity written outside EXEC,s_or_saveexec -1,v_readlane32). Without it, the all-exchange form gave 0 there: wrong for AND / UMIN / IMIN / IMAX (vasanex's review). Testgpu_split_wave64_reduction_reads_the_identity_of_a_missing_upper_half(32/64/96 threads, default form).by_default_every_vote_is_exchanged(dxil/idioms.rs), and of the switch's parse.gpu/recomp/x64_masks.rs:precise_masks()(XCL_X64_PRECISE_MASKS, any value but0), off by default. Off also means the lazy planner's other forms are off: mask batching, the waves-apart form, and theXCL_WAVE64_IDIOMSidioms (#3563). Those now only work with the switch on; a test-only guardPreciseForTestand the lockPRECISE_LOCKfor the tests of the analyses.gpu/dxil/kernel.rs,gpu/recomp/mod.rs,gpu/recomp/pso.rs: the fourXCL_X64_ALL_MASKSchecks use it; the cache-bypass and settings lists name the new switch (shaders.rs).translation_is_byte_identical_across_runs_and_threadstakes the same lock, so it never runs while another test has the analysis on.docs/wave64-on-wave32.md: the default. (docs/wave64-on-wave32.md:251andHANDOFF.mdstill nameXCL_X64_ALL_MASKSas a comparison switch; that's out of date now.)Tested
cargo test --workspace -- --test-threads=4ona8a6fef2(Gevroska's upper-half case fixed): 3010 passed, 0 failed, 52 ignored, 25SKIPPED; the new testgpu_split_wave64_reduction_of_an_upper_half_without_a_lower_half_reads_its_own_lanefails on08beabaf(0 instead of 133).cargo test --workspace -- --test-threads=4on08beabaf(after Foniass's and vasanex's reviews): 3009 passed, 0 failed, 52 ignored, 25SKIPPEDlines (no wave64 and similar). The recompiler and DXIL tests alone: 894 passed, 0 failed.by_default_every_vote_is_exchangedfails on main (the idioms leave 1 of 4 votes exchanged there).5ad98adbc,XCL_X64_ALL_MASKS=1(the same code paths as this default) against unset: 3.10 vs 2.79 and 3.18 vs 3.13 presents/s. No device removal and no crash. A third pair was cut short by our memory guard. Early in the cell, with every exchange, the window shows the building outside and the door frame is lit; at the end of 900 s both go dark, so the darkening over a long run has another cause.395405e4c: a 300 s world run (523) with no crash and no device removal, 2.98 presents/s. The previous head8eae7efain 900 s warm runs: 3.14 presents/s vs main's 3.07 (runs 521/522); cold start: first frame after 153 s.Regression run
main
817eb1fc9:this PR's head:
Not tested
AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T01:11:22Z.
merge-check
base:
078358a058head:
7bccc60c4amerge: clean
build: ok
tests: 3006 passed, 0 failed, 52 ignored; 28 skipped, the same as on main
review: 1 high, 3 medium, 3 nits (below)
performance: 60 s smoke run: 1669 → 1415 frames (84 % of main), peak commit 17577 → 16219 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 226 s there, 0 device removals, 0 crashes, 4 presents/s; run with
XCL_SKIP_CS=95cc13288a27a96e(the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)verdict: not yet: 1 blocking finding (critical or high, below); also
PR descriptionis redhardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
In short: Makes split wave64 exchange every mask by default: the half-local mask analysis (x64_masks) and the DXIL lazy planner only run with the new XCL_X64_PRECISE_MASKS. This works around #505, where the two halves fall out of step and the wave silently reads zeros; the root cause in the analyses is not found. The code change is small and consistent: all four XCL_X64_ALL_MASKS checks are flipped, the cache and policy keys follow, and the 8 tests of the analyses turn it on through a guard. It is blocked only because no test fails without the change, which the repo rules require for a bug fix.
High
Medium
Nit
!= "0"form.Checked and fine
How this was tested
078358a0, thencargo build --workspaceandcargo test --workspace --no-fail-fast -- --test-threads=4.scripts/smoke.ps1: 60 s of a retail title on main078358a0and on this merge; presents per 2 s at the end: 60 60 61.XCL_RUN_SECONDS=300and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by throny on 2026-12-03T02:45:13Z.
@Foniass thanks, all in
8eae7efa:by_default_every_vote_is_exchanged(dxil/idioms.rs) translates the three-vote program without the guard, holdingPRECISE_LOCK, and asserts all 4 votes are exchanged, with or without idioms. On main the idioms leave 1 of 4, so the test fails there.precise_masks_is_off_unless_set_to_something_but_0covers the parse.XCL_X64_PRECISE_MASKS. The 4080 and 5090 numbers are with all of that off, and still at least as fast.PRECISE_LOCKnow says any new test that asserts exchange counts or bytes of a split wave64 translation without the guard takes it.XCL_X64_ALL_MASKSis out of the pipeline settings list.XCL_X64_PRECISE_MASKS=0is off now (same!= "0"form as the other switches).On your smoke run's 84 % frames: the first start after this change translates every split program again, because the translator source hash changes, and a 60 s smoke run spends part of that time preparing. Our smoke at this head was taken warm: 1575 frames, against 1559 on main.
Whole suite at
8eae7efa: 3008 passed, 0 failed; smoke block updated. Could you re-check?AI use: Claude Code (Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by throny on 2026-12-03T02:45:29Z.
Root-cause issue for the analyses: #3758. AI use: Claude Code (Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T03:15:04Z.
Code review location:
crates/xcl/src/gpu/recomp/x64_masks.rs; line 413Finding 1 (medium, read): most GPU tests of the planned lowerings no longer run them, and which form they run depends on test scheduling.
Nine GPU tests translate with
split: trueand have no guard, so alone they now run the all-exchange form: inmask_exchange.rsgpu_split_wave64_scalar_compare_and_half_written_pair,..._local_exec_skip_runs_in_one_half_and_meets_again,..._lazy_meets_carry_masks_and_lane_reads,..._half_leaves_a_loop_alone_and_meets_the_other_after_it,..._first_lane_under_the_groups_thread_0,..._own_first_lane_and_lane_number_compare,..._compare_batch_preserves_both_words, and inidioms.rsgpu_split_wave64_local_votes_leave_what_the_exchange_leavesandgpu_split_wave64_uniform_first_lanes_read_what_the_exchange_reads. The last two compare idioms on against off, which is now the same translation twice. Theirplan()assertions still hold, but the GPU run no longer covers what the plan lowers to.Because this counter is process-wide, the same tests do get the planned form whenever one of the eight guarded tests is alive on another thread. So a regression in the planned lowering shows up only on some runs.
The analyses stay shipped behind
XCL_X64_PRECISE_MASKSand #3758 is about fixing them, so their GPU coverage matters. Suggested: guard these nine as well. If the serialising is a concern, a thread-local would do instead of the counter:kernel.rsalready handsIDIOMS_IN_TESTandNO_SELECT_FOLDon to the translator's worker thread.Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T03:15:04Z.
Code review location:
crates/xcl/src/gpu/dxil/mask_exchange.rs; line 1641Finding 2 (low, measured; a question): this test's GPU result differs under the new default, so "both forms are correct, a test beside one only sees other exchange counts" (
x64_masks.rs) does not hold for it.With the guard replaced by
PRECISE_LOCK(analysis off, as the default now is) and nothing else running, it fails on the result, not on a count:That is the 32-thread group (no upper half): the folded form gives lane 0's value for the AND, the all-exchange form gives 0. (
gpu_split_wave64_waves_apart_run_without_meeting_at_the_startalso fails without the guard, but on its "the waves do not meet" assertion, which is expected.)Which of the two is right for a group whose upper half does not exist? If the missing lanes' values are simply undefined on the console, both are fine and the comment could say so; if the fold's answer is the intended one, the default now gives a different result for such groups and no test pins what it gives. Either way a version of this test for the default form would settle it.
Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T03:15:04Z.
Review: COMMENTED
Review of
8eae7efa(code reading, the suite and smoke run below, and two checks of the tests; not a merge-check) · 2 findings, both about tests, neither about the default itselfIn short: the new default is the path
maintakes withXCL_X64_ALL_MASKS=1at all four sites, and nothing else onmainread that variable. A translation made under the old default cannot be loaded under the new one: the translator source ids change with these files, and with the switch set every stage bypasses the caches.by_default_every_vote_is_exchangedanswers the earlier merge check's high point: it fails withmain's default put back (below). What is left is in the tests of the analyses, which stay shipped behind the switch (inline).Measured (RTX 3080, Ryzen 9 7950X, merge of this head onto
main395405e4)cargo test --workspace --no-fail-fast -- --test-threads=4(debug): 3014 passed, 0 failed, 56 ignored; 25 SKIPPED, the same tests as onmain(3012 passed, 0 failed, 56 ignored there).scripts/smoke.ps1, 60 s, release, offline: 1699 frames, exit 0x0, 0 device removals, 0 crashes, peak commit 18040 MB (main395405e4, same title and time: 1689 frames, 18158 MB). The start screen only; this was the first start after the change, and the retranslation did not show in the frame count on this title.by_default_every_vote_is_exchangedwithprecise_masks()returningmain's default: fails; on the merge: passes.mask_exchange.rsrun under the new default (guard replaced by the lock): numbers inline.Note, not blocking: on
main,XCL_X64_ALL_MASKS=1also madecache_allowedfalse, so the 900 s comparison runs in the description had the all-masks side translating without the memory and disk caches. That counts against all-masks, so the conclusion stands; from now on it is the other way round (XCL_X64_PRECISE_MASKS=1runs uncached, and=0bypasses the caches while changing nothing), which is worth knowing for the next comparison.Not checked: a world run (this card does not get past loading on plain
main); AMD (not reached, as the description says); module size and compile time of the all-exchange form on a retail title; the HLSL fallback's extra group barriers; the per-lane form.Review by Claude Code (Claude Fable 5.2), with an independent second read by a subagent (Claude Fable 5.2) whose points were checked before use, posted without a human check of each point. An automated PR review workflow is running at the request of the user.
Imported from ivall/xcl. Originally posted by throny on 2026-12-03T04:53:32Z.
Thanks, both findings were right. Amended into the single commit (
08beabafc).Finding 1 (test coverage).
PRECISE_FOR_TESTis now a thread-local,PRECISE_IN_TEST(crates/xcl/src/gpu/recomp/x64_masks.rs:416).PreciseForTestsaves the old value and puts it back when it is dropped (x64_masks.rs:427, :434). The translator's worker thread gets the value the same way it getsIDIOMS_IN_TESTandNO_SELECT_FOLD(gpu/dxil/kernel.rs:269, :279), and so does the per-lane form's thread (gpu/recomp/lower_dxil.rs:484, :490). A guard therefore only affects its own test, whatever else is running.PRECISE_LOCKis gone: the byte-identity test andby_default_every_vote_is_exchangedno longer need it. The nine tests you listed now takePreciseForTest::on(), so they run the planned lowerings again (seven in mask_exchange.rs, two in idioms.rs).Finding 2 (32-thread group). The folded answer is the console's answer for the reduction the compiler actually writes, and the default form was wrong there. On RDNA2 a 32-thread group still runs as one wave64. Lanes 32..63 exist but are not in the launch EXEC. The compiler's whole-wave reduction first writes the operation's identity into every lane outside the saved EXEC (
v_cndmaskwith the saved mask; see docs/wave64-on-wave32.md, "What the retail pack does"). It then runss_or_saveexec_b64 s, -1and does the last steps.v_readlaneignores EXEC, sov_readlane s, v, 32returns the identity, and the result is lane 0's partial value combined with the identity, which is lane 0's value. In the split form that upper half does not exist, and the exchange returns 0 for it. That is correct for OR, XOR, ADD and UMAX, whose identity is 0. It is wrong for AND and UMIN (identity -1) and for IMIN and IMAX. The planner's fold got these right by leaving the missing half out, and this PR made the exchange the default, so the bug came with it.Fix: for split compute and mesh groups whose last console wave has 1..32 threads, kernel.rs:871-880 runs
recomp::upper_lanes(the analysis 32-lane VS / PS waves already use). It records eachv_readlanewhose lane ≥ 32 holds a constant on the console. When such a read targets an upper half with no lanes (xn == 0: always for ≤ 32 threads, and for the last wave of, say, 96 threads), it reads that constant instead of the exchange's 0 (gpu/dxil/lower_valu.rs:1090).On the GPU,
gpu_split_wave64_reduction_reads_the_identity_of_a_missing_upper_half(mask_exchange.rs:1686) runs the compiler's pattern in the default form for OR, AND, XOR, ADD, UMIN and UMAX in groups of 32, 64 and 96 threads. Without the lower_valu.rs change it fails withlane 1 of 32(the AND gives 0), and with the change it passes.Your original test still runs with
PreciseForTest. Its program writes no identity: lane 32 there holds37 + v0of a lane that has no thread, and the ISA does not define that value. So both of its answers are allowed for that synthetic program. The new test pins what the default gives for the pattern real programs use.Not covered: the HLSL path and the per-lane form also give 0 for such a lane (they did before this PR as well). Reads
upper_lanescannot resolve to a constant still give 0.Tested: RTX 4080, Windows 11, debug.
cargo test -p xcl --lib -- gpu::recomp gpu::dxil x64 shader_cache --test-threads=4: 894 passed, 0 failed, 25 ignored. 22 tests printed SKIPPED, all "no wave64" (NVIDIA).Pushed as
08beabaf: whole suite 3009 passed, 0 failed; a 300 s world run of the retail title on top of main without a crash or device removal (2.98 presents/s). An independent review of the fix found nothing blocking. Thanks, finding 2 was a real bug in the new default.AI use: Claude Code (Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T04:56:48Z.
Code review location:
crates/xcl/src/gpu/recomp/x64_masks.rs; line 413Fixed in
08beabaf. Read in the delta from8eae7efa: the switch is a thread-local thattranslate_entry_withand the per-lane form hand to their worker threads, the lock is gone, and the nine tests takePreciseForTest::on()(seven in mask_exchange.rs, two in idioms.rs).Measured on a merge of
08beabafonto main395405e4(RTX 3080, debug):cargo test -p xcl --lib -- gpu::dxil::mask_exchange gpu::dxil::idioms gpu::recomp::x64_masks gpu::dxil::robustness_tests gpu::recomp::upper_lanes --test-threads=4: 80 passed, 0 failed, 2 ignored, no SKIPPED. That run has the byte-identity test andby_default_every_vote_is_exchangedbeside the guarded tests on four threads.Follow-up by Claude Code (Claude Fable 5.2), posted without a human check of each point. An automated PR review workflow is running at the request of the user.
Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T04:56:50Z.
Code review location:
crates/xcl/src/gpu/dxil/mask_exchange.rs; line 1641Fixed in
08beabaf, and thanks for the explanation of the identity: that answers the question.Measured on a merge of
08beabafonto main395405e4(RTX 3080, debug):gpu_split_wave64_reduction_reads_the_identity_of_a_missing_upper_halfpasses (in the run named in the other thread: 80 passed, 0 failed, 2 ignored). With thet = self.sel(absent, c, t)line in lower_valu.rs taken out it fails as you describe:lane 1 of 32, left 0, right 37 (mask_exchange: 20 passed, 1 failed).Read, not measured: the constant is used only where the lane is ≥ 32 and the partner half has no lanes, so waves with both halves keep the exchange. The whole suite and a title run were not run for this follow-up.
Follow-up by Claude Code (Claude Fable 5.2), posted without a human check of each point. An automated PR review workflow is running at the request of the user.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T07:23:50Z.
merge-check
base:
078358a058head:
08beabafcemerge: clean
build: ok
tests: 3009 passed, 0 failed, 52 ignored; 28 skipped, the same as on main
review: 1 high, 3 medium, 2 nits (below)
performance: 60 s smoke run: 1669 → 1670 frames (100 % of main), peak commit 17577 → 18035 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 223 s there, 0 device removals, 0 crashes, 5 presents/s; run with
XCL_SKIP_CS=95cc13288a27a96e(the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)verdict: not yet: 1 blocking finding (critical or high, below); also
PR descriptionis redhardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
In short: This push makes the debug switch a per-thread flag that is passed on to the translator's threads, guards the nine GPU tests of the planned form, and adds a fix: a v_readlane of lane 32 or above reads the console's constant (a reduction's identity) when the upper half has no threads. The fix is right for the lower half, but it also fires in the upper half when the lower half has no threads inside a dispatch's thread limit, and there it overwrites the upper half's own correct value. The three findings from my
8eae7efareview are all still open.High
Medium
8eae7efareview. by_default_every_vote_is_exchanged (idioms.rs ~486) still fails on main only through the planner path. gpu_split_wave64_reduction_reads_the_identity_of_a_missing_upper_half runs the default form, but it should pass on main as well (main's planner folds that reduction), so it tests the new fix, not the default. Still no test pins that x64_masks::full_mask_destinations (recomp/mod.rs ~2007, the HLSL path) or whole_live (kernel.rs ~868) is off by default. Add an unguarded assertion on the gpu_split_wave64_lane_local_masks program (recomp/tests.rs ~8899) that every mask is exchanged, e.g. a count of "= xcl_x_ballot(and(" that fails on main.Nit
Checked and fine
395405e4How this was tested
078358a0, thencargo build --workspaceandcargo test --workspace --no-fail-fast -- --test-threads=4.scripts/smoke.ps1: 60 s of a retail title on main078358a0and on this merge; presents per 2 s at the end: 60 61 60.XCL_RUN_SECONDS=300and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T07:25:41Z.
Code review location:
crates/xcl/src/gpu/dxil/mask_exchange.rs; line 1641A correction to my "fixed" above. The case this thread was about (a reduction read in a wave whose upper half has no threads) is fixed in
08beabaf, as measured. But my sentence "the constant is used only where the lane is ≥ 32 and the partner half has no lanes, so waves with both halves keep the exchange" missed a case, which Foniass's merge check found (its point 1): in the upper half the partner is the lower half. Thereread_lane_uniformalready returns the half's own lane (lh == self.half), and the new select replaces it with the constant whenxn == 0, that is when the lower half has no running threads (possible with a dispatch's thread limits). So a wave with only an upper half gets the identity instead of its own value.Read against the code at
08beabaf(lower_valu.rsat theabsentselect,lanes.rsread_lane_uniform,kernel.rscompute_gate), not measured: I have no test for it. Their suggested condition (the lane read is in the other half,lh != self.half, instead oflh != 0) fits what I read. This thread is open again from my side until that is in.Follow-up by Claude Code (Claude Fable 5.2), posted without a human check of each point. An automated PR review workflow is running at the request of the user.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-03T10:08:29Z.
Test report: RTX 3090, split compute fuzz programs (not a merge-check)
XCL_X64_ALL_MASKS=1on two trees, as the same code path as this PR's default (I did not build this PR's head). RTX 3090, driver 621.47, Windows 11 22631, debug build. The programs are the split compute programs of the #3716 wave64 fuzzer, compared with the RDNA2 reference; no application data.12 programs the analyses get wrong (details and how to run them on #3758):
XCL_X64_ALL_MASKS=1main5ad98adb+ #3716d2293dcb+ a test-only probe + a local change to the split helpers' arguments7b19e27d+ #3716d2293dcb+ the same probeThe four controls (2, 10, 11, 188) are right either way.
8,000 fuzz seeds (direct split form, #3707's tree): 201 seeds differ from the RDNA2 reference with the default, 188 with
XCL_X64_ALL_MASKS=1. The 13 seeds it fixes include all 12 above; no seed differs only with all masks. The 188 left are other issues (groups of 96 threads, #3779, a signed zero).AI use: Claude Code (Claude Opus 5.5) ran the programs on the 3090 and wrote this; checked and posted by me.
Imported from ivall/xcl. Originally posted by Gevroska on 2026-12-03T11:15:04Z.
@throny I reproduced the upper-half case on my RTX 3080 with a test-only fixture on
08beabaf. In a48×3compute group with thread limits[8,3,1], one split wave has no active lower lanes and eight active upper lanes. Lane 32 of that wave holds133. All eight active threads (IDs 96–103) read back0xffffffffinstead of133. With the thread limit removed, all 144 output words matched.I reran the identical fixture with a local change that applies the constant only when a lower-half reader targets its missing upper partner. All eight threads then returned
133, and the complete-group control still passed.The direction matters here. In my earlier 32/64/96-thread tests, direct DXIL passed when the upper partner was absent, while the HLSL and per-lane paths returned zero for partial-wave AND and unsigned MIN. The new direct-DXIL failure occurs with an active upper half and an empty lower half.
AI disclosure: OpenAI Codex GPT-6 Sol (Daybreak) wrote and ran the asymmetric fixture. GPT-6.2 Sol ran the earlier backend comparison and tested the local correction. A separate GPT-6.2 Sol reviewer verified the evidence. GPT-6.2 Astra drafted this comment.
I reviewed and approved this comment before posting.
Imported from ivall/xcl. Originally posted by lucsoft on 2026-12-03T11:31:55Z.
merge-check claim
head:
08beabafceRX 7800 XT (RADV, Wine): suite, smoke and a title run on the AMD side.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-03T12:42:55Z.
Test note on the missing-upper-half fix (
lower_valu.rs~1090), from a census of the retail title, a code read and fuzz runs; not a merge-check.Retail title, offline (no GPU): of 1,914 compute programs it uses, 1,053 have a group size that is not a multiple of 64, but almost all of them are wave32 programs (984 groups of 32). 25 are wave64, and 3 of those have a whole-wave section that reads lane 32 (5 reads). All three are the compiler's reduction with identity 0 and an add (
v_add_nc_u32in two,v_add_f32in one), so the 0 the split form returns is already the right value there, and this change gives the same result. Nov_readlaneof a lane ≥ 32 outside a section, nov_writelaneto a lane ≥ 32, nods_bpermute,row_shareorrow_bcastin those 25 programs. The 1,850 mesh programs all have groups that are a multiple of 64.Two limits of the constant, from the code:
upper_lanes::binaryfollows only integer ops, so a float min / max reduction (identity ±inf) still reads 0 in a missing half; and a value that is uniform but not constant there (for exampleop(x, v_readlane(x, 0)), which the #3716 fuzzer generates) staysUnknownand reads 0. Some of the latter also depend on VGPRs the missing lanes never wrote, which the console leaves undefined, so the fuzzer's reference value is only one of the allowed ones there.Measured on the RTX 3090 (driver 621.47), direct split form, the 8,000 #3716 seeds at
de05c50e(bases 0, 1e6, 2e6, 3e6 × 2,000), debug build of this PR's head merged with #3716's head plus local test-only probe commits (a probe test and the switch below); the witness ismain078358a0merged with #3716 plus the probe test. Mismatches in the class "a group's last wave with an empty upper half" (96-thread compute):main078358a0+ #3716: 134 seeds.08beabaf): 47. 88 fixed, 1 new.v_readlaneconstant left out (a local switch): 133. So the repair is the constant, not the all-masks default.XCL_X64_PRECISE_MASKS=1: 132. The constant only repairs in the default mode.A CPU replay of the reference that makes a missing lane read 0, or this PR's constant, predicts these sets: 133 of the 134 seeds on
main, and all 47 with this PR (48 predicted). So the missing-lane read is the only cause there. The 48 the replay predicts all read a valueupper_lanesleavesUnknown: 34 seeds read a uniform value that is not constant (U-data), 19 an identity the analysis does not follow (U-identity: float,ds_swizzle, ...); some have both. 7 of the 48, and the 1 new seed (2001361: the constant gives0xffffffffwhere the reference gives 0), depend on VGPRs the missing lanes never wrote, which the console leaves undefined.Outside this class, this PR also fixes 10 of the 11 other compute mismatches (9 with the constant left out); the 57 kernel-mode ones and the 1 signed-zero one are unchanged.
AI use: Claude Code (Claude Opus 5.5) ran the census, the fuzz runs and the CPU replay, and wrote this; checked and posted by me.
Imported from ivall/xcl. Originally posted by lucsoft on 2026-12-03T13:20:00Z.
merge-check
base:
a815de932chead:
08beabafcemerge: clean
build: ok (cargo build --release -p xcl, cargo test --workspace --release --no-run)
tests: lib 2838 passed, 17 failed, 36 ignored, 2 died; integration 151 passed, 5 failed; the same failures as main + #3707, none new
review: confirms Foniass's high finding (lower_valu.rs ~1090:
absentchecks only that the read lane is ≥ 32 and that the partner half is empty; in an upper half whose lower half is past the thread limit that replaces its own lane's value); no further findingsperformance: no change measurable: on main
0c725d5dboth trees hit an intermittent ring timeout ~50 s into the world (device removed at ~170 s; cause open, under investigation), 1.63 vs 1.26 presents/s in the world before ittitle run: retail title, RX 7800 XT (RADV, Wine), main
a815de93+ this PR: 458 s in the world, no crash, no device removal, 0 page faults, 0.71 presents/sverdict: not yet: the high finding above (Gevroska's fix, applying the constant only when a lower-half reader reads the missing upper half, would close it); the AMD side is otherwise clean
hardware / tool and model: RX 7800 XT (RADV, Wine 11.21 Staging, Linux) / Claude Code (Claude Opus 5.5)
Imported from ivall/xcl. Originally posted by throny on 2026-12-03T15:53:40Z.
Thanks, confirmed and fixed in
a8a6fef(squashed into the PR's commit).xncounts the lanes of the partner half, so with an empty lower half an upper-half reader sawxn == 0and took the identity for a lane of its own half. The constant now applies only when a lower-half reader targets lane ≥ 32 of a missing upper half (lower_valu.rs,v_readlane_b32), which is the correction you tested.New test
gpu_split_wave64_reduction_of_an_upper_half_without_a_lower_half_reads_its_own_lane(mask_exchange.rs): your 48×3 group with x limited to 8, an OR reduction's lane-32 read. Threads 96–103 must read 133.Tested (RTX 4080, driver 621.40, i9-12900K, Windows 11 26300, debug)
08beabaf: fails (0 instead of 133); ona8a6fef: passescargo test -p xcl --lib split_wave64: 51 passed, 0 failed, 1 ignoredcargo test --workspace -- --test-threads=4ona8a6fef: 3010 passed, 0 failed, 52 ignored, 25 SKIPPED (no wave64 on this GPU). An earlier run of the same tree stopped once with an access violation in the lib test binary; the rerun passed, so this looks flaky, not tied to this change.Not tested: AMD; the smoke run on the new head is still to come.
Claude Code, Claude Opus 5.5 (found the cause, wrote the fix and test, ran them, wrote this reply).
Imported from ivall/xcl. Originally posted by lucsoft on 2026-12-03T15:55:58Z.
merge-check claim
head:
a8a6fef205RX 7800 XT (RADV, Wine): build, suite and a title run on the AMD side.
Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T16:14:45Z.
Code review location:
crates/xcl/src/gpu/dxil/mask_exchange.rs; line 1641fixed in
a8a6fef2.Read: the constant now needs a lower-half reader (
!self.upper) besides lane ≥ 32 and an empty partner half, so an upper half without a lower one reads its own lane again; a lower half reading a missing upper half still gets the constant.Measured (RTX 3080, Windows 11,
a8a6fef2merged onto maina815de93= 3d0cf845, debug):cargo test -p xcl --lib split_wave64 -- --test-threads=4: 51 passed, 0 failed, 1 ignored, the new test among them. With the three added lines inlower_valu.rstaken out again, the new test fails (thread 96, lane 32 of wave 1: 0 instead of 133) and the other 50 pass. The whole suite and a smoke run were not rerun on this head.Follow-up by Claude Code (Claude Fable 5.2).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.