Skip to content

Tests: the bridged mask write checks for no barrier past the first branch - #2379

Closed
gefydev wants to merge 1 commit into
xcl-dev:mainfrom
gefydev:lower-dxil-bridged-mask-test-entry-barriers
Closed

gefydev wants to merge 1 commit into
xcl-dev:mainfrom
gefydev:lower-dxil-bridged-mask-test-entry-barriers

Conversation

@gefydev

@gefydev gefydev commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

The test of #2074, a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, fails on main (68a284a) on every machine that has DXC: it wanted exactly one group barrier in the whole program and the program has three. Reported on #2074 by @DarkPanda69 (RX 9070 XT and RTX 3060, main 50a9fde) and traced by @Gevroska: all three barriers are in the entry block, before the first conditional branch, and two of them surround the exchange that computes the whole-wave EXEC condition of s_cbranch_execz, which a change merged after #2074's base added. The guarded float compare still ballots its own half and its block has no barrier, so the property the test protects holds; its count was too coarse.

What is in it

  • crates/xcl/src/gpu/recomp/lower_dxil.rs, in the test module only: the test now wants at least one barrier in the entry block and none past the first conditional branch, where only one half may be. A total of three would have let a barrier move into the guarded block and still pass.

Tested

  • NVIDIA GeForce GTX 1650 4 GB (32-lane waves), driver 621.24, AMD Ryzen 5 1600, 16 GB RAM, Windows 11 Pro 26300, Rust 1.100.0, DXC 1.9.2602.17, debug, CARGO_BUILD_JOBS=2.
  • Reproduced on a clean checkout of main 68a284a: left: 3, right: 1 in 0.02 s (the static count; no GPU run). With the change the test passes in 0.4 s, including its GPU dispatch.
  • With the Recompiler: a bridged mask write in the split form meets no barrier #2074 fix switched off (self.lw.local_masks = false in DxilIr::foreign) the new check fails on a group barrier past the first conditional branch, so it still catches the deadlock the test was written for.
  • cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4 on feb33f2: 1290 passed, 0 failed, 46 ignored. 28 SKIPPED, none on a path this changes: 21 wave64 cases (no wave64 on this GPU), 3 per-lane f16 cases the per-lane form refuses, 1 "no heap windows", 3 for the D3D12 debug layer not being installed.

Regression run

  • No smoke pair: the diff is the test module of a runtime file, no runtime code changes. Per CONTRIBUTING a maintainer can apply the test-only label after reading the diff (12 lines added, 4 removed), which waives the smoke check for this revision.

Reported by others on this PR

Not tested

  • The whole workspace on other machines. I ran nothing on AMD myself; see the reports above.

AI use

  • Claude Code with Claude Sonnet 5.5 reproduced the failure, wrote the change and this description, and ran the checks.

…anch

a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier (xcl-dev#2074) counted the group
barriers of the whole program and wanted exactly one. Since xcl-dev#2074 other changes reached main
(a whole-wave EXEC branch now meets an exchange of its condition in the entry block), so the
program has three, all in the entry block, before the first conditional branch, where every
lane of both halves is. The test failed on every machine with DXC although the property it
protects still holds: the guarded float compare ballots its own half and its block has none.

The test now wants at least one barrier in the entry block and none past the first conditional
branch, where only one half may be. With the xcl-dev#2074 fix switched off, the new check fails on the
barriers of the guarded block, so it still catches the deadlock it was written for. A count of
the whole program would have let a barrier move into the guarded block and still pass.

Found by DarkPanda69 and Gevroska on xcl-dev#2074.
@gefydev

gefydev commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

@raylitebull or anyone with the Triage role: this is the fix for the test of #2074 that fails on main (68a284a) on every machine with DXC (the count of group barriers in the whole program is three now, all in the entry block). It changes only the test module of lower_dxil.rs (12 lines added, 4 removed), so the check is red only for the missing smoke block. If the diff reads as test-only to you, the test-only label would waive that check for this revision, and the PR could then merge. Build and test is green, and the whole suite passed on my GTX 1650: 1290 passed, 0 failed, 46 ignored.

AI use: Claude Code (Claude Sonnet 5.5) wrote this comment for @gefydev.

teidenzero added a commit to teidenzero/xcl that referenced this pull request Nov 25, 2026
The DXIL adapter's half of the VS / PS stages (xcl-dev#1269):

- `DxilIr` sets a VS / PS up in `Lw`'s entry block, as `kernel.rs` does:
  `setup_lanes_gfx`, then xcl-dev#1426's `setup_vertex` / `setup_pixel`, whose
  input loads must come before every use. `graphics_start` hands the
  lowering the initial VGPRs and the lane's bit of the launch EXEC
  (`ballot(true)`, without a PS's helper lanes); `graphics_end` is xcl-dev#1426's
  `finish_gfx`.
- A VS / PS's ballots and lane reads go through `Lw`'s `ballot`, `rla` and
  `read_lane_half`, which know a wave32 program's half in 64-lane hardware
  and see a PS's helper lanes through quad reads.
- `lower_dxil::vertex` / `pixel` give the signed containers.
- The bridge passes an export's EXEC only as the guard, which xcl-dev#1426's
  `export_gfx` takes, as it does for `v_cmpx`: passed as a number, EXEC
  refused every export ("s126: a mask read as a number").

The exports write xcl-dev#1426's output temporaries. These reach `finish_gfx` in
the exit block through `Lw`'s SSA, since the adapter's branches go through
`Lw` (gefydev's point in xcl-dev#1269), so the lowering needs no variable of its
own for them.

Tested on an RTX 4090 (32-lane waves; Windows 10 22H2, DXC 1.8.2502):
- per_lane_vs_and_ps_with_a_branch_before_their_exports_draw_as_the_hlsl_path
  (new): a VS and a PS whose exports follow a branch draw what the HLSL
  path's stages draw for both branch directions, and each links with the
  HLSL path's other stage. It fails without the bridge change (the VS is
  refused) and with the adapter's branches bypassing `Lw` (the VS fails
  validation);
- cargo test --workspace -- --test-threads=1 on main 68a284a with this
  commit: 1289 passed, 2 failed, 46 ignored (lib 1219 passed). Neither
  failure is in this change: main fails
  a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier the
  same way (its test-only fix is xcl-dev#2379), and
  d32s8_targets_take_their_own_size_of_video_memory passes on its own,
  with and without this commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Anon64

Anon64 commented Nov 25, 2026

Copy link
Copy Markdown

Tested feb33f2 (the PR head), and bisected the cause of the failure on main.

Bisect: I bisected main's first-parent history from #2074's base 3da2abb8 to af066dd, applying #2074's commit 254a058 at each step. The first bad commit is fef1d5d, the merge of #2203 (whole-wave branches in split wave64). The test passes on #2074's own head, and on ca04ad6 (the commit just before #2203's merge) with 254a058 applied. So it is the interaction of the two PRs, and neither one is broken on its own. That fits the trace above: the two extra barriers surround the exchange that #2203's whole-wave s_cbranch_execz needs, and they are in the entry block, which every lane of both halves reaches.

Tested:

  • RTX 3060 12 GB (32-lane waves, no wave64), Windows 11 26200, DXC 1.8.2502.11, debug test build.
  • main 68a284a: a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier FAILED (left: 3, right: 1). Barriers at the start, and before and after the exchange, all ahead of the first br.
  • feb33f2: cargo test -p xcl --lib -- gpu::recomp::lower_dxil passed 21, failed 0, ignored 0. The bridged test passed, including its GPU dispatch and readback. 17 SKIPPED lines, all for "no wave64" or a per-lane refusal (V_MUL_F16).

Not tested: the whole workspace on feb33f2, AMD.

AI use: Claude Code, Claude Opus 5.5 ran the bisect and the tests and wrote this report.

@DarkPanda69

Copy link
Copy Markdown

Confirming on the two cards where I first saw the failure on #2074, including AMD (listed as untested) in both its native and split forms: the updated test passes everywhere.

Head feb33f2 applied on main 68a284a, debug, Windows 11 Pro 26200, cargo test -p xcl --lib -- a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier --test-threads=1:

  • RX 9070 XT (RDNA4, 32.0.32029.2010), native wave64: ok
  • RX 9070 XT with XCL_SPLIT_WAVE64=1 (the split form this test's GPU stage is for): ok
  • RTX 3060 (32.0.16.1088): ok

On main 68a284a without this PR the same command fails on both cards. Whole gpu:: filter with this PR: RTX 3060 650 passed, 0 failed; RX 9070 XT 648 passed, 2 failed (the #2115 fuzz seeds only).

AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@gefydev

gefydev commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

@Anon64 @DarkPanda69 thank you both.

@Anon64: the bisect closes the open point of the description. The first bad commit is fef1d5d, the merge of #2203 (whole-wave branches in split wave64), applying #2074's 254a058 at each step from 3da2abb, and the test passes on ca04ad6 just before it. So the two PRs interact and neither is broken alone, as you say. Noted your numbers on feb33f2 (RTX 3060 12 GB, DXC 1.8.2502.11): gpu::recomp::lower_dxil 21 passed, 0 failed, the bridged test passing with its GPU dispatch, 17 SKIPPED lines for "no wave64" or a per-lane refusal.

@DarkPanda69: noted the AMD results, which the description listed as untested: the bridged test passes on an RX 9070 XT in native wave64 and with XCL_SPLIT_WAVE64=1, and on an RTX 3060, and fails on both cards without this PR. gpu:: with the PR: RTX 3060 650 passed, 0 failed; RX 9070 XT 648 passed, 2 failed, only the #2115 fuzz seeds.

I added both reports to the description. What is left is the test-only label from a maintainer.

AI use: Claude Code (Claude Sonnet 5.5) wrote this comment for @gefydev.

@raylitebull

Copy link
Copy Markdown
Member

Diff review on exact head feb33f2 looks clean (entry block keeps >= 1 group barrier while past the first br i1 has 0), Build and test is green, and both AMD (RX 9070 XT native + XCL_SPLIT_WAVE64=1) and NVIDIA (RTX 3060, GTX 1650) checks pass.

Two items remain before merge:

  1. PR description is still failing (needs either the test-only label from a maintainer or paired xcl-smoke v1 output).
  2. #2420 addresses the same failing test, so only one of the two should land.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@ivall

ivall commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Thank you for this one, and for finding the cause first. #2420 fixes the same test and was merged before I had seen this PR; that was my mistake, this was here earlier. The check of at least one barrier in the entry block is stronger than what is on main now: if you rebase down to that, I will take it.

AI use: Claude Code (Claude Opus 5.5) wrote this on the maintainer's behalf.

@gefydev

gefydev commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

Closing: main already has c828d8c, which fixes the same test, so this branch is empty after a rebase. Thank you @Anon64, @DarkPanda69, @raylitebull and @DavidM1911 for the bisect and the runs.

AI use: Claude Code (Claude Sonnet 5.5) wrote this comment for @gefydev.

@gefydev gefydev closed this Nov 25, 2026
@gefydev
gefydev deleted the lower-dxil-bridged-mask-test-entry-barriers branch November 25, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants