Recompiler: split wave64 half-local masks read their words from the first lane #3792

Open
CharlyRien wants to merge 2 commits from upstream-pr/3792 into main
CharlyRien commented 2026-12-03 15:00:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-03T15:00:05Z.


Works around group 6 of the #3716 fuzzer (point 6 of https://github.com/xcl-dev/xcl/pull/3716#issuecomment-7358845851), discussed in #3758.

In the direct split form (a wave64 program run as two 32-lane hardware waves), a compare mask that is never read whole stays a half-local pair: Lw::write_mask (gpu/dxil/lower.rs) builds it as (select(upper, 0, ballot), select(upper, ballot, 0)) and the halves exchange nothing at the compare. On an RTX 3090 (drivers 616.56 and 621.47), NVIDIA's shader compiler reads the lower half's own word of that pair as 0 at a later branch on EXEC in some programs: 12 programs of group 6 give wrong words in every run. The same DXIL gives the reference words on WARP and in a CPU interpreter of it, and in that interpreter only zeroing that word reproduces the 3090's 128 wrong words in the shrunk program (#3758, second comment). The same shape written by hand in HLSL is right on the 3090 at DXC -O3, -O1 and -Od, so only the DXIL the translator emits meets it.

Both words of the pair are the same in the lanes that run the ballot together, so this change reads each of them once more with WaveReadLaneFirst (Lw::read_pair_first):

  • the ballot is the same in those lanes;
  • upper is the same in every lane of a hardware wave: each hardware wave is one 32-lane half, its lanes are a base that is a multiple of 32, read from the first lane, plus a rank below 32 (setup_lanes, setup_lanes_compute).

So the read changes nothing in the program's meaning, and the halves exchange nothing more. It applies to every split entry (compute, mesh, the GS). It also stops the translator's select folds on the pair: a lane's bit of it used to fold back to the ballot word and is now a select of the two reads, so the DXIL grows a little (measured below).

Lw::ballot builds the same pair when there is no partner half (Partner::Missing: the other half's word is 0):

  • in a compute or mesh group of 32 threads or fewer, the only hardware wave is the lower half, so upper is now the constant false there (setup_lanes_compute): the selects fold to (ballot, 0) and there is nothing to read. batch_ballot and meet_at build the pair without a partner only in compute and mesh programs, so they fold too;
  • in the split form's GS (the lower hardware wave alone), upper is not a constant where the GS's EXEC is made, so that pair is read from the first lane too.

It is not applied:

  • where upper is a constant (apart, groups of 32 threads or fewer): no select;
  • when the pair goes nowhere (Dst::Null);
  • in native wave64, wave32 and VS / PS, which have no half-local pair.

This is not #3784's read: #3784 reads a mask word before a lane's bit test, and #3758's second comment notes that this does not fix these programs (the branch reads 0 too). This change reads the pair's words where they are made. The two commits touch different lines and merge without conflict.

With #3748 (every mask exchanged by default), Lw::write_mask would take the half-local branch for an SGPR destination only under XCL_X64_PRECISE_MASKS=1; by default only the GS-alone Lw::ballot pair would keep the read. The measurements here are of main a815de93's default, where the half-local analysis runs unless XCL_X64_ALL_MASKS is set. Whichever of the two PRs lands second adapts the tests: the two group6 CPU tests need the analysis on.

What is in it

  • gpu/dxil/lower.rs: Lw::read_pair_first, called from Lw::write_mask's half-local branch; a test-only switch to show the old form (NO_PAIR_READ_FIRST_IN_TEST).
  • gpu/dxil/lanes.rs: upper is the constant false in split compute / mesh groups of 32 threads or fewer; Lw::ballot reads its pair from the first lane when there is no partner half.
  • gpu/dxil/kernel.rs: the translator thread takes that switch over, like the existing ones; translate_compute_as (test only), the compute twin of translate_full_as.
  • gpu/dxil/lower.rs, tests (split_pair_tests), on group 6's shrunk program (seed 1000823 shrunk to 120 instructions, assembled by hand; 96 threads, 2 groups). The CPU tests translate in the plain form (not the compact one, whatever XCL_DIRECT_COMPACT says) and skip without dxcompiler.dll, checked before translating (translation validates under test). The two group6 CPU tests also skip when XCL_X64_ALL_MASKS is set (no half-local pair then), and their "no half-local pair" messages name that premise:
    • split_half_local_pairs_are_read_from_the_first_lane (CPU): in the split form each word of a half-local pair (a select between a ballot's word and 0) is read once from the first lane, nothing else uses the word, and the program uses each read; none is read without the change; the ballots, groupshared accesses and barriers are the same. The native wave64 form has no such pair and the same reads as before.
    • split_groups_of_32_threads_or_fewer_have_no_pair_to_read (CPU): the same program in split groups of 32 and 20 threads has no such pair and no read more.
    • split_gs_alone_reads_its_exec_pair_from_the_first_lane (CPU): the split form's GS alone reads its EXEC pair from the first lane, and only the reads use it.
    • gpu_split_half_local_exec_branch (GPU): the program in the split form, every stored word checked (v1..v16 and s4..s15 of all 192 threads, 5,376 words; the expected words are the #3716 RDNA2 reference's for this program). It also runs the old form and prints its wrong words without asserting them, since other GPUs may compile it right. It skips without a GPU, a wave32 GPU or DXC, checked before translating.
  • Second commit (88a810f4, tests only, after Foniass's review): the GPU test's DXC check, and the XCL_X64_ALL_MASKS skip and messages above. The runtime code is the first commit's.

No cache bump: the change is under gpu/dxil, whose hash is XCL_DIRECT_DXIL_SOURCE_ID, so split-form direct translations get a new identity on their own; the HLSL path's XCL_TRANSLATOR_SOURCE_ID is unchanged.

Measured before this PR

RTX 3090, driver 621.47. These runs use a local probe, not this commit: the same read behind a variable, applied in the whole half-local branch (also with apart, local_masks and Dst::Null), on #3707 7b19e27d + #3716 d2293dcb. Only the split form was run.

pair form group 6 cases right (the shrunk program, the 12 seeds, 4 controls)
as on main 4 / 17 (the controls)
WaveReadLaneFirst of each word (this PR) 17 / 17
WaveReadLaneFirst of the ballot, then the selects 4 / 17
no select: ballot & (upper - 1), ballot & (0 - upper) 4 / 17
the compare's ballot exchanged where it is made, when a SAVEEXEC reads it 17 / 17 (but more exchanges)

8,000 programs of the #3716 fuzzer (seeds 0–1999, 1000000–1001999, 2000000–2001999, 3000000–3001999), direct split form:

without the read with the read
programs that differ from the reference 201 188
fixed — 13 (the 12 group 6 seeds, and seed 358, which was already wrong without the read with driver 621.47)
wrong only with the read — 0

The other 188 are other issues: group 5 (#3779), group 1 and one signed zero (the same split as in #3784's description).

With this commit, on main a815de93 + #3716 de05c50e (whose generator changed, so the seed numbers above need not be the same programs) and the same fuzz probe, against the same tree without the commit, over the same 8,000 seeds: 203 programs differ from the reference without it, 193 with it; fixed: 10 (seeds 155, 358, 746, 824, 1869, 1000716, 1001176, 2000677, 2000986, 2001922); wrong only with it: 0.

Over the same 8,000 programs, the direct split form's containers grow from 50,574,952 to 50,723,040 bytes (+0.29 %): 1,767 programs larger (at most +356 bytes), none smaller, 6,233 the same.

This is a workaround chosen from the shapes seen on one card with two drivers. It does not prove that other shapes do not meet the same driver bug.

Tested

  • RTX 3090 (driver 621.47), Ryzen 9 5950X, Windows 11 22631, Rust 1.100.0, debug, DXC 1.9.2602.17.
  • This head (88a810f4): cargo build --workspace and cargo test --workspace --no-run: ok
  • This head: cargo test --workspace --no-fail-fast -- --test-threads=4: 3,020 passed, 2 failed (the same two debug-layer tests as below), 56 ignored, over 45 test binaries; SKIPPED: the same 25 lines as below.
  • This head: the four new tests by name with XCL_REQUIRE_GPU=mesh: passed; gpu_split_half_local_exec_branch, 3 runs: 128 wrong words without the read each time, 0 with it. Release build: the four tests passed.
  • The first commit alone (01d941e1, the same runtime code), on the same machine: cargo build --workspace and cargo test --workspace --no-run: ok
  • 01d941e1: cargo test --workspace --no-fail-fast -- --test-threads=4: 3,020 passed, 2 failed (test_title_draws_with_a_root_signature_under_the_debug_layer, test_title_runs_under_the_debug_layer_with_dred), 56 ignored, over 45 test binaries. The same two debug-layer tests fail on this machine without this commit (main 16c2fd08 + another one-commit recompiler branch: 3,013 passed, the same 2 failed); main a815de93 itself was not run through the whole suite.
  • 01d941e1: SKIPPED on this adapter: 25 lines: 22 "no wave64", 3 "no heap windows" or "no GPU_UPLOAD heaps", the reasons this card always gives.
  • 01d941e1: the four new tests by name with XCL_REQUIRE_GPU=mesh: passed, and passed again in the whole suite. gpu_split_half_local_exec_branch, 3 runs: the old form gave 128 wrong words each time (v1 of group 0's first threads read 0, as in #3758), the new form 0. A release build of this head passed the four tests too.

Regression run
scripts/smoke.ps1, 60 s each, the same title, the same machine and driver (621.47), a fresh shader cache on each side; main first, then this head (88a810f4), then the first head (01d941e1, the same runtime code) for reference:

xcl-smoke v1
commit: a815de932c4dc8da3b383ca44f4b094aa406fec9
gpu: NVIDIA GeForce RTX 3090
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 495 (PresentX 495)
presents per 2 s (last 3): 61 61 60
device removals: 0
crashes: 0
peak commit: 15974 MB
xcl-smoke v1
commit: 88a810f4e5b68b536b6688ab0aa2d9e94944ec15
gpu: NVIDIA GeForce RTX 3090
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 1642 (PresentX 1642)
presents per 2 s (last 3): 61 60 61
device removals: 0
crashes: 0
peak commit: 15878 MB
xcl-smoke v1
commit: 01d941e1411e3589eeb78bab5b69604a13794be9
gpu: NVIDIA GeForce RTX 3090
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 532 (PresentX 532)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 15926 MB

This head: frames 1,642 / 495 (332 %), peak commit 15,878 / 15,974 MB (99 %), no device removal, no crash. This head changes only tests, so its runtime code is 01d941e1's; the higher frame count is not from it. A likely cause (not checked) is the driver's own shader cache, warm from the 01d941e1 run of the same DXIL. 01d941e1: frames 532 / 495 (107 %), peak commit 15,926 / 15,974 MB (100 %), no device removal, no crash.

Not tested

  • AMD with this commit (no split form there by default; XCL_SPLIT_WAVE64=1 would use it), Intel, other NVIDIA cards and drivers. Without this commit, @stijn-boer's run of the same probe on main a815de93 (RX 9060 XT, #3779 comment) already matched on all 12 G6 programs, so the miscompile is seen on NVIDIA only so far.
  • The same pair is still built without the read, not measured on the 3090: in the per-lane form's bridge (Lw::local_masks, XCL_PER_LANE=1), and in the HLSL path's xcl_x_ballot_local (recomp/emit.rs), which split programs take when the direct translator refuses them.
  • The GS read and the constant upper of groups of 32 threads or fewer: covered by the CPU tests and by the existing split GPU tests of 32-thread groups in the whole suite; no fuzz program reaches the GS.
  • Frame time: the read adds two WaveReadLaneFirst per half-local compare mask in split programs and stops some select folds; not measured beyond the smoke run.

AI use

  • AI use: Claude Code (Claude Opus 5.5) shrank the failing program, ran the driver and fuzz checks, wrote the change, its tests, the review follow-up commit and this description; checked and posted by me.

Base: main a815de93, two commits (the change, then its test follow-up), no local switches.

<!-- greyfinch-sync:ivall/xcl:issue:5629026896 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3792). Originally posted by [CharlyRien](https://github.com/CharlyRien) on 2026-12-03T15:00:05Z. --- Works around group 6 of the #3716 fuzzer (point 6 of https://github.com/xcl-dev/xcl/pull/3716#issuecomment-7358845851), discussed in #3758. In the direct split form (a wave64 program run as two 32-lane hardware waves), a compare mask that is never read whole stays a half-local pair: `Lw::write_mask` (`gpu/dxil/lower.rs`) builds it as `(select(upper, 0, ballot), select(upper, ballot, 0))` and the halves exchange nothing at the compare. On an RTX 3090 (drivers 616.56 and 621.47), NVIDIA's shader compiler reads the lower half's own word of that pair as 0 at a later branch on EXEC in some programs: 12 programs of group 6 give wrong words in every run. The same DXIL gives the reference words on WARP and in a CPU interpreter of it, and in that interpreter only zeroing that word reproduces the 3090's 128 wrong words in the shrunk program (#3758, second comment). The same shape written by hand in HLSL is right on the 3090 at DXC `-O3`, `-O1` and `-Od`, so only the DXIL the translator emits meets it. Both words of the pair are the same in the lanes that run the ballot together, so this change reads each of them once more with `WaveReadLaneFirst` (`Lw::read_pair_first`): - the ballot is the same in those lanes; - `upper` is the same in every lane of a hardware wave: each hardware wave is one 32-lane half, its lanes are a base that is a multiple of 32, read from the first lane, plus a rank below 32 (`setup_lanes`, `setup_lanes_compute`). So the read changes nothing in the program's meaning, and the halves exchange nothing more. It applies to every split entry (compute, mesh, the GS). It also stops the translator's select folds on the pair: a lane's bit of it used to fold back to the ballot word and is now a select of the two reads, so the DXIL grows a little (measured below). `Lw::ballot` builds the same pair when there is no partner half (`Partner::Missing`: the other half's word is 0): - in a compute or mesh group of 32 threads or fewer, the only hardware wave is the lower half, so `upper` is now the constant false there (`setup_lanes_compute`): the selects fold to `(ballot, 0)` and there is nothing to read. `batch_ballot` and `meet_at` build the pair without a partner only in compute and mesh programs, so they fold too; - in the split form's GS (the lower hardware wave alone), `upper` is not a constant where the GS's EXEC is made, so that pair is read from the first lane too. It is not applied: - where `upper` is a constant (`apart`, groups of 32 threads or fewer): no select; - when the pair goes nowhere (`Dst::Null`); - in native wave64, wave32 and VS / PS, which have no half-local pair. This is not #3784's read: #3784 reads a mask word before a lane's bit test, and #3758's second comment notes that this does not fix these programs (the branch reads 0 too). This change reads the pair's words where they are made. The two commits touch different lines and merge without conflict. With #3748 (every mask exchanged by default), `Lw::write_mask` would take the half-local branch for an SGPR destination only under `XCL_X64_PRECISE_MASKS=1`; by default only the GS-alone `Lw::ballot` pair would keep the read. The measurements here are of `main` `a815de93`'s default, where the half-local analysis runs unless `XCL_X64_ALL_MASKS` is set. Whichever of the two PRs lands second adapts the tests: the two `group6` CPU tests need the analysis on. **What is in it** - `gpu/dxil/lower.rs`: `Lw::read_pair_first`, called from `Lw::write_mask`'s half-local branch; a test-only switch to show the old form (`NO_PAIR_READ_FIRST_IN_TEST`). - `gpu/dxil/lanes.rs`: `upper` is the constant false in split compute / mesh groups of 32 threads or fewer; `Lw::ballot` reads its pair from the first lane when there is no partner half. - `gpu/dxil/kernel.rs`: the translator thread takes that switch over, like the existing ones; `translate_compute_as` (test only), the compute twin of `translate_full_as`. - `gpu/dxil/lower.rs`, tests (`split_pair_tests`), on group 6's shrunk program (seed 1000823 shrunk to 120 instructions, assembled by hand; 96 threads, 2 groups). The CPU tests translate in the plain form (not the compact one, whatever `XCL_DIRECT_COMPACT` says) and skip without `dxcompiler.dll`, checked before translating (translation validates under test). The two `group6` CPU tests also skip when `XCL_X64_ALL_MASKS` is set (no half-local pair then), and their "no half-local pair" messages name that premise: - `split_half_local_pairs_are_read_from_the_first_lane` (CPU): in the split form each word of a half-local pair (a select between a ballot's word and 0) is read once from the first lane, nothing else uses the word, and the program uses each read; none is read without the change; the ballots, groupshared accesses and barriers are the same. The native wave64 form has no such pair and the same reads as before. - `split_groups_of_32_threads_or_fewer_have_no_pair_to_read` (CPU): the same program in split groups of 32 and 20 threads has no such pair and no read more. - `split_gs_alone_reads_its_exec_pair_from_the_first_lane` (CPU): the split form's GS alone reads its EXEC pair from the first lane, and only the reads use it. - `gpu_split_half_local_exec_branch` (GPU): the program in the split form, every stored word checked (v1..v16 and s4..s15 of all 192 threads, 5,376 words; the expected words are the #3716 RDNA2 reference's for this program). It also runs the old form and prints its wrong words without asserting them, since other GPUs may compile it right. It skips without a GPU, a wave32 GPU or DXC, checked before translating. - Second commit (`88a810f4`, tests only, after Foniass's review): the GPU test's DXC check, and the `XCL_X64_ALL_MASKS` skip and messages above. The runtime code is the first commit's. No cache bump: the change is under `gpu/dxil`, whose hash is `XCL_DIRECT_DXIL_SOURCE_ID`, so split-form direct translations get a new identity on their own; the HLSL path's `XCL_TRANSLATOR_SOURCE_ID` is unchanged. **Measured before this PR** RTX 3090, driver 621.47. These runs use a local probe, not this commit: the same read behind a variable, applied in the whole half-local branch (also with `apart`, `local_masks` and `Dst::Null`), on #3707 `7b19e27d` + #3716 `d2293dcb`. Only the split form was run. | pair form | group 6 cases right (the shrunk program, the 12 seeds, 4 controls) | |---|---| | as on `main` | 4 / 17 (the controls) | | `WaveReadLaneFirst` of each word (this PR) | 17 / 17 | | `WaveReadLaneFirst` of the ballot, then the selects | 4 / 17 | | no select: `ballot & (upper - 1)`, `ballot & (0 - upper)` | 4 / 17 | | the compare's ballot exchanged where it is made, when a SAVEEXEC reads it | 17 / 17 (but more exchanges) | 8,000 programs of the #3716 fuzzer (seeds 0–1999, 1000000–1001999, 2000000–2001999, 3000000–3001999), direct split form: | | without the read | with the read | |---|---|---| | programs that differ from the reference | 201 | 188 | | fixed | — | 13 (the 12 group 6 seeds, and seed 358, which was already wrong without the read with driver 621.47) | | wrong only with the read | — | 0 | The other 188 are other issues: group 5 (#3779), group 1 and one signed zero (the same split as in #3784's description). With this commit, on `main` `a815de93` + #3716 `de05c50e` (whose generator changed, so the seed numbers above need not be the same programs) and the same fuzz probe, against the same tree without the commit, over the same 8,000 seeds: 203 programs differ from the reference without it, 193 with it; fixed: 10 (seeds 155, 358, 746, 824, 1869, 1000716, 1001176, 2000677, 2000986, 2001922); wrong only with it: 0. Over the same 8,000 programs, the direct split form's containers grow from 50,574,952 to 50,723,040 bytes (+0.29 %): 1,767 programs larger (at most +356 bytes), none smaller, 6,233 the same. This is a workaround chosen from the shapes seen on one card with two drivers. It does not prove that other shapes do not meet the same driver bug. **Tested** - RTX 3090 (driver 621.47), Ryzen 9 5950X, Windows 11 22631, Rust 1.100.0, debug, DXC 1.9.2602.17. - This head (`88a810f4`): `cargo build --workspace` and `cargo test --workspace --no-run`: ok - This head: `cargo test --workspace --no-fail-fast -- --test-threads=4`: 3,020 passed, 2 failed (the same two debug-layer tests as below), 56 ignored, over 45 test binaries; `SKIPPED`: the same 25 lines as below. - This head: the four new tests by name with `XCL_REQUIRE_GPU=mesh`: passed; `gpu_split_half_local_exec_branch`, 3 runs: 128 wrong words without the read each time, 0 with it. Release build: the four tests passed. - The first commit alone (`01d941e1`, the same runtime code), on the same machine: `cargo build --workspace` and `cargo test --workspace --no-run`: ok - `01d941e1`: `cargo test --workspace --no-fail-fast -- --test-threads=4`: 3,020 passed, 2 failed (`test_title_draws_with_a_root_signature_under_the_debug_layer`, `test_title_runs_under_the_debug_layer_with_dred`), 56 ignored, over 45 test binaries. The same two debug-layer tests fail on this machine without this commit (`main` `16c2fd08` + another one-commit recompiler branch: 3,013 passed, the same 2 failed); `main` `a815de93` itself was not run through the whole suite. - `01d941e1`: `SKIPPED` on this adapter: 25 lines: 22 "no wave64", 3 "no heap windows" or "no `GPU_UPLOAD` heaps", the reasons this card always gives. - `01d941e1`: the four new tests by name with `XCL_REQUIRE_GPU=mesh`: passed, and passed again in the whole suite. `gpu_split_half_local_exec_branch`, 3 runs: the old form gave 128 wrong words each time (`v1` of group 0's first threads read 0, as in #3758), the new form 0. A release build of this head passed the four tests too. **Regression run** `scripts/smoke.ps1`, 60 s each, the same title, the same machine and driver (621.47), a fresh shader cache on each side; `main` first, then this head (`88a810f4`), then the first head (`01d941e1`, the same runtime code) for reference: ``` xcl-smoke v1 commit: a815de932c4dc8da3b383ca44f4b094aa406fec9 gpu: NVIDIA GeForce RTX 3090 title: 16b5e5d4 seconds: 60 exit: 0x0 frames shown: 495 (PresentX 495) presents per 2 s (last 3): 61 61 60 device removals: 0 crashes: 0 peak commit: 15974 MB ``` ``` xcl-smoke v1 commit: 88a810f4e5b68b536b6688ab0aa2d9e94944ec15 gpu: NVIDIA GeForce RTX 3090 title: 16b5e5d4 seconds: 60 exit: 0x0 frames shown: 1642 (PresentX 1642) presents per 2 s (last 3): 61 60 61 device removals: 0 crashes: 0 peak commit: 15878 MB ``` ``` xcl-smoke v1 commit: 01d941e1411e3589eeb78bab5b69604a13794be9 gpu: NVIDIA GeForce RTX 3090 title: 16b5e5d4 seconds: 60 exit: 0x0 frames shown: 532 (PresentX 532) presents per 2 s (last 3): 60 61 60 device removals: 0 crashes: 0 peak commit: 15926 MB ``` This head: frames 1,642 / 495 (332 %), peak commit 15,878 / 15,974 MB (99 %), no device removal, no crash. This head changes only tests, so its runtime code is `01d941e1`'s; the higher frame count is not from it. A likely cause (not checked) is the driver's own shader cache, warm from the `01d941e1` run of the same DXIL. `01d941e1`: frames 532 / 495 (107 %), peak commit 15,926 / 15,974 MB (100 %), no device removal, no crash. **Not tested** - AMD with this commit (no split form there by default; `XCL_SPLIT_WAVE64=1` would use it), Intel, other NVIDIA cards and drivers. Without this commit, @stijn-boer's run of the same probe on `main` `a815de93` (RX 9060 XT, [#3779 comment](https://github.com/xcl-dev/xcl/issues/3779#issuecomment-7379217124)) already matched on all 12 G6 programs, so the miscompile is seen on NVIDIA only so far. - The same pair is still built without the read, not measured on the 3090: in the per-lane form's bridge (`Lw::local_masks`, `XCL_PER_LANE=1`), and in the HLSL path's `xcl_x_ballot_local` (`recomp/emit.rs`), which split programs take when the direct translator refuses them. - The GS read and the constant `upper` of groups of 32 threads or fewer: covered by the CPU tests and by the existing split GPU tests of 32-thread groups in the whole suite; no fuzz program reaches the GS. - Frame time: the read adds two `WaveReadLaneFirst` per half-local compare mask in split programs and stops some select folds; not measured beyond the smoke run. **AI use** - AI use: Claude Code (Claude Opus 5.5) shrank the failing program, ran the driver and fuzz checks, wrote the change, its tests, the review follow-up commit and this description; checked and posted by me. Base: `main` `a815de93`, two commits (the change, then its test follow-up), no local switches.
Foniass commented 2026-12-03 15:05:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T15:05:21Z.


Review of 01d941e1 (code reading only, not a merge-check; draft) · 1 medium, 1 nit

In short: In the split wave64 form, this PR adds a WaveReadLaneFirst on each word of a half-local mask pair (Lw::write_mask, and Lw::ballot when there is no partner half). It also makes upper the constant false in split compute and mesh groups of 32 threads or fewer. Both words are uniform within each 32-lane hardware wave, so the read does not change what the program computes. Nothing blocks the PR. One medium point is how it interacts with #3748, and one nit is a GPU test that does not skip without DXC.

Medium

  1. Interaction with #3748.

    • For an SGPR destination, write_mask takes the half-local branch only through whole_live (dxil/lower.rs ~1081). On this base, whole_live is filled whenever XCL_X64_ALL_MASKS is unset (kernel.rs ~873).
    • #3748 changes that condition to x64_masks::precise_masks(), which is off by default. If it lands, the write_mask read here applies only with XCL_X64_PRECISE_MASKS=1, and by default only the GS-alone ballot path keeps it.
    • Both new CPU tests would then lose their premise: group6 in 96-thread groups has no half-local pair, so assert!(pairs > 0, …) (~2884) and assert!(pairs96 > 0, …) (~2911) would fail.

    Whichever of the two lands second has to handle this. The tests should turn the precise analyses on (for example with #3748's test guard), and the description should say which default the measurements apply to.

Nit

  1. The GPU test does not skip without DXC. gpu_split_half_local_exec_branch (lower.rs ~2958) checks only runner::adapter() and wave32_supported(). It then calls translate, which validates under test and panics through unwrap_or_else(|e| panic!(…)) when dxcompiler.dll is missing. The CPU tests in the same module check have_dxc() first, and other GPU tests check dxc::location() (for example compact_tests.rs gpu_compact_form_runs_as_the_plain_form). Add the same check, with skip_test("no DXC").
Checked and fine
  • upper is uniform within each hardware wave in every split entry. setup_lanes and setup_lanes_compute build the lane as a base that is a multiple of 32, read with WaveReadLaneFirst, plus a rank below 32. So reading each word of the pair from the first active lane changes nothing.
  • upper = false for split groups of 32 threads or fewer (lanes.rs ~203) is correct: with total <= 32 the base is always 0. Geometry always uses 64 threads, and Kernel uses setup_lanes, so neither is affected.
  • read_pair_first returns the pair unchanged in four cases: when upper is a constant, in the per-lane bridge (local_masks), and with the test switch on. const_u64 handles the i1 constant from b(false).
  • Partner::Missing with a non-constant upper occurs only in the GS. batch_ballot and meet_at are used only in planned compute and mesh programs, where upper is now constant whenever the partner is missing.
  • The split path never records own bits, so lane-bit lookups are unaffected. live_exec and exec_cache key on the values ballot returns.
  • The test switch NO_PAIR_READ_FIRST_IN_TEST is carried to the translator thread like the existing ones.
  • The CPU tests fail without the change: they require each pair word to be read from the first lane and the reads to be used. They also cover the constant upper (20 and 32 threads) and the GS-alone ballot. The branch targets in the hand-assembled group6 program match their comments.
  • No cache bump is needed: build.rs hashes every file under src/gpu/dxil.
  • About 60 lines are code and the rest are tests, all one logical change. #3784 (same author) is a different read, as the description says.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7382542085 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3792#issuecomment-7382542085). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T15:05:21Z. --- **Review** of `01d941e1` (code reading only, not a merge-check; draft) · 1 medium, 1 nit **In short:** In the split wave64 form, this PR adds a `WaveReadLaneFirst` on each word of a half-local mask pair (`Lw::write_mask`, and `Lw::ballot` when there is no partner half). It also makes `upper` the constant false in split compute and mesh groups of 32 threads or fewer. Both words are uniform within each 32-lane hardware wave, so the read does not change what the program computes. Nothing blocks the PR. One medium point is how it interacts with #3748, and one nit is a GPU test that does not skip without DXC. #### Medium 1. **Interaction with #3748.** - For an SGPR destination, `write_mask` takes the half-local branch only through `whole_live` (`dxil/lower.rs` ~1081). On this base, `whole_live` is filled whenever `XCL_X64_ALL_MASKS` is unset (`kernel.rs` ~873). - #3748 changes that condition to `x64_masks::precise_masks()`, which is off by default. If it lands, the `write_mask` read here applies only with `XCL_X64_PRECISE_MASKS=1`, and by default only the GS-alone `ballot` path keeps it. - Both new CPU tests would then lose their premise: `group6` in 96-thread groups has no half-local pair, so `assert!(pairs > 0, …)` (~2884) and `assert!(pairs96 > 0, …)` (~2911) would fail. Whichever of the two lands second has to handle this. The tests should turn the precise analyses on (for example with #3748's test guard), and the description should say which default the measurements apply to. #### Nit 2. **The GPU test does not skip without DXC.** `gpu_split_half_local_exec_branch` (`lower.rs` ~2958) checks only `runner::adapter()` and `wave32_supported()`. It then calls `translate`, which validates under test and panics through `unwrap_or_else(|e| panic!(…))` when `dxcompiler.dll` is missing. The CPU tests in the same module check `have_dxc()` first, and other GPU tests check `dxc::location()` (for example `compact_tests.rs` `gpu_compact_form_runs_as_the_plain_form`). Add the same check, with `skip_test("no DXC")`. <details><summary>Checked and fine</summary> - `upper` is uniform within each hardware wave in every split entry. `setup_lanes` and `setup_lanes_compute` build the lane as a base that is a multiple of 32, read with `WaveReadLaneFirst`, plus a rank below 32. So reading each word of the pair from the first active lane changes nothing. - `upper = false` for split groups of 32 threads or fewer (`lanes.rs` ~203) is correct: with `total <= 32` the base is always 0. Geometry always uses 64 threads, and Kernel uses `setup_lanes`, so neither is affected. - `read_pair_first` returns the pair unchanged in four cases: when `upper` is a constant, in the per-lane bridge (`local_masks`), and with the test switch on. `const_u64` handles the `i1` constant from `b(false)`. - `Partner::Missing` with a non-constant `upper` occurs only in the GS. `batch_ballot` and `meet_at` are used only in planned compute and mesh programs, where `upper` is now constant whenever the partner is missing. - The split path never records own bits, so lane-bit lookups are unaffected. `live_exec` and `exec_cache` key on the values `ballot` returns. - The test switch `NO_PAIR_READ_FIRST_IN_TEST` is carried to the translator thread like the existing ones. - The CPU tests fail without the change: they require each pair word to be read from the first lane and the reads to be used. They also cover the constant `upper` (20 and 32 threads) and the GS-alone `ballot`. The branch targets in the hand-assembled `group6` program match their comments. - No cache bump is needed: `build.rs` hashes every file under `src/gpu/dxil`. - About 60 lines are code and the rest are tests, all one logical change. #3784 (same author) is a different read, as the description says. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
CharlyRien commented 2026-12-03 15:49:16 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-03T15:49:16Z.


Thanks for the review. Both points are in 88a810f4 (a new commit, tests only):

  1. #3748 (medium). Agreed. On this base the two group6 CPU tests now skip when XCL_X64_ALL_MASKS is set (a failure under XCL_REQUIRE_GPU), and their "no half-local pair" messages say they need kernel to fill whole_live. I did not add a test override for the analysis here: it would sit on the same lines #3748 changes. Whichever PR lands second switches these two tests to #3748's guard (PreciseForTest). The description now says that, with #3748, the write_mask read applies only under XCL_X64_PRECISE_MASKS=1, and that the measurements are of main a815de93's default.
  2. DXC (nit). gpu_split_half_local_exec_branch now checks dxc::location() with the adapter, before translating, and skips with "no DXC".

New head on the RTX 3090 (621.47): whole suite 3,020 passed, 2 failed (the two known debug-layer tests), 56 ignored; the four tests by name passed; smoke: no device removal or crash, peak commit 15,878 / 15,974 MB (frames 1,642 / 495, but this head changes only tests: see the description). The description is updated.

AI use: Claude Code (Claude Opus 5.5) made the change, ran the tests and wrote this reply; checked and posted by me.

<!-- greyfinch-sync:ivall/xcl:comment:7383787940 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3792#issuecomment-7383787940). Originally posted by [CharlyRien](https://github.com/CharlyRien) on 2026-12-03T15:49:16Z. --- Thanks for the review. Both points are in `88a810f4` (a new commit, tests only): 1. **#3748 (medium).** Agreed. On this base the two `group6` CPU tests now skip when `XCL_X64_ALL_MASKS` is set (a failure under `XCL_REQUIRE_GPU`), and their "no half-local pair" messages say they need `kernel` to fill `whole_live`. I did not add a test override for the analysis here: it would sit on the same lines #3748 changes. Whichever PR lands second switches these two tests to #3748's guard (`PreciseForTest`). The description now says that, with #3748, the `write_mask` read applies only under `XCL_X64_PRECISE_MASKS=1`, and that the measurements are of `main` `a815de93`'s default. 2. **DXC (nit).** `gpu_split_half_local_exec_branch` now checks `dxc::location()` with the adapter, before translating, and skips with "no DXC". New head on the RTX 3090 (621.47): whole suite 3,020 passed, 2 failed (the two known debug-layer tests), 56 ignored; the four tests by name passed; smoke: no device removal or crash, peak commit 15,878 / 15,974 MB (frames 1,642 / 495, but this head changes only tests: see the description). The description is updated. AI use: Claude Code (Claude Opus 5.5) made the change, ran the tests and wrote this reply; checked and posted by me.
Foniass commented 2026-12-03 15:50:50 +00:00 (Migrated from github.com)

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


Follow-up review of 88a810f4, since 01d941e1 (code reading only, not a merge-check; draft) · 1 nit

In short: The new commit 88a810f4 is test-only. The GPU test now skips without DXC, and the two group6 CPU tests now skip when XCL_X64_ALL_MASKS turns the half-local analysis off. The description now covers #3748: the measurements are of main's default, and whichever PR lands second adapts the tests. The first commit is unchanged. Nothing new found; one small point remains.

Nit

  1. The new skip does not follow #3748's switch. half_local_masks() (lower.rs ~2783) checks only XCL_X64_ALL_MASKS. #3748 turns the analysis off by default through x64_masks::precise_masks(), with no environment variable set. If #3748 lands first, the two tests still run and fail on pairs > 0, now with a clearer message, not skip. That matches the description ("whichever lands second adapts the tests"), so this is only a note. Once #3748 is in, half_local_masks() should call precise_masks(), or the tests should turn it on.
Checked and fine
  • Earlier finding fixed: gpu_split_half_local_exec_branch now checks dxc::location() and skips with "no DXC", after the GPU check, as the module's other GPU tests do.
  • Earlier finding fixed (as far as this PR can go before #3748 lands): the description names the interaction, says which default the measurements are of, and says which tests need the analysis on.
  • The skip message names the reason, and the assertion messages now say what to check if whole_live stops being filled by default.
  • 01d941e1 is unchanged since the last review (range-diff =).

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7383830588 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3792#issuecomment-7383830588). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T15:50:50Z. --- **Follow-up review** of `88a810f4`, since `01d941e1` (code reading only, not a merge-check; draft) · 1 nit **In short:** The new commit `88a810f4` is test-only. The GPU test now skips without DXC, and the two `group6` CPU tests now skip when `XCL_X64_ALL_MASKS` turns the half-local analysis off. The description now covers #3748: the measurements are of `main`'s default, and whichever PR lands second adapts the tests. The first commit is unchanged. Nothing new found; one small point remains. #### Nit 1. **The new skip does not follow #3748's switch.** `half_local_masks()` (`lower.rs` ~2783) checks only `XCL_X64_ALL_MASKS`. #3748 turns the analysis off by default through `x64_masks::precise_masks()`, with no environment variable set. If #3748 lands first, the two tests still run and fail on `pairs > 0`, now with a clearer message, not skip. That matches the description ("whichever lands second adapts the tests"), so this is only a note. Once #3748 is in, `half_local_masks()` should call `precise_masks()`, or the tests should turn it on. <details><summary>Checked and fine</summary> - Earlier finding fixed: `gpu_split_half_local_exec_branch` now checks `dxc::location()` and skips with "no DXC", after the GPU check, as the module's other GPU tests do. - Earlier finding fixed (as far as this PR can go before #3748 lands): the description names the interaction, says which default the measurements are of, and says which tests need the analysis on. - The skip message names the reason, and the assertion messages now say what to check if `whole_live` stops being filled by default. - `01d941e1` is unchanged since the last review (range-diff `=`). </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
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/3792:upstream-pr/3792'
git switch 'upstream-pr/3792'

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/3792'
git switch 'upstream-pr/3792'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3792'
git switch 'upstream-pr/3792'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3792'
git switch 'main'
git merge --squash 'upstream-pr/3792'
git switch 'main'
git merge --ff-only 'upstream-pr/3792'
git switch 'main'
git merge 'upstream-pr/3792'
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!3792
No description provided.