Direct DXIL: make multi-wave Compute and Mesh s_barrier early-exit-safe #1783

Closed
mastrr9 wants to merge 1 commit from upstream-pr/1793 into main
mastrr9 commented 2026-11-24 20:51:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by mastrr9 on 2026-11-24T20:51:42Z.


Summary

Makes the multi-wave Compute and Mesh s_barrier in the Direct DXIL path safe against early-exiting waves on split-wave64 NVIDIA GPUs.

#1741 bounds the single-wave split exchanges. This change covers the remaining unguarded GROUP_SYNC in s_barrier (lower.rs), related to #1727. A wave that exits early no longer leaves the others waiting at a barrier it will never reach.

  • Ports the HLSL path's xcl_s_barrier live-wave bookkeeping (0c02b87) to Direct DXIL (group_barrier.rs).
  • Honors XCL_SAFE_BARRIER=0 to turn the guard off.
  • Keeps TGSM within 32 KiB.
  • With LDS, the non-split form takes only words 8189 and 8190 from the program (an access to either goes to word 8188), so words 8188 and 8191 stay separate. Accesses to 8189 and 8190 themselves still alias 8188: the 32 KB block has no spare room.
  • No TRANSLATOR_VERSION change: #1947 hashes the gpu/dxil sources into the cache identity.
  • Adds XCL_SAFE_BARRIER to the translation cache-bypass list.

Tested

Current head e935deb, on macOS: cargo check --locked --workspace --all-targets --target x86_64-pc-windows-msvc (Rust 1.100.0, the C compiler for one dependency stubbed out) finished with no errors. This is a type check only; nothing was run.

Earlier runs, made before the rebase and the LDS fix, not on the current head:

Windows 11 x64, NVIDIA GeForce RTX 5080 16 GB, DXC 1.9.2602.17.

  • cargo test -p xcl --lib dxil::core_tests -- --test-threads=1: 17 passed, 0 failed, 1 ignored
  • XCL_DIRECT_DXIL=1 cargo test -p xcl --lib gpu_split_wave64 -- --test-threads=1: 5 passed, 0 failed
  • cargo test -p xcl --lib gpu::dxil -- --test-threads=1: 89 passed, 0 failed, 1 ignored
  • cargo test -p xcl --lib -- --test-threads=1: 849 passed, 0 failed, 22 ignored (no new warnings)

Not tested

  • Building, linking and any test run on Windows for the current head, including the new GPU readback test and the DXIL validator checks. GPU re-verification is queued.
  • Regression run: none for the current head.

AI use

  • Claude Opus 5.5 co-authored the original change.
  • Claude Code (Claude Sonnet 5.5) did the rebase, the LDS fix and its test, the type check, and updated this description.
<!-- greyfinch-sync:ivall/xcl:issue:5480121542 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1793). Originally posted by [mastrr9](https://github.com/mastrr9) on 2026-11-24T20:51:42Z. --- ## Summary Makes the multi-wave Compute and Mesh `s_barrier` in the Direct DXIL path safe against early-exiting waves on split-wave64 NVIDIA GPUs. `#1741` bounds the single-wave split exchanges. This change covers the remaining unguarded `GROUP_SYNC` in `s_barrier` (`lower.rs`), related to `#1727`. A wave that exits early no longer leaves the others waiting at a barrier it will never reach. - Ports the HLSL path's `xcl_s_barrier` live-wave bookkeeping (`0c02b87`) to Direct DXIL (`group_barrier.rs`). - Honors `XCL_SAFE_BARRIER=0` to turn the guard off. - Keeps TGSM within 32 KiB. - With LDS, the non-split form takes only words 8189 and 8190 from the program (an access to either goes to word 8188), so words 8188 and 8191 stay separate. Accesses to 8189 and 8190 themselves still alias 8188: the 32 KB block has no spare room. - No `TRANSLATOR_VERSION` change: #1947 hashes the `gpu/dxil` sources into the cache identity. - Adds `XCL_SAFE_BARRIER` to the translation cache-bypass list. **Tested** Current head `e935deb`, on macOS: `cargo check --locked --workspace --all-targets --target x86_64-pc-windows-msvc` (Rust 1.100.0, the C compiler for one dependency stubbed out) finished with no errors. This is a type check only; nothing was run. Earlier runs, made before the rebase and the LDS fix, **not on the current head**: Windows 11 x64, NVIDIA GeForce RTX 5080 16 GB, DXC 1.9.2602.17. - `cargo test -p xcl --lib dxil::core_tests -- --test-threads=1`: 17 passed, 0 failed, 1 ignored - `XCL_DIRECT_DXIL=1 cargo test -p xcl --lib gpu_split_wave64 -- --test-threads=1`: 5 passed, 0 failed - `cargo test -p xcl --lib gpu::dxil -- --test-threads=1`: 89 passed, 0 failed, 1 ignored - `cargo test -p xcl --lib -- --test-threads=1`: 849 passed, 0 failed, 22 ignored (no new warnings) **Not tested** - Building, linking and any test run on Windows for the current head, including the new GPU readback test and the DXIL validator checks. GPU re-verification is queued. - Regression run: none for the current head. **AI use** - Claude Opus 5.5 co-authored the original change. - Claude Code (Claude Sonnet 5.5) did the rebase, the LDS fix and its test, the type check, and updated this description.
upipibi commented 2026-11-24 22:06:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by upipibi on 2026-11-24T21:31:34Z.


Two data points for the premise, RTX 3070 (Ampere), driver 616.56, Windows 11:

  • #1727 turned out not to be a barrier hang. The trigger is gpu_sparse_vram_descriptors_buffers_and_xmem re-initialising the backend, which #614 fixes: 0 of 4 whole-lib runs hung with it, 3 of 4 on main (numbers).
  • Exited warps did not hang a plain group barrier here. I ran the HLSL path's gpu_safe_s_barrier_multi_warp_and_early_endpgm with XCL_SAFE_BARRIER=0. The emitted HLSL puts both GroupMemoryBarrierWithGroupSync() inside if (!xcl_skip_end), so the upper console wave's 2 warps skip them and leave main. The lower 2 warps still passed both barriers with the correct LDS values, in 2 of 2 runs. On Ampere, warps that have exited seem to count as arrived.

So the guard may not be what stops a hang on NVIDIA. It still covers Intel, where boykopovar/AnyPS5#26756 reports the ended-wave hang, and it covers waves that skip a barrier but stay alive. A test that hangs or fails without the guard on the RTX 5080 would show which case this PR fixes there. The update below runs this PR.

Update, this PR's direct path: I sent the same test's early-exit shader (128 threads, the upper console wave ends before two s_barriers) through direct_or locally. With XCL_DIRECT_DXIL=1 it then runs on this PR's direct translator. At 9648fe9, RTX 3070:

  • XCL_SAFE_BARRIER=1 (the new guard): passes.
  • XCL_SAFE_BARRIER=0 (SBarrier::Sync, a plain group sync): passes, 2 of 2.

So on Ampere the direct path doesn't hang without the guard either. That is consistent with the HLSL result above.

AI-assisted (Claude Code). Synthetic tests only.

<!-- greyfinch-sync:ivall/xcl:comment:7145045267 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1793#issuecomment-7145045267). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-24T21:31:34Z. --- Two data points for the premise, RTX 3070 (Ampere), driver 616.56, Windows 11: - **#1727** turned out not to be a barrier hang. The trigger is `gpu_sparse_vram_descriptors_buffers_and_xmem` re-initialising the backend, which #614 fixes: 0 of 4 whole-lib runs hung with it, 3 of 4 on `main` ([numbers](https://github.com/xcl-dev/xcl/issues/1727#issuecomment-7144654315)). - **Exited warps did not hang a plain group barrier here.** I ran the HLSL path's `gpu_safe_s_barrier_multi_warp_and_early_endpgm` with `XCL_SAFE_BARRIER=0`. The emitted HLSL puts both `GroupMemoryBarrierWithGroupSync()` inside `if (!xcl_skip_end)`, so the upper console wave's 2 warps skip them and leave `main`. The lower 2 warps still passed both barriers with the correct LDS values, in 2 of 2 runs. On Ampere, warps that have exited seem to count as arrived. So the guard may not be what stops a hang on NVIDIA. It still covers Intel, where boykopovar/AnyPS5#26756 reports the ended-wave hang, and it covers waves that skip a barrier but stay alive. A test that hangs or fails without the guard on the RTX 5080 would show which case this PR fixes there. The update below runs this PR. **Update, this PR's direct path:** I sent the same test's early-exit shader (128 threads, the upper console wave ends before two `s_barrier`s) through `direct_or` locally. With `XCL_DIRECT_DXIL=1` it then runs on this PR's direct translator. At `9648fe9`, RTX 3070: - `XCL_SAFE_BARRIER=1` (the new guard): passes. - `XCL_SAFE_BARRIER=0` (`SBarrier::Sync`, a plain group sync): passes, 2 of 2. So on Ampere the direct path doesn't hang without the guard either. That is consistent with the HLSL result above. AI-assisted (Claude Code). Synthetic tests only.
lewisnic94-max commented 2026-11-24 22:50:12 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by lewisnic94-max on 2026-11-24T22:50:12Z.

Review: COMMENTED


[P1] Guest LDS address aliasing

On a6ace09, the clamp at line 80 maps guest LDS words 8188 and 8191 to the same word. After storing 11 and 22, all 64 threads read [22,22] in three RTX 3080 runs. The merge base returned [11,22]. Exposing only word 8191 restored the expected result while the barrier counters at 8189/8190 remained active.

Please preserve distinct guest addresses and add this two-word GPU readback test.

AI-assisted validation by Codex (GPT-6).

<!-- greyfinch-sync:ivall/xcl:review:6048631461 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1793#pullrequestreview-6048631461). Originally posted by [lewisnic94-max](https://github.com/lewisnic94-max) on 2026-11-24T22:50:12Z. **Review:** COMMENTED --- **[P1] Guest LDS address aliasing** On `a6ace09`, the clamp at line 80 maps guest LDS words 8188 and 8191 to the same word. After storing 11 and 22, all 64 threads read `[22,22]` in three RTX 3080 runs. The merge base returned `[11,22]`. Exposing only word 8191 restored the expected result while the barrier counters at 8189/8190 remained active. Please preserve distinct guest addresses and add this two-word GPU readback test. AI-assisted validation by Codex (GPT-6).
DavidM1911 commented 2026-11-25 00:09:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T23:41:46Z.


Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

<!-- greyfinch-sync:ivall/xcl:comment:7147691994 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1793#issuecomment-7147691994). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T23:41:46Z. --- Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** — needs a rebase before it can be tested.
futurepro62 commented 2026-11-25 00:09:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T23:53:09Z.


Full-suite run, since this PR has no test report yet. Tested exact head a6ace09 (on its base 689f2db).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, 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 --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::dxil::fuzz_tests: 972 passed, 0 failed, 43 ignored. SKIPPED (no wave64): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • The new tests ran and passed: s_barrier_policy_matches_the_recompiler, programs_without_s_barrier_have_no_safe_barrier, multi_wave_s_barrier_is_early_exit_safe, safe_barrier_decrements_on_every_exit, single_wave_s_barrier_is_a_fence, kernel_s_barrier_stays_a_group_sync, safe_barrier_words_live_in_the_lds_block.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 981 passed, 0 failed, 45 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main 62265d3 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (#1651) and the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

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:7147902352 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1793#issuecomment-7147902352). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T23:53:09Z. --- Full-suite run, since this PR has no test report yet. Tested exact head `a6ace09` (on its base `689f2db`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, 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 --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::dxil::fuzz_tests`: **972 passed, 0 failed, 43 ignored**. SKIPPED (no wave64): `a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu`, `a_per_lane_2d_or_3d_group_runs_on_the_gpu`, `coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu`, `cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu`, `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`, `the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu`. - The new tests ran and passed: `s_barrier_policy_matches_the_recompiler`, `programs_without_s_barrier_have_no_safe_barrier`, `multi_wave_s_barrier_is_early_exit_safe`, `safe_barrier_decrements_on_every_exit`, `single_wave_s_barrier_is_a_fence`, `kernel_s_barrier_stays_a_group_sync`, `safe_barrier_words_live_in_the_lds_block`. - Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1`: **981 passed, 0 failed, 45 ignored**. SKIPPED: `f16_programs_on_the_gpu` (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), `f16_programs_on_the_gpu` (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), `f16_programs_on_the_gpu` (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), `f16_programs_on_the_gpu` (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), `f32_programs_on_the_gpu` (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), `f32_programs_on_the_gpu` (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). - `--skip` leaves out tests that fail on main `62265d3` too, not because of this PR. On NVIDIA: `heap_window_out_of_memory_falls_back_to_the_switch_form` (#1651) and the four `gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu` tests ([follow-up on #1651](https://github.com/xcl-dev/xcl/issues/1651#issuecomment-7146069648)) fail because `runner::skip_test` turns their skips into failures under `XCL_REQUIRE_GPU=mesh`, and `gpu::dxil::fuzz_tests` seeds 70, 545, 1019 and 1507 fail `CreateComputePipelineState` with `E_OUTOFMEMORY` on this card (drivers 616.64 and 621.40). On AMD: `fuzz_validate_and_gpu_1` fails on seed 540 (`res[833]` 0x7 vs CPU 0x6). The AMD run does not set `XCL_REQUIRE_GPU`. **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.
Anon64 commented 2026-11-25 01:10:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Anon64 on 2026-11-25T00:18:39Z.


Regression run for this PR: head a6ace09, based on main 689f2db. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release, XCL_NETWORK=0, A pressed every 4 s from 20 s, scripts/smoke.ps1 on a retail title for 60 s, in one batch with the main run.

main 689f2db:

xcl-smoke v1
commit: 689f2db477c3c062cf162649781640ef8a977c18
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1590 (PresentX 1591)
presents per 2 s (last 3): 44 53 35
device removals: 0
crashes: 0
peak commit: 25217 MB

this PR:

xcl-smoke v1
commit: a6ace09a58cb9de261e0ad7e995a246a6196a334
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1602 (PresentX 1603)
presents per 2 s (last 3): 59 44 37
device removals: 0
crashes: 0
peak commit: 24507 MB

No device removals or crashes; 100 % of main's frames, 97 % of its peak commit.

Not tested: the whole suite; the direct DXIL path this PR changes (these runs use the default HLSL path, XCL_DIRECT_DXIL unset).

Written with Claude Code (Claude Opus 5.5) from runs on this machine.

<!-- greyfinch-sync:ivall/xcl:comment:7148374932 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1793#issuecomment-7148374932). Originally posted by [Anon64](https://github.com/Anon64) on 2026-11-25T00:18:39Z. --- Regression run for this PR: head `a6ace09`, based on `main` `689f2db`. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release, `XCL_NETWORK=0`, A pressed every 4 s from 20 s, `scripts/smoke.ps1` on a retail title for 60 s, in one batch with the `main` run. main `689f2db`: ``` xcl-smoke v1 commit: 689f2db477c3c062cf162649781640ef8a977c18 gpu: NVIDIA GeForce RTX 3060 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1590 (PresentX 1591) presents per 2 s (last 3): 44 53 35 device removals: 0 crashes: 0 peak commit: 25217 MB ``` this PR: ``` xcl-smoke v1 commit: a6ace09a58cb9de261e0ad7e995a246a6196a334 gpu: NVIDIA GeForce RTX 3060 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1602 (PresentX 1603) presents per 2 s (last 3): 59 44 37 device removals: 0 crashes: 0 peak commit: 24507 MB ``` No device removals or crashes; 100 % of main's frames, 97 % of its peak commit. **Not tested:** the whole suite; the direct DXIL path this PR changes (these runs use the default HLSL path, `XCL_DIRECT_DXIL` unset). Written with Claude Code (Claude Opus 5.5) from runs on this machine.
mastrr9 commented 2026-11-25 08:08:19 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by mastrr9 on 2026-11-25T07:50:07Z.


Thanks @lewisnic94-max for the clear report and repro. A fix is pushed in e935deb (rebased onto current main).

  • In the non-split form only the barrier's two words, 8189 and 8190, are now taken from the program, instead of clamping everything above 8188. Words 8188 and 8191 stay separate.
  • Your two-word readback is added as gpu_safe_barrier_keeps_lds_words_8188_and_8191_apart.
  • One limit remains: accesses to 8189 or 8190 themselves still go to word 8188, as the 32 KB group-shared block has no spare room for the two counters.
  • From reading the code (not run): the HLSL path on main also clamps to XCL_LDS_TOP 8188 with the safe barrier (recomp/emit.rs). This PR does not change that.

Not yet verified on Windows: this head has only passed a Windows-target cargo check on macOS, so no test has run, including the new one. Windows GPU re-verification is queued for the next PC session.

AI use: Claude Code (Claude Sonnet 5.5) made the fix and wrote this reply.

<!-- greyfinch-sync:ivall/xcl:comment:7156305028 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1793#issuecomment-7156305028). Originally posted by [mastrr9](https://github.com/mastrr9) on 2026-11-25T07:50:07Z. --- Thanks @lewisnic94-max for the clear report and repro. A fix is pushed in `e935deb` (rebased onto current `main`). - In the non-split form only the barrier's two words, 8189 and 8190, are now taken from the program, instead of clamping everything above 8188. Words 8188 and 8191 stay separate. - Your two-word readback is added as `gpu_safe_barrier_keeps_lds_words_8188_and_8191_apart`. - One limit remains: accesses to 8189 or 8190 themselves still go to word 8188, as the 32 KB group-shared block has no spare room for the two counters. - From reading the code (not run): the HLSL path on `main` also clamps to `XCL_LDS_TOP` 8188 with the safe barrier (`recomp/emit.rs`). This PR does not change that. Not yet verified on Windows: this head has only passed a Windows-target `cargo check` on macOS, so no test has run, including the new one. Windows GPU re-verification is queued for the next PC session. AI use: Claude Code (Claude Sonnet 5.5) made the fix and wrote this reply.
lewisnic94-max commented 2026-11-25 09:19:09 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by lewisnic94-max on 2026-11-25T09:19:09Z.

Review: COMMENTED


Reviewed commit e935debf939cba5af6e3ecf3fbd6df5b3b3c29a0.

The original two-address direct-DXIL compute fixture now returns [11, 22] on all 64 lanes for guest LDS words 8188 and 8191. The prior head a6ace09a58 returned [22, 22] on all 64 lanes in three runs. I would retire the P1 for this specific pair.

I also checked the boundary you documented. With the safe barrier enabled, pairs 8188/8189 and 8189/8190 still returned [22, 22] on 64/64 lanes. Both returned [11, 22] with the safe barrier disabled. In lower_mem.rs the unsigned range test redirects exactly words 8189 and 8190 to 8188 on the non-split path. The split path clamps below its exchange and counters. On split wave64, 10/11 stayed distinct and 8188/8191 aliased on all 128 threads with either barrier setting. I would retain the reserved-word limitation in the PR description.

Windows 11 x64, Ryzen 7 5800X, GeForce RTX 3080 (616.92), Rust 1.100.0 MSVC and DXC 1.9.2602.17. One exact regression and two boundary test invocations passed, zero failed, ignored or skipped. These exercised a convergent compute barrier. Mesh shaders, divergent exits and native wave64 were outside this run.

AI assistance: OpenAI Codex (GPT-6) inspected the implementation, analyzed the synthetic test evidence and drafted this review.

<!-- greyfinch-sync:ivall/xcl:review:6054809591 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1793#pullrequestreview-6054809591). Originally posted by [lewisnic94-max](https://github.com/lewisnic94-max) on 2026-11-25T09:19:09Z. **Review:** COMMENTED --- Reviewed commit `e935debf939cba5af6e3ecf3fbd6df5b3b3c29a0`. The original two-address direct-DXIL compute fixture now returns [11, 22] on all 64 lanes for guest LDS words 8188 and 8191. The prior head a6ace09a58cb9de261e0ad7e995a246a6196a334 returned [22, 22] on all 64 lanes in three runs. I would retire the P1 for this specific pair. I also checked the boundary you documented. With the safe barrier enabled, pairs 8188/8189 and 8189/8190 still returned [22, 22] on 64/64 lanes. Both returned [11, 22] with the safe barrier disabled. In lower_mem.rs the unsigned range test redirects exactly words 8189 and 8190 to 8188 on the non-split path. The split path clamps below its exchange and counters. On split wave64, 10/11 stayed distinct and 8188/8191 aliased on all 128 threads with either barrier setting. I would retain the reserved-word limitation in the PR description. Windows 11 x64, Ryzen 7 5800X, GeForce RTX 3080 (616.92), Rust 1.100.0 MSVC and DXC 1.9.2602.17. One exact regression and two boundary test invocations passed, zero failed, ignored or skipped. These exercised a convergent compute barrier. Mesh shaders, divergent exits and native wave64 were outside this run. AI assistance: OpenAI Codex (GPT-6) inspected the implementation, analyzed the synthetic test evidence and drafted this review.
Toons29 commented 2026-11-25 14:10:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Toons29 on 2026-11-25T13:48:24Z.


Regression run of e935debf on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 1a0bbe3a, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1628 (PresentX 1628)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14561 MB
xcl-smoke v1
commit: e935debf939cba5af6e3ecf3fbd6df5b3b3c29a0
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1631 (PresentX 1631)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14593 MB

Against the limits in CONTRIBUTING.md: 100 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; a script posted this right after the run, with both blocks exactly as printed.

<!-- greyfinch-sync:ivall/xcl:comment:7164316969 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1793#issuecomment-7164316969). Originally posted by [Toons29](https://github.com/Toons29) on 2026-11-25T13:48:24Z. --- Regression run of `e935debf` on the retail title, for this PR's **Regression run** section. Both blocks are from `scripts/smoke.ps1` as printed, not edited: `main` on `1a0bbe3a`, this PR on its head commit with no uncommitted changes, same title and time. ``` xcl-smoke v1 commit: 1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6 gpu: AMD Radeon RX 9070 title: 34df7c50 seconds: 60 exit: 0x0 frames shown: 1628 (PresentX 1628) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14561 MB ``` ``` xcl-smoke v1 commit: e935debf939cba5af6e3ecf3fbd6df5b3b3c29a0 gpu: AMD Radeon RX 9070 title: 34df7c50 seconds: 60 exit: 0x0 frames shown: 1631 (PresentX 1631) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14593 MB ``` Against the limits in CONTRIBUTING.md: 100 % of `main`'s frames, 100 % of its peak commit, no crash, no device removal. AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, 60 s, `XCL_NETWORK=0`. This is a regression check only: it does not show whether the run reaches the code this PR changes. AI use: Claude Code (Claude Opus 5.5) built both trees and ran `scripts/smoke.ps1`; a script posted this right after the run, with both blocks exactly as printed.
DavidM1911 commented 2026-11-26 01:05:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T00:29:10Z.


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:7178806246 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1793#issuecomment-7178806246). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T00:29:10Z. --- 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.
thehollowedone commented 2026-11-27 11:06:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-27T11:06:58Z.


Independent Windows GPU check of #1793 head e935debf. The PR description already notes that its safe-barrier storage aliases two guest LDS words. I confirmed that boundary on an RTX 3080 Ti (driver 621.35), Windows 11 build 26300, DXC 1.8.2502.11.

I changed only the existing synthetic GPU test's second LDS address from word 8191 to 8189. With XCL_SAFE_BARRIER=1, cargo test --offline --locked -j 4 -p xcl --lib gpu_safe_barrier_keeps_lds_words_8188_and_8191_apart -- --nocapture --test-threads=1 failed (0 passed, 1 failed, 0 ignored, no GPU skip): wave32 thread 0 read [22, 22] after distinct writes, rather than [11, 22]. With XCL_SAFE_BARRIER=0, the same local fixture passed (1/0/0; wave64 subcase skipped), isolating the storage alias. The switch-off run is only an alias control; it does not validate early-wave-exit synchronization. The unmodified PR-head 8188/8191 test passed its wave32 case and skipped wave64.

Minimal synthetic repro change
diff --git a/crates/xcl/src/gpu/dxil/core_tests.rs b/crates/xcl/src/gpu/dxil/core_tests.rs
@@ -786,13 +786,10 @@
 fn gpu_safe_barrier_keeps_lds_words_8188_and_8191_apart() {
     use crate::gpu::recomp::runner;
-    if !super::group_barrier::safe_barrier_enabled() {
-        return;
-    }
     const LIT: u64 = 255;
     let code = prog(&[
         ("V_MOV_B32", "ENC_VOP1", &[("VDST", 1), ("SRC0", LIT)], Some(4 * 8188)),
-        ("V_MOV_B32", "ENC_VOP1", &[("VDST", 2), ("SRC0", LIT)], Some(4 * 8191)),
+        ("V_MOV_B32", "ENC_VOP1", &[("VDST", 2), ("SRC0", LIT)], Some(4 * 8189)),

This keeps the original test name only to minimize the local repro diff; it would need renaming if adopted.

A correctness-preserving route is to reserve barrier counters only when the actual guest LDS allocation plus translator scratch fits the 32 KiB group-shared limit. For a proven uniform barrier where every wave reaches it, native group sync can preserve the full guest LDS address space without counters. If early exit is possible and there is no room for counters, the translator needs a separately verified scratch mechanism or must refuse that form; simply falling back to HLSL does not resolve this alias because its safe-barrier path also clamps those upper guest words. Keep a full-LDS regression and an early-exit regression separate. This is a design suggestion, not a tested production fix or a GPU-time claim.

The separate #1413 overlaps this PR's cache-switch handling and covers historical HLSL cache identity; please reconcile that during rebase. I also forced an early-exit fixture through Direct DXIL (no HLSL fallback, nonempty DXIL result); it passed on this head and its parent, so it supplies output coverage here but no red/green proof of the new guard. AI use: Codex (GPT-6.2 Sol) ran and checked the GPU controls; Codex (GPT-6.2 Astra) independently traced the LDS and fallback paths.

<!-- greyfinch-sync:ivall/xcl:comment:7216696821 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1793#issuecomment-7216696821). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-11-27T11:06:58Z. --- Independent Windows GPU check of [#1793 head `e935debf`](https://github.com/xcl-dev/xcl/commit/e935debf939cba5af6e3ecf3fbd6df5b3b3c29a0). The PR description already notes that its safe-barrier storage aliases two guest LDS words. I confirmed that boundary on an RTX 3080 Ti (driver 621.35), Windows 11 build 26300, DXC 1.8.2502.11. I changed only the existing synthetic GPU test's second LDS address from word 8191 to 8189. With `XCL_SAFE_BARRIER=1`, `cargo test --offline --locked -j 4 -p xcl --lib gpu_safe_barrier_keeps_lds_words_8188_and_8191_apart -- --nocapture --test-threads=1` **failed** (0 passed, 1 failed, 0 ignored, no GPU skip): wave32 thread 0 read `[22, 22]` after distinct writes, rather than `[11, 22]`. With `XCL_SAFE_BARRIER=0`, the same local fixture **passed** (1/0/0; wave64 subcase skipped), isolating the storage alias. The switch-off run is only an alias control; it does not validate early-wave-exit synchronization. The unmodified PR-head 8188/8191 test passed its wave32 case and skipped wave64. <details><summary>Minimal synthetic repro change</summary> ```diff diff --git a/crates/xcl/src/gpu/dxil/core_tests.rs b/crates/xcl/src/gpu/dxil/core_tests.rs @@ -786,13 +786,10 @@ fn gpu_safe_barrier_keeps_lds_words_8188_and_8191_apart() { use crate::gpu::recomp::runner; - if !super::group_barrier::safe_barrier_enabled() { - return; - } const LIT: u64 = 255; let code = prog(&[ ("V_MOV_B32", "ENC_VOP1", &[("VDST", 1), ("SRC0", LIT)], Some(4 * 8188)), - ("V_MOV_B32", "ENC_VOP1", &[("VDST", 2), ("SRC0", LIT)], Some(4 * 8191)), + ("V_MOV_B32", "ENC_VOP1", &[("VDST", 2), ("SRC0", LIT)], Some(4 * 8189)), ``` This keeps the original test name only to minimize the local repro diff; it would need renaming if adopted. </details> A correctness-preserving route is to reserve barrier counters only when the **actual guest LDS allocation plus translator scratch** fits the 32 KiB group-shared limit. For a proven uniform barrier where every wave reaches it, native group sync can preserve the full guest LDS address space without counters. If early exit is possible and there is no room for counters, the translator needs a separately verified scratch mechanism or must refuse that form; simply falling back to HLSL does not resolve this alias because its safe-barrier path also clamps those upper guest words. Keep a full-LDS regression and an early-exit regression separate. This is a design suggestion, not a tested production fix or a GPU-time claim. The separate [#1413](https://github.com/xcl-dev/xcl/pull/1413) overlaps this PR's cache-switch handling and covers historical HLSL cache identity; please reconcile that during rebase. I also forced an early-exit fixture through Direct DXIL (no HLSL fallback, nonempty DXIL result); it passed on this head and its parent, so it supplies output coverage here but no red/green proof of the new guard. AI use: Codex (GPT-6.2 Sol) ran and checked the GPU controls; Codex (GPT-6.2 Astra) independently traced the LDS and fallback paths.
thehollowedone commented 2026-11-27 11:38:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-27T11:38:21Z.


A stronger GPU regression for #1793 head e935debf, following my earlier LDS alias check. This synthetic one-group fixture has 96 threads: the third native wave exits before s_barrier, while the other two write and read four distinct values at the top of guest LDS. It runs both Direct DXIL and the HLSL path and checks the retired wave's output separately.

With only the test patch on the unchanged PR head, XCL_SAFE_BARRIER=1 cargo test -p xcl --lib gpu_early_exit_preserves_full_lds -- --nocapture --test-threads=1 reported 0 passed, 1 failed, 0 ignored, no GPU skip on RTX 3080 Ti / 621.35, Windows 11 build 26300, DXC 1.8.2502.11. Both surviving waves should read [11,12,13,14]; Direct DXIL read [11,11,11,14] and HLSL read [11,11,11,11]. All 32 retired outputs remained zero. This confirms the HLSL fallback also aliases guest LDS in the case that needs early-exit protection.

Standalone 55-line GPU regression diff
diff --git a/crates/xcl/src/gpu/dxil/core_tests.rs b/crates/xcl/src/gpu/dxil/core_tests.rs
index 30768905..0052290b 100644
--- a/crates/xcl/src/gpu/dxil/core_tests.rs
+++ b/crates/xcl/src/gpu/dxil/core_tests.rs
@@ -603,6 +603,61 @@ fn s_barrier_policy_matches_the_recompiler() {
     }
 }
 
+#[test]
+fn gpu_early_exit_preserves_full_lds() {
+    // A third native wave retires before the other two reach this barrier.
+    use crate::gpu::recomp::{self, dxc, runner};
+    if !super::group_barrier::safe_barrier_enabled() {
+        return runner::skip_test("XCL_SAFE_BARRIER=0");
+    }
+    if runner::wave32_supported() != Ok(true) {
+        return runner::skip_test("no wave32");
+    }
+    if dxc::location().is_err() {
+        return runner::skip_test("no DXC");
+    }
+    let code = prog(&[
+        ("V_READFIRSTLANE_B32", "ENC_VOP1", &[("VDST", 10), ("SRC0", 256)], None),
+        ("S_CMP_GE_U32", "ENC_SOPC", &[("SSRC0", 10), ("SSRC1", 192)], None),
+        ("S_CBRANCH_SCC0", "ENC_SOPP", &[("SIMM16", 1)], None),
+        ("S_ENDPGM", "ENC_SOPP", &[], None),
+        ("V_AND_B32", "ENC_VOP2", &[("VDST", 1), ("SRC0", 131), ("VSRC1", 0)], None),
+        ("V_ADD_NC_U32", "ENC_VOP2", &[("VDST", 2), ("SRC0", 128 + 11), ("VSRC1", 1)], None),
+        ("V_LSHLREV_B32", "ENC_VOP2", &[("VDST", 1), ("SRC0", 130), ("VSRC1", 1)], None),
+        ("S_MOV_B64", "ENC_SOP1", &[("SDST", 2), ("SSRC0", 126)], None),
+        ("V_CMPX_GT_U32", "ENC_VOPC", &[("SRC0", 132), ("VSRC1", 0)], None),
+        ("DS_WRITE_B32", "ENC_DS", &[("ADDR", 1), ("DATA0", 2), ("OFFSET0", 0xf0), ("OFFSET1", 0x7f)], None),
+        S_BARRIER,
+        ("S_MOV_B64", "ENC_SOP1", &[("SDST", 126), ("SSRC0", 2)], None),
+        ("DS_READ_B32", "ENC_DS", &[("ADDR", 1), ("VDST", 5), ("OFFSET0", 0xf0), ("OFFSET1", 0x7f)], None),
+        // global memory at s0 + tid * 4: the word read
+        ("V_LSHLREV_B32", "ENC_VOP2", &[("VDST", 7), ("SRC0", 130), ("VSRC1", 0)], None),
+        ("V_ADD_NC_U32", "ENC_VOP2", &[("VDST", 7), ("SRC0", 0), ("VSRC1", 7)], None),
+        ("V_MOV_B32", "ENC_VOP1", &[("VDST", 8), ("SRC0", 128)], None),
+        ("GLOBAL_STORE_DWORD", "ENC_FLAT_GLBL", &[("ADDR", 7), ("DATA", 5), ("SADDR", 0x7D)], None),
+    ]);
+    let cs = recomp::CsInterface { user_sgprs: 2, ..cs([96, 1, 1]) };
+    let direct = super::kernel::translate_compute(&code, KernelOptions { wave64: false, split: false, mem_windows: 1, sampler_base: 0 }, &cs).unwrap();
+    let opt = recomp::Options { mode: recomp::Mode::Compute(cs), wave64: false, ..Default::default() };
+    let hlsl = recomp::translate(&code, &opt).unwrap();
+    assert!(hlsl.complete(), "{:?}", hlsl.unsupported_why);
+    let fallback = dxc::compile(&hlsl.hlsl, "main", "cs_6_6", &[]).unwrap();
+    let base = 0x100usize;
+    let mut io = vec![0u32; 128];
+    io[0] = base as u32;
+    let mem = vec![0u32; base / 4 + 96];
+    let mut failed = Vec::new();
+    for (backend, dxil) in [("direct", direct.dxil), ("HLSL", fallback)] {
+        let out = runner::dispatch(&dxil, [1, 1, 1], &io, &mem).unwrap();
+        let result = &out[base / 4..];
+        assert!(result[64..].iter().all(|&v| v == 0), "{backend}: exited wave stored");
+        if result[..64].iter().enumerate().any(|(i, &v)| v != 11 + (i % 4) as u32) {
+            failed.push((backend, result[..4].to_vec(), result[32..36].to_vec()));
+        }
+    }
+    assert!(failed.is_empty(), "expected [11, 12, 13, 14] in both surviving waves: {failed:?}");
+}
+
 fn cs(threads: [u32; 3]) -> crate::gpu::recomp::CsInterface {
     crate::gpu::recomp::CsInterface { threads, user_sgprs: 0, tgid: [false; 3], tg_size: false, tid_components: 1 }
 }

I also tested a local, incomplete direct-DXIL improvement: a proven single-block, non-split compute/mesh program uses native group sync and keeps all 8,192 guest LDS words. A four-word GPU fixture turned green, and the focused s_barrier subset reported 9 passed, 0 failed, 0 ignored (one native wave64 subcase skipped). Its eligibility check now excludes an otherwise unflagged halt instruction and has negative tests for indirect PC changes. That fast path does not fix this early-exit regression or split-wave64, so it is not a replacement PR or a merge-readiness claim.

A complete change needs two independently checked paths: keep native sync only where every hardware wave is proven to reach it; for early exits, use barrier bookkeeping that never permanently occupies guest LDS words, including the split-wave mailbox case. If scratch placement depends on an LDS allocation field, verify that it is the effective dispatch allocation before using it; an unknown size must not be treated as free space. Keep full-LDS, early-exit, split-wave, and cache-identity regressions separate, then measure GPU cost and run the required full suite and clean-head smoke pair. AI use: Codex (GPT-6.2 Astra) traced and ran this regression and reviewed the staged design; Codex (GPT-6.2 Sol) checked the findings.

<!-- greyfinch-sync:ivall/xcl:comment:7217305566 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1793#issuecomment-7217305566). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-11-27T11:38:21Z. --- A stronger GPU regression for [#1793 head `e935debf`](https://github.com/xcl-dev/xcl/commit/e935debf939cba5af6e3ecf3fbd6df5b3b3c29a0), following [my earlier LDS alias check](https://github.com/xcl-dev/xcl/pull/1793#issuecomment-7216696821). This synthetic one-group fixture has 96 threads: the third native wave exits before `s_barrier`, while the other two write and read four distinct values at the top of guest LDS. It runs both Direct DXIL and the HLSL path and checks the retired wave's output separately. With only the test patch on the **unchanged PR head**, `XCL_SAFE_BARRIER=1 cargo test -p xcl --lib gpu_early_exit_preserves_full_lds -- --nocapture --test-threads=1` reported **0 passed, 1 failed, 0 ignored, no GPU skip** on RTX 3080 Ti / 621.35, Windows 11 build 26300, DXC 1.8.2502.11. Both surviving waves should read `[11,12,13,14]`; Direct DXIL read `[11,11,11,14]` and HLSL read `[11,11,11,11]`. All 32 retired outputs remained zero. This confirms the HLSL fallback also aliases guest LDS in the case that needs early-exit protection. <details><summary>Standalone 55-line GPU regression diff</summary> ```diff diff --git a/crates/xcl/src/gpu/dxil/core_tests.rs b/crates/xcl/src/gpu/dxil/core_tests.rs index 30768905..0052290b 100644 --- a/crates/xcl/src/gpu/dxil/core_tests.rs +++ b/crates/xcl/src/gpu/dxil/core_tests.rs @@ -603,6 +603,61 @@ fn s_barrier_policy_matches_the_recompiler() { } } +#[test] +fn gpu_early_exit_preserves_full_lds() { + // A third native wave retires before the other two reach this barrier. + use crate::gpu::recomp::{self, dxc, runner}; + if !super::group_barrier::safe_barrier_enabled() { + return runner::skip_test("XCL_SAFE_BARRIER=0"); + } + if runner::wave32_supported() != Ok(true) { + return runner::skip_test("no wave32"); + } + if dxc::location().is_err() { + return runner::skip_test("no DXC"); + } + let code = prog(&[ + ("V_READFIRSTLANE_B32", "ENC_VOP1", &[("VDST", 10), ("SRC0", 256)], None), + ("S_CMP_GE_U32", "ENC_SOPC", &[("SSRC0", 10), ("SSRC1", 192)], None), + ("S_CBRANCH_SCC0", "ENC_SOPP", &[("SIMM16", 1)], None), + ("S_ENDPGM", "ENC_SOPP", &[], None), + ("V_AND_B32", "ENC_VOP2", &[("VDST", 1), ("SRC0", 131), ("VSRC1", 0)], None), + ("V_ADD_NC_U32", "ENC_VOP2", &[("VDST", 2), ("SRC0", 128 + 11), ("VSRC1", 1)], None), + ("V_LSHLREV_B32", "ENC_VOP2", &[("VDST", 1), ("SRC0", 130), ("VSRC1", 1)], None), + ("S_MOV_B64", "ENC_SOP1", &[("SDST", 2), ("SSRC0", 126)], None), + ("V_CMPX_GT_U32", "ENC_VOPC", &[("SRC0", 132), ("VSRC1", 0)], None), + ("DS_WRITE_B32", "ENC_DS", &[("ADDR", 1), ("DATA0", 2), ("OFFSET0", 0xf0), ("OFFSET1", 0x7f)], None), + S_BARRIER, + ("S_MOV_B64", "ENC_SOP1", &[("SDST", 126), ("SSRC0", 2)], None), + ("DS_READ_B32", "ENC_DS", &[("ADDR", 1), ("VDST", 5), ("OFFSET0", 0xf0), ("OFFSET1", 0x7f)], None), + // global memory at s0 + tid * 4: the word read + ("V_LSHLREV_B32", "ENC_VOP2", &[("VDST", 7), ("SRC0", 130), ("VSRC1", 0)], None), + ("V_ADD_NC_U32", "ENC_VOP2", &[("VDST", 7), ("SRC0", 0), ("VSRC1", 7)], None), + ("V_MOV_B32", "ENC_VOP1", &[("VDST", 8), ("SRC0", 128)], None), + ("GLOBAL_STORE_DWORD", "ENC_FLAT_GLBL", &[("ADDR", 7), ("DATA", 5), ("SADDR", 0x7D)], None), + ]); + let cs = recomp::CsInterface { user_sgprs: 2, ..cs([96, 1, 1]) }; + let direct = super::kernel::translate_compute(&code, KernelOptions { wave64: false, split: false, mem_windows: 1, sampler_base: 0 }, &cs).unwrap(); + let opt = recomp::Options { mode: recomp::Mode::Compute(cs), wave64: false, ..Default::default() }; + let hlsl = recomp::translate(&code, &opt).unwrap(); + assert!(hlsl.complete(), "{:?}", hlsl.unsupported_why); + let fallback = dxc::compile(&hlsl.hlsl, "main", "cs_6_6", &[]).unwrap(); + let base = 0x100usize; + let mut io = vec![0u32; 128]; + io[0] = base as u32; + let mem = vec![0u32; base / 4 + 96]; + let mut failed = Vec::new(); + for (backend, dxil) in [("direct", direct.dxil), ("HLSL", fallback)] { + let out = runner::dispatch(&dxil, [1, 1, 1], &io, &mem).unwrap(); + let result = &out[base / 4..]; + assert!(result[64..].iter().all(|&v| v == 0), "{backend}: exited wave stored"); + if result[..64].iter().enumerate().any(|(i, &v)| v != 11 + (i % 4) as u32) { + failed.push((backend, result[..4].to_vec(), result[32..36].to_vec())); + } + } + assert!(failed.is_empty(), "expected [11, 12, 13, 14] in both surviving waves: {failed:?}"); +} + fn cs(threads: [u32; 3]) -> crate::gpu::recomp::CsInterface { crate::gpu::recomp::CsInterface { threads, user_sgprs: 0, tgid: [false; 3], tg_size: false, tid_components: 1 } } ``` </details> I also tested a **local, incomplete** direct-DXIL improvement: a proven single-block, non-split compute/mesh program uses native group sync and keeps all 8,192 guest LDS words. A four-word GPU fixture turned green, and the focused `s_barrier` subset reported **9 passed, 0 failed, 0 ignored** (one native wave64 subcase skipped). Its eligibility check now excludes an otherwise unflagged halt instruction and has negative tests for indirect PC changes. That fast path does not fix this early-exit regression or split-wave64, so it is not a replacement PR or a merge-readiness claim. A complete change needs two independently checked paths: keep native sync only where every hardware wave is proven to reach it; for early exits, use barrier bookkeeping that never permanently occupies guest LDS words, including the split-wave mailbox case. If scratch placement depends on an LDS allocation field, verify that it is the effective dispatch allocation before using it; an unknown size must not be treated as free space. Keep full-LDS, early-exit, split-wave, and cache-identity regressions separate, then measure GPU cost and run the required full suite and clean-head smoke pair. AI use: Codex (GPT-6.2 Astra) traced and ran this regression and reviewed the staged design; Codex (GPT-6.2 Sol) checked the findings.
Foniass commented 2026-11-29 22:29:06 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-11-29T22:29:06Z.


For the record: #3264 (merged, 5dd0bdb3) makes multi-wave s_barrier early-exit-safe in direct DXIL, which is what this PR does. If something here is still missing on main, it could go in a smaller PR on top. Otherwise this one can be closed.

(Claude Code, Claude Opus 5.5, for Foniass)

<!-- greyfinch-sync:ivall/xcl:comment:7263708850 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1793#issuecomment-7263708850). Originally posted by [Foniass](https://github.com/Foniass) on 2026-11-29T22:29:06Z. --- For the record: #3264 (merged, 5dd0bdb3) makes multi-wave `s_barrier` early-exit-safe in direct DXIL, which is what this PR does. If something here is still missing on `main`, it could go in a smaller PR on top. Otherwise this one can be closed. (Claude Code, Claude Opus 5.5, for Foniass)
Foniass commented 2026-12-01 06:48:23 +00:00 (Migrated from github.com)

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


Triage (#1607) – head e935deb

#3264, merged as 5dd0bdb3, solves the same problem on main. In direct DXIL, compute and mesh groups of more than one hardware wave that have an s_barrier use a bounded LDS arrival barrier: Lw::safe_barrier_init / safe_barrier_exit / safe_barrier_sync in lanes.rs, wired in kernel.rs, sopp in lower.rs, and gated by recomp::emit::safe_barrier_wanted. The group_barrier.rs module here is a second implementation of that barrier and conflicts with it.
Recommendation: close (superseded by #3264).

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:7303299128 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1793#issuecomment-7303299128). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T06:48:23Z. --- **Triage (#1607)** – head e935deb #3264, merged as 5dd0bdb3, solves the same problem on main. In direct DXIL, compute and mesh groups of more than one hardware wave that have an `s_barrier` use a bounded LDS arrival barrier: `Lw::safe_barrier_init` / `safe_barrier_exit` / `safe_barrier_sync` in `lanes.rs`, wired in `kernel.rs`, `sopp` in `lower.rs`, and gated by `recomp::emit::safe_barrier_wanted`. The `group_barrier.rs` module here is a second implementation of that barrier and conflicts with it. Recommendation: close (superseded by #3264). AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
throny commented 2026-12-01 12:48:23 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T12:48:23Z.


Closing as superseded: this change is already on main (5dd0bdb3). #3264 merged as 5dd0bdb3 (Foniass, raylitebull's implementation) lowers the early-exit-safe multi-wave s_barrier in Direct DXIL (safe_barrier_init/exit/sync in lanes.rs/kernel.rs/lower.rs, XCL_SAFE_BARRIER=0 off switch); same goal as this PR (which used group_barrier.rs), different code

Two independent checks found this: Foniass's close list on #1607 and ours against current main. If something here is still missing on main, say so and reopen it, or ask and I will.

AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

<!-- greyfinch-sync:ivall/xcl:comment:7311673359 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1793#issuecomment-7311673359). Originally posted by [throny](https://github.com/throny) on 2026-12-01T12:48:23Z. --- Closing as superseded: this change is already on `main` (5dd0bdb3). #3264 merged as 5dd0bdb3 (Foniass, raylitebull's implementation) lowers the early-exit-safe multi-wave s_barrier in Direct DXIL (safe_barrier_init/exit/sync in lanes.rs/kernel.rs/lower.rs, XCL_SAFE_BARRIER=0 off switch); same goal as this PR (which used group_barrier.rs), different code Two independent checks found this: Foniass's close list on #1607 and ours against current `main`. If something here is still missing on `main`, say so and reopen it, or ask and I will. AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

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