Recompiler: a split-wave64 bitwise mask tree exchanges once, at its end #1587

Closed
MiguelMachado-dev wants to merge 3 commits from upstream-pr/1597 into main
MiguelMachado-dev commented 2026-11-24 18:06:13 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by MiguelMachado-dev on 2026-11-24T18:06:13Z.


Stacked on #1596, which is stacked on #1111; only the top commit (6acbfb1, +328 / −9 with its tests) belongs here. The diff against main also carries those two PRs, which is why it is over 800 lines. Part of #1269.

Compares that 64-bit bitwise ops combine into a mask that is read whole (s_bcnt1, a saveexec, a live scc, …) each exchanged the two halves' ballots. The combination is lane-wise, so only its result needs both halves. Within one basic block, x64_masks now follows such trees. When two or more compares or carries feed a tree of lane-wise s_*_b64 ops (not s_cmov / s_cselect) and nothing else reads them, the compares keep the local ballot. The tree's last op exchanges its result once, with xcl_x_sync_mask, before scc is derived from it.

A block ends after every branch, conditional or not, and wherever a jump lands. Ending one only at branch targets would be unsafe: a tree on the fall-through side could make local a compare that the taken side of a conditional branch reads whole. LOOP_GUARD runs only at block starts.

What is in it

  • crates/xcl/src/gpu/recomp/x64_masks.rs: the liveness solution is shared (solve), and analyze returns Plan { whole_live, sync }. by_pc is gone; its one caller now uses analyze.
  • crates/xcl/src/gpu/recomp/emit.rs: x64_sync; salu64 exchanges the result at those pcs; the xcl_x_sync_mask helper. In a partial wave with no other half, the helper keeps the word this half computed for the missing one.
  • crates/xcl/src/gpu/recomp/mod.rs: uses analyze.
  • Tests:
    • unit tests a_bitwise_tree_read_whole_exchanges_once_at_its_end and a_compare_read_whole_outside_the_tree_keeps_its_exchange. The latter covers a compare that is read whole after the tree, copied to a whole-live pair, or read on the taken side of a conditional branch. With the old block rule (blocks split only at branch targets), the branch case fails.
    • GPU test gpu_split_wave64_bitwise_mask_tree_exchanges_once: s_bcnt1 of an s_and_b64 of two compares, and scc of an s_and_b64 whose match is in the upper half only. 4 local compares, 2 syncs, and whole-wave results in both halves.
    • GPU test gpu_split_wave64_bitwise_mask_tree_in_a_partial_wave: a wave64 group of 32 threads, so there is no upper half. It runs s_nor_b64 of two compares, read by s_bcnt1 and by scc. The compares' bits in the missing half are 0, but s_nor_b64 sets them, and the helper used to replace that word with 0: s_bcnt1 gave 16 instead of 48. @MatyEjsr found this and reproduced it on an RTX 3090 (comment on this PR).
    • gpu_split_wave64_bitwise_lane_masks (#1111) expected the two compares under a live scc to exchange. They now stay local and the s_and_b64 exchanges; the scc result it checks is unchanged.

Measured with the same temporary local test as the PR below this one (all wave64 CS / MS programs of the retail 1.0.2.1 shaders.rpf, split form, 4 windows). An exchange here is a mask write that uses xcl_x_ballot, or an xcl_x_sync_mask:

commit exchanged mask writes tree syncs exchanges
main 9e3831e 210 324 0 210 324
PR below 524b25c 153 728 0 153 728
this PR b71f7ee 127 965 10 473 138 438 (−10.0 % on 524b25c, −34.2 % on main)

HLSL over the 10 490 programs: 2 648.5 MB → 2 652.9 MB (+0.17 %).

These numbers were measured at b71f7ee. 6acbfb1 changes only what xcl_x_sync_mask returns when there is no other half, not where the exchanges go; they were not measured again.

docs/wave64-on-wave32.md:41 says a mask skips the exchange only when it "is only read lane by lane". After this change that is no longer the whole rule. The doc is not edited here.

Tested

  • NVIDIA GeForce RTX 5080 (32-lane waves, so the split form), driver 621.24; Intel Core i7-14700KF, 64 GB; Windows 11 build 26300; rustc 1.97.1; DXC 1.8.2502.11; debug for tests, release for the smoke run.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4 at 6acbfb1: 789 passed, 0 failed, 41 ignored.
  • gpu_split_wave64_bitwise_mask_tree_in_a_partial_wave without the xcl_x_sync_mask fix: failed (s_bcnt1 16, expected 48). With it, cargo test -p xcl --lib gpu_split_wave64 -- --test-threads=1: 9 passed, 0 failed.
  • SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).

Regression run
Each block is the second of two back-to-back 60 s runs of the same build (the first one filled the shader and driver caches).

main:

xcl-smoke v1
commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485
gpu: NVIDIA GeForce RTX 5080
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1617 (PresentX 1617)
presents per 2 s (last 3): 60 60 59
device removals: 0
crashes: 0
peak commit: 15047 MB

PR:

xcl-smoke v1
commit: 6acbfb1f4d57e5d914161dde56faaf28da18f973
gpu: NVIDIA GeForce RTX 5080
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1612 (PresentX 1612)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14621 MB

Not tested

  • AMD and native wave64 GPUs, where the split form is not used.
  • DXC and driver compile times before and after; only the exchange counts were measured.
  • Trees across basic blocks, which are left exchanged.
  • Whether the smoke run reaches the changed code: in 60 s it built 26 compute pipelines from translated console CS, and the log does not say how many of them are wave64 programs in the split form. The exchange counts above cover the whole pack.

AI use

  • Claude Code, Claude Opus 5.5: wrote the code, the tests, the measurement script and this description, and ran the tests, the smoke runs and the measurement on the hardware above.
<!-- greyfinch-sync:ivall/xcl:issue:5477667804 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1597). Originally posted by [MiguelMachado-dev](https://github.com/MiguelMachado-dev) on 2026-11-24T18:06:13Z. --- Stacked on #1596, which is stacked on #1111; only the top commit (`6acbfb1`, +328 / −9 with its tests) belongs here. The diff against `main` also carries those two PRs, which is why it is over 800 lines. Part of #1269. Compares that 64-bit bitwise ops combine into a mask that is read whole (`s_bcnt1`, a saveexec, a live `scc`, …) each exchanged the two halves' ballots. The combination is lane-wise, so only its result needs both halves. Within one basic block, `x64_masks` now follows such trees. When two or more compares or carries feed a tree of lane-wise `s_*_b64` ops (not `s_cmov` / `s_cselect`) and nothing else reads them, the compares keep the local ballot. The tree's last op exchanges its result once, with `xcl_x_sync_mask`, before `scc` is derived from it. A block ends after every branch, conditional or not, and wherever a jump lands. Ending one only at branch targets would be unsafe: a tree on the fall-through side could make local a compare that the taken side of a conditional branch reads whole. `LOOP_GUARD` runs only at block starts. **What is in it** - `crates/xcl/src/gpu/recomp/x64_masks.rs`: the liveness solution is shared (`solve`), and `analyze` returns `Plan { whole_live, sync }`. `by_pc` is gone; its one caller now uses `analyze`. - `crates/xcl/src/gpu/recomp/emit.rs`: `x64_sync`; `salu64` exchanges the result at those pcs; the `xcl_x_sync_mask` helper. In a partial wave with no other half, the helper keeps the word this half computed for the missing one. - `crates/xcl/src/gpu/recomp/mod.rs`: uses `analyze`. - Tests: - unit tests `a_bitwise_tree_read_whole_exchanges_once_at_its_end` and `a_compare_read_whole_outside_the_tree_keeps_its_exchange`. The latter covers a compare that is read whole after the tree, copied to a whole-live pair, or read on the taken side of a conditional branch. With the old block rule (blocks split only at branch targets), the branch case fails. - GPU test `gpu_split_wave64_bitwise_mask_tree_exchanges_once`: `s_bcnt1` of an `s_and_b64` of two compares, and `scc` of an `s_and_b64` whose match is in the upper half only. 4 local compares, 2 syncs, and whole-wave results in both halves. - GPU test `gpu_split_wave64_bitwise_mask_tree_in_a_partial_wave`: a wave64 group of 32 threads, so there is no upper half. It runs `s_nor_b64` of two compares, read by `s_bcnt1` and by `scc`. The compares' bits in the missing half are 0, but `s_nor_b64` sets them, and the helper used to replace that word with 0: `s_bcnt1` gave 16 instead of 48. @MatyEjsr found this and reproduced it on an RTX 3090 (comment on this PR). - `gpu_split_wave64_bitwise_lane_masks` (#1111) expected the two compares under a live `scc` to exchange. They now stay local and the `s_and_b64` exchanges; the `scc` result it checks is unchanged. Measured with the same temporary local test as the PR below this one (all wave64 CS / MS programs of the retail 1.0.2.1 `shaders.rpf`, split form, 4 windows). An exchange here is a mask write that uses `xcl_x_ballot`, or an `xcl_x_sync_mask`: | commit | exchanged mask writes | tree syncs | exchanges | |---|---|---|---| | `main` `9e3831e` | 210 324 | 0 | 210 324 | | PR below `524b25c` | 153 728 | 0 | 153 728 | | this PR `b71f7ee` | 127 965 | 10 473 | 138 438 (−10.0 % on `524b25c`, −34.2 % on `main`) | HLSL over the 10 490 programs: 2 648.5 MB → 2 652.9 MB (+0.17 %). These numbers were measured at `b71f7ee`. `6acbfb1` changes only what `xcl_x_sync_mask` returns when there is no other half, not where the exchanges go; they were not measured again. `docs/wave64-on-wave32.md:41` says a mask skips the exchange only when it "is only read lane by lane". After this change that is no longer the whole rule. The doc is not edited here. **Tested** - NVIDIA GeForce RTX 5080 (32-lane waves, so the split form), driver 621.24; Intel Core i7-14700KF, 64 GB; Windows 11 build 26300; rustc 1.97.1; DXC 1.8.2502.11; debug for tests, release for the smoke run. - `cargo build --workspace && cargo test --workspace -- --test-threads=4` at `6acbfb1`: 789 passed, 0 failed, 41 ignored. - `gpu_split_wave64_bitwise_mask_tree_in_a_partial_wave` without the `xcl_x_sync_mask` fix: failed (`s_bcnt1` 16, expected 48). With it, `cargo test -p xcl --lib gpu_split_wave64 -- --test-threads=1`: 9 passed, 0 failed. - SKIPPED: `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware` (no wave64), `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). **Regression run** Each block is the second of two back-to-back 60 s runs of the same build (the first one filled the shader and driver caches). main: ``` xcl-smoke v1 commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485 gpu: NVIDIA GeForce RTX 5080 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1617 (PresentX 1617) presents per 2 s (last 3): 60 60 59 device removals: 0 crashes: 0 peak commit: 15047 MB ``` PR: ``` xcl-smoke v1 commit: 6acbfb1f4d57e5d914161dde56faaf28da18f973 gpu: NVIDIA GeForce RTX 5080 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1612 (PresentX 1612) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14621 MB ``` **Not tested** - AMD and native wave64 GPUs, where the split form is not used. - DXC and driver compile times before and after; only the exchange counts were measured. - Trees across basic blocks, which are left exchanged. - Whether the smoke run reaches the changed code: in 60 s it built 26 compute pipelines from translated console CS, and the log does not say how many of them are wave64 programs in the split form. The exchange counts above cover the whole pack. **AI use** - Claude Code, Claude Opus 5.5: wrote the code, the tests, the measurement script and this description, and ran the tests, the smoke runs and the measurement on the hardware above.
upipibi commented 2026-11-24 19:07:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by upipibi on 2026-11-24T18:52:48Z.


Read b71f7ee against the ISA. The split-form side holds up:

  • Which ops can stay local: lane_wise_salu64 has only ops whose two dwords don't mix: not/and/or/xor/andn2/orn2/nand/nor/xnor, and s_wqm_b64 (its 4-lane quads never straddle lane 32). Shifts, s_brev_b64, s_bfe_*64, s_bitreplicate, s_ff*/s_bcnt* aren't in it, which is right, since they move or count bits across the boundary.
  • The halves stay in step: both halves run the same instruction stream, so the tree's last op exchanges in both at the same point, and the exchange count stays matched.

One wording point: the description says s_cmov / s_cselect are not tree ops, but lane_wise_salu64 classes them with s_mov_b64 (lane-wise, no scc write). That is only safe while the scc they read is the same in both halves, i.e. never derived from a local, unsynced tree value. The rule that a live scc makes the op whole-live seems to give that. If so, a comment there saying it is the guarantee would help the next reader.

I haven't run it (the RTX 5080 run covers the 32-lane case).

AI use: Claude Code (Claude Opus 5.5) read the change and wrote this.

<!-- greyfinch-sync:ivall/xcl:comment:7141280463 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1597#issuecomment-7141280463). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-24T18:52:48Z. --- Read `b71f7ee` against the ISA. The split-form side holds up: - **Which ops can stay local:** `lane_wise_salu64` has only ops whose two dwords don't mix: not/and/or/xor/andn2/orn2/nand/nor/xnor, and `s_wqm_b64` (its 4-lane quads never straddle lane 32). Shifts, `s_brev_b64`, `s_bfe_*64`, `s_bitreplicate`, `s_ff*`/`s_bcnt*` aren't in it, which is right, since they move or count bits across the boundary. - **The halves stay in step:** both halves run the same instruction stream, so the tree's last op exchanges in both at the same point, and the exchange count stays matched. One wording point: the description says `s_cmov` / `s_cselect` are not tree ops, but `lane_wise_salu64` classes them with `s_mov_b64` (lane-wise, no `scc` write). That is only safe while the `scc` they read is the same in both halves, i.e. never derived from a local, unsynced tree value. The rule that a live `scc` makes the op whole-live seems to give that. If so, a comment there saying it is the guarantee would help the next reader. I haven't run it (the RTX 5080 run covers the 32-lane case). AI use: Claude Code (Claude Opus 5.5) read the change and wrote this.
futurepro62 commented 2026-11-24 19:07:49 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T18:55:13Z.


Full-suite run, since this PR has no test report yet. Tested exact head b71f7ee (on its base 9e3831e).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form: 787 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: gpu_split_wave64_bitwise_lane_masks, gpu_split_wave64_predicated_exec_masks, gpu_split_wave64_bitwise_mask_tree_exchanges_once, saveexec_needs_whole_inputs_only_for_a_whole_read, a_bitwise_tree_read_whole_exchanges_once_at_its_end, a_compare_read_whole_outside_the_tree_keeps_its_exchange, bitwise_mask_chain_for_selector_needs_no_exchange, bitwise_mask_with_live_scc_keeps_exchange, bitwise_mask_feeding_whole_read_keeps_exchange, cselect_and_cmov_b64_propagate_lane_masks_and_keep_scc_uniform, vccz_operand_and_odd_alignment_in_bitwise_ops_keep_exchange, loop_exit_reading_scc_keeps_exchange_inside_loop.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 788 passed, 0 failed, 41 ignored. SKIPPED: heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • heap_window_out_of_memory_falls_back_to_the_switch_form was skipped with --skip. It fails on main 9e3831e too, not because of this PR: under XCL_REQUIRE_GPU=mesh, runner::skip_test turns every skip except "no wave64" into a failure, including this test's opt-in "no heap windows" skip (XCL_HEAP_WINDOWS unset). Reported as #1651.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:ivall/xcl:comment:7141336599 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1597#issuecomment-7141336599). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T18:55:13Z. --- Full-suite run, since this PR has no test report yet. Tested exact head `b71f7ee` (on its base `9e3831e`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form`: **787 passed, 0 failed, 41 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - The new tests ran and passed: `gpu_split_wave64_bitwise_lane_masks`, `gpu_split_wave64_predicated_exec_masks`, `gpu_split_wave64_bitwise_mask_tree_exchanges_once`, `saveexec_needs_whole_inputs_only_for_a_whole_read`, `a_bitwise_tree_read_whole_exchanges_once_at_its_end`, `a_compare_read_whole_outside_the_tree_keeps_its_exchange`, `bitwise_mask_chain_for_selector_needs_no_exchange`, `bitwise_mask_with_live_scc_keeps_exchange`, `bitwise_mask_feeding_whole_read_keeps_exchange`, `cselect_and_cmov_b64_propagate_lane_masks_and_keep_scc_uniform`, `vccz_operand_and_odd_alignment_in_bitwise_ops_keep_exchange`, `loop_exit_reading_scc_keeps_exchange_inside_loop`. - Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4`: **788 passed, 0 failed, 41 ignored**. SKIPPED: `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). - `heap_window_out_of_memory_falls_back_to_the_switch_form` was skipped with `--skip`. It fails on main `9e3831e` too, not because of this PR: under `XCL_REQUIRE_GPU=mesh`, `runner::skip_test` turns every skip except "no wave64" into a failure, including this test's opt-in "no heap windows" skip (`XCL_HEAP_WINDOWS` unset). Reported as #1651. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
ScaryFr92 commented 2026-11-24 19:07:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ScaryFr92 on 2026-11-24T18:56:49Z.


Tested #1597 at b71f7ee (with #1596 and #1111 below it) on Ampere: 788 passed, 0 failed, 41 ignored; the 8 split-wave64 GPU tests pass with XCL_REQUIRE_GPU=wave64.

Tested

  • NVIDIA GeForce RTX 3070 8 GB (Ampere, 32-lane waves, so the split form), driver 32.0.16.1088; Intel Core i7-10700K, 32 GB; Windows 11 Pro build 26200; Rust 1.100.0 x86_64-pc-windows-msvc; DXC 1.9.2602.17 (Windows SDK 10.0.26100); debug build, clean tree at b71f7ee.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4: 788 passed, 0 failed, 41 ignored (same counts as the RTX 5080 run in the description, which used DXC 1.8).
  • SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • With XCL_REQUIRE_GPU=wave64: cargo test -p xcl --lib gpu::recomp::tests::gpu_split_wave64 -- --test-threads=1: 8 passed, 0 failed, 0 skipped, including gpu_split_wave64_bitwise_mask_tree_exchanges_once and gpu_split_wave64_predicated_exec_masks.

Not tested

  • No retail title: no smoke run, no exchange counts on a shader pack, no performance numbers.
  • AMD, and NVIDIA generations other than Ampere.

AI use

  • Claude Code (Claude Opus 5.5) ran the build and the tests and drafted this report.
<!-- greyfinch-sync:ivall/xcl:comment:7141374141 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1597#issuecomment-7141374141). Originally posted by [ScaryFr92](https://github.com/ScaryFr92) on 2026-11-24T18:56:49Z. --- **Tested #1597 at `b71f7ee` (with #1596 and #1111 below it) on Ampere: 788 passed, 0 failed, 41 ignored; the 8 split-wave64 GPU tests pass with `XCL_REQUIRE_GPU=wave64`.** **Tested** - NVIDIA GeForce RTX 3070 8 GB (Ampere, 32-lane waves, so the split form), driver 32.0.16.1088; Intel Core i7-10700K, 32 GB; Windows 11 Pro build 26200; Rust 1.100.0 `x86_64-pc-windows-msvc`; DXC 1.9.2602.17 (Windows SDK 10.0.26100); debug build, clean tree at `b71f7ee`. - `cargo build --workspace && cargo test --workspace -- --test-threads=4`: 788 passed, 0 failed, 41 ignored (same counts as the RTX 5080 run in the description, which used DXC 1.8). - SKIPPED: `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware` (no wave64), `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). - With `XCL_REQUIRE_GPU=wave64`: `cargo test -p xcl --lib gpu::recomp::tests::gpu_split_wave64 -- --test-threads=1`: 8 passed, 0 failed, 0 skipped, including `gpu_split_wave64_bitwise_mask_tree_exchanges_once` and `gpu_split_wave64_predicated_exec_masks`. **Not tested** - No retail title: no smoke run, no exchange counts on a shader pack, no performance numbers. - AMD, and NVIDIA generations other than Ampere. **AI use** - Claude Code (Claude Opus 5.5) ran the build and the tests and drafted this report.
MatyEjsr commented 2026-11-24 21:09:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by MatyEjsr on 2026-11-24T20:12:10Z.


Updated verification of PR #1597 at head commit 6acbfb1f4d57e5d914161dde56faaf28da18f973 on NVIDIA GeForce RTX 3090 (split-wave64). Confirmed that the partial-wave xcl_x_sync_mask bug from b71f7ee is fixed.

Environment

  • OS: Windows 11 Pro for Workstations 10.0.26200 (Build 26200)
  • CPU: AMD Ryzen 7 7800X3D 8-Core Processor
  • GPU: NVIDIA GeForce RTX 3090, driver 617.42 (32.0.16.1742)
  • RAM: 31.4 GB
  • Toolchain: rustc 1.100.0 (x86_64-pc-windows-msvc, debug build), DXC 1.9.2602.17 (21d28f72) + dxil.dll 1.9.2602.17

Tested

  • cargo build --workspace -j 8: ok (13.27s, 0 errors)
  • cargo test --workspace -j 8 -- --test-threads=4 --nocapture: 789 passed (784 executed + 5 SKIPPED), 0 failed, 41 ignored
    • SKIPPED:
      • gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask (no wave64)
      • gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware (no wave64)
      • test_title_draws_with_a_root_signature_under_the_debug_layer (no d3d12SDKLayers.dll)
      • heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows)
      • uploads_start_from_each_subresources_state (no D3D12 debug layer, 0x887A002D)
  • cargo test -p xcl --lib x64_masks -- --test-threads=4 --nocapture: 25 passed, 0 failed, 0 ignored (0.00s)
  • XCL_REQUIRE_GPU=wave64 cargo test -p xcl --lib gpu_split_wave64 -- --test-threads=1: 9 passed, 0 failed, 0 ignored, 0 skipped (0.67s)
    • Verified all 9 split-wave64 GPU tests pass on RTX 3090, including the new gpu_split_wave64_bitwise_mask_tree_in_a_partial_wave, gpu_split_wave64_bitwise_mask_tree_exchanges_once, gpu_split_wave64_bitwise_lane_masks, and gpu_split_wave64_predicated_exec_masks.

Code review & follow-up notes

  • Earlier finding verified fixed (6acbfb1): xcl_x_sync_mask in crates/xcl/src/gpu/recomp/emit.rs now falls back to select(xcl_half != 0u, lo, hi) when xcl_x_meet() is false, preserving the absent-half word computed by inverting or uniform-combining tree ops on unpaired partial waves (xcl_xn == 0u), and gpu_split_wave64_bitwise_mask_tree_in_a_partial_wave covers both s_bcnt1_i32_b64 (48) and scc (s_cselect_b32 = 77) on a [32, 1, 1] wave64 dispatch.
  • Soundness check: all tree_op instructions (S_MOV_B64, S_NOT_B64, S_WQM_B64, and the 8 binary bitwise S_*_B64 ops) go through Em::salu64, where xcl_x_sync_mask runs before scc derivation and write64. In x64_masks::analyze, live_out is only cleared inside exchange_at when leaves.len() >= 2 alongside inserting node into plan.sync, so any tree dropped with whole = false safely retains per-leaf exchanges.
  • Rebase note: the branch is currently 322 commits behind main (568e7db) with conflicts in emit.rs, mod.rs, tests.rs, and x64_masks.rs (including #1090 7bea019 block-level liveness and 39ef551), and crates/xcl/src/gpu/dxil/kernel.rs on main still calls x64_masks::by_pc(insts, kernel) which this PR removes. Keeping a by_pc helper or updating dxil/kernel.rs will be needed when rebasing onto main.

Not tested

  • AMD / native wave64 GPUs, release build, retail title smoke run, D3D12 debug layer tests, heap-window OOM fallback test, and rebased integration onto current main.

AI use

  • agy with gemini-4-neon-high (audited by gemini-4-neon-medium): reviewed the 6acbfb1 diff and x64_masks.rs / emit.rs, ran the workspace build and tests on the hardware above, and drafted and audited this report.
<!-- greyfinch-sync:ivall/xcl:comment:7143184007 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1597#issuecomment-7143184007). Originally posted by [MatyEjsr](https://github.com/MatyEjsr) on 2026-11-24T20:12:10Z. --- Updated verification of PR #1597 at head commit `6acbfb1f4d57e5d914161dde56faaf28da18f973` on NVIDIA GeForce RTX 3090 (split-wave64). Confirmed that the partial-wave `xcl_x_sync_mask` bug from `b71f7ee` is fixed. **Environment** - OS: Windows 11 Pro for Workstations 10.0.26200 (Build 26200) - CPU: AMD Ryzen 7 7800X3D 8-Core Processor - GPU: NVIDIA GeForce RTX 3090, driver 617.42 (32.0.16.1742) - RAM: 31.4 GB - Toolchain: rustc 1.100.0 (`x86_64-pc-windows-msvc`, debug build), DXC 1.9.2602.17 (21d28f72) + `dxil.dll` 1.9.2602.17 **Tested** - `cargo build --workspace -j 8`: ok (13.27s, 0 errors) - `cargo test --workspace -j 8 -- --test-threads=4 --nocapture`: 789 passed (784 executed + 5 SKIPPED), 0 failed, 41 ignored - SKIPPED: - `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask` (`no wave64`) - `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware` (`no wave64`) - `test_title_draws_with_a_root_signature_under_the_debug_layer` (`no d3d12SDKLayers.dll`) - `heap_window_out_of_memory_falls_back_to_the_switch_form` (`no heap windows`) - `uploads_start_from_each_subresources_state` (`no D3D12 debug layer`, `0x887A002D`) - `cargo test -p xcl --lib x64_masks -- --test-threads=4 --nocapture`: 25 passed, 0 failed, 0 ignored (0.00s) - `XCL_REQUIRE_GPU=wave64 cargo test -p xcl --lib gpu_split_wave64 -- --test-threads=1`: 9 passed, 0 failed, 0 ignored, 0 skipped (0.67s) - Verified all 9 split-wave64 GPU tests pass on RTX 3090, including the new `gpu_split_wave64_bitwise_mask_tree_in_a_partial_wave`, `gpu_split_wave64_bitwise_mask_tree_exchanges_once`, `gpu_split_wave64_bitwise_lane_masks`, and `gpu_split_wave64_predicated_exec_masks`. **Code review & follow-up notes** - **Earlier finding verified fixed (`6acbfb1`):** `xcl_x_sync_mask` in `crates/xcl/src/gpu/recomp/emit.rs` now falls back to `select(xcl_half != 0u, lo, hi)` when `xcl_x_meet()` is false, preserving the absent-half word computed by inverting or uniform-combining tree ops on unpaired partial waves (`xcl_xn == 0u`), and `gpu_split_wave64_bitwise_mask_tree_in_a_partial_wave` covers both `s_bcnt1_i32_b64` (48) and `scc` (`s_cselect_b32` = 77) on a `[32, 1, 1]` wave64 dispatch. - **Soundness check:** all `tree_op` instructions (`S_MOV_B64`, `S_NOT_B64`, `S_WQM_B64`, and the 8 binary bitwise `S_*_B64` ops) go through `Em::salu64`, where `xcl_x_sync_mask` runs before `scc` derivation and `write64`. In `x64_masks::analyze`, `live_out` is only cleared inside `exchange_at` when `leaves.len() >= 2` alongside inserting `node` into `plan.sync`, so any tree dropped with `whole = false` safely retains per-leaf exchanges. - **Rebase note:** the branch is currently 322 commits behind `main` (`568e7db`) with conflicts in `emit.rs`, `mod.rs`, `tests.rs`, and `x64_masks.rs` (including #1090 `7bea019` block-level liveness and `39ef551`), and `crates/xcl/src/gpu/dxil/kernel.rs` on `main` still calls `x64_masks::by_pc(insts, kernel)` which this PR removes. Keeping a `by_pc` helper or updating `dxil/kernel.rs` will be needed when rebasing onto `main`. **Not tested** - AMD / native wave64 GPUs, release build, retail title smoke run, D3D12 debug layer tests, heap-window OOM fallback test, and rebased integration onto current `main`. **AI use** - agy with gemini-4-neon-high (audited by gemini-4-neon-medium): reviewed the `6acbfb1` diff and `x64_masks.rs` / `emit.rs`, ran the workspace build and tests on the hardware above, and drafted and audited this report.
DavidM1911 commented 2026-11-24 21:09:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T20:12:17Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7143186799 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1597#issuecomment-7143186799). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T20:12:17Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
MiguelMachado-dev commented 2026-11-24 21:09:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by MiguelMachado-dev on 2026-11-24T20:57:53Z.


@MatyEjsr thanks for finding this, and for the reproduction. The fix is in 6acbfb1 (squashed into this PR's commit). It is the fallback you suggested: with no other half, xcl_x_sync_mask keeps the word this half computed for the missing one instead of 0.

New GPU test, gpu_split_wave64_bitwise_mask_tree_in_a_partial_wave: a wave64 group of 32 threads with s_nor_b64 of two compares, read by s_bcnt1 and by scc. On an RTX 5080 it fails without the fix (s_bcnt1 16, expected 48) and passes with it. At 6acbfb1: cargo test -p xcl --lib gpu_split_wave64 -- --test-threads=1 gives 9 passed, and the whole suite gives 789 passed, 0 failed, 41 ignored.

AI use: Claude Code (Claude Opus 5.5) wrote the fix, the test and this comment.

<!-- greyfinch-sync:ivall/xcl:comment:7144292499 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1597#issuecomment-7144292499). Originally posted by [MiguelMachado-dev](https://github.com/MiguelMachado-dev) on 2026-11-24T20:57:53Z. --- @MatyEjsr thanks for finding this, and for the reproduction. The fix is in `6acbfb1` (squashed into this PR's commit). It is the fallback you suggested: with no other half, `xcl_x_sync_mask` keeps the word this half computed for the missing one instead of 0. New GPU test, `gpu_split_wave64_bitwise_mask_tree_in_a_partial_wave`: a wave64 group of 32 threads with `s_nor_b64` of two compares, read by `s_bcnt1` and by `scc`. On an RTX 5080 it fails without the fix (`s_bcnt1` 16, expected 48) and passes with it. At `6acbfb1`: `cargo test -p xcl --lib gpu_split_wave64 -- --test-threads=1` gives 9 passed, and the whole suite gives 789 passed, 0 failed, 41 ignored. AI use: Claude Code (Claude Opus 5.5) wrote the fix, the test and this comment.
qcdaark commented 2026-11-25 07:05:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by qcdaark on 2026-11-25T06:23:06Z.


Retail data point on RTX 3070 Ti (split-wave64): with this PR the world-load GPU hang from #675 is still there, 2 of 2 runs, with the default spin meet and with XCL_WAVE64_SPIN=0.

Setup: RTX 3070 Ti 8 GB, driver 621.24, Ryzen 9 7900X, 32 GB, Windows 11 26300, release. Retail 1.0.2.1 from #675.

  • Tree: my test-1428 tree, c160d86 + #640 + #1428 + #1323, with this PR's three commits cherry-picked on top (ce0eeec, 524b25c, 6acbfb1, no conflicts).
    • On that tree, without this PR, the GPU hangs on every run in CS_DepthProcessingHBO, record b78fa10b425b8e54 (Aftermath, see #675).
    • Refusing that one program removes the hang (2 of 2).
  • Env: XCL_PSO_WAIT_MS=50 XCL_PSO_TRACE=1 XCL_ACTIVITY=1 XCL_NETWORK=0 XCL_PRESS_A_AT=25,35,45 XCL_RUN_SECONDS=420. The translated cache is keyed by the translator source, so the programs were translated again with this PR.
run meet end
A default (counter spin) 0x887a0006 at 154 s, then 0x80000003 at +0x2474606
B XCL_WAVE64_SPIN=0 0x887a0006 at 221 s, then the process ends with the same status

+0x2474606 after the device removal is the same signature as the HBO hang runs on this card. Aftermath was off for these two runs, so I can't say which program was in flight this time.

A build note for the rebase: this PR removes x64_masks::by_pc, but main still calls it in crates/xcl/src/gpu/dxil/kernel.rs (direct DXIL, lw.whole_live = …by_pc(insts, kernel)), and my older tree calls it there too. To build, I kept a by_pc that returns solve's liveness without the mask trees, since the direct path does not emit xcl_x_sync_mask. That patch is attached as build-fix.patch.

Attached (user name removed): xcl.log and report.json for both runs.

AI use: Claude Code (Claude Opus 5.5) built the tree, ran the title and wrote this; I checked it before posting.
build-fix.patch
runA-pr1597-default-report.json
runA-pr1597-default-xcl.log
runB-pr1597-spin0-report.json
runB-pr1597-spin0-xcl.log

<!-- greyfinch-sync:ivall/xcl:comment:7154735292 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1597#issuecomment-7154735292). Originally posted by [qcdaark](https://github.com/qcdaark) on 2026-11-25T06:23:06Z. --- **Retail data point on RTX 3070 Ti (split-wave64): with this PR the world-load GPU hang from #675 is still there, 2 of 2 runs, with the default spin meet and with `XCL_WAVE64_SPIN=0`.** **Setup:** RTX 3070 Ti 8 GB, driver 621.24, Ryzen 9 7900X, 32 GB, Windows 11 26300, release. Retail 1.0.2.1 from #675. - **Tree:** my `test-1428` tree, `c160d86` + #640 + #1428 + #1323, with this PR's three commits cherry-picked on top (`ce0eeec`, `524b25c`, `6acbfb1`, no conflicts). - On that tree, without this PR, the GPU hangs on every run in `CS_DepthProcessingHBO`, record `b78fa10b425b8e54` (Aftermath, see #675). - Refusing that one program removes the hang (2 of 2). - **Env:** `XCL_PSO_WAIT_MS=50 XCL_PSO_TRACE=1 XCL_ACTIVITY=1 XCL_NETWORK=0 XCL_PRESS_A_AT=25,35,45 XCL_RUN_SECONDS=420`. The translated cache is keyed by the translator source, so the programs were translated again with this PR. | run | meet | end | |---|---|---| | A | default (counter spin) | `0x887a0006` at 154 s, then `0x80000003` at `+0x2474606` | | B | `XCL_WAVE64_SPIN=0` | `0x887a0006` at 221 s, then the process ends with the same status | `+0x2474606` after the device removal is the same signature as the HBO hang runs on this card. Aftermath was off for these two runs, so I can't say which program was in flight this time. **A build note for the rebase:** this PR removes `x64_masks::by_pc`, but `main` still calls it in `crates/xcl/src/gpu/dxil/kernel.rs` (direct DXIL, `lw.whole_live = …by_pc(insts, kernel)`), and my older tree calls it there too. To build, I kept a `by_pc` that returns `solve`'s liveness without the mask trees, since the direct path does not emit `xcl_x_sync_mask`. That patch is attached as `build-fix.patch`. Attached (user name removed): `xcl.log` and `report.json` for both runs. AI use: Claude Code (Claude Opus 5.5) built the tree, ran the title and wrote this; I checked it before posting. [build-fix.patch](https://github.com/user-attachments/files/35396677/build-fix.patch) [runA-pr1597-default-report.json](https://github.com/user-attachments/files/35396678/runA-pr1597-default-report.json) [runA-pr1597-default-xcl.log](https://github.com/user-attachments/files/35396679/runA-pr1597-default-xcl.log) [runB-pr1597-spin0-report.json](https://github.com/user-attachments/files/35396680/runB-pr1597-spin0-report.json) [runB-pr1597-spin0-xcl.log](https://github.com/user-attachments/files/35396682/runB-pr1597-spin0-xcl.log)
grahamster2 commented 2026-11-25 07:05:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by grahamster2 on 2026-11-25T06:32:46Z.


Some numbers on why this one matters for the split-wave64 cost on NVIDIA.

I counted the static exchanges in the split-form HLSL of the 374 wave64 compute programs in a retail title's shader pack (main cbc296a, xcl shaders --export-hlsl, RTX 3080 as the 32-lane device). There are 25,352 exchanges, and 22,825 of them (90 %) are xcl_x_ballot: a v_cmp mask exchanged on its way through s_and/s_or/s_xor_b64 into s_and_saveexec_b64 / s_cbranch_execz. That is the mask-tree pattern this PR folds into one exchange at the end. 4.7k of the exchanges sit inside loops.

The other open exchange PRs, each cherry-picked onto the same main and counted the same way:

PR exchanges change in loops
main 25,352 4,746
#1193 (uniform readfirstlane) 24,945 -1.6 % 4,696
#944 (batching) 24,711 -2.5 % 4,441
#573 (wave size from the header) 25,276 -0.3 % 4,732

None of them touches the ballots. On the 3080 an exchange costs about 3x a native loop iteration in the one-wave-group spin form (numbers in #1244 and #675), so the ballots are where the time goes.

This branch is based 491 commits behind main and doesn't cherry-pick cleanly, so I couldn't count it. Once it's rebased on current main, I'm happy to run the same count (total, in loops, per program) and the bench_split_wave64 / bench_compute_lds_block loops on the 3080 and post the numbers here.

AI-assisted (Claude Code, Claude Opus 5.5); counts and timings from runs on my machine.

<!-- greyfinch-sync:ivall/xcl:comment:7154901625 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1597#issuecomment-7154901625). Originally posted by [grahamster2](https://github.com/grahamster2) on 2026-11-25T06:32:46Z. --- Some numbers on why this one matters for the split-wave64 cost on NVIDIA. I counted the static exchanges in the split-form HLSL of the 374 wave64 compute programs in a retail title's shader pack (main cbc296a, `xcl shaders --export-hlsl`, RTX 3080 as the 32-lane device). There are 25,352 exchanges, and 22,825 of them (90 %) are `xcl_x_ballot`: a `v_cmp` mask exchanged on its way through `s_and/s_or/s_xor_b64` into `s_and_saveexec_b64` / `s_cbranch_execz`. That is the mask-tree pattern this PR folds into one exchange at the end. 4.7k of the exchanges sit inside loops. The other open exchange PRs, each cherry-picked onto the same main and counted the same way: | PR | exchanges | change | in loops | |---|---|---|---| | main | 25,352 | | 4,746 | | #1193 (uniform readfirstlane) | 24,945 | -1.6 % | 4,696 | | #944 (batching) | 24,711 | -2.5 % | 4,441 | | #573 (wave size from the header) | 25,276 | -0.3 % | 4,732 | None of them touches the ballots. On the 3080 an exchange costs about 3x a native loop iteration in the one-wave-group spin form (numbers in #1244 and #675), so the ballots are where the time goes. This branch is based 491 commits behind main and doesn't cherry-pick cleanly, so I couldn't count it. Once it's rebased on current main, I'm happy to run the same count (total, in loops, per program) and the `bench_split_wave64` / `bench_compute_lds_block` loops on the 3080 and post the numbers here. _AI-assisted (Claude Code, Claude Opus 5.5); counts and timings from runs on my machine._
Raghav314 commented 2026-11-25 20:08:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Raghav314 on 2026-11-25T19:09:33Z.


@MiguelMachado-dev this PR carried onto current main 3f27770, on top of the #1596 port (comment there): Raghav314/xcl x64/exec-local-mask-trees, commit b31b96a, with you as co-author.

How it maps onto main:

  • x64_masks::analyze_split returns Plan { whole_live, sync }: the split-mode liveness, then your per-block tree walk. A block ends after every branch and wherever a jump lands, as in your PR.
  • whole_live_out_mode now also returns where scc is live, and the successor computation is shared.
  • HLSL: xcl_x_sync_mask in salu64 as you wrote it, with the same fallback that keeps the half's own word when there is no other half.
  • Direct DXIL (new): Lw::sync_mask does the same exchange in salu64, through the split form's exchange slot. It uses 2 words: the value, and a word telling a met partner apart from an absent one, for the same fallback. The compact form's block key includes it.
  • Test change: split_wave64_reduction_tail_rules is new on main and counts xcl_x_meet() ? in the prelude, which now has one more helper (3 → 4).

Tests (RTX 4090, 617.14):

  • Your two GPU tests pass, and each now also runs the direct translator's split form on the GPU. Without Lw::sync_mask, the direct run gives (27, 11) for (37, 77).
  • gpu_split_wave64_bitwise_lane_masks is updated as in your PR.
  • Full lib suite: 1290 passed, 1 failed (a_bridged_mask_write…, the same on plain main), 26 ignored.

Cold driver build, direct DXIL, split wave64, heap windows (4), NVIDIA implicit caches off, one process each:

program + #1111 + #1596 + this PR
062468c09af883b9 1,242,336 B · 14.6 / 14.7 s 1,240,008 B · 14.3 / 14.3 s
73fb752d7f62c3a5 1,427,468 B · 23.7 s 1,421,896 B · 22.1 s

That is a smaller step than #1596's (main: 20.4 s and 33.2 s). These programs have few multi-compare trees read whole. Full numbers are on #2088.

Not tested: a title run; AMD (split only).

AI use: Claude Code (Claude Opus 5.5) ported the change, ran the tests and timings, and wrote this for @Raghav314.

<!-- greyfinch-sync:ivall/xcl:comment:7171897702 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1597#issuecomment-7171897702). Originally posted by [Raghav314](https://github.com/Raghav314) on 2026-11-25T19:09:33Z. --- @MiguelMachado-dev this PR carried onto current `main` `3f27770`, on top of the #1596 port ([comment there](https://github.com/xcl-dev/xcl/pull/1596#issuecomment-7171227902)): [`Raghav314/xcl` `x64/exec-local-mask-trees`](https://github.com/Raghav314/xcl/commits/x64/exec-local-mask-trees), commit `b31b96a`, with you as co-author. **How it maps onto `main`:** - `x64_masks::analyze_split` returns `Plan { whole_live, sync }`: the split-mode liveness, then your per-block tree walk. A block ends after every branch and wherever a jump lands, as in your PR. - `whole_live_out_mode` now also returns where `scc` is live, and the successor computation is shared. - **HLSL:** `xcl_x_sync_mask` in `salu64` as you wrote it, with the same fallback that keeps the half's own word when there is no other half. - **Direct DXIL (new):** `Lw::sync_mask` does the same exchange in `salu64`, through the split form's exchange slot. It uses 2 words: the value, and a word telling a met partner apart from an absent one, for the same fallback. The compact form's block key includes it. - **Test change:** `split_wave64_reduction_tail_rules` is new on `main` and counts `xcl_x_meet() ?` in the prelude, which now has one more helper (3 → 4). **Tests** (RTX 4090, 617.14): - Your two GPU tests pass, and each now also runs the direct translator's split form on the GPU. Without `Lw::sync_mask`, the direct run gives (27, 11) for (37, 77). - `gpu_split_wave64_bitwise_lane_masks` is updated as in your PR. - Full lib suite: 1290 passed, 1 failed (`a_bridged_mask_write…`, the same on plain `main`), 26 ignored. **Cold driver build**, direct DXIL, split wave64, heap windows (4), NVIDIA implicit caches off, one process each: | program | + #1111 + #1596 | + this PR | |---|---|---| | `062468c09af883b9` | 1,242,336 B · 14.6 / 14.7 s | 1,240,008 B · 14.3 / 14.3 s | | `73fb752d7f62c3a5` | 1,427,468 B · 23.7 s | 1,421,896 B · 22.1 s | That is a smaller step than #1596's (`main`: 20.4 s and 33.2 s). These programs have few multi-compare trees read whole. Full numbers are on #2088. **Not tested:** a title run; AMD (split only). AI use: Claude Code (Claude Opus 5.5) ported the change, ran the tests and timings, and wrote this for @Raghav314.
grahamster2 commented 2026-11-25 20:08:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by grahamster2 on 2026-11-25T19:29:26Z.


Counts and timings for the port on current main, as promised above.

I counted the static exchanges in the split-form HLSL of the wave64 compute programs in a retail title's shader pack (xcl shaders --export-hlsl --split 1, one export per build, the RTX 3080 as the 32-lane device). 356 of the 374 programs I used earlier come out in split form on this main; the same 356 are counted in every column. The counter now also counts xcl_x_sync_mask( calls, so the new helper's exchanges are included in the totals (and shown on their own below).

main + #1111 + #1596 + #1597
exchanges, total 25,276 18,127 16,639
change vs main -28.3 % -34.2 %
change vs previous column -28.3 % -8.2 %
exchanges in loops 4,732 3,897 3,442
in loops, change vs main -17.6 % -27.3 %
xcl_x_ballot share of exchanges 90.2 % 86.3 % 78.4 %
xcl_x_sync_mask exchanges 0 0 1,114 (6.7 %)

Per program, #1597 against the column before it: 179 of 356 programs got fewer exchanges, 177 got the same number, none got more. In loops: 57 programs fewer, none more. Against main the three columns together: 212 programs fewer, 144 the same, none more. The largest single-program reduction from #1597 alone is 75 %.

On the benchmark (cargo test --release -p xcl --lib -- --ignored bench_split_wave64 --nocapture, RTX 3080, median of 9 per cell, two runs per build), nothing moves, which is expected: its loop has one v_cmp read lane by lane and no bitwise mask tree.

bench_split_wave64, wave64 split vs wave32 main + #1596 + #1597
v_cmp + v_cndmask, 64 threads 1.10x 1.10x 1.10x
same, 256 threads 1.11x to 1.12x 1.11x 1.11x
+ v_readfirstlane (1 exchange / iteration), 64 threads 3.93x 3.93x to 3.96x 3.93x
same, 256 threads 3.70x 3.70x 3.70x

bench_compute_lds_block does not exist on main 3f27770, so I did not run it.

Method: main 3f27770, 577b075 (the #1111 and #1596 ports), b31b96a (this PR on top), from Raghav314's x64/exec-local-mask-trees, release builds, a fresh worktree for each. These are static counts in the emitted HLSL, not run time.

Not tested: a title run, the run-time effect of the lower count on the hang from #675, AMD, and the direct DXIL form's exchange count (only the HLSL export was counted).

AI-assisted (Claude Code, Claude Opus 5.5); counts and timings from runs on my machine.

<!-- greyfinch-sync:ivall/xcl:comment:7172369319 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1597#issuecomment-7172369319). Originally posted by [grahamster2](https://github.com/grahamster2) on 2026-11-25T19:29:26Z. --- Counts and timings for the port on current `main`, as promised above. I counted the static exchanges in the split-form HLSL of the wave64 compute programs in a retail title's shader pack (`xcl shaders --export-hlsl --split 1`, one export per build, the RTX 3080 as the 32-lane device). 356 of the 374 programs I used earlier come out in split form on this `main`; the same 356 are counted in every column. The counter now also counts `xcl_x_sync_mask(` calls, so the new helper's exchanges are included in the totals (and shown on their own below). | | main | + #1111 + #1596 | + #1597 | |---|---|---|---| | exchanges, total | 25,276 | 18,127 | 16,639 | | change vs `main` | | -28.3 % | -34.2 % | | change vs previous column | | -28.3 % | -8.2 % | | exchanges in loops | 4,732 | 3,897 | 3,442 | | in loops, change vs `main` | | -17.6 % | -27.3 % | | `xcl_x_ballot` share of exchanges | 90.2 % | 86.3 % | 78.4 % | | `xcl_x_sync_mask` exchanges | 0 | 0 | 1,114 (6.7 %) | Per program, #1597 against the column before it: 179 of 356 programs got fewer exchanges, 177 got the same number, none got more. In loops: 57 programs fewer, none more. Against `main` the three columns together: 212 programs fewer, 144 the same, none more. The largest single-program reduction from #1597 alone is 75 %. On the benchmark (`cargo test --release -p xcl --lib -- --ignored bench_split_wave64 --nocapture`, RTX 3080, median of 9 per cell, two runs per build), nothing moves, which is expected: its loop has one `v_cmp` read lane by lane and no bitwise mask tree. | `bench_split_wave64`, wave64 split vs wave32 | main | + #1596 | + #1597 | |---|---|---|---| | `v_cmp` + `v_cndmask`, 64 threads | 1.10x | 1.10x | 1.10x | | same, 256 threads | 1.11x to 1.12x | 1.11x | 1.11x | | + `v_readfirstlane` (1 exchange / iteration), 64 threads | 3.93x | 3.93x to 3.96x | 3.93x | | same, 256 threads | 3.70x | 3.70x | 3.70x | `bench_compute_lds_block` does not exist on `main` 3f27770, so I did not run it. Method: `main` 3f27770, `577b075` (the #1111 and #1596 ports), `b31b96a` (this PR on top), from Raghav314's `x64/exec-local-mask-trees`, release builds, a fresh worktree for each. These are static counts in the emitted HLSL, not run time. Not tested: a title run, the run-time effect of the lower count on the hang from #675, AMD, and the direct DXIL form's exchange count (only the HLSL export was counted). _AI-assisted (Claude Code, Claude Opus 5.5); counts and timings from runs on my machine._
bmjask commented 2026-11-25 21:31:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T21:31:27Z.

Review: COMMENTED


No concrete source defect found. Conservative tree analysis, final one-time both-word synchronization, and partial-wave fallback preserve mask semantics; focused coverage is strong. This dirty/non-mergeable stack needs rebase/current Windows CI, AMD/native-wave64 validation, and title smoke that reaches changed split-wave code. Docs claiming only lane-wise reads can skip exchange are now stale and should be updated when behavior changes. I found no blocker beyond evidence/readiness.

<!-- greyfinch-sync:ivall/xcl:review:6065255530 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1597#pullrequestreview-6065255530). Originally posted by [bmjask](https://github.com/bmjask) on 2026-11-25T21:31:27Z. **Review:** COMMENTED --- No concrete source defect found. Conservative tree analysis, final one-time both-word synchronization, and partial-wave fallback preserve mask semantics; focused coverage is strong. This dirty/non-mergeable stack needs rebase/current Windows CI, AMD/native-wave64 validation, and title smoke that reaches changed split-wave code. Docs claiming only lane-wise reads can skip exchange are now stale and should be updated when behavior changes. I found no blocker beyond evidence/readiness.
DavidM1911 commented 2026-11-26 06:06:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T05:48:37Z.


Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current main on the new head — needs another rebase before it can be tested.

<!-- greyfinch-sync:ivall/xcl:comment:7183825332 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1597#issuecomment-7183825332). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T05:48:37Z. --- Re-verification on RTX 3060 Ti (Windows 11): still a **merge conflict with current `main`** on the new head — needs another rebase before it can be tested.
JJAutoCompare commented 2026-11-26 22:49:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-26T22:49:37Z.


Tested

Independent run at clean PR head 6acbfb1f4d57e5d914161dde56faaf28da18f973 on Intel Arc A770 (driver 32.0.101.9175), Ryzen 7 3800X, Windows 11 x64 26200.9974, Rust/Cargo 1.100.0 MSVC, DXC/DXIL 1.9.2609.5, debug test profile.

Prebuilt with cargo test --locked -p xcl --lib -j 2 --no-run --message-format=json outside the GPU mutex. Ran <test-exe> gpu::recomp::tests::gpu_split_wave64_bitwise_mask_tree_exchanges_once --exact --nocapture --test-threads=1 and <test-exe> gpu::recomp::tests::gpu_split_wave64_bitwise_mask_tree_in_a_partial_wave --exact --nocapture --test-threads=1 under the Arc mutex with XCL_ADAPTER=A770.

2 passed, 0 failed, 0 ignored and 0 GPU skips with XCL_SPLIT_WAVE64=1. The intact and partial-wave HLSL/DXC cases each performed two exchanges and returned bitcounts 37 and 48 respectively. Both selected 77 through SCC.

Not tested

Direct DXIL, native wave64, the workspace suite and retail smoke.

AI use

T3 Code / Codex (gpt-6.2-sol) ran the original verification and summarized the saved results.

<!-- greyfinch-sync:ivall/xcl:comment:7205018003 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1597#issuecomment-7205018003). Originally posted by [JJAutoCompare](https://github.com/JJAutoCompare) on 2026-11-26T22:49:37Z. --- **Tested** Independent run at clean PR head `6acbfb1f4d57e5d914161dde56faaf28da18f973` on Intel Arc A770 (driver 32.0.101.9175), Ryzen 7 3800X, Windows 11 x64 26200.9974, Rust/Cargo 1.100.0 MSVC, DXC/DXIL 1.9.2609.5, debug test profile. Prebuilt with `cargo test --locked -p xcl --lib -j 2 --no-run --message-format=json` outside the GPU mutex. Ran `<test-exe> gpu::recomp::tests::gpu_split_wave64_bitwise_mask_tree_exchanges_once --exact --nocapture --test-threads=1` and `<test-exe> gpu::recomp::tests::gpu_split_wave64_bitwise_mask_tree_in_a_partial_wave --exact --nocapture --test-threads=1` under the Arc mutex with `XCL_ADAPTER=A770`. 2 passed, 0 failed, 0 ignored and 0 GPU skips with `XCL_SPLIT_WAVE64=1`. The intact and partial-wave HLSL/DXC cases each performed two exchanges and returned bitcounts 37 and 48 respectively. Both selected `77` through SCC. **Not tested** Direct DXIL, native wave64, the workspace suite and retail smoke. **AI use** T3 Code / Codex (gpt-6.2-sol) ran the original verification and summarized the saved results.
Foniass commented 2026-12-01 06:13:49 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:13:49Z.


Triage (#1607) – head 6acbfb1

Stacked on #1596, which is stacked on #1111; only the top commit 6acbfb1 (bitwise mask trees exchange once via xcl_x_sync_mask) belongs here. The shared lines with #1596 and #1111 are those base PRs, not a duplicate.
No other open PR adds tree-end syncs in x64_masks.rs / emit.rs.
The Build and test (Windows, no GPU) check fails on this head and the PR conflicts with main.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7302636340 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1597#issuecomment-7302636340). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T06:13:49Z. --- **Triage (#1607)** – head 6acbfb1 Stacked on #1596, which is stacked on #1111; only the top commit 6acbfb1 (bitwise mask trees exchange once via `xcl_x_sync_mask`) belongs here. The shared lines with #1596 and #1111 are those base PRs, not a duplicate. No other open PR adds tree-end syncs in x64_masks.rs / emit.rs. The `Build and test (Windows, no GPU)` check fails on this head and the PR conflicts with main. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

Pull request closed

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!1587
No description provided.