Recompiler: split wave64 bit tests read the mask word from the first lane #3784

Open
CharlyRien wants to merge 1 commit from upstream-pr/3784 into main
CharlyRien commented 2026-12-03 12:41:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-03T12:41:35Z.


Works around #3779.

In the direct split form (a wave64 program run as two 32-lane hardware waves), Lw::lanebit (gpu/dxil/lanes.rs) tests a lane's bit of a mask as (select(upper, hi, lo) >> lane31) & 1. On an RTX 3090 (drivers 616.56 and 621.47), and as others reported in #3779 on an RTX 3070 Laptop (621.40) and an RTX 3080, NVIDIA's shader compiler gets this test wrong in some programs: all 58 programs of the #3716 fuzzer's group 5 fail there. The same shape written as plain HLSL (the repro in #3779) fails with DXC -O3 / -O1 and passes with -Od and on WARP, so this looks like a driver compiler bug, not a translator bug. On an AMD RX 9060 XT, all 58 programs and the repro are right (also reported in #3779).

In the split form the mask word is the same in every lane of a hardware wave, so this change reads it once more with WaveReadLaneFirst before the shift:

  • each hardware wave is one 32-lane half: upper comes from a base that is a multiple of 32, read from the first lane, plus a rank below 32 (setup_lanes, setup_lanes_compute);
  • the words are scalars: ballots, the other half's word from an exchange, constants, and scalar ops on them (v_readfirstlane / v_readlane results come from WaveReadLaneAt too).

So the read changes nothing in the program's meaning; it only changes the shape the driver compiles. It is not applied:

  • in native wave64, where upper varies within the wave;
  • in wave32 programs and in VS / PS (no split form there);
  • in the per-lane form's bridge (recomp::lower_dxil, Lw::local_masks), which passes a mask read lane by lane as a word holding only that lane's own bit;
  • with apart (each hardware wave runs its own console wave): there tid is the flattened group thread id, so TG_SIZE's tid / 64 can differ inside one hardware wave of a group of more than 64 threads, and a scalar compare on it (uniform_compare) can give an EXEC word that differs by lane. I did not show that this cannot reach lanebit, so apart keeps the old test.

lanebit_at (a bit of another lane) is unchanged.

What is in it

  • gpu/dxil/lanes.rs: the read in Lw::lanebit, split form only, not with apart, not under local_masks; a test-only switch to show the old form (NO_READ_FIRST_IN_TEST).
  • gpu/dxil/kernel.rs: the translator thread takes that test switch over, like the existing ones.
  • gpu/dxil/lanes.rs, tests (split_lanebit_tests):
    • split_lane_bits_test_the_mask_word_read_from_the_first_lane (CPU, needs DXC): translated in the plain form (not the compact one, whatever XCL_DIRECT_COMPACT says); in the split form, the bit test behind v17's select (v4 or -1) shifts a word read from the first lane, and did not without the change; the v_bfe_i32 and the groupshared accesses are the same with and without it; the native wave64 form's bit tests do not read from the first lane, with the same number of WaveReadLaneFirst. It skips only when DXC is missing; a disassembly failure with DXC present fails it.
    • gpu_split_lane_bit_of_an_exec_with_an_empty_half (GPU): #3779's program (group 5's smallest program, shrunk), assembled by hand, run in the split form (plain); every register checked. It also runs the old form and prints its wrong words, without asserting them, since other GPUs compile it right.
    • split_bridge_lane_bits_test_each_lanes_own_word (CPU + GPU): a bridged carry-in from a bridged carry-out in the per-lane split form: no first-lane read in its DXIL, and the right sums on the GPU (same DXC handling).

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

8,000 programs of the #3716 fuzzer (seeds 0–1999, 1000000–1001999, 2000000–2001999, 3000000–3001999), direct split form only, RTX 3090, driver 621.47. These runs use a local probe, not this commit: the same WaveReadLaneFirst read behind a variable, applied in every form, on #3716's head d2293dcb (on main 5ad98adb). Only the split form was run.

without the read with the read
programs that differ from the reference 201 143
group 5 (kernel programs starting with one half of EXEC empty) 59 1
programs wrong only with the read — 0
  • The 58 group 5 programs listed in #3779 all pass with the read. The one left (seed 1000650) is not this bug: its loop computes ∞ − ∞, both sides give a quiet NaN (reference 0xFFC00000, RTX 3090 0x7FFFFFFF), and the fuzzer at d2293dcb compares that word bit for bit (its later head de05c50e accepts any NaN made by float arithmetic).
  • The other differences (group 1: 129 / 128; group 6: 12 / 13, one program moves from group 1 to group 6 as its first wrong word changes; one signed zero) are other issues: no program there is fixed or newly wrong.
  • On driver 616.56, the same probe turned one compute program (seed 358) wrong, deterministically (3 runs of 3), while it was right without the read. On 621.47 that program is wrong without the read too, with the same word and value, and the read adds nothing. So on 616.56 the read can itself meet a driver miscompile; I could not find one on 621.47.
  • A narrower variant (the read only where one word of the mask is a constant, group 5's shape) left 18 of the 58 wrong and turned 11 other programs wrong on 621.47, so it was dropped.

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.
  • cargo build --workspace and cargo test --workspace --no-run: ok
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 3013 passed, 2 failed (the same two e2e debug-layer tests), 56 ignored, over 45 test binaries; main 1c8b5514 on the same machine: 2907 passed, 2 failed (two e2e debug-layer tests), 51 ignored.
  • SKIPPED on this adapter: 25, all no wave64 (8 tests, plus 17 wave64 cases of the arithmetic / mask tests); the same 25 as on main.
  • The three new tests by name with XCL_REQUIRE_GPU=mesh: passed, and passed again in the whole suite. gpu_split_lane_bit_of_an_exec_with_an_empty_half, 3 runs: the old form gave 31 wrong words each time (v17 = 0xFFFFFFFF where the program wants its select's other value), the new form 0.

Regression run
scripts/smoke.ps1, 60 s each, the same title, the same machine and driver (621.47), a fresh shader cache on both sides; main first, then this head:

xcl-smoke v1
commit: 16c2fd082ae2e96967a2ab553bc2e1032e491f70
gpu: NVIDIA GeForce RTX 3090
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 488 (PresentX 488)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 16164 MB
xcl-smoke v1
commit: b2a2395540b78b5ce91fb89a74f30c89ab8b2537
gpu: NVIDIA GeForce RTX 3090
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 510 (PresentX 510)
presents per 2 s (last 3): 61 60 61
device removals: 0
crashes: 0
peak commit: 16268 MB

Frames 510 / 488 (104 %), peak commit 16,268 / 16,164 MB (101 %), no device removal, no crash.

Not tested

  • AMD (no split form there by default; XCL_SPLIT_WAVE64=1 would use it), Intel, other NVIDIA cards and drivers.
  • The 8,000-program fuzz with this exact commit (it was run with the probe described above).
  • The HLSL path's split form keeps the old test (lanebit in recomp/emit.rs), the shape of the plain-HLSL repro in #3779. In the #3716 fuzz (the same 8,000 seeds, RTX 3090, driver 616.56), the HLSL split form gave none of the 58 group 5 failures, so I left it out of this PR. A split program the direct translator rejects, or one with LDS under XCL_PER_LANE=1, takes that path. A follow-up can apply the same read there, but not for xcl_w32 (a wave32 program in a 64-lane hardware wave, two console waves in one hardware wave).
  • Frame time: the read adds one WaveReadLaneFirst per mask and block in split programs; not measured.

Limits (unchanged by this PR)

  • Scalar memory loads are per-lane raw loads: if a mutable word changes while lanes read it, lanes can see different versions, and a mask built from it can differ by lane. That gap predates this PR; the read only changes which version the bit test uses.
  • A VOP3 mask operand given as a VGPR pair (outside its declared scalar class, but accepted by the source decoder) is not rejected; the read would then use the first lane's value. Not changed here.

AI use

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

Base: main 16c2fd08, one commit, no local switches.

<!-- greyfinch-sync:ivall/xcl:issue:5626693819 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3784). Originally posted by [CharlyRien](https://github.com/CharlyRien) on 2026-12-03T12:41:35Z. --- Works around #3779. In the direct split form (a wave64 program run as two 32-lane hardware waves), `Lw::lanebit` (`gpu/dxil/lanes.rs`) tests a lane's bit of a mask as `(select(upper, hi, lo) >> lane31) & 1`. On an RTX 3090 (drivers 616.56 and 621.47), and as others reported in #3779 on an RTX 3070 Laptop (621.40) and an RTX 3080, NVIDIA's shader compiler gets this test wrong in some programs: all 58 programs of the #3716 fuzzer's group 5 fail there. The same shape written as plain HLSL (the repro in #3779) fails with DXC `-O3` / `-O1` and passes with `-Od` and on WARP, so this looks like a driver compiler bug, not a translator bug. On an AMD RX 9060 XT, all 58 programs and the repro are right (also reported in #3779). In the split form the mask word is the same in every lane of a hardware wave, so this change reads it once more with `WaveReadLaneFirst` before the shift: - each hardware wave is one 32-lane half: `upper` comes from a base that is a multiple of 32, read from the first lane, plus a rank below 32 (`setup_lanes`, `setup_lanes_compute`); - the words are scalars: ballots, the other half's word from an exchange, constants, and scalar ops on them (`v_readfirstlane` / `v_readlane` results come from `WaveReadLaneAt` too). So the read changes nothing in the program's meaning; it only changes the shape the driver compiles. It is not applied: - in native wave64, where `upper` varies within the wave; - in wave32 programs and in VS / PS (no split form there); - in the per-lane form's bridge (`recomp::lower_dxil`, `Lw::local_masks`), which passes a mask read lane by lane as a word holding only that lane's own bit; - with `apart` (each hardware wave runs its own console wave): there `tid` is the flattened group thread id, so TG_SIZE's `tid / 64` can differ inside one hardware wave of a group of more than 64 threads, and a scalar compare on it (`uniform_compare`) can give an EXEC word that differs by lane. I did not show that this cannot reach `lanebit`, so `apart` keeps the old test. `lanebit_at` (a bit of another lane) is unchanged. **What is in it** - `gpu/dxil/lanes.rs`: the read in `Lw::lanebit`, split form only, not with `apart`, not under `local_masks`; a test-only switch to show the old form (`NO_READ_FIRST_IN_TEST`). - `gpu/dxil/kernel.rs`: the translator thread takes that test switch over, like the existing ones. - `gpu/dxil/lanes.rs`, tests (`split_lanebit_tests`): - `split_lane_bits_test_the_mask_word_read_from_the_first_lane` (CPU, needs DXC): translated in the plain form (not the compact one, whatever `XCL_DIRECT_COMPACT` says); in the split form, the bit test behind v17's select (v4 or -1) shifts a word read from the first lane, and did not without the change; the `v_bfe_i32` and the groupshared accesses are the same with and without it; the native wave64 form's bit tests do not read from the first lane, with the same number of `WaveReadLaneFirst`. It skips only when DXC is missing; a disassembly failure with DXC present fails it. - `gpu_split_lane_bit_of_an_exec_with_an_empty_half` (GPU): #3779's program (group 5's smallest program, shrunk), assembled by hand, run in the split form (plain); every register checked. It also runs the old form and prints its wrong words, without asserting them, since other GPUs compile it right. - `split_bridge_lane_bits_test_each_lanes_own_word` (CPU + GPU): a bridged carry-in from a bridged carry-out in the per-lane split form: no first-lane read in its DXIL, and the right sums on the GPU (same DXC handling). 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** 8,000 programs of the #3716 fuzzer (seeds 0–1999, 1000000–1001999, 2000000–2001999, 3000000–3001999), direct split form only, RTX 3090, driver 621.47. These runs use a local probe, not this commit: the same `WaveReadLaneFirst` read behind a variable, applied in **every** form, on #3716's head `d2293dcb` (on `main` `5ad98adb`). Only the split form was run. | | without the read | with the read | |---|---|---| | programs that differ from the reference | 201 | 143 | | group 5 (kernel programs starting with one half of EXEC empty) | 59 | 1 | | programs wrong only with the read | — | 0 | - The 58 group 5 programs listed in #3779 all pass with the read. The one left (seed 1000650) is not this bug: its loop computes ∞ − ∞, both sides give a quiet NaN (reference `0xFFC00000`, RTX 3090 `0x7FFFFFFF`), and the fuzzer at `d2293dcb` compares that word bit for bit (its later head `de05c50e` accepts any NaN made by float arithmetic). - The other differences (group 1: 129 / 128; group 6: 12 / 13, one program moves from group 1 to group 6 as its first wrong word changes; one signed zero) are other issues: no program there is fixed or newly wrong. - On driver 616.56, the same probe turned one compute program (seed 358) wrong, deterministically (3 runs of 3), while it was right without the read. On 621.47 that program is wrong without the read too, with the same word and value, and the read adds nothing. So on 616.56 the read can itself meet a driver miscompile; I could not find one on 621.47. - A narrower variant (the read only where one word of the mask is a constant, group 5's shape) left 18 of the 58 wrong and turned 11 other programs wrong on 621.47, so it was dropped. 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. - `cargo build --workspace` and `cargo test --workspace --no-run`: ok - `cargo test --workspace --no-fail-fast -- --test-threads=4`: 3013 passed, 2 failed (the same two e2e debug-layer tests), 56 ignored, over 45 test binaries; `main` 1c8b5514 on the same machine: 2907 passed, 2 failed (two e2e debug-layer tests), 51 ignored. - `SKIPPED` on this adapter: 25, all `no wave64` (8 tests, plus 17 wave64 cases of the arithmetic / mask tests); the same 25 as on `main`. - The three new tests by name with `XCL_REQUIRE_GPU=mesh`: passed, and passed again in the whole suite. `gpu_split_lane_bit_of_an_exec_with_an_empty_half`, 3 runs: the old form gave 31 wrong words each time (v17 = 0xFFFFFFFF where the program wants its select's other value), the new form 0. **Regression run** `scripts/smoke.ps1`, 60 s each, the same title, the same machine and driver (621.47), a fresh shader cache on both sides; `main` first, then this head: ``` xcl-smoke v1 commit: 16c2fd082ae2e96967a2ab553bc2e1032e491f70 gpu: NVIDIA GeForce RTX 3090 title: 16b5e5d4 seconds: 60 exit: 0x0 frames shown: 488 (PresentX 488) presents per 2 s (last 3): 60 61 60 device removals: 0 crashes: 0 peak commit: 16164 MB ``` ``` xcl-smoke v1 commit: b2a2395540b78b5ce91fb89a74f30c89ab8b2537 gpu: NVIDIA GeForce RTX 3090 title: 16b5e5d4 seconds: 60 exit: 0x0 frames shown: 510 (PresentX 510) presents per 2 s (last 3): 61 60 61 device removals: 0 crashes: 0 peak commit: 16268 MB ``` Frames 510 / 488 (104 %), peak commit 16,268 / 16,164 MB (101 %), no device removal, no crash. **Not tested** - AMD (no split form there by default; `XCL_SPLIT_WAVE64=1` would use it), Intel, other NVIDIA cards and drivers. - The 8,000-program fuzz with this exact commit (it was run with the probe described above). - The HLSL path's split form keeps the old test (`lanebit` in `recomp/emit.rs`), the shape of the plain-HLSL repro in #3779. In the #3716 fuzz (the same 8,000 seeds, RTX 3090, driver 616.56), the HLSL split form gave none of the 58 group 5 failures, so I left it out of this PR. A split program the direct translator rejects, or one with LDS under `XCL_PER_LANE=1`, takes that path. A follow-up can apply the same read there, but not for `xcl_w32` (a wave32 program in a 64-lane hardware wave, two console waves in one hardware wave). - Frame time: the read adds one `WaveReadLaneFirst` per mask and block in split programs; not measured. **Limits (unchanged by this PR)** - Scalar memory loads are per-lane raw loads: if a mutable word changes while lanes read it, lanes can see different versions, and a mask built from it can differ by lane. That gap predates this PR; the read only changes which version the bit test uses. - A VOP3 mask operand given as a VGPR pair (outside its declared scalar class, but accepted by the source decoder) is not rejected; the read would then use the first lane's value. Not changed here. **AI use** - AI use: Claude Code (Claude Opus 5.5) shrank the failing program, ran the fuzz and driver checks, wrote the change, its tests and this description; checked and posted by me. Base: `main` `16c2fd08`, one commit, no local switches.
Foniass commented 2026-12-03 12:49:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T12:49:36Z.


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

In short: The PR works around an NVIDIA driver miscompile (#3779). In the direct translator's split wave64 form, Lw::lanebit reads the mask word once more with WaveReadLaneFirst before the shift, except under apart, in the per-lane bridge (local_masks) and outside the split form. The word is uniform in every hardware wave the read applies to, so program meaning does not change, and nothing blocks it. One gap: the HLSL fallback keeps the same bit test.

Medium

  1. The HLSL path's split form keeps the old bit test.

    • recomp/emit.rs ~6909 still defines lanebit as ((select(lane_id < 32u, lo, hi) >> (lane_id & 31u)) & 1u) != 0u. That is the shape of the plain-HLSL repro in #3779, which fails on NVIDIA at -O1 / -O3.
    • On NVIDIA, split wave64 programs the direct translator rejects fall back to this path, and so do split programs with LDS under XCL_PER_LANE=1. So the workaround covers only the direct form.

    Fix: say so under Not tested and open a follow-up, or apply the same read there. If you do, xcl_w32 (a wave32 program in a 64-lane hardware wave) puts two console waves in one hardware wave, so the read must not apply in that case.

Checked and fine
  • upper is uniform within each hardware wave of the split form. setup_lanes / setup_lanes_compute (lanes.rs ~85-152) give each 32-lane hardware wave a base that is a multiple of 32, read with WaveReadLaneFirst, and the split form always compiles with WaveSize(32).
  • Graphics entries never take the split form, and the geometry GS phase runs in the lower hardware wave alone.
  • Dispatch-chain continuations replay the split tid prefix (module/split.rs ~160, ~262-274), so their masks stay uniform.
  • The per-lane form reaches Lw only through Ir::foreign, which sets local_masks, and that path is excluded.
  • The local write_mask path in the direct split form gives (sel(upper, 0, w), sel(upper, w, 0)) from a ballot, which is uniform per hardware wave.
  • Excluding apart matches the code: there lane31 is the hardware lane index and upper is false.
  • NO_READ_FIRST_IN_TEST exists only under #[cfg(test)] and reaches the translator thread like the other switches. The disassembly test compares against the form without the read, so it fails if the change is removed.
  • build.rs hashes src/gpu/dxil, so no version bump is needed. About 30 runtime lines; the rest are tests. No duplicate.

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

<!-- greyfinch-sync:ivall/xcl:comment:7378896420 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3784#issuecomment-7378896420). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T12:49:36Z. --- **Review** of `b2a23955` (code reading only, not a merge-check; draft) · 1 medium **In short:** The PR works around an NVIDIA driver miscompile (#3779). In the direct translator's split wave64 form, `Lw::lanebit` reads the mask word once more with `WaveReadLaneFirst` before the shift, except under `apart`, in the per-lane bridge (`local_masks`) and outside the split form. The word is uniform in every hardware wave the read applies to, so program meaning does not change, and nothing blocks it. One gap: the HLSL fallback keeps the same bit test. #### Medium 1. **The HLSL path's split form keeps the old bit test.** - `recomp/emit.rs` ~6909 still defines `lanebit` as `((select(lane_id < 32u, lo, hi) >> (lane_id & 31u)) & 1u) != 0u`. That is the shape of the plain-HLSL repro in #3779, which fails on NVIDIA at `-O1` / `-O3`. - On NVIDIA, split wave64 programs the direct translator rejects fall back to this path, and so do split programs with LDS under `XCL_PER_LANE=1`. So the workaround covers only the direct form. Fix: say so under **Not tested** and open a follow-up, or apply the same read there. If you do, `xcl_w32` (a wave32 program in a 64-lane hardware wave) puts two console waves in one hardware wave, so the read must not apply in that case. <details><summary>Checked and fine</summary> - `upper` is uniform within each hardware wave of the split form. `setup_lanes` / `setup_lanes_compute` (`lanes.rs` ~85-152) give each 32-lane hardware wave a base that is a multiple of 32, read with `WaveReadLaneFirst`, and the split form always compiles with `WaveSize(32)`. - Graphics entries never take the split form, and the geometry GS phase runs in the lower hardware wave alone. - Dispatch-chain continuations replay the split `tid` prefix (`module/split.rs` ~160, ~262-274), so their masks stay uniform. - The per-lane form reaches `Lw` only through `Ir::foreign`, which sets `local_masks`, and that path is excluded. - The local `write_mask` path in the direct split form gives `(sel(upper, 0, w), sel(upper, w, 0))` from a ballot, which is uniform per hardware wave. - Excluding `apart` matches the code: there `lane31` is the hardware lane index and `upper` is false. - `NO_READ_FIRST_IN_TEST` exists only under `#[cfg(test)]` and reaches the translator thread like the other switches. The disassembly test compares against the form without the read, so it fails if the change is removed. - `build.rs` hashes `src/gpu/dxil`, so no version bump is needed. About 30 runtime lines; the rest are tests. No duplicate. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
Gevroska commented 2026-12-03 13:44:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Gevroska on 2026-12-03T13:44:43Z.


If the workaround is extended to the HLSL fallback, I’d keep the WaveReadLaneFirst guard specific to mask words known to be uniform within each hardware wave. I tested three mask producers on my RTX 3080 using the split-wave HLSL helpers from b2a23955. Each form ran three times with fenced readback.

Mask supplied to the lane test True predicates, original True predicates, with broadcast
Exchanged split ballot 17 17
Half-local split ballot 17 17
Synthetic per-lane mask, each lane supplying its own bit 17 1

The half-local ballot still supplied the same word throughout each 32-lane half, so broadcasting preserved every result. In the per-lane control, only lane 32 remained true after broadcast; the same 16 predicates disappeared in every trial.

This concerns a possible HLSL extension. The current PR changes direct DXIL. I haven’t reproduced the reported failure through stock XCL-emitted fallback HLSL, so I’d want that failing case before carrying the workaround over.

AI disclosure: OpenAI Codex GPT-6.2 Sol led the fixture work, and an independent Codex review checked the readbacks. GPT-6.2 Astra drafted this comment.

I reviewed and approved this comment before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7380318080 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3784#issuecomment-7380318080). Originally posted by [Gevroska](https://github.com/Gevroska) on 2026-12-03T13:44:43Z. --- If the workaround is extended to the HLSL fallback, I’d keep the `WaveReadLaneFirst` guard specific to mask words known to be uniform within each hardware wave. I tested three mask producers on my RTX 3080 using the split-wave HLSL helpers from `b2a23955`. Each form ran three times with fenced readback. | Mask supplied to the lane test | True predicates, original | True predicates, with broadcast | |---|---:|---:| | Exchanged split ballot | 17 | 17 | | Half-local split ballot | 17 | 17 | | Synthetic per-lane mask, each lane supplying its own bit | 17 | 1 | The half-local ballot still supplied the same word throughout each 32-lane half, so broadcasting preserved every result. In the per-lane control, only lane 32 remained true after broadcast; the same 16 predicates disappeared in every trial. This concerns a possible HLSL extension. The current PR changes direct DXIL. I haven’t reproduced the reported failure through stock XCL-emitted fallback HLSL, so I’d want that failing case before carrying the workaround over. AI disclosure: OpenAI Codex GPT-6.2 Sol led the fixture work, and an independent Codex review checked the readbacks. GPT-6.2 Astra drafted this comment. I reviewed and approved this comment before posting.
CharlyRien commented 2026-12-03 15:06:22 +00:00 (Migrated from github.com)

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


Thanks for the review, and thanks @Gevroska for the measurement.

  1. The HLSL path's split form. Right, it keeps the old bit test. I left it out of this PR and said so under Not tested in the description: in the #3716 fuzz (the same 8,000 seeds, RTX 3090, driver 616.56), the HLSL split form gave none of the 58 group 5 failures, so I have no failing case through the HLSL that XCL emits, only the hand-written repro in #3779. The description names the two ways a split program takes that path (rejected by the direct translator, or LDS under XCL_PER_LANE=1) and the xcl_w32 exception.

Gevroska's table is a good reason not to carry the read over blindly: a broadcast is only safe on a word that is the same in every lane of the hardware wave. In the direct form, upper and the mask words are (the review's checked points), and the read is skipped under local_masks, where each lane supplies its own bit. A follow-up for the HLSL path would need the same guard, plus the xcl_w32 exception, and I'd want a failing XCL-emitted HLSL program first, as Gevroska says. I'll open one if the fuzz or a game program shows such a case.

AI use: Claude Code (Claude Opus 5.5) checked the points against the code and the fuzz results and wrote this reply; checked and posted by me.

<!-- greyfinch-sync:ivall/xcl:comment:7382571200 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3784#issuecomment-7382571200). Originally posted by [CharlyRien](https://github.com/CharlyRien) on 2026-12-03T15:06:22Z. --- Thanks for the review, and thanks @Gevroska for the measurement. 1. **The HLSL path's split form.** Right, it keeps the old bit test. I left it out of this PR and said so under **Not tested** in the description: in the #3716 fuzz (the same 8,000 seeds, RTX 3090, driver 616.56), the HLSL split form gave none of the 58 group 5 failures, so I have no failing case through the HLSL that XCL emits, only the hand-written repro in #3779. The description names the two ways a split program takes that path (rejected by the direct translator, or LDS under `XCL_PER_LANE=1`) and the `xcl_w32` exception. Gevroska's table is a good reason not to carry the read over blindly: a broadcast is only safe on a word that is the same in every lane of the hardware wave. In the direct form, `upper` and the mask words are (the review's checked points), and the read is skipped under `local_masks`, where each lane supplies its own bit. A follow-up for the HLSL path would need the same guard, plus the `xcl_w32` exception, and I'd want a failing XCL-emitted HLSL program first, as Gevroska says. I'll open one if the fuzz or a game program shows such a case. AI use: Claude Code (Claude Opus 5.5) checked the points against the code and the fuzz results and wrote this reply; checked and posted by me.
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/3784:upstream-pr/3784'
git switch 'upstream-pr/3784'

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