Recompiler: split wave64 exchanges every mask by default #3748

Open
throny wants to merge 1 commit from upstream-pr/3748 into main
throny commented 2026-12-03 00:37:59 +00:00 (Migrated from github.com)

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=1 turns 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

  • Groups whose last wave has 1-32 threads (no upper half): in the lower half, a v_readlane of 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_readlane 32). Without it, the all-exchange form gave 0 there: wrong for AND / UMIN / IMIN / IMAX (vasanex's review). Test gpu_split_wave64_reduction_reads_the_identity_of_a_missing_upper_half (32/64/96 threads, default form).
  • The test switch is a thread-local handed to the translator's worker threads; the nine split GPU tests of the planned lowerings are guarded.
  • Test of the default: 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 but 0), off by default. Off also means the lazy planner's other forms are off: mask batching, the waves-apart form, and the XCL_WAVE64_IDIOMS idioms (#3563). Those now only work with the switch on; a test-only guard PreciseForTest and the lock PRECISE_LOCK for the tests of the analyses.
  • gpu/dxil/kernel.rs, gpu/recomp/mod.rs, gpu/recomp/pso.rs: the four XCL_X64_ALL_MASKS checks use it; the cache-bypass and settings lists name the new switch (shaders.rs).
  • The 8 tests of the analyses turn it on for their duration. translation_is_byte_identical_across_runs_and_threads takes 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:251 and HANDOFF.md still name XCL_X64_ALL_MASKS as a comparison switch; that's out of date now.)

Tested

  • RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0.
  • cargo test --workspace -- --test-threads=4 on a8a6fef2 (Gevroska's upper-half case fixed): 3010 passed, 0 failed, 52 ignored, 25 SKIPPED; the new test gpu_split_wave64_reduction_of_an_upper_half_without_a_lower_half_reads_its_own_lane fails on 08beabaf (0 instead of 133).
  • cargo test --workspace -- --test-threads=4 on 08beabaf (after Foniass's and vasanex's reviews): 3009 passed, 0 failed, 52 ignored, 25 SKIPPED lines (no wave64 and similar). The recompiler and DXIL tests alone: 894 passed, 0 failed. by_default_every_vote_is_exchanged fails on main (the idioms leave 1 of 4 votes exchanged there).
  • Retail title, 900 s warm world runs on main 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.
  • This head on main 395405e4c: a 300 s world run (523) with no crash and no device removal, 2.98 presents/s. The previous head 8eae7efa in 900 s warm runs: 3.14 presents/s vs main's 3.07 (runs 521/522); cold start: first frame after 153 s.
  • With all masks, #3707's GPU queue watchdog stop (2 of 2 runs) did not occur (2 of 2).

Regression run

main 817eb1fc9:

xcl-smoke v1
commit: 817eb1fc9fb0763008ae5d8de1f7f586f442b51d
gpu: NVIDIA GeForce RTX 4080
title: 21222967
seconds: 120
exit: 0x0
frames shown: 2925 (PresentX 2925)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16653 MB

this PR's head:

xcl-smoke v1
commit: a8a6fef20593eafa494a2ecbf4ba49704edb3260
gpu: NVIDIA GeForce RTX 4080
title: 21222967
seconds: 120
exit: 0x0
frames shown: 3321 (PresentX 3321)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 17366 MB

Not tested

  • The missing-upper-half fix in the HLSL fallback for compute and in the per-lane form (they still give 0 there, as before), and in the opt-in precise form.
  • AMD (only 64-lane waves there, so it does not reach this code: split wave64 is the 32-lane path).
  • The first start after this change: every split program translates again (the translator source hash changes).

AI use

  • Claude Code with Claude Opus 5.5 wrote the change, the tests and this description, and ran the tests and world runs. An independent Claude Opus 5.5 review found the byte-identity test risk that the lock fixes.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5617378381 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3748). Originally posted by [throny](https://github.com/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=1` turns 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** - Groups whose last wave has 1-32 threads (no upper half): in the lower half, a `v_readlane` of 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_readlane` 32). Without it, the all-exchange form gave 0 there: wrong for AND / UMIN / IMIN / IMAX (vasanex's review). Test `gpu_split_wave64_reduction_reads_the_identity_of_a_missing_upper_half` (32/64/96 threads, default form). - The test switch is a thread-local handed to the translator's worker threads; the nine split GPU tests of the planned lowerings are guarded. - Test of the default: `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 but `0`), off by default. Off also means the lazy planner's other forms are off: mask batching, the waves-apart form, and the `XCL_WAVE64_IDIOMS` idioms (#3563). Those now only work with the switch on; a test-only guard `PreciseForTest` and the lock `PRECISE_LOCK` for the tests of the analyses. - `gpu/dxil/kernel.rs`, `gpu/recomp/mod.rs`, `gpu/recomp/pso.rs`: the four `XCL_X64_ALL_MASKS` checks use it; the cache-bypass and settings lists name the new switch (`shaders.rs`). - The 8 tests of the analyses turn it on for their duration. `translation_is_byte_identical_across_runs_and_threads` takes 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:251` and `HANDOFF.md` still name `XCL_X64_ALL_MASKS` as a comparison switch; that's out of date now.) **Tested** - RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0. - `cargo test --workspace -- --test-threads=4` on `a8a6fef2` (Gevroska's upper-half case fixed): 3010 passed, 0 failed, 52 ignored, 25 `SKIPPED`; the new test `gpu_split_wave64_reduction_of_an_upper_half_without_a_lower_half_reads_its_own_lane` fails on `08beabaf` (0 instead of 133). - `cargo test --workspace -- --test-threads=4` on `08beabaf` (after Foniass's and vasanex's reviews): 3009 passed, 0 failed, 52 ignored, 25 `SKIPPED` lines (no wave64 and similar). The recompiler and DXIL tests alone: 894 passed, 0 failed. `by_default_every_vote_is_exchanged` fails on main (the idioms leave 1 of 4 votes exchanged there). - Retail title, 900 s warm world runs on main `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. - This head on main `395405e4c`: a 300 s world run (523) with no crash and no device removal, 2.98 presents/s. The previous head `8eae7efa` in 900 s warm runs: 3.14 presents/s vs main's 3.07 (runs 521/522); cold start: first frame after 153 s. - With all masks, #3707's GPU queue watchdog stop (2 of 2 runs) did not occur (2 of 2). **Regression run** main `817eb1fc9`: ``` xcl-smoke v1 commit: 817eb1fc9fb0763008ae5d8de1f7f586f442b51d gpu: NVIDIA GeForce RTX 4080 title: 21222967 seconds: 120 exit: 0x0 frames shown: 2925 (PresentX 2925) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16653 MB ``` this PR's head: ``` xcl-smoke v1 commit: a8a6fef20593eafa494a2ecbf4ba49704edb3260 gpu: NVIDIA GeForce RTX 4080 title: 21222967 seconds: 120 exit: 0x0 frames shown: 3321 (PresentX 3321) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 17366 MB ``` **Not tested** - The missing-upper-half fix in the HLSL fallback for compute and in the per-lane form (they still give 0 there, as before), and in the opt-in precise form. - AMD (only 64-lane waves there, so it does not reach this code: split wave64 is the 32-lane path). - The first start after this change: every split program translates again (the translator source hash changes). **AI use** - Claude Code with Claude Opus 5.5 wrote the change, the tests and this description, and ran the tests and world runs. An independent Claude Opus 5.5 review found the byte-identity test risk that the lock fixes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Foniass commented 2026-12-03 01:11:22 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T01:11:22Z.


merge-check
base: 078358a058
head: 7bccc60c4a
merge: 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 description is red
hardware / 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

  1. No test of the new default. Every touched test turns the analysis on (PreciseForTest), and none checks what the default now does, so the whole suite passes the same on main and on this PR. Add a test that fails on main, e.g. translate the lane-local mask program from gpu_split_wave64_lane_local_masks (recomp/tests.rs ~8899) without the guard and assert it holds one "= xcl_x_ballot(and(" (or assert kernel::translate_compute(...).exchange_sites is the all-masks count), plus assert!(!precise_masks()) with the variable unset.

Medium

  1. Default also turns off planner optimisations, not just left-out exchanges. In dxil/kernel.rs ~350, planned=false skips mask_exchange::plan_of entirely. That turns off mask batching (batch_end), the waves-apart form (apart), uniform_reads/local_votes, and with them the #3563 idioms; XCL_WAVE64_IDIOMS now does nothing unless XCL_X64_PRECISE_MASKS is set. The description only talks about exchanges being kept. Say this in the description. The cost is measured on one title (RTX 4080 smoke, RTX 5090 #505 data); HANDOFF.md:1691 shows all-masks at 1.04-1.11x on the RTX 3090 mask-only loop, and bench_split_wave64 was not rerun.
  2. Known-bad analysis left opt-in with no reproducer. The analyses that put the halves out of step are kept behind XCL_X64_PRECISE_MASKS with no record of which pattern breaks them. Anyone who turns them back on, or later PRs that build on them (#1111, #1193 skip more exchanges), can hit #505 again. Open or link an issue for the root cause and say in x64_masks::precise_masks's doc comment that the analysis is known to be wrong in some programs.
  3. Process-wide test switch can make unguarded tests flaky. PRECISE_FOR_TEST (x64_masks.rs ~406) is a global counter, so any unguarded test that translates split wave64 while a guarded test runs gets the precise form. Only translation_is_byte_identical_across_runs_and_threads takes PRECISE_LOCK. No other test asserts exchange counts or compares bytes unguarded today (checked recomp/tests.rs, dxil tests, pso and compute_build_key tests), so this does not fail now. A future test that does will pass or fail depending on test order; a doc line on PRECISE_LOCK telling such tests to take it would help.

Nit

  1. Old switch still listed as a pipeline setting. shaders.rs:40 keeps XCL_X64_ALL_MASKS in semantic_pipeline_setting although it no longer changes anything, so setting it still splits the pipeline settings for no effect. Remove it, or note that it is kept on purpose for old caches.
  2. Any value enables the new switch. precise_masks() checks var_os(...).is_some(), so XCL_X64_PRECISE_MASKS=0 turns the analysis on. Other switches here (XCL_WAVE64_SPIN, XCL_SAFE_BARRIER, XCL_WAVE64_IDIOMS) treat "0" as off. Use the same != "0" form.
  3. Stale docs naming XCL_X64_ALL_MASKS. docs/wave64-on-wave32.md:251 and HANDOFF.md:1691 still describe XCL_X64_ALL_MASKS as the comparison switch. The PR description already says so, which is what the rules ask; nothing to change in this PR.
Checked and fine
  • All four XCL_X64_ALL_MASKS checks (kernel.rs 350 and 863, recomp/mod.rs 2007, pso.rs 59) now use precise_masks(), and no other code reads the old variable
  • Old cached translations are not reused: x64_masks.rs, recomp/mod.rs and the direct DXIL sources are in build.rs's translator source hash, and ComputePolicyKey.precise_x64_masks flips with the default
  • cache_allowed and shader_cache_bypasses_debug_overrides swap XCL_X64_ALL_MASKS for XCL_X64_PRECISE_MASKS together, so the debug switch still bypasses the cache
  • No assertion deleted or weakened; the 8 tests of the analyses keep their asserts and run with the analysis on; gpu_split_wave64_masks_read_whole_after_partial_writes (unguarded) holds in both modes (null-destination compare has no exchange either way)
  • Hang risk on NVIDIA: with every mask exchanged, both halves take every scalar decision from exchanged state and reach the same exchanges in the same order; each wait is still bounded by the spin exit from #3652
  • PreciseForTest handles a poisoned lock (unwrap_or_else into_inner) and decrements in Drop, so a panicking test does not leave the switch on
  • Pixel shaders keep their full_mask_destinations path (recomp/mod.rs ~2009), so non-split and AMD wave64 output is unchanged
  • Scope: 65 added / 9 removed lines, one logical change, Recompiler prefix, AI use names Claude Code with Claude Opus 5.5, both smoke blocks present (60 s, same title, 1554 vs 1559 frames, peak commit lower)
How this was tested
  • Merged onto main 078358a0, then cargo build --workspace and cargo test --workspace --no-fail-fast -- --test-threads=4.
  • The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar).
  • scripts/smoke.ps1: 60 s of a retail title on main 078358a0 and on this merge; presents per 2 s at the end: 60 60 61.
  • Title run: the release build of this merge launched the retail title with XCL_RUN_SECONDS=300 and 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.

<!-- greyfinch-sync:ivall/xcl:comment:7364056871 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3748#issuecomment-7364056871). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T01:11:22Z. --- merge-check base: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a head: 7bccc60c4a7c30191847066d2c19fa1ba85a3787 merge: 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 description` is red hardware / 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 1. **No test of the new default.** Every touched test turns the analysis on (PreciseForTest), and none checks what the default now does, so the whole suite passes the same on main and on this PR. Add a test that fails on main, e.g. translate the lane-local mask program from gpu_split_wave64_lane_local_masks (recomp/tests.rs ~8899) without the guard and assert it holds one "= xcl_x_ballot(and(" (or assert kernel::translate_compute(...).exchange_sites is the all-masks count), plus assert!(!precise_masks()) with the variable unset. #### Medium 2. **Default also turns off planner optimisations, not just left-out exchanges.** In dxil/kernel.rs ~350, planned=false skips mask_exchange::plan_of entirely. That turns off mask batching (batch_end), the waves-apart form (apart), uniform_reads/local_votes, and with them the #3563 idioms; XCL_WAVE64_IDIOMS now does nothing unless XCL_X64_PRECISE_MASKS is set. The description only talks about exchanges being kept. Say this in the description. The cost is measured on one title (RTX 4080 smoke, RTX 5090 #505 data); HANDOFF.md:1691 shows all-masks at 1.04-1.11x on the RTX 3090 mask-only loop, and bench_split_wave64 was not rerun. 3. **Known-bad analysis left opt-in with no reproducer.** The analyses that put the halves out of step are kept behind XCL_X64_PRECISE_MASKS with no record of which pattern breaks them. Anyone who turns them back on, or later PRs that build on them (#1111, #1193 skip more exchanges), can hit #505 again. Open or link an issue for the root cause and say in x64_masks::precise_masks's doc comment that the analysis is known to be wrong in some programs. 4. **Process-wide test switch can make unguarded tests flaky.** PRECISE_FOR_TEST (x64_masks.rs ~406) is a global counter, so any unguarded test that translates split wave64 while a guarded test runs gets the precise form. Only translation_is_byte_identical_across_runs_and_threads takes PRECISE_LOCK. No other test asserts exchange counts or compares bytes unguarded today (checked recomp/tests.rs, dxil tests, pso and compute_build_key tests), so this does not fail now. A future test that does will pass or fail depending on test order; a doc line on PRECISE_LOCK telling such tests to take it would help. #### Nit 5. **Old switch still listed as a pipeline setting.** shaders.rs:40 keeps XCL_X64_ALL_MASKS in semantic_pipeline_setting although it no longer changes anything, so setting it still splits the pipeline settings for no effect. Remove it, or note that it is kept on purpose for old caches. 6. **Any value enables the new switch.** precise_masks() checks var_os(...).is_some(), so XCL_X64_PRECISE_MASKS=0 turns the analysis on. Other switches here (XCL_WAVE64_SPIN, XCL_SAFE_BARRIER, XCL_WAVE64_IDIOMS) treat "0" as off. Use the same `!= "0"` form. 7. **Stale docs naming XCL_X64_ALL_MASKS.** docs/wave64-on-wave32.md:251 and HANDOFF.md:1691 still describe XCL_X64_ALL_MASKS as the comparison switch. The PR description already says so, which is what the rules ask; nothing to change in this PR. <details><summary>Checked and fine</summary> - All four XCL_X64_ALL_MASKS checks (kernel.rs 350 and 863, recomp/mod.rs 2007, pso.rs 59) now use precise_masks(), and no other code reads the old variable - Old cached translations are not reused: x64_masks.rs, recomp/mod.rs and the direct DXIL sources are in build.rs's translator source hash, and ComputePolicyKey.precise_x64_masks flips with the default - cache_allowed and shader_cache_bypasses_debug_overrides swap XCL_X64_ALL_MASKS for XCL_X64_PRECISE_MASKS together, so the debug switch still bypasses the cache - No assertion deleted or weakened; the 8 tests of the analyses keep their asserts and run with the analysis on; gpu_split_wave64_masks_read_whole_after_partial_writes (unguarded) holds in both modes (null-destination compare has no exchange either way) - Hang risk on NVIDIA: with every mask exchanged, both halves take every scalar decision from exchanged state and reach the same exchanges in the same order; each wait is still bounded by the spin exit from #3652 - PreciseForTest handles a poisoned lock (unwrap_or_else into_inner) and decrements in Drop, so a panicking test does not leave the switch on - Pixel shaders keep their full_mask_destinations path (recomp/mod.rs ~2009), so non-split and AMD wave64 output is unchanged - Scope: 65 added / 9 removed lines, one logical change, Recompiler prefix, AI use names Claude Code with Claude Opus 5.5, both smoke blocks present (60 s, same title, 1554 vs 1559 frames, peak commit lower) </details> <details><summary>How this was tested</summary> - Merged onto main `078358a0`, then `cargo build --workspace` and `cargo test --workspace --no-fail-fast -- --test-threads=4`. - The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar). - `scripts/smoke.ps1`: 60 s of a retail title on main `078358a0` and on this merge; presents per 2 s at the end: 60 60 61. - Title run: the release build of this merge launched the retail title with `XCL_RUN_SECONDS=300` and 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. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
throny commented 2026-12-03 02:45:13 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-03T02:45:13Z.


@Foniass thanks, all in 8eae7efa:

  1. High, no test of the new default: by_default_every_vote_is_exchanged (dxil/idioms.rs) translates the three-vote program without the guard, holding PRECISE_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_0 covers the parse.
  2. Planner forms off with it: right. The doc comment and the description now say that batching, the waves-apart form and the #3563 idioms only work with XCL_X64_PRECISE_MASKS. The 4080 and 5090 numbers are with all of that off, and still at least as fast.
  3. Known-bad analysis: the doc comment says the analyses are known to be wrong in some programs (#505), with the pattern not found yet, so turning them back on can bring it back. A root-cause issue will follow; #1111 and #1193 should rebase on this.
  4. Process-wide test switch: a doc line on PRECISE_LOCK now says any new test that asserts exchange counts or bytes of a split wave64 translation without the guard takes it.
  5. XCL_X64_ALL_MASKS is out of the pipeline settings list.
  6. XCL_X64_PRECISE_MASKS=0 is off now (same != "0" form as the other switches).
  7. The stale docs are noted in the description.

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).

<!-- greyfinch-sync:ivall/xcl:comment:7365823034 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3748#issuecomment-7365823034). Originally posted by [throny](https://github.com/throny) on 2026-12-03T02:45:13Z. --- @Foniass thanks, all in `8eae7efa`: 1. **High, no test of the new default:** `by_default_every_vote_is_exchanged` (`dxil/idioms.rs`) translates the three-vote program without the guard, holding `PRECISE_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_0` covers the parse. 2. **Planner forms off with it:** right. The doc comment and the description now say that batching, the waves-apart form and the #3563 idioms only work with `XCL_X64_PRECISE_MASKS`. The 4080 and 5090 numbers are with all of that off, and still at least as fast. 3. **Known-bad analysis:** the doc comment says the analyses are known to be wrong in some programs (#505), with the pattern not found yet, so turning them back on can bring it back. A root-cause issue will follow; #1111 and #1193 should rebase on this. 4. **Process-wide test switch:** a doc line on `PRECISE_LOCK` now says any new test that asserts exchange counts or bytes of a split wave64 translation without the guard takes it. 5. `XCL_X64_ALL_MASKS` is out of the pipeline settings list. 6. `XCL_X64_PRECISE_MASKS=0` is off now (same `!= "0"` form as the other switches). 7. The stale docs are noted in the description. 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).*
throny commented 2026-12-03 02:45:29 +00:00 (Migrated from github.com)

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).

<!-- greyfinch-sync:ivall/xcl:comment:7365827779 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3748#issuecomment-7365827779). Originally posted by [throny](https://github.com/throny) on 2026-12-03T02:45:29Z. --- Root-cause issue for the analyses: #3758. *AI use: Claude Code (Claude Opus 5.5).*
vasanex commented 2026-12-03 03:15:04 +00:00 (Migrated from github.com)

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 413

@@ -387,6 +387,59 @@ fn uses_with_table(d: &Decoded, table: &UsePlanTable) -> (Regs, Regs) {
     (whole, written)
 }
 
+/// Whether split wave64 leaves out the exchanges this analysis (and the lazy planner in
+/// gpu/dxil/kernel.rs) find unneeded. Off by default: in some programs a left-out exchange put
+/// the two halves out of step, the next exchange gave up after its spin limit and the wave read
+/// zeros from then on (dark lighting, 31-32 ms GPU calls; #505, measured on an RTX 4080 and an
+/// RTX 5090, where keeping every exchange was also 9-11 % faster). The analyses are known to be
+/// wrong in some programs and the pattern that breaks them is not found yet (#505), so turning
+/// them back on can bring that back. `XCL_X64_PRECISE_MASKS=1` (not `0`) turns them back on: the
+/// planner too, with its mask batching, waves-apart form and the `XCL_WAVE64_IDIOMS` idioms.
+/// (`XCL_X64_ALL_MASKS`, the old way to turn them off, is now the default.)
+pub fn precise_masks() -> bool {
+    #[cfg(test)]
+    if PRECISE_FOR_TEST.load(std::sync::atomic::Ordering::SeqCst) > 0 {
+        return true;
+    }
+    precise_masks_from(std::env::var("XCL_X64_PRECISE_MASKS").ok().as_deref())
+}
+
+/// `XCL_X64_PRECISE_MASKS`: on for any value but `0` (as `XCL_WAVE64_SPIN` and the other switches).
+fn precise_masks_from(v: Option<&str>) -> bool {
+    v.is_some_and(|v| v.trim() != "0")
+}
+
+/// Guards alive (`PreciseForTest`). Process-wide, not per thread: translation can run on worker
+/// threads. Both forms are correct, so a test running beside one only sees other exchange counts.

Finding 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: true and have no guard, so alone they now run the all-exchange form: in mask_exchange.rs gpu_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 in idioms.rs gpu_split_wave64_local_votes_leave_what_the_exchange_leaves and gpu_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. Their plan() 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_MASKS and #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.rs already hands IDIOMS_IN_TEST and NO_SELECT_FOLD on to the translator's worker thread.

<!-- greyfinch-sync:ivall/xcl:review-comment:4779425107 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3748#discussion_r4779425107). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-03T03:15:04Z. **Code review location:** `crates/xcl/src/gpu/recomp/x64_masks.rs`; line 413 ~~~~diff @@ -387,6 +387,59 @@ fn uses_with_table(d: &Decoded, table: &UsePlanTable) -> (Regs, Regs) { (whole, written) } +/// Whether split wave64 leaves out the exchanges this analysis (and the lazy planner in +/// gpu/dxil/kernel.rs) find unneeded. Off by default: in some programs a left-out exchange put +/// the two halves out of step, the next exchange gave up after its spin limit and the wave read +/// zeros from then on (dark lighting, 31-32 ms GPU calls; #505, measured on an RTX 4080 and an +/// RTX 5090, where keeping every exchange was also 9-11 % faster). The analyses are known to be +/// wrong in some programs and the pattern that breaks them is not found yet (#505), so turning +/// them back on can bring that back. `XCL_X64_PRECISE_MASKS=1` (not `0`) turns them back on: the +/// planner too, with its mask batching, waves-apart form and the `XCL_WAVE64_IDIOMS` idioms. +/// (`XCL_X64_ALL_MASKS`, the old way to turn them off, is now the default.) +pub fn precise_masks() -> bool { + #[cfg(test)] + if PRECISE_FOR_TEST.load(std::sync::atomic::Ordering::SeqCst) > 0 { + return true; + } + precise_masks_from(std::env::var("XCL_X64_PRECISE_MASKS").ok().as_deref()) +} + +/// `XCL_X64_PRECISE_MASKS`: on for any value but `0` (as `XCL_WAVE64_SPIN` and the other switches). +fn precise_masks_from(v: Option<&str>) -> bool { + v.is_some_and(|v| v.trim() != "0") +} + +/// Guards alive (`PreciseForTest`). Process-wide, not per thread: translation can run on worker +/// threads. Both forms are correct, so a test running beside one only sees other exchange counts. ~~~~ --- **Finding 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: true` and have no guard, so alone they now run the all-exchange form: in `mask_exchange.rs` `gpu_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 in `idioms.rs` `gpu_split_wave64_local_votes_leave_what_the_exchange_leaves` and `gpu_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. Their `plan()` 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_MASKS` and #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.rs` already hands `IDIOMS_IN_TEST` and `NO_SELECT_FOLD` on to the translator's worker thread.
vasanex commented 2026-12-03 03:15:04 +00:00 (Migrated from github.com)

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 1641

@@ -1638,6 +1638,7 @@ mod tests {
 
     #[test]
     fn gpu_split_wave64_reductions_fold_when_the_halves_meet() {
+        let _precise = crate::gpu::recomp::x64_masks::PreciseForTest::on(); // tests the analysis, off by default (#505)

Finding 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:

gpu_split_wave64_reductions_fold_when_the_halves_meet: lane 1 of 32: left 0, right 37

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_start also 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.

<!-- greyfinch-sync:ivall/xcl:review-comment:4779425122 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3748#discussion_r4779425122). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-03T03:15:04Z. **Code review location:** `crates/xcl/src/gpu/dxil/mask_exchange.rs`; line 1641 ~~~~diff @@ -1638,6 +1638,7 @@ mod tests { #[test] fn gpu_split_wave64_reductions_fold_when_the_halves_meet() { + let _precise = crate::gpu::recomp::x64_masks::PreciseForTest::on(); // tests the analysis, off by default (#505) ~~~~ --- **Finding 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: ``` gpu_split_wave64_reductions_fold_when_the_halves_meet: lane 1 of 32: left 0, right 37 ``` 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_start` also 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.
vasanex commented 2026-12-03 03:15:04 +00:00 (Migrated from github.com)

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 itself

In short: the new default is the path main takes with XCL_X64_ALL_MASKS=1 at all four sites, and nothing else on main read 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_exchanged answers the earlier merge check's high point: it fails with main'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 main 395405e4)

  • cargo test --workspace --no-fail-fast -- --test-threads=4 (debug): 3014 passed, 0 failed, 56 ignored; 25 SKIPPED, the same tests as on main (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 (main 395405e4, 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_exchanged with precise_masks() returning main's default: fails; on the merge: passes.
  • The two guarded GPU tests in mask_exchange.rs run under the new default (guard replaced by the lock): numbers inline.

Note, not blocking: on main, XCL_X64_ALL_MASKS=1 also made cache_allowed false, 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=1 runs uncached, and =0 bypasses 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.

<!-- greyfinch-sync:ivall/xcl:review:6163111482 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3748#pullrequestreview-6163111482). Originally posted by [vasanex](https://github.com/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 itself **In short:** the new default is the path `main` takes with `XCL_X64_ALL_MASKS=1` at all four sites, and nothing else on `main` read 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_exchanged` answers the earlier merge check's high point: it fails with `main`'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 `main` `395405e4`) - `cargo test --workspace --no-fail-fast -- --test-threads=4` (debug): 3014 passed, 0 failed, 56 ignored; 25 SKIPPED, the same tests as on `main` (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 (`main` `395405e4`, 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_exchanged` with `precise_masks()` returning `main`'s default: fails; on the merge: passes. - The two guarded GPU tests in `mask_exchange.rs` run under the new default (guard replaced by the lock): numbers inline. **Note, not blocking:** on `main`, `XCL_X64_ALL_MASKS=1` also made `cache_allowed` false, 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=1` runs uncached, and `=0` bypasses 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.
throny commented 2026-12-03 04:53:32 +00:00 (Migrated from github.com)

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_TEST is now a thread-local, PRECISE_IN_TEST (crates/xcl/src/gpu/recomp/x64_masks.rs:416). PreciseForTest saves 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 gets IDIOMS_IN_TEST and NO_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_LOCK is gone: the byte-identity test and by_default_every_vote_is_exchanged no longer need it. The nine tests you listed now take PreciseForTest::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_cndmask with the saved mask; see docs/wave64-on-wave32.md, "What the retail pack does"). It then runs s_or_saveexec_b64 s, -1 and does the last steps. v_readlane ignores EXEC, so v_readlane s, v, 32 returns 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 each v_readlane whose 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 with lane 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 holds 37 + v0 of 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_lanes cannot 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).

<!-- greyfinch-sync:ivall/xcl:comment:7368153300 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3748#issuecomment-7368153300). Originally posted by [throny](https://github.com/throny) on 2026-12-03T04:53:32Z. --- Thanks, both findings were right. Amended into the single commit (08beabafc). **Finding 1 (test coverage).** `PRECISE_FOR_TEST` is now a thread-local, `PRECISE_IN_TEST` (crates/xcl/src/gpu/recomp/x64_masks.rs:416). `PreciseForTest` saves 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 gets `IDIOMS_IN_TEST` and `NO_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_LOCK` is gone: the byte-identity test and `by_default_every_vote_is_exchanged` no longer need it. The nine tests you listed now take `PreciseForTest::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_cndmask` with the saved mask; see docs/wave64-on-wave32.md, "What the retail pack does"). It then runs `s_or_saveexec_b64 s, -1` and does the last steps. `v_readlane` ignores EXEC, so `v_readlane s, v, 32` returns 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 each `v_readlane` whose 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 with `lane 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 holds `37 + v0` of 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_lanes` cannot 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).*
vasanex commented 2026-12-03 04:56:48 +00:00 (Migrated from github.com)

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 413

@@ -387,6 +387,59 @@ fn uses_with_table(d: &Decoded, table: &UsePlanTable) -> (Regs, Regs) {
     (whole, written)
 }
 
+/// Whether split wave64 leaves out the exchanges this analysis (and the lazy planner in
+/// gpu/dxil/kernel.rs) find unneeded. Off by default: in some programs a left-out exchange put
+/// the two halves out of step, the next exchange gave up after its spin limit and the wave read
+/// zeros from then on (dark lighting, 31-32 ms GPU calls; #505, measured on an RTX 4080 and an
+/// RTX 5090, where keeping every exchange was also 9-11 % faster). The analyses are known to be
+/// wrong in some programs and the pattern that breaks them is not found yet (#505), so turning
+/// them back on can bring that back. `XCL_X64_PRECISE_MASKS=1` (not `0`) turns them back on: the
+/// planner too, with its mask batching, waves-apart form and the `XCL_WAVE64_IDIOMS` idioms.
+/// (`XCL_X64_ALL_MASKS`, the old way to turn them off, is now the default.)
+pub fn precise_masks() -> bool {
+    #[cfg(test)]
+    if PRECISE_FOR_TEST.load(std::sync::atomic::Ordering::SeqCst) > 0 {
+        return true;
+    }
+    precise_masks_from(std::env::var("XCL_X64_PRECISE_MASKS").ok().as_deref())
+}
+
+/// `XCL_X64_PRECISE_MASKS`: on for any value but `0` (as `XCL_WAVE64_SPIN` and the other switches).
+fn precise_masks_from(v: Option<&str>) -> bool {
+    v.is_some_and(|v| v.trim() != "0")
+}
+
+/// Guards alive (`PreciseForTest`). Process-wide, not per thread: translation can run on worker
+/// threads. Both forms are correct, so a test running beside one only sees other exchange counts.

Fixed in 08beabaf. Read in the delta from 8eae7efa: the switch is a thread-local that translate_entry_with and the per-lane form hand to their worker threads, the lock is gone, and the nine tests take PreciseForTest::on() (seven in mask_exchange.rs, two in idioms.rs).

Measured on a merge of 08beabaf onto main 395405e4 (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 and by_default_every_vote_is_exchanged beside 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.

<!-- greyfinch-sync:ivall/xcl:review-comment:4780100759 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3748#discussion_r4780100759). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-03T04:56:48Z. **Code review location:** `crates/xcl/src/gpu/recomp/x64_masks.rs`; line 413 ~~~~diff @@ -387,6 +387,59 @@ fn uses_with_table(d: &Decoded, table: &UsePlanTable) -> (Regs, Regs) { (whole, written) } +/// Whether split wave64 leaves out the exchanges this analysis (and the lazy planner in +/// gpu/dxil/kernel.rs) find unneeded. Off by default: in some programs a left-out exchange put +/// the two halves out of step, the next exchange gave up after its spin limit and the wave read +/// zeros from then on (dark lighting, 31-32 ms GPU calls; #505, measured on an RTX 4080 and an +/// RTX 5090, where keeping every exchange was also 9-11 % faster). The analyses are known to be +/// wrong in some programs and the pattern that breaks them is not found yet (#505), so turning +/// them back on can bring that back. `XCL_X64_PRECISE_MASKS=1` (not `0`) turns them back on: the +/// planner too, with its mask batching, waves-apart form and the `XCL_WAVE64_IDIOMS` idioms. +/// (`XCL_X64_ALL_MASKS`, the old way to turn them off, is now the default.) +pub fn precise_masks() -> bool { + #[cfg(test)] + if PRECISE_FOR_TEST.load(std::sync::atomic::Ordering::SeqCst) > 0 { + return true; + } + precise_masks_from(std::env::var("XCL_X64_PRECISE_MASKS").ok().as_deref()) +} + +/// `XCL_X64_PRECISE_MASKS`: on for any value but `0` (as `XCL_WAVE64_SPIN` and the other switches). +fn precise_masks_from(v: Option<&str>) -> bool { + v.is_some_and(|v| v.trim() != "0") +} + +/// Guards alive (`PreciseForTest`). Process-wide, not per thread: translation can run on worker +/// threads. Both forms are correct, so a test running beside one only sees other exchange counts. ~~~~ --- Fixed in 08beabaf. Read in the delta from 8eae7efa: the switch is a thread-local that `translate_entry_with` and the per-lane form hand to their worker threads, the lock is gone, and the nine tests take `PreciseForTest::on()` (seven in mask_exchange.rs, two in idioms.rs). Measured on a merge of 08beabaf onto main 395405e4 (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 and `by_default_every_vote_is_exchanged` beside 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.
vasanex commented 2026-12-03 04:56:50 +00:00 (Migrated from github.com)

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 1641

@@ -1638,6 +1638,7 @@ mod tests {
 
     #[test]
     fn gpu_split_wave64_reductions_fold_when_the_halves_meet() {
+        let _precise = crate::gpu::recomp::x64_masks::PreciseForTest::on(); // tests the analysis, off by default (#505)

Fixed in 08beabaf, and thanks for the explanation of the identity: that answers the question.

Measured on a merge of 08beabaf onto main 395405e4 (RTX 3080, debug): gpu_split_wave64_reduction_reads_the_identity_of_a_missing_upper_half passes (in the run named in the other thread: 80 passed, 0 failed, 2 ignored). With the t = 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.

<!-- greyfinch-sync:ivall/xcl:review-comment:4780101028 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3748#discussion_r4780101028). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-03T04:56:50Z. **Code review location:** `crates/xcl/src/gpu/dxil/mask_exchange.rs`; line 1641 ~~~~diff @@ -1638,6 +1638,7 @@ mod tests { #[test] fn gpu_split_wave64_reductions_fold_when_the_halves_meet() { + let _precise = crate::gpu::recomp::x64_masks::PreciseForTest::on(); // tests the analysis, off by default (#505) ~~~~ --- Fixed in 08beabaf, and thanks for the explanation of the identity: that answers the question. Measured on a merge of 08beabaf onto main 395405e4 (RTX 3080, debug): `gpu_split_wave64_reduction_reads_the_identity_of_a_missing_upper_half` passes (in the run named in the other thread: 80 passed, 0 failed, 2 ignored). With the `t = 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.
Foniass commented 2026-12-03 07:23:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T07:23:50Z.


merge-check
base: 078358a058
head: 08beabafce
merge: 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 description is red
hardware / 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 8eae7efa review are all still open.

High

  1. Upper half reads the identity instead of its own lane when the lower half is empty. lower_valu.rs ~1090 decides "absent" as (l >> 5 != 0) && xn == 0. xn is the partner half's count of threads inside the dispatch's thread limits (compute_gate, kernel.rs ~1301), so in the upper half it counts the lower half's threads. A DispatchX with thread dimensions can leave a wave's lower half wholly past the x limit while the upper half runs. Example: group [48,6,1] (288 threads, so the t % 64 gate passes), wave 1 lower half = row 1 x 16..47, upper half = row 2 x 0..31, x limit 10. In the upper half, read_lane_uniform (lanes.rs ~971) gives the correct value of its own lane 32, and the new select replaces it with the constant. An OR / ADD / XOR / UMAX reduction then comes out 0 where main and the previous head gave the right answer. Test that the lane read is in the other half: cmp(Ne, lh, self.half) instead of cmpc(Ne, lh, 0), or AND with !self.upper. Add a GPU case with a thread limit that empties a lower half (as in core_tests.rs ~1216 / lanes.rs ~1515).

Medium

  1. The new default test covers only the planner. Still open from my 8eae7efa review. 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.
  2. Open PRs that test the analysis will fail after this merges. Still open. #1111 (updated 2026-12-02, gpu_split_wave64_bitwise_lane_masks asserts 0 and 2 ballots) and #1637 (split_wave64_* tests assert local ballots) still translate split wave64 without PreciseForTest. Their assertions only hold with the analysis on, so they fail once this merges. Tell the authors on those PRs to take the guard, or list them in the description as needing a rebase.
  3. Reductions the analysis cannot resolve still read 0 where main's planner folded them. upper_consts takes only Read::Const from upper_lanes (kernel.rs ~875). A v_readlane of lane 32 or above that comes out Read::Unknown gives the exchange's 0 for a missing upper half; that happens when EXEC's upper word is unknown or the identity comes from something the analysis does not follow. Main's planner folded these correctly, so AND / UMIN / IMIN / IMAX are still wrong there by default. The (1..=32).contains(t % 64) gate also skips groups whose upper half is emptied at run time by a thread limit (t % 64 == 0), although the select is already gated on xn at run time and could cover them. Widen the gate to every split compute / mesh program. Say in the description which reads still give 0, or log them under XCL_RECOMP_WHY.

Nit

  1. XCL_X64_PRECISE_MASKS=0 still counts as set. Still open. precise_masks() now treats "0" as off, but cache_allowed is still called with var_os(name).is_some() (pso.rs ~258, ~1500, ~1671). So =0 still skips the shader caches and changes nothing else. shaders.rs ~49 also records the "0" value as a pipeline setting, and by_default_every_vote_is_exchanged (idioms.rs ~489) returns early on var_os is_some, so it never runs with =0. Check through precise_masks_from or the same != "0" form in those places.
  2. PR description still describes PRECISE_LOCK. The "What is in it" list still says the tests use "the lock PRECISE_LOCK" and that translation_is_byte_identical_across_runs_and_threads "takes the same lock". This head removed both (x64_masks.rs ~412 is now a thread-local). Update the bullets.
Checked and fine
  • PRECISE_IN_TEST is a thread-local that PreciseForTest saves and restores (nesting works), and it is passed on to both threads that do translation (kernel.rs ~269/~279, lower_dxil.rs ~484/~490); the other spawned threads (ssa.rs, dxc.rs, pso.rs) do not call precise_masks()
  • vasanex's finding 1 is fixed: the nine GPU tests of the planned lowerings (seven in mask_exchange.rs, two in idioms.rs) now take PreciseForTest and so run the planned form on every run
  • Removing PRECISE_LOCK is safe: with a per-thread switch, translation_is_byte_identical_across_runs_and_threads and by_default_every_vote_is_exchanged cannot see another test's guard
  • For the lower half, the identity fix matches the console: upper_lanes assumes EXEC's upper word is 0 at the start, which holds for a wave with no threads in its upper half, and lanes.rs ~185 sets xn from the group shape when the program has a group barrier (leave = false)
  • The new GPU test computes its expected values correctly for 32, 64 and 96 threads (lanes 0 and 32: 37 / 69 and 3 / -1; lane 64: 101 / -5) for OR, AND, XOR, ADD, UMIN and UMAX
  • No assertion deleted or weakened; the 11 guarded tests keep their asserts
  • Default cost: upper_lanes::analyze runs only for split compute / mesh programs with a partial last wave, and the select adds a few ALU operations at the v_readlane sites it resolves to a constant
  • Scope: 196 added / 10 removed lines in one commit; the identity fix repairs a regression this PR's default introduced, so it belongs here; GitHub reports the PR mergeable into main 395405e4
How this was tested
  • Merged onto main 078358a0, then cargo build --workspace and cargo test --workspace --no-fail-fast -- --test-threads=4.
  • The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar).
  • scripts/smoke.ps1: 60 s of a retail title on main 078358a0 and on this merge; presents per 2 s at the end: 60 61 60.
  • Title run: the release build of this merge launched the retail title with XCL_RUN_SECONDS=300 and 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.

<!-- greyfinch-sync:ivall/xcl:comment:7370947242 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3748#issuecomment-7370947242). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T07:23:50Z. --- merge-check base: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a head: 08beabafce95fb6fe4fdda0a94bae108607e6f60 merge: 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 description` is red hardware / 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 8eae7efa review are all still open. #### High 1. **Upper half reads the identity instead of its own lane when the lower half is empty.** lower_valu.rs ~1090 decides "absent" as (l >> 5 != 0) && xn == 0. xn is the partner half's count of threads inside the dispatch's thread limits (compute_gate, kernel.rs ~1301), so in the upper half it counts the lower half's threads. A DispatchX with thread dimensions can leave a wave's lower half wholly past the x limit while the upper half runs. Example: group [48,6,1] (288 threads, so the t % 64 gate passes), wave 1 lower half = row 1 x 16..47, upper half = row 2 x 0..31, x limit 10. In the upper half, read_lane_uniform (lanes.rs ~971) gives the correct value of its own lane 32, and the new select replaces it with the constant. An OR / ADD / XOR / UMAX reduction then comes out 0 where main and the previous head gave the right answer. Test that the lane read is in the other half: cmp(Ne, lh, self.half) instead of cmpc(Ne, lh, 0), or AND with !self.upper. Add a GPU case with a thread limit that empties a lower half (as in core_tests.rs ~1216 / lanes.rs ~1515). #### Medium 2. **The new default test covers only the planner.** Still open from my 8eae7efa review. 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. 3. **Open PRs that test the analysis will fail after this merges.** Still open. #1111 (updated 2026-12-02, gpu_split_wave64_bitwise_lane_masks asserts 0 and 2 ballots) and #1637 (split_wave64_* tests assert local ballots) still translate split wave64 without PreciseForTest. Their assertions only hold with the analysis on, so they fail once this merges. Tell the authors on those PRs to take the guard, or list them in the description as needing a rebase. 4. **Reductions the analysis cannot resolve still read 0 where main's planner folded them.** upper_consts takes only Read::Const from upper_lanes (kernel.rs ~875). A v_readlane of lane 32 or above that comes out Read::Unknown gives the exchange's 0 for a missing upper half; that happens when EXEC's upper word is unknown or the identity comes from something the analysis does not follow. Main's planner folded these correctly, so AND / UMIN / IMIN / IMAX are still wrong there by default. The (1..=32).contains(t % 64) gate also skips groups whose upper half is emptied at run time by a thread limit (t % 64 == 0), although the select is already gated on xn at run time and could cover them. Widen the gate to every split compute / mesh program. Say in the description which reads still give 0, or log them under XCL_RECOMP_WHY. #### Nit 5. **XCL_X64_PRECISE_MASKS=0 still counts as set.** Still open. precise_masks() now treats "0" as off, but cache_allowed is still called with var_os(name).is_some() (pso.rs ~258, ~1500, ~1671). So =0 still skips the shader caches and changes nothing else. shaders.rs ~49 also records the "0" value as a pipeline setting, and by_default_every_vote_is_exchanged (idioms.rs ~489) returns early on var_os is_some, so it never runs with =0. Check through precise_masks_from or the same != "0" form in those places. 6. **PR description still describes PRECISE_LOCK.** The "What is in it" list still says the tests use "the lock PRECISE_LOCK" and that translation_is_byte_identical_across_runs_and_threads "takes the same lock". This head removed both (x64_masks.rs ~412 is now a thread-local). Update the bullets. <details><summary>Checked and fine</summary> - PRECISE_IN_TEST is a thread-local that PreciseForTest saves and restores (nesting works), and it is passed on to both threads that do translation (kernel.rs ~269/~279, lower_dxil.rs ~484/~490); the other spawned threads (ssa.rs, dxc.rs, pso.rs) do not call precise_masks() - vasanex's finding 1 is fixed: the nine GPU tests of the planned lowerings (seven in mask_exchange.rs, two in idioms.rs) now take PreciseForTest and so run the planned form on every run - Removing PRECISE_LOCK is safe: with a per-thread switch, translation_is_byte_identical_across_runs_and_threads and by_default_every_vote_is_exchanged cannot see another test's guard - For the lower half, the identity fix matches the console: upper_lanes assumes EXEC's upper word is 0 at the start, which holds for a wave with no threads in its upper half, and lanes.rs ~185 sets xn from the group shape when the program has a group barrier (leave = false) - The new GPU test computes its expected values correctly for 32, 64 and 96 threads (lanes 0 and 32: 37 / 69 and 3 / -1; lane 64: 101 / -5) for OR, AND, XOR, ADD, UMIN and UMAX - No assertion deleted or weakened; the 11 guarded tests keep their asserts - Default cost: upper_lanes::analyze runs only for split compute / mesh programs with a partial last wave, and the select adds a few ALU operations at the v_readlane sites it resolves to a constant - Scope: 196 added / 10 removed lines in one commit; the identity fix repairs a regression this PR's default introduced, so it belongs here; GitHub reports the PR mergeable into main 395405e4 </details> <details><summary>How this was tested</summary> - Merged onto main `078358a0`, then `cargo build --workspace` and `cargo test --workspace --no-fail-fast -- --test-threads=4`. - The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar). - `scripts/smoke.ps1`: 60 s of a retail title on main `078358a0` and on this merge; presents per 2 s at the end: 60 61 60. - Title run: the release build of this merge launched the retail title with `XCL_RUN_SECONDS=300` and 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. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
vasanex commented 2026-12-03 07:25:41 +00:00 (Migrated from github.com)

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 1641

@@ -1638,6 +1638,7 @@ mod tests {
 
     #[test]
     fn gpu_split_wave64_reductions_fold_when_the_halves_meet() {
+        let _precise = crate::gpu::recomp::x64_masks::PreciseForTest::on(); // tests the analysis, off by default (#505)

A 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. There read_lane_uniform already returns the half's own lane (lh == self.half), and the new select replaces it with the constant when xn == 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.rs at the absent select, lanes.rs read_lane_uniform, kernel.rs compute_gate), not measured: I have no test for it. Their suggested condition (the lane read is in the other half, lh != self.half, instead of lh != 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.

<!-- greyfinch-sync:ivall/xcl:review-comment:4781266174 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3748#discussion_r4781266174). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-03T07:25:41Z. **Code review location:** `crates/xcl/src/gpu/dxil/mask_exchange.rs`; line 1641 ~~~~diff @@ -1638,6 +1638,7 @@ mod tests { #[test] fn gpu_split_wave64_reductions_fold_when_the_halves_meet() { + let _precise = crate::gpu::recomp::x64_masks::PreciseForTest::on(); // tests the analysis, off by default (#505) ~~~~ --- A 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. There `read_lane_uniform` already returns the half's own lane (`lh == self.half`), and the new select replaces it with the constant when `xn == 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.rs` at the `absent` select, `lanes.rs` `read_lane_uniform`, `kernel.rs` `compute_gate`), not measured: I have no test for it. Their suggested condition (the lane read is in the other half, `lh != self.half`, instead of `lh != 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.
CharlyRien commented 2026-12-03 10:08:29 +00:00 (Migrated from github.com)

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=1 on 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):

tree default XCL_X64_ALL_MASKS=1
main 5ad98adb + #3716 d2293dcb + a test-only probe + a local change to the split helpers' arguments 12 / 12 wrong 12 / 12 right
#3707 7b19e27d + #3716 d2293dcb + the same probe 12 / 12 wrong 12 / 12 right

The 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.

<!-- greyfinch-sync:ivall/xcl:comment:7374794847 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3748#issuecomment-7374794847). Originally posted by [CharlyRien](https://github.com/CharlyRien) on 2026-12-03T10:08:29Z. --- **Test report: RTX 3090, split compute fuzz programs** (not a merge-check) `XCL_X64_ALL_MASKS=1` on 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): | tree | default | `XCL_X64_ALL_MASKS=1` | |---|---|---| | `main` `5ad98adb` + #3716 `d2293dcb` + a test-only probe + a local change to the split helpers' arguments | 12 / 12 wrong | 12 / 12 right | | #3707 `7b19e27d` + #3716 `d2293dcb` + the same probe | 12 / 12 wrong | 12 / 12 right | The 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.
Gevroska commented 2026-12-03 11:15:04 +00:00 (Migrated from github.com)

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 a 48×3 compute 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 holds 133. All eight active threads (IDs 96–103) read back 0xffffffff instead of 133. 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.

<!-- greyfinch-sync:ivall/xcl:comment:7376426291 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3748#issuecomment-7376426291). Originally posted by [Gevroska](https://github.com/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 a `48×3` compute 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 holds `133`. All eight active threads (IDs 96–103) read back `0xffffffff` instead of `133`. 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.
lucsoft commented 2026-12-03 11:31:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by lucsoft on 2026-12-03T11:31:55Z.


merge-check claim
head: 08beabafce
RX 7800 XT (RADV, Wine): suite, smoke and a title run on the AMD side.

<!-- greyfinch-sync:ivall/xcl:comment:7376828858 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3748#issuecomment-7376828858). Originally posted by [lucsoft](https://github.com/lucsoft) on 2026-12-03T11:31:55Z. --- merge-check claim head: 08beabafce95fb6fe4fdda0a94bae108607e6f60 RX 7800 XT (RADV, Wine): suite, smoke and a title run on the AMD side.
CharlyRien commented 2026-12-03 12:42:55 +00:00 (Migrated from github.com)

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_u32 in two, v_add_f32 in one), so the 0 the split form returns is already the right value there, and this change gives the same result. No v_readlane of a lane ≥ 32 outside a section, no v_writelane to a lane ≥ 32, no ds_bpermute, row_share or row_bcast in 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::binary follows 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 example op(x, v_readlane(x, 0)), which the #3716 fuzzer generates) stays Unknown and 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 is main 078358a0 merged with #3716 plus the probe test. Mismatches in the class "a group's last wave with an empty upper half" (96-thread compute):

  • main 078358a0 + #3716: 134 seeds.
    • this PR (08beabaf): 47. 88 fixed, 1 new.
  • the same exe with the v_readlane constant left out (a local switch): 133. So the repair is the constant, not the all-masks default.
  • the same exe with 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 value upper_lanes leaves Unknown: 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 gives 0xffffffff where 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.

<!-- greyfinch-sync:ivall/xcl:comment:7378726246 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3748#issuecomment-7378726246). Originally posted by [CharlyRien](https://github.com/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_u32` in two, `v_add_f32` in one), so the 0 the split form returns is already the right value there, and this change gives the same result. No `v_readlane` of a lane ≥ 32 outside a section, no `v_writelane` to a lane ≥ 32, no `ds_bpermute`, `row_share` or `row_bcast` in 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::binary` follows 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 example `op(x, v_readlane(x, 0))`, which the #3716 fuzzer generates) stays `Unknown` and 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 is `main` `078358a0` merged with #3716 plus the probe test. Mismatches in the class "a group's last wave with an empty upper half" (96-thread compute): - `main` `078358a0` + #3716: 134 seeds. - + this PR (`08beabaf`): 47. 88 fixed, 1 new. - the same exe with the `v_readlane` constant left out (a local switch): 133. So the repair is the constant, not the all-masks default. - the same exe with `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 value `upper_lanes` leaves `Unknown`: 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 gives `0xffffffff` where 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.
lucsoft commented 2026-12-03 13:20:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by lucsoft on 2026-12-03T13:20:00Z.


merge-check
base: a815de932c
head: 08beabafce
merge: 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: absent checks 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 findings
performance: no change measurable: on main 0c725d5d both 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 it
title 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/s
verdict: 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)

<!-- greyfinch-sync:ivall/xcl:comment:7379656161 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3748#issuecomment-7379656161). Originally posted by [lucsoft](https://github.com/lucsoft) on 2026-12-03T13:20:00Z. --- merge-check base: a815de932c4dc8da3b383ca44f4b094aa406fec9 head: 08beabafce95fb6fe4fdda0a94bae108607e6f60 merge: 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: `absent` checks 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 findings performance: no change measurable: on main 0c725d5d both 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 it title 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/s verdict: 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)
throny commented 2026-12-03 15:53:40 +00:00 (Migrated from github.com)

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).

xn counts the lanes of the partner half, so with an empty lower half an upper-half reader saw xn == 0 and 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)

  • the new test on 08beabaf: fails (0 instead of 133); on a8a6fef: passes
  • cargo test -p xcl --lib split_wave64: 51 passed, 0 failed, 1 ignored
  • cargo test --workspace -- --test-threads=4 on a8a6fef: 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).

<!-- greyfinch-sync:ivall/xcl:comment:7383910111 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3748#issuecomment-7383910111). Originally posted by [throny](https://github.com/throny) on 2026-12-03T15:53:40Z. --- Thanks, confirmed and fixed in a8a6fef (squashed into the PR's commit). `xn` counts the lanes of the *partner* half, so with an empty lower half an upper-half reader saw `xn == 0` and 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) - the new test on 08beabaf: fails (0 instead of 133); on a8a6fef: passes - `cargo test -p xcl --lib split_wave64`: 51 passed, 0 failed, 1 ignored - `cargo test --workspace -- --test-threads=4` on a8a6fef: 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).
lucsoft commented 2026-12-03 15:55:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by lucsoft on 2026-12-03T15:55:58Z.


merge-check claim
head: a8a6fef205
RX 7800 XT (RADV, Wine): build, suite and a title run on the AMD side.

<!-- greyfinch-sync:ivall/xcl:comment:7383974795 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3748#issuecomment-7383974795). Originally posted by [lucsoft](https://github.com/lucsoft) on 2026-12-03T15:55:58Z. --- merge-check claim head: a8a6fef20593eafa494a2ecbf4ba49704edb3260 RX 7800 XT (RADV, Wine): build, suite and a title run on the AMD side.
vasanex commented 2026-12-03 16:14:45 +00:00 (Migrated from github.com)

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 1641

@@ -1638,6 +1638,7 @@ mod tests {
 
     #[test]
     fn gpu_split_wave64_reductions_fold_when_the_halves_meet() {
+        let _precise = crate::gpu::recomp::x64_masks::PreciseForTest::on(); // tests the analysis, off by default (#505)

fixed 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, a8a6fef2 merged onto main a815de93 = 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 in lower_valu.rs taken 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).

<!-- greyfinch-sync:ivall/xcl:review-comment:4787673233 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3748#discussion_r4787673233). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-03T16:14:45Z. **Code review location:** `crates/xcl/src/gpu/dxil/mask_exchange.rs`; line 1641 ~~~~diff @@ -1638,6 +1638,7 @@ mod tests { #[test] fn gpu_split_wave64_reductions_fold_when_the_halves_meet() { + let _precise = crate::gpu::recomp::x64_masks::PreciseForTest::on(); // tests the analysis, off by default (#505) ~~~~ --- fixed 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, a8a6fef2 merged onto main a815de93 = 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 in `lower_valu.rs` taken 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).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3748:upstream-pr/3748'
git switch 'upstream-pr/3748'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/3748'
git switch 'upstream-pr/3748'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3748'
git switch 'upstream-pr/3748'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3748'
git switch 'main'
git merge --squash 'upstream-pr/3748'
git switch 'main'
git merge --ff-only 'upstream-pr/3748'
git switch 'main'
git merge 'upstream-pr/3748'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3748
No description provided.