Skip to content

Recompiler: split wave64 halves meet before each LDS access - #1252

Open
not-rex wants to merge 3 commits into
xcl-dev:mainfrom
not-rex:w64-lds-order
Open

not-rex wants to merge 3 commits into
xcl-dev:mainfrom
not-rex:w64-lds-order

Conversation

@not-rex

@not-rex not-rex commented Nov 24, 2026 •

Copy link
Copy Markdown

On GPUs with 32-lane waves only, a console wave64 program runs as two hardware wave32s ("halves"), and nothing ordered their LDS accesses. A console wave runs an instruction in all 64 lanes before the next one, so a lane reads the LDS word another lane wrote an instruction earlier without an s_barrier. Split, a read could run before the other half's write (it got a stale word) or after that half's later write. The halves now meet before every LDS access. Part of #675 (plan: #675 (comment)).

To reproduce on a GPU with 64-lane waves (AMD): XCL_SPLIT_WAVE64=1 forces the split form there, so cargo test -p xcl --lib split_wave64 runs the same path as on NVIDIA.

What is in it

  • crates/xcl/src/gpu/recomp/emit.rs (17 lines): x64_lds_meet() emits xcl_x_meet(); in the split form in kernel, compute and mesh mode. The DS handler calls it before each LDS access (ds_read*, ds_write*, the ADDTID forms, the 8 / 16-bit and d16 forms, the LDS atomics), once the access is known to be translated: a refused one (GDS, an unknown DS op) gets none. Nothing is exchanged: the meeting waits for the other half's arrival count (spin form) or is a group barrier (XCL_WAVE64_SPIN=0), so each half's earlier instructions are done before the access. Both halves run the same instruction stream, so their exchange counts stay in step. Geometry mode is unchanged. ds_bpermute and ds_swizzle do not touch LDS and are unchanged. Native wave64 and wave32 translations are unchanged.
  • crates/xcl/src/gpu/recomp/tests.rs:
    • split_wave64_meets_before_each_lds_access (no GPU, so CI and a wave64 machine run it): the emitted HLSL of the test program has six xcl_x_meet(); in the split form and none natively, as a wave32 program, or for a GDS access.
    • gpu_split_wave64_lds_follows_instruction_order: a wave64 compute program in groups of one console wave (64 threads) and of four (256 threads, the counter-paired form), 1,024 groups each. Lanes 32..63 write a word each, lanes 0..31 read them and write a second bank, lanes 32..63 read that and overwrite the first bank, lanes 0..31 overwrite the second. The EXEC masks are constants, so no exchange lies between the accesses. The values carry the group, so a word another group left in the LDS does not pass. It runs natively where the GPU has 64-lane waves and skips without a GPU or DXC.
  • docs/wave64-on-wave32.md: a row in the exchange table, hazard 6 (LDS order), and LDS accesses added to the cost paragraph. Hazard 6 also says what the meeting does not do: it orders instructions, not the lanes of one instruction, and geometry mode assumes ES code reads no other lane's item before the s_barrier.

Follow-up commits (after the RTX 3060 report below; review asked for them as separate commits)

  • 8a79b8e leaves out meetings that order nothing: a read right after a read in the same basic block, and any access with an exchange (itself a meeting) between it and the block's previous LDS access. Block starts, writes, atomics and reads after writes still meet. Em::new now takes the block starts, so no caller can elide across blocks by leaving them empty. On a read-heavy test program the meetings go from 8 to 5; on the retail title's 370 wave64 compute and mesh programs with LDS (@erickbobd's census in the comments) from 11,127 to 6,694 statically (−39.8 %).
  • 2473e2f adds XCL_WAVE64_LDS_ORDER=0, which leaves the meetings out entirely (default on), so anyone can A/B them; set, it bypasses the translation caches like XCL_WAVE64_SPIN.
  • New tests: a local mask (v_cmp into VCC never read whole) is not a meeting, a loop head meets, and a read run with and without an exchange is checked on the GPU in 64- and 256-thread groups. Builds with a meeting wrongly elided fail them.

Rebased again on main 1a0bbe3a (head c483200): the conflicts were neighbours only (img_writes beside x64_lds / block_starts in Em, XCL_DXIL_NO_OPT beside XCL_WAVE64_LDS_ORDER in the cache-bypass list and its test); the change is the same (+306/-5). The RTX 3080 suite and smoke runs below are from this head. Before that, on main 8f5fca5b (head 0141ee9): main moved the GDS check in ds() above the ADDTID branch and rewrote write_mask; the meeting now sits after main's single GDS check, and x64_met() before the new ballot_px_quad match. RTX 5070 Ti (Windows Sandbox, GPU-PV): split_wave64 14 of 14; full suite 1100 passed, 8 failed, the same 8 that fail on main there.

Not covered: the direct RDNA2-to-DXIL path (#1426, gpu/dxil/lower_mem.rs, opt-in with XCL_DIRECT_DXIL) has its own split form and the same LDS ordering gap; this PR only changes the HLSL path.

Tested

  • RTX 3080, cargo test --workspace -- --test-threads=4 at the head c483200 (on main 1a0bbe3a): 1256 passed, 0 failed, 46 ignored; the SKIPPED lines are main's new lower/lower_dxil GPU agreement tests, the two no-wave64 tests and pso_measurement_compiles_an_exact_synthetic_record.

  • NVIDIA GeForce RTX 3080 10 GB (driver 610.88 / 32.0.16.1088, 32-lane waves), AMD Ryzen 9 5900X, Windows 11 Pro 26200; Rust 1.100.0 stable-x86_64-pc-windows-msvc; tests in the default (debug) profile, smoke runs in release.

  • cargo test --workspace -- --test-threads=4 at the head 2473e2f: 747 passed, 0 failed, 41 ignored (at 77a8190: 743 passed, 0 failed, 41 ignored) (SKIPPED GPU tests: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask and gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware, both "no wave64").

  • RTX 3080, separate runs of each test, the final form of the test with the meetings taken out (same test file, emit.rs as on main) and at this commit:

    test, variant without the meetings with them
    gpu_split_wave64_lds_follows_instruction_order, default (spin form) 0 of 20 pass; 45,588 to 54,028 of 65,536 threads wrong 20 of 20
    the same, XCL_WAVE64_SPIN=0 (barrier form) 0 of 10; 30,860 to 32,112 wrong 10 of 10
    split_wave64_meets_before_each_lds_access (no GPU) fails passes
  • RTX 5070 Ti through GPU-PV in Windows Sandbox (32-lane waves; the guest reports driver 10.0.26100.1150), Rust 1.100.0, debug, cargo test --workspace --frozen --no-fail-fast -- <filter> --test-threads=4.

  • First form of the GPU test (64-thread groups only) and of the change (the meeting one line earlier in the DS handler), 20 separate runs per variant:

    variant without the meetings with them
    default (spin form) 0 of 20 pass; 47,492 to 50,080 of 65,536 threads wrong 20 of 20
    XCL_WAVE64_SPIN=0 (barrier form) 0 of 20; 26,048 to 27,360 wrong 20 of 20
    filter split_wave64 --include-ignored (the five other gpu_split_wave64_* tests, mesh_split_wave64_form and bench_split_wave64 in the same process, 4 threads) 0 of 20; 41,860 to 50,688 wrong 20 of 20

    Wrong values seen: 0 (read before the other half's write) and the overwriting value (read after its later write).

  • This commit's tree, filter split_wave64, 5 separate runs: 8 passed, 0 failed, 1 ignored in each. With the meetings taken out and only the 256-thread groups run: 0 of 5 pass, 237,824 to 239,936 of 262,144 threads wrong, and split_wave64_meets_before_each_lds_access fails (0 meetings, not 6).

  • Whole suite, this commit's tree: 741 passed, 2 failed, 41 ignored; SKIPPED gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware (no wave64). The failures are launcher::tests::console_detection (it reads System32\notepad.exe; the sandbox image has none) and hle::d3d12x::fence_x::tests::the_cell_follows_the_fence (left 7, right 9), which did not fail in the run of the first form (741 passed, 1 failed).

  • Cost, same GPU, first form: the test's program (6 LDS accesses in 28 instructions) goes from 1 exchange to 7. GPU time of a 16,384-group dispatch, median of 9, two rounds: 0.046 to 0.120 and 0.123 ms in the spin form (2.6 times), 0.035 to 0.035 and 0.036 ms in the barrier form.

Regression run
RTX 3080, scripts/smoke.ps1, 300 s each, menus only (fresh data), main 1a0bbe3a (this PR's base) and then this PR's head c483200:

xcl-smoke v1
commit: 1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6
gpu: NVIDIA GeForce RTX 3080
title: 06a19912
seconds: 300
exit: 0x0
frames shown: 8233 (PresentX 8233)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15316 MB
xcl-smoke v1
commit: c4832004e3667339fb100ab04d789b48ca737d57
gpu: NVIDIA GeForce RTX 3080
title: 06a19912
seconds: 300
exit: 0x0
frames shown: 8240 (PresentX 8240)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15328 MB

In the world (RTX 3080, main 930e8b4 + #1123 + #1254, warm data and caches, XCL_PSO_WAIT_MS=50, A at 30 and 40 s, 400 s; one run each):

main + 77a8190 + head (2473e2f) head, XCL_WAVE64_LDS_ORDER=0
first ListX #101 90.3 s 68.2 s 89.3 s 91.7 s
presents after #101 12 167 27 18
GPU queue.Wait timeouts (first) 18 (125.1 s) 12 (131.8 s) 9 (132.9 s) 19 (135.3 s)
end 0x887A0006 168.5 s watchdog +0x23cf683 178.4 s 0xC0000005 +0x2215c35 158.5 s 0x887A0006 160.7 s
peak commit 31.9 GB 32.6 GB 32.7 GB 33.0 GB
allocators put aside / E_OUTOFMEMORY none none none none

All four stop in the same GPU-side stall 35-55 s after #101 (GPU at 100 % until the end), with or without the meetings, so on this card the meetings don't change the world; the RTX 3060 regression report below is not reproduced here.

Not tested

  • A GPU with 64-lane waves (AMD): the new tests, the unchanged native path, and XCL_SPLIT_WAVE64=1 there (since run by a reviewer on an RX 9070 XT, see the comments).
  • Linux / Mesa RADV: there the meeting's poll is hoisted out of its loop (gpu_geometry_wave32_prefix_count_over_a_mask: flaky on AMD (load-sensitive) - NVIDIA wave32 rigs skip it, so AMD is the only place it runs #847), so it orders nothing until Recompiler: split wave64 spin loops poll with a compare-exchange, not an add of 0 (#847) #1244's compare-exchange poll is in.
  • Mesh mode and kernel mode on the GPU with an LDS program: the new GPU test is compute mode only. The existing mesh and kernel tests pass.
  • On the RTX 5070 Ti: the 20-run matrix and the timing for the final form of the test and of the change (5 runs of the split_wave64 filter instead). On the RTX 3080: the run under load and the timing.
  • Same-instruction conflicts: lanes of both halves writing or atomically updating one word in one instruction are still not in the console's order.
  • The retail title: no count of wave64 compute or mesh programs that use LDS, how many exchanges the meetings add per frame there, or whether any dispatch gets slower. One exchange per LDS instruction is paid in loops too; the spin form is the expensive one (2.6 times for the test's LDS-only program). A per-basic-block tracker could skip a meeting when another exchange already lies between the access and the block's previous LDS access; that is a possible follow-up, not in this PR.
  • Exchange timeouts (xcl_x_dead) in a real run. More exchanges mean more places where a pair that is already out of step waits out its 2^20 polls.
  • Whether the title reaches a split wave64 program with LDS at all: in both 300 s runs it stayed in its first-run screens and menus (no world loading).

AI use

  • Claude Code with Claude Fable 5.2 wrote the code, the tests and the doc lines and ran the Sandbox runs above; Claude Opus 5.5 reviewed the change and worked on this description. Claude Code (Claude Opus 5.5) wrote the two follow-up commits and their tests after an Opus review, and ran the RTX 3080 suite, test, smoke and world runs on my machine.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

  • cargo test -p xcl --lib lib recomp: 191 passed, 0 failed.

Thanks!

@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

I read the ordering argument through and it holds. With a meet before every access, a half can be at most one access ahead of the other, and the GroupMemoryBarrier() on each side of the arrival count makes the earlier LDS writes visible. Three things to weigh:

  1. On Mesa/RADV the meet does not order anything until Recompiler: split wave64 spin loops poll with a compare-exchange, not an add of 0 (#847) #1244 lands. xcl_x_meet polls with InterlockedAdd(…, 0u, c), and Mesa's NIR hoists that load out of the spin loop (gpu_geometry_wave32_prefix_count_over_a_mask: flaky on AMD (load-sensitive) - NVIDIA wave32 rigs skip it, so AMD is the only place it runs #847: one ds_load before the loop, none in it). So on RADV a half that arrives late is never seen: the waiting half spins out its 2^20 polls, sets xcl_x_dead, and runs on unordered. Your XCL_SPLIT_WAVE64=1 reproduction on AMD would pass on Windows drivers and still fail under load on Linux. Recompiler: split wave64 spin loops poll with a compare-exchange, not an add of 0 (#847) #1244 changes the poll to a compare-exchange; the two touch different parts of emit.rs and merge cleanly.
  2. Cost in loops. On an RTX 3070, I measured a meet at about 0.23 µs (Newer retail title (TitleID 7952987A): reaches world loading, then the title's GPU watchdog ("GPU Loc Sig") after ListX #101 stub #505: one exchange per iteration, 64-thread groups). A loop that runs to the LOOP_GUARD budget therefore costs about 15 ms more per wave for each LDS access in its body. Newer retail title (TitleID 7952987A): reaches world loading, then the title's GPU watchdog ("GPU Loc Sig") after ListX #101 stub #505's stalled programs are loops of that kind, with 3–4 exchanges already. Your test's 2.6x is the same effect.
  3. A cheap reduction: a read needs no meet when the access before it in straight-line code (no branch target between them) was also a read. Two reads cannot conflict, and the meet before the first read already ordered both after the other half's earlier writes. A write, or a read after a write, still needs one. LDS-heavy code that reads a table several times in a row would keep most of its speed.

Not run here; read from the diff, plus the timing from #505.

AI-assisted (Claude Code).

@teidenzero

Copy link
Copy Markdown
Contributor

RTX 4090 (Ada, 32-lane waves) at 77a8190: the 20-run matrix and the timing of the final form

Machine: NVIDIA GeForce RTX 4090 24 GB, driver 621.24 (32.0.16.2124), 32-lane waves; AMD Ryzen 7 3700X; Windows 10 Pro 22H2 build 19045.6466 with the D3D12 Agility SDK 1.620.2; Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug; DXC 1.8.2502.11 (Windows SDK 10.0.26100).

Whole suite at this commit, cargo test --workspace --no-fail-fast -- --test-threads=4: 743 passed, 0 failed, 41 ignored; SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.

Matrix, 20 separate cargo test processes per cell. "Without the meetings" is this commit with x64_lds_meet() emitting nothing (a local change, same test file). Without them the test stops at the 64-thread groups, so the 256-thread rows ran a local copy of the test with only those groups.

run without the meetings with them
gpu_split_wave64_lds_follows_instruction_order, spin form (default) 0 of 20; 50,028 to 51,840 of 65,536 threads wrong 20 of 20 (both group sizes)
the same, XCL_WAVE64_SPIN=0 0 of 20; 37,152 to 38,208 of 65,536 20 of 20 (both group sizes)
256-thread groups only, spin form 0 of 20; 185,960 to 193,728 of 262,144 in the rows above
256-thread groups only, XCL_WAVE64_SPIN=0 0 of 20; 189,032 to 195,712 of 262,144 in the rows above
filter split_wave64 -- --include-ignored --test-threads=4 (9 tests, one process) 0 of 20: the two new tests fail, the other 7 pass 20 of 20

Wrong values in the quoted examples: 0 (read before the other half's write) and the overwriting values (3 << 28 | n, 4 << 28 | n). In 2 of the 20 filter runs, two early reads returned 0x1 and 0x9FF, which this program never writes (presumably LDS left by another test in the same process).

GPU time of a 16,384-group dispatch, median of 9 (runner::dispatch_timed, from a local ignored test), round 1 / round 2:

groups form without the meetings with them
64 threads spin 0.0236 / 0.0236 ms 0.0563 / 0.0553 ms (2.4×)
64 threads XCL_WAVE64_SPIN=0 0.0205 / 0.0205 ms 0.0225 / 0.0215 ms
256 threads spin 0.0307 / 0.0297 ms 0.0676 / 0.0676 ms (2.2–2.3×)
256 threads XCL_WAVE64_SPIN=0 0.0307 / 0.0297 ms 0.0676 / 0.0676 ms

On this GPU the barrier form avoids the cost only for the 64-thread groups: the 256-thread groups take the same time with and without XCL_WAVE64_SPIN=0, so for this program they pay about 2.3× either way.

Not tested

AI use

  • Claude Code (Claude Opus 5.5) ran the tests, made the local changes for the "without" column and the timing test, and drafted this comment.

@IvyNotFound

Copy link
Copy Markdown

Retail run on an RTX 5080 (32-lane waves): 77a8190 merged onto main 930e8b4 – no device removal, the split-wave64 programs run into world loading; the #505 GPU-wait stalls are still there, and one of two runs ended in the title's 0xc0000409 as some main runs do

Tested

main 930e8b4 PR, run 1 PR, run 2
exit / device removals 0x0 / 0 0x0 / 0 0xc0000409 at ~126 s / 0
frames shown 1434 1433 – (did not reach its end)
peak commit 33 004 MB 33 920 MB 41 321 MB
GPU queue.Wait … did not complete within 5000 ms 19, first at 118.6 s 24, first at 122.5 s 48, first at 115.2 s
xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: NVIDIA GeForce RTX 5080
title: game
seconds: 140
exit: 0x0
frames shown: 1434 (PresentX 1435)
presents per 2 s (last 3): 1 0 0
device removals: 0
crashes: 0
peak commit: 33004 MB
xcl-smoke v1
commit: 03b6de1a62ff4dcc264af87c202d9f76c98bdca1
gpu: NVIDIA GeForce RTX 5080
title: game
seconds: 140
exit: 0x0
frames shown: 1433 (PresentX 1438)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 33920 MB

Not tested

  • the whole suite at this merge
  • whether the meetings change any picture: the title shows no world frame here either way

AI use

  • Claude Code, Claude Opus 5.5: merged and built the PR, ran the runs, read the logs and wrote this report.

@DarkPanda69

DarkPanda69 commented Nov 24, 2026 •

Copy link
Copy Markdown

Update for head c483200: same result. Applied on main 1a0bbe3, both GPU tests (gpu_split_wave64_lds_follows_instruction_order, gpu_split_wave64_lds_read_run_follows_instruction_order) pass on the RX 9070 XT (native wave64) and the RTX 3060 (split wave64). With XCL_SPLIT_WAVE64=1 on the RX 9070 XT, paired against main: the only differences are this PR's 6 new tests (all ok). Whole gpu:: filter: RX 9070 XT 635 passed, 2 failed (the #2115 fuzz seeds, same on main); RTX 3060 637 passed, 0 failed.


AMD run with 64-lane waves, which the other reports here don't cover. Updated for head 0141ee9 (earlier runs on 77a8190 and 2473e2f, same result).

Tested: pass, head 0141ee9 as is (it no longer applies as a patch on main aaa0936), debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17.
cargo test -p xcl --lib -- gpu::recomp --test-threads=4:

adapter mode result
AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010, waves 32..64 native wave64 347 passed, 0 failed, 19 ignored
AMD RX 9070 XT XCL_SPLIT_WAVE64=1 (split form on 64-lane hardware) 347 passed, 0 failed, 19 ignored
NVIDIA RTX 3060, driver 32.0.16.1088, waves 32 only split 347 passed, 0 failed, 19 ignored

gpu_split_wave64_lds_follows_instruction_order and gpu_split_wave64_lds_read_run_follows_instruction_order ok in all three.

Not tested: XCL_WAVE64_LDS_ORDER=0; mesh and kernel mode with an LDS program; the whole workspace suite; a title.

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

@not-rex

not-rex commented Nov 24, 2026

Copy link
Copy Markdown
Author

Thanks all. @teidenzero's matrix (RTX 4090) and @DarkPanda69's RX 9070 XT run (native wave64 and XCL_SPLIT_WAVE64=1) cover two of the "Not tested" lines, and @IvyNotFound's retail run shows no device removal with the meetings in the world load.

@upipibi, on your three points:

  1. RADV: agreed. On Mesa the meeting only orders anything once Recompiler: split wave64 spin loops poll with a compare-exchange, not an add of 0 (#847) #1244's compare-exchange poll is in, since a hoisted load never sees the late half. The two merge cleanly; this PR changes nothing for the hoisting itself. I'll mention it under "Not tested" (Linux/RADV).
  2. Cost in loops: yes, that is the price of one meeting per LDS access. I'd keep this PR as the correctness fix the reports above measured.
  3. Read after read: I agree it is safe. Both halves run the same straight-line stream, so between two reads with no branch target, write or atomic in between, the other half can only be reading too. The meeting before the first read already orders both reads after its earlier writes, and the next write's meeting waits for this half to finish the second read. I'll do it as a follow-up PR with its own test (a run of reads, then a write, checked against the same LDS test), so the evidence on this one stays valid.

AI use: Claude Code (Claude Opus 5.5) worked through the read-after-read argument and wrote this reply.

@Rodriguerra

Copy link
Copy Markdown

Tested this on real hardware (NVIDIA RTX 3060 12 GB, driver 32.0.16.1088, Windows 11 26200, wave32 split-wave64) on a retail title entering a heavy 3D world with Mesh Shaders + compute passes:

  • Without Recompiler: split wave64 halves meet before each LDS access #1252: 0 present readback timeouts, only 4 allocator resets across ~13 min, 16 GPU queue.Wait timeouts, local VRAM stayed flat (~13.9 GB, no crash).
  • With Recompiler: split wave64 halves meet before each LDS access #1252: the moment 3D Mesh Shader / compute passes started (11.5k dispatches / 4.9k draws), every 3D frame stalled the GPU past 2000 ms (present: frame dump copy: GPU fence still pending after 2000 ms x3), GPU queue.Wait timeouts jumped 10x (16 -> 159), and alloc_pool piled up 160 put-aside PC command allocators (160 made, 160 put aside), pushing local VRAM from 9.0 GB -> 21.7 GB and process commit to 39.1 GB until E_OUTOFMEMORY (0x8007000e).

Putting an unconditional xcl_x_meet() spin-barrier before every ds_read/ds_write/ds_atomic in real wave32 shaders seems to cause severe warp-scheduler stalls / livelock on NVIDIA when shaders do frequent or divergent LDS ops. Might need either a hazard/liveness check (only emitting when a write can cross halves) or an opt-in switch until NVIDIA wave32 overhead is addressed.

@not-rex
not-rex marked this pull request as draft November 24, 2026 15:56
@not-rex

not-rex commented Nov 24, 2026

Copy link
Copy Markdown
Author

@Rodriguerra thanks, that is a serious result and I'm treating it as one. I've moved this PR to draft until it is understood.

A few details would help me reproduce it:

  • the tree: base commit and any other PRs merged in (several open PRs change the same split-wave64 code or the waits);
  • whether it was the default spin form or XCL_WAVE64_SPIN=0 – one run with XCL_WAVE64_SPIN=0 would show whether the spin itself is the cost;
  • where the 21.7 GB local video memory figure comes from (DXGI's local usage on a 12 GB card, or something else).

One note on scope: the meetings are only emitted for console wave64 programs in the split form (xcl_x_meet() between the two 32-lane halves). Programs that are wave32 on the console are not touched. A program that does many LDS accesses in a loop does pay one meeting per access, and @upipibi measured that at about 0.23 µs each, so a heavy LDS loop can get much slower; I didn't measure that in a world.

What I'll do: our RTX 3080 now gets into world loading, so I'll run main and this PR there back to back with the same settings and post the counts (frames, GPU-wait timeouts, allocators put aside, commit). In parallel, @upipibi's read-after-read reduction cuts the meetings in read-heavy code; I'll measure how much it removes in the title's programs before deciding whether this needs a switch or a narrower rule (only where a write can cross halves, as you suggest).

AI use: Claude Code (Claude Opus 5.5) helped read the report and write this reply.

@not-rex

not-rex commented Nov 24, 2026

Copy link
Copy Markdown
Author

RTX 3080 (10 GB, driver 610.88), retail title into the world: main vs this PR, one run each. I don't see the RTX 3060 regression here.

Tree: main 930e8b4 + #1123 + #1254 (our diagnostics), with and without 77a8190, release. Same warm data and caches, XCL_PSO_WAIT_MS=50, A at 30 and 40 s, 400 s limit, XCL_ACTIVITY=1. Presents are summed from the 2 s activity lines (no run reached its end, so there is no smoke block).

main + this PR + this PR, XCL_WAVE64_SPIN=0
first ListX #101 90.3 s 68.2 s 88.1 s
presents after #101 12 167 17
last present 124.1 s 128.1 s 144.1 s
GPU queue.Wait … did not complete within 5000 ms 18 (first 125.1 s) 12 (first 131.8 s) 30 (first 140.7 s)
"would close a GPU cycle" 5 8 36
end 0x887A0006 at 168.5 s title watchdog +0x23cf683 at 178.4 s 0x887A0006 at 156.7 s
peak commit 31.9 GB 32.6 GB 31.8 GB
allocators put aside / E_OUTOFMEMORY none none none

In all three the GPU sits at 100 % from about 122-126 s, with video memory at the card's 9.9 GB, until the hang or the watchdog: the same GPU-side stall about 35-55 s after #101, with or without the meetings. With one run each I read the differences as noise. The 159 timeouts, the 160 put-aside allocators and the out-of-memory from the RTX 3060 report don't appear on this card.

So far that is one 3080 against one 3060 with an unknown tree, so I'm keeping this in draft until @Rodriguerra's details are in. Meanwhile I'm testing @upipibi's read-after-read reduction and an XCL_WAVE64_LDS_ORDER=0 switch as a follow-up commit, which would make the meetings cheaper and let anyone A/B them.

Not tested: more than one run per arm; the RTX 3060; Linux/RADV.

AI use: Claude Code (Claude Opus 5.5) ran the three runs on my machine through a scripted runner and wrote this comment.

@WebIdentity1

WebIdentity1 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Independent Kernel and Mesh LDS execution validation of 77a8190e4528a135cb0ed9fd7de9a31e5699371f. Test-only fixtures below; no runtime changes or competing PR. This fills the previously untested mode coverage, within the synthetic cases described here.

Tested — Kernel
Reuse this PR's lds_order_program with Options { mode: Mode::Kernel, wave64: true, .. } selected through on_gpu. Eight single-console-wave dispatches with different synthetic group tags;64 lanes each. Every lane's v4/v5 and corresponding GLOBAL_STORE_DWORDX2 output are checked against independent CPU expectations.512 lane checks per variant. The split translation is asserted to have exactly six xcl_x_meet(); calls; native wave64 has zero.

Adapter / variant PR translation Only six LDS meetings removed
RTX3090, split, XCL_WAVE64_SPIN=1 1 passed,0 failed;0 wrong lanes 0 passed,1 failed;512 wrong lanes
RTX3090, split, XCL_WAVE64_SPIN=0 1/0;0 wrong lanes 0/1;512 wrong lanes
AMD integrated, native wave64 1/0;0 wrong lanes not applicable
AMD integrated, forced split, spin1 1/0;0 wrong lanes 0/1;512 wrong lanes
AMD integrated, forced split, spin0 1/0;0 wrong lanes 0/1;512 wrong lanes

All runs:0 ignored, no skips/timeouts. Negative runs exit101 on the output assertion, positives exit0. The control removes only those six calls from the translated HLSL before DXC, preserving the rest of the emitted program and CPU expectations; it does not remove other exchange mechanisms or alter the runtime source. Both selected adapter names and split status print in the logs.

Command, each variant in a fresh process:
cargo test --locked -p xcl --lib gpu_kernel_split_wave64_lds_order_probe -- --test-threads=1 --show-output --nocapture

Set XCL_ADAPTER=3090 / AMD and XCL_WAVE64_SPIN=1 / 0. On AMD set XCL_SPLIT_WAVE64=1 for forced split; unset it for native. Set local diagnostic XCL_PROBE_OMIT_LDS_MEETS=1 only for the negative control, otherwise unset. Kernel fixture/source was identical across its matrix; all 221 source hashes matched the Windows tree. The Mesh fixture below was appended afterward; the Kernel fixture itself is unchanged. The patch reverse-apply check passes against the instrumented source.

Tested — Mesh
The real Mode::Mesh translation executes through the existing two-pass runner: translated compute shader writes mesh records, native passthrough mesh shader consumes them, pixel shader renders green/red according to the LDS-derived vertex attribute. Reuses this PR's LDS program with Mesh input initialization. Two groups each at 64 and 128 threads: checks headers, primitive indices, 384 vertex attribute records against a CPU oracle, and six pixels (two triangle interiors and one clear pixel per group size). Exactly six LDS meeting calls in split HLSL, zero in native; omission control removes only those six calls before DXC.

Each table entry is one fresh-process test running both group sizes. Wrong-record/pixel totals are out of 384/6.

Mesh variant PR translation: passed/failed/ignored; wrong records/pixels Six meetings omitted: passed/failed/ignored; wrong records/pixels
RTX3090 split, spin env=1 1/0/0; 0/0 0/1/0; 192/4
RTX3090 split, spin env=0 1/0/0; 0/0 0/1/0; 192/2
AMD integrated, native wave64 1/0/0; 0/0 not applicable
AMD integrated, forced split, spin env=1 1/0/0; 0/0 1/0/0; 0/0
AMD integrated, forced split, spin env=0 1/0/0; 0/0 1/0/0; 0/0

No skips or timeouts. NVIDIA omission controls exit101 on the final output assertion; all other Mesh runs exit0. AMD's Mesh omission controls still pass: this fixture demonstrates correctness on that adapter, but does not detect the omitted-meeting fault there. No inference that AMD never needs these meetings.

The 128-thread split case always emits spin, including when XCL_WAVE64_SPIN=0; only the 64-thread case emits the barrier form with that setting. Logs print actual emitted_spin. In the NVIDIA 64-thread barrier omission control, 64/128 records are wrong although all three sampled pixels match. The 128-thread omission case has 128/256 wrong records and both triangles red. Checking pixels alone would miss some corruption.

Command:
cargo test --locked -p xcl --lib gpu_mesh_split_wave64_lds_order_probe -- --test-threads=1 --show-output --nocapture

Same environment matrix as Kernel above. Final Mesh source identical across all nine reported runs; all 221 source hashes match Windows. Reverse-apply check and git diff --check pass. An earlier fixture revision incorrectly assumed Mesh v5 started at zero; final fixture saves its group input then explicitly initializes the LDS result register, matching the Kernel setup. No runtime fix or relaxed assertion was needed.

Correction to my earlier coordination note: the AMD iGPU does support this native mesh path. Actual adapter-selected execution above replaces that mistaken capability assumption.

Windows10 Home19045, Ryzen7 7800X3D, RTX3090 driver591.74, AMD Radeon integrated32.0.21030.2001; Rust1.98.1 MSVC, DXC/dxil1.8.2502.11, Agility1.620.2, debug. SSH Session0. No proprietary inputs.

Not tested
Multiple console waves per Kernel dispatch, Linux/RADV, GPU performance, stress under load, current-main integration, full workspace with these additional fixtures, or a retail title / xcl-smoke. These results do not resolve the reported world-load regression or justify removing draft status. Existing Compute coverage is not claimed as a new run here.

AI use
Codex (GPT-6) inspected ownership/coverage, wrote the local fixtures, ran native validation and prepared this report, reusing the program already in this PR.

Complete Kernel + Mesh fixture patch against77a8190 (130 added lines)
diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs
index 44a4bb7..93d7cd2 100644
--- a/crates/xcl/src/gpu/recomp/tests.rs
+++ b/crates/xcl/src/gpu/recomp/tests.rs
@@ -7553,3 +7553,133 @@ fn fspx_containers_translate_and_compile() {
     println!("FSPX: {ok} / {n} translated and compiled");
     assert_eq!(ok, n);
 }
+
+/// Local Kernel-mode counterpart of the PR1252 Compute test; run each variant in a fresh process.
+#[test]
+fn gpu_kernel_split_wave64_lds_order_probe() {
+    if !gpu_ready() { return; }
+    let p = lds_order_program();
+    let options = on_gpu(Options { mode: Mode::Kernel, wave64: true, ..Default::default() });
+    let split = options.split_wave64;
+    let mut t = translate(&p, &options).unwrap();
+    assert!(t.complete(), "{:?}", t.unsupported_why);
+    let meets = t.hlsl.matches("xcl_x_meet();").count();
+    assert_eq!(meets, if split { 6 } else { 0 });
+    let omit = std::env::var_os("XCL_PROBE_OMIT_LDS_MEETS").is_some();
+    if omit {
+        assert!(split, "negative control requires split translation");
+        t.hlsl = t.hlsl.replace("xcl_x_meet();", "");
+    }
+    println!("adapter={} split={split} spin={} meets={meets} omit={omit}", runner::adapter().unwrap(),
+        std::env::var("XCL_WAVE64_SPIN").unwrap_or_else(|_| "default".into()));
+    let dxil = super::dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).unwrap();
+    let mut failures = Vec::new();
+    // Tags vary across runs so an earlier dispatch's LDS contents cannot satisfy the oracle.
+    for tag in [0usize, 1, 7, 17, 31, 63, 127, 1023] {
+        let mut st = KernelState::default();
+        st.sgpr[0] = 0x100;
+        st.sgpr[1] = 6;
+        st.sgpr[4] = tag as u32;
+        for lane in 0..64 { st.vgpr[lane][0] = lane as u32; }
+        let mut mem: Vec<u32> = p.chunks_exact(4).map(|b| u32::from_le_bytes(b.try_into().unwrap())).collect();
+        mem.resize((0x100 + (tag + 1) * 64 * 8) / 4, 0);
+        let out = runner::run(&dxil, &st, &mem).unwrap();
+        for lane in 0..64 {
+            let other = (tag * 64 + (lane ^ 32)) as u32;
+            let want = if lane < 32 { [0x1000_0000 | other, 0] } else { [0, 0x2000_0000 | other] };
+            let at = (0x100 + (tag * 64 + lane) * 8) / 4;
+            if out.vgpr[lane][4..6] != want || out.mem[at..at + 2] != want {
+                failures.push(format!("tag={tag} lane={lane} vgpr={:x?} memory={:x?} want={want:x?}",
+                    &out.vgpr[lane][4..6], &out.mem[at..at + 2]));
+            }
+        }
+    }
+    println!("dispatches=8 checked_lanes=512 mismatched_lanes={}", failures.len());
+    assert!(failures.is_empty(), "{} wrong lanes: {}", failures.len(), failures[..failures.len().min(4)].join("; "));
+}
+
+/// Local two-pass Mesh execution check for PR1252's LDS ordering, including rendered pixels.
+#[test]
+fn gpu_mesh_split_wave64_lds_order_probe() {
+    if !gpu_ready() || !mesh_ready() { return; }
+    use super::{dxc, mesh_passthrough, MsInterface, MESH_HEADER};
+    let sig = |name: &str, sv, reg, ty| crate::gpu::dxbc::SigElement {
+        name: name.into(), index: 0, system_value: sv, component_type: ty,
+        register: reg, mask: 0xF, rw_mask: 0xF, stream: 0,
+    };
+    let mut wrong_vertices = 0;
+    let mut wrong_pixels = 0;
+    let omit = std::env::var_os("XCL_PROBE_OMIT_LDS_MEETS").is_some();
+    for threads in [64u32, 128] {
+        let shift = threads.trailing_zeros() as u64;
+        let ms = MsInterface { outputs: vec![sig("SV_Position", 1, 0, 3), sig("TEXCOORD", 0, 1, 1)],
+            threads, max_vertices: threads, max_primitives: 1 };
+        let mut code = prog(&[
+            ("S_BFE_U32", "ENC_SOP2", &[("SDST", 6), ("SSRC0", 3), ("SSRC1", 255)], Some(0x40018)),
+            ("V_MBCNT_LO_U32_B32", "ENC_VOP3", &[("VDST", 0), ("SRC0", 193), ("SRC1", 128)], None),
+            ("V_MBCNT_HI_U32_B32", "ENC_VOP3", &[("VDST", 0), ("SRC0", 193), ("SRC1", V)], None),
+            ("V_LSHL_ADD_U32", "ENC_VOP3", &[("VDST", 0), ("SRC0", 6), ("SRC1", 134), ("SRC2", V)], None),
+            ("V_READFIRSTLANE_B32", "ENC_VOP1", &[("VDST", 4), ("SRC0", V + 5)], None),
+            ("S_LSHR_B32", "ENC_SOP2", &[("SDST", 4), ("SSRC0", 4), ("SSRC1", 128 + shift)], None),
+            ("V_MOV_B32", "ENC_VOP1", &[("VDST", 5), ("SRC0", 128)], None), // after saving Mesh v5 group input, seed LDS result as in Kernel
+
+            ("S_MOV_B32", "ENC_SOP1", &[("SDST", 1), ("SSRC0", 128 + shift)], None),
+            ("S_MOV_B32", "ENC_SOP1", &[("SDST", 0), ("SSRC0", 255)], Some(0x2000)),
+            ("S_MOV_B32", "ENC_SOP1", &[("SDST", 124), ("SSRC0", 255)], Some(1 << 12 | threads)),
+            ("S_SENDMSG", "ENC_SOPP", &[("SIMM16", 9)], None),
+        ]);
+        code.truncate(code.len() - 4); // replace END with the PR's LDS program
+        let lds = lds_order_program();
+        code.extend_from_slice(&lds[..lds.len() - 4]);
+        code.extend(prog(&[
+            ("BUFFER_LOAD_DWORDX4", "ENC_MUBUF", &[("VDATA", 10), ("VADDR", 0), ("SRSRC", 4), ("SOFFSET", 128), ("IDXEN", 1)], None),
+            ("V_CVT_F32_U32", "ENC_VOP1", &[("VDST", 20), ("SRC0", 4)], None),
+            ("V_ADD_F32", "ENC_VOP2", &[("VDST", 10), ("SRC0", V + 20), ("VSRC1", 10)], None),
+            ("EXP", "ENC_EXP", &[("TGT", 12), ("EN", 15), ("VSRC0", 10), ("VSRC1", 11), ("VSRC2", 12), ("VSRC3", 13), ("DONE", 1)], None),
+            ("EXP", "ENC_EXP", &[("TGT", 32), ("EN", 3), ("VSRC0", 4), ("VSRC1", 5)], None),
+            ("V_CMPX_EQ_U32", "ENC_VOPC", &[("SRC0", 128), ("VSRC1", 0)], None),
+            ("V_MOV_B32", "ENC_VOP1", &[("VDST", 21), ("SRC0", 255)], Some(1 << 10 | 2 << 20)),
+            ("EXP", "ENC_EXP", &[("TGT", 20), ("EN", 1), ("VSRC0", 21), ("DONE", 1)], None),
+        ]));
+        let options = on_gpu(Options { mode: Mode::Mesh(ms.clone()), wave64: true, ..Default::default() });
+        let mut t = translate(&code, &options).unwrap();
+        assert!(t.complete(), "{:?}", t.unsupported_why);
+        assert_eq!(t.hlsl.matches("xcl_x_meet();").count(), if options.split_wave64 { 6 } else { 0 });
+        let spin = t.hlsl.contains("#define XCL_X_SPIN 1");
+        if omit {
+            assert!(options.split_wave64);
+            t.hlsl = t.hlsl.replace("xcl_x_meet();", "");
+        }
+        println!("adapter={} threads={threads} split={} emitted_spin={spin} omit={omit}", runner::adapter().unwrap(), options.split_wave64);
+        let cs = dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).unwrap();
+        let msb = dxc::compile(&mesh_passthrough(&ms), "main", "ms_6_6", &[]).unwrap();
+        let ps = dxc::compile("struct V { float4 pos : SV_Position; nointerpolation uint4 p0 : TEXCOORD0; }; float4 main(V v) : SV_Target0 { return (v.p0.x & 0xf0000000u) == 0x10000000u ? float4(0,1,0,1) : float4(1,0,0,1); }", "main", "ps_6_6", &[]).unwrap();
+        let mut mem = vec![0u32; 4096];
+        for i in 0..threads as usize {
+            let xy = [(-1.0f32, -1.0f32), (-1.0, 1.0), (0.0, -1.0)][i.min(2)];
+            mem[0x40 + i * 4..0x40 + i * 4 + 4].copy_from_slice(&[f(xy.0), f(xy.1), f(0.0), f(1.0)]);
+        }
+        let mut sg = vec![0u32; 128];
+        sg[16..20].copy_from_slice(&[0x100, 16 << 16, threads, 0]);
+        let (px, records) = runner::mesh_draw(&cs, &msb, &ps, 2, ms.record_dwords(), &sg, &mem, 32, [-1.0; 4]).unwrap();
+        let mut bad = 0;
+        for g in 0..2usize {
+            let r = &records[g * ms.record_dwords()..(g + 1) * ms.record_dwords()];
+            assert_eq!((r[0], r[1]), (threads, 1));
+            assert_eq!(r[MESH_HEADER + threads as usize * ms.vert_dwords()], 1 << 10 | 2 << 20);
+            for lane in 0..threads as usize {
+                let other = (g * threads as usize + (lane ^ 32)) as u32;
+                let want = if lane % 64 < 32 { [0x1000_0000 | other, 0] } else { [0, 0x2000_0000 | other] };
+                let at = MESH_HEADER + lane * ms.vert_dwords() + 4;
+                if r[at..at + 2] != want { bad += 1; }
+            }
+        }
+        let samples = [px[29 * 32 + 3], px[29 * 32 + 19], px[3 * 32 + 29]];
+        let want = [[0.0, 1.0, 0.0, 1.0], [0.0, 1.0, 0.0, 1.0], [-1.0; 4]];
+        let pixels = samples.iter().zip(want).filter(|(a, b)| **a != *b).count();
+        println!("vertices_checked={} wrong_vertices={bad} pixel_samples={samples:?} wrong_pixels={pixels}", threads * 2);
+        wrong_vertices += bad;
+        wrong_pixels += pixels;
+    }
+    assert_eq!((wrong_vertices, wrong_pixels), (0, 0), "LDS order must reach the mesh records and pixels");
+}

@Filip722

Copy link
Copy Markdown

Tested exact #1252 at 77a8190e4528a135cb0ed9fd7de9a31e5699371f on main 9e3831e with our local Series X storage and texture work. RTX 5060 Laptop GPU (8 GB, NVIDIA 615.78.08), Bazzite 44 Testing, Proton Experimental 11.0-20261112, vkd3d-proton 3.1 4522cc1, dxil-spirv 1dc543f.

The Windows MSVC release split_wave64 filter passed eight tests with one ignored benchmark in both XCL_WAVE64_SPIN=1 and 0. The LDS ordering test ran on the NVIDIA GPU in both modes. No focused test skipped its body.

Matched title runs in both modes accepted the scripted A input and reached loading artwork. Spin recorded 2,688 presents and exited through a title null-write path. Barrier mode recorded 2,431 presents and reached the title GPU watchdog. Both had zero storage failures, logged bind timeouts, device removals and kernel GPU faults. The visible milestone stayed at loading.

OpenAI Codex with GPT-6.2-Sol high prepared the local build, ran the tests and wrote this report.

@erickbobd

Copy link
Copy Markdown

Retail numbers for two of the Not tested lines: how many programs of the retail title this touches, and what the per-basic-block tracker you mention as a follow-up saves. Counts only, from the retail 1.0.2.1 pack, main b7aa9f3; no title run with this PR.

Which programs (detect_wave64 on the code, the pack's FSSM interfaces):

programs
compute 2 689
wave64 compute 1 208
… that write and read LDS 351
… with no s_barrier at all 188, all in groups of 64 threads or fewer (one console wave)
mesh (all wave64) 9 282, of which 5 write and read LDS

Meetings in the split form, static (the 370 wave64 compute and mesh programs with LDS accesses, all fully translated, 4 memory windows):

rule meetings
one before each LDS access (this PR) 11 127
a tracker: no meeting when only reads happened since the halves last met; every basic block starts as unknown 6 946 (−38 %)

The median program has 16 accesses. The largest has 417, and the tracker still gives it 405 meetings. So the tracker removes about a third statically, not an order of magnitude. I have no per-frame count, so I cannot say whether it would change the RTX 3060 result.

The tracker is about 40 lines in emit.rs. The state resets in Em::take(), which ends every block in all three emission loops. Geometry is left out, as here. With a read-after-write and write-after-read test it passes the whole suite on an RTX 5070 Ti (native, 32-lane waves, NVIDIA 617.14, debug): 771 passed, 0 failed, 41 ignored, SKIPPED the two no-wave64 tests. Its test fails with the meetings taken out, and also with only the write-after-read meetings taken out. I can open it stacked on this PR if you want it, or leave it.

Not tested

  • Per-frame meeting counts and GPU time on the retail title, and the RTX 3060 regression.
  • This PR's own head on this card, and the title in the world: on main here it stops at the title's watchdog after ~278 s.

AI use

  • Claude Code (Claude Opus 5.5) wrote the census and the tracker, ran them on this machine and drafted this comment.

not-rex added a commit to not-rex/xcl that referenced this pull request Nov 24, 2026
The meeting before every LDS access (previous commit) made a heavy-LDS world
stall on an RTX 3060 (PR xcl-dev#1252). Two cases need no meeting:

- a read right after a read in the same basic block (two reads need no order;
  the meeting before the run's first read orders it after the other half's
  earlier writes, and the next write's meeting waits for this half's reads);
- an access when an exchange (ballot, readlane, readfirstlane, bpermute,
  coherent scalar load) lies between it and the block's previous LDS access:
  the exchange is a meeting. A mask kept in its half (xcl_x_ballot_local) is
  no exchange.

A block's first access, every write / atomic and a read after a write still
meet, so for any two accesses of the stream, one a write, the halves meet
between them. Em::new takes the block starts (the branch leaders), so no
caller can elide across blocks by leaving them out.

Meetings: lds_order_program stays at 6 (every access is a write or a read
after a write); the new lds_read_run_program (2 writes, 4 reads, 2 writes)
goes from 8 to 5, and to 3 with an exchange after the writes and after the
reads. split_wave64_meets_once_per_read_run, ..._lds_local_mask_is_no_meeting
and ..._lds_meets_at_loop_head check the rule without a GPU (they fail with a
local mask counted as a meeting or without the block-start reset);
gpu_split_wave64_lds_read_run_follows_instruction_order checks on the GPU that
the reads without a meeting see the other half's writes before the run and
not those after it (64 / 256-thread groups, with meetings and with exchanges).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
not-rex added a commit to not-rex/xcl that referenced this pull request Nov 24, 2026
A switch to compare a title with and without the split wave64 meetings
before LDS accesses (the RTX 3060 report on PR xcl-dev#1252). Default on: the
meetings are a correctness fix. Set, it bypasses the shader caches like
XCL_WAVE64_SPIN; unset, the HLSL is unchanged.

With it at 0 the LDS order tests fail as expected (no meetings; the GPU
tests read out of order), which shows the switch takes effect.

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

not-rex commented Nov 24, 2026

Copy link
Copy Markdown
Author

Pushed two follow-up commits (description updated with the counts):

  • 8a79b8e: @upipibi's read-after-read reduction, plus leaving out a meeting when an exchange already lies between two LDS accesses (8 -> 5 meetings on a read-heavy program; writes and reads after writes still meet).
  • 2473e2f: XCL_WAVE64_LDS_ORDER=0 switches the meetings off, so they can be A/B'd on any machine.

RTX 3080, in the world: the head behaves like main and the first form (same GPU stall 35-55 s after #101, no allocators put aside, no out-of-memory); suite 747 passed, 0 failed; menus smoke pair against main 930e8b4 in the description.

@Rodriguerra, if you can, one run of your RTX 3060 setup at this head with and without XCL_WAVE64_LDS_ORDER=0 would show whether the meetings are what you saw. I'm keeping this in draft until then.

AI use: Claude Code (Claude Opus 5.5) wrote the commits after an Opus review, ran the 3080 runs on my machine and wrote this.

@not-rex

not-rex commented Nov 24, 2026

Copy link
Copy Markdown
Author

@erickbobd thanks, those counts fill two of the Not tested lines (351 wave64 compute + 5 mesh programs with LDS; 11,127 meetings statically).

The head I pushed an hour ago (8a79b8e) already has the same rule as your tracker: no meeting for a read when only reads happened since the halves last met, with every basic block starting unknown (block starts come from the branch leaders, so loop heads meet too). It also counts an exchange (ballot, lane reads, bpermute, coherent scalar load) as a meeting, which the tracker could add on top. So I'd rather not stack a second PR on the same rule; if you can, your census run on 2473e2f would show what the exchange rule adds over your 6,946 (−38 %).

AI use: Claude Code (Claude Opus 5.5) compared the two rules and wrote this.

@erickbobd

Copy link
Copy Markdown

@not-rex the census on 2473e2f, as you asked. Same pack and the same 370 wave64 compute and mesh programs with LDS accesses, all fully translated, 4 memory windows. Meetings are counted as the xcl_x_meet(); lines the LDS rule emits, so the exchanges themselves are not in the count.

rule meetings
one before each LDS access (77a8190) 11 127
read after read only (my tracker, on main b7aa9f3) 6 946
2473e2f: read after read, and an exchange counts as a meeting 6 694

So the exchange rule leaves out 252 more meetings than the tracker (3.6 % of its count), and −39.8 % against one per access in all. Two programs need no LDS meeting at all under it. The largest program, with 417 accesses, goes to 404.

Static counts only: nothing on per-frame counts or timing. The bases differ (b7aa9f3 for my tracker, 47efa2e for this PR), but the programs and their 11 127 accesses are the same in both.

AI use: Claude Code (Claude Opus 5.5) ran the census and wrote this comment.

@ivall ivall added the goal:world-load Bears on the retail title getting past world loading label Nov 24, 2026
@qcdaark

qcdaark commented Nov 24, 2026

Copy link
Copy Markdown

@not-rex A/B of the new head on another NVIDIA card, since you asked for one before taking this out of draft. RTX 3070 Ti 8 GB (driver 621.24), Ryzen 9 7900X, 32 GB, Windows 11 26300.

Tree: main c160d86 + #640 + #1428 + #1323 + this PR at 2473e2f (merged cleanly), plus a local 2-line patch so the #1323 report also runs on device removal (in the zip). Env: XCL_PAGE_BUDGET_MB=3072 XCL_PSO_WAIT_MS=50 XCL_ACTIVITY=1 XCL_NETWORK=0 XCL_PRESS_A_AT=25 XCL_RUN_SECONDS=300 XCL_GPU_CULPRIT=1. Title: the retail build from #675, story load.

run XCL_WAVE64_LDS_ORDER device removed 0x887a0006 after A Aftermath
1 default (meetings on) 128.4 s ~103 s dump, "Hung", no page fault
2 0 149.7 s ~125 s no dump written

Both runs hang in the same window as without this PR (my earlier runs on #675: 131 s and 140 s). In both, the #1323 report says 0 of 278 / 0 of 343 lists have dispatches started and not done, and the title then stops at +0x2474606.

Run 1's dump: all 97 warps on the GPU are in one compute program. Its Aftermath hash matches a 121,380 B DXIL in the cache. That is between the sizes I got for the same program without meetings (120,060 B) and with the first form of this PR (123,752 B, 77a8190), so it is very likely the same program with the reduced meetings. In the first form it was also the only hung program (40 and 28 warps).

So on this card neither the meetings nor leaving them out change the hang: it happens with or without them. For this title the meetings don't look like the cause, and they don't fix it either.

Logs (user name removed) + the local patch: gta6-1252b.zip

AI use: Claude Code (Claude Opus 5.5) ran the tests, read the logs and the Aftermath dump, and wrote this; I checked it before posting.
local-culprit-on-removal.patch
off-report.json
off-xcl.log
on-report.json
on-xcl.log

@not-rex

not-rex commented Nov 24, 2026

Copy link
Copy Markdown
Author

@qcdaark thanks, that's the A/B I was hoping for. With my RTX 3080 runs it makes two NVIDIA cards where the head behaves like main (same hang window, with the meetings on or off), and neither shows the RTX 3060 regression above. I'll take this out of draft in the morning unless @Rodriguerra's details point somewhere else.

AI use: Claude Code (Claude Opus 5.5) wrote this.

@not-rex

not-rex commented Nov 25, 2026

Copy link
Copy Markdown
Author

One more data point on the RTX 3060 report above: its allocator signature appears on plain main without this PR. RTX 3080, main 20cf1302 + #1123 + #1254 (no #1252), XCL_COHERENT_HEAPS=0 XCL_COHERENT_MB=512, XCL_PSO_WAIT_MS=50, in the world: at 166.5 s the log says "512 allocator resets so far with recordings still held or on the GPU: another PC allocator took its place (268 made, 268 put aside now)", the same pattern as the report's "160 made, 160 put aside". So that part at least isn't from the meetings.

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

not-rex added a commit to not-rex/xcl that referenced this pull request Nov 25, 2026
The meeting before every LDS access (previous commit) made a heavy-LDS world
stall on an RTX 3060 (PR xcl-dev#1252). Two cases need no meeting:

- a read right after a read in the same basic block (two reads need no order;
  the meeting before the run's first read orders it after the other half's
  earlier writes, and the next write's meeting waits for this half's reads);
- an access when an exchange (ballot, readlane, readfirstlane, bpermute,
  coherent scalar load) lies between it and the block's previous LDS access:
  the exchange is a meeting. A mask kept in its half (xcl_x_ballot_local) is
  no exchange.

A block's first access, every write / atomic and a read after a write still
meet, so for any two accesses of the stream, one a write, the halves meet
between them. Em::new takes the block starts (the branch leaders), so no
caller can elide across blocks by leaving them out.

Meetings: lds_order_program stays at 6 (every access is a write or a read
after a write); the new lds_read_run_program (2 writes, 4 reads, 2 writes)
goes from 8 to 5, and to 3 with an exchange after the writes and after the
reads. split_wave64_meets_once_per_read_run, ..._lds_local_mask_is_no_meeting
and ..._lds_meets_at_loop_head check the rule without a GPU (they fail with a
local mask counted as a meeting or without the block-start reset);
gpu_split_wave64_lds_read_run_follows_instruction_order checks on the GPU that
the reads without a meeting see the other half's writes before the run and
not those after it (64 / 256-thread groups, with meetings and with exchanges).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
not-rex added a commit to not-rex/xcl that referenced this pull request Nov 25, 2026
A switch to compare a title with and without the split wave64 meetings
before LDS accesses (the RTX 3060 report on PR xcl-dev#1252). Default on: the
meetings are a correctness fix. Set, it bypasses the shader caches like
XCL_WAVE64_SPIN; unset, the HLSL is unchanged.

With it at 0 the LDS order tests fail as expected (no meetings; the GPU
tests read out of order), which shows the switch takes effect.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@not-rex
not-rex marked this pull request as ready for review November 25, 2026 04:38
@JJAutoCompare

Copy link
Copy Markdown

Tested

Independent native Windows run at clean detached PR #1252 head 0141ee9b0e6e1de67d5f17133d11a6cdb3ef0b5e. STOR-WINLAB, Windows 11 Enterprise Evaluation x64 26200.9974, Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust/Cargo 1.100.0 x86_64-pc-windows-msvc, DXC/DXIL 1.9.2609.5. Unoptimized test profile with incremental compilation and debug info disabled.

cargo test --locked -p xcl --lib --no-run -j 2 --message-format=json ran outside the Arc mutex and exited 0. Used XCL_ADAPTER=A770, XCL_DIRECT_DXIL=0, and XCL_DXC_DIR=%LOCALAPPDATA%/XclTooling/dxc-1.9.2609/bin/x64. Left the LDS-order and spin settings at their defaults.

& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test {
    & 'L:/XclTooling/verify-pr1523-1362129-t3-cf2e05e7/target/debug/build/xcl/97fdf2b9ff8e1482/out/xcl-97fdf2b9ff8e1482.exe' --exact gpu::recomp::tests::gpu_split_wave64_lds_follows_instruction_order --nocapture --test-threads=1
}

1 passed, 0 failed, 0 ignored, 0 GPU skips in 0.59 s. Libtest filtered out 1,084 other tests. The fixture and mutex wrapper exited 0, and the executable digest matched before waiting, inside the mutex, and after exit.

The HLSL/DXC split-wave64 fixture dispatched 1,024 groups of 64 threads and 1,024 groups of 256 threads. All 327,680 two-word comparisons matched the expected cross-half LDS readback.

Not tested

Other LDS or read-run fixtures, ordering disabled, native wave64, direct DXIL, the PR base, other adapters, the full test suite, and title smoke runs.

AI use

T3 Code / Codex (gpt-6.2-sol) verified the revision, ran the checked-in fixture, and wrote this report.

not-rex added a commit to not-rex/xcl that referenced this pull request Nov 25, 2026
The meeting before every LDS access (previous commit) made a heavy-LDS world
stall on an RTX 3060 (PR xcl-dev#1252). Two cases need no meeting:

- a read right after a read in the same basic block (two reads need no order;
  the meeting before the run's first read orders it after the other half's
  earlier writes, and the next write's meeting waits for this half's reads);
- an access when an exchange (ballot, readlane, readfirstlane, bpermute,
  coherent scalar load) lies between it and the block's previous LDS access:
  the exchange is a meeting. A mask kept in its half (xcl_x_ballot_local) is
  no exchange.

A block's first access, every write / atomic and a read after a write still
meet, so for any two accesses of the stream, one a write, the halves meet
between them. Em::new takes the block starts (the branch leaders), so no
caller can elide across blocks by leaving them out.

Meetings: lds_order_program stays at 6 (every access is a write or a read
after a write); the new lds_read_run_program (2 writes, 4 reads, 2 writes)
goes from 8 to 5, and to 3 with an exchange after the writes and after the
reads. split_wave64_meets_once_per_read_run, ..._lds_local_mask_is_no_meeting
and ..._lds_meets_at_loop_head check the rule without a GPU (they fail with a
local mask counted as a meeting or without the block-start reset);
gpu_split_wave64_lds_read_run_follows_instruction_order checks on the GPU that
the reads without a meeting see the other half's writes before the run and
not those after it (64 / 256-thread groups, with meetings and with exchanges).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
not-rex added a commit to not-rex/xcl that referenced this pull request Nov 25, 2026
A switch to compare a title with and without the split wave64 meetings
before LDS accesses (the RTX 3060 report on PR xcl-dev#1252). Default on: the
meetings are a correctness fix. Set, it bypasses the shader caches like
XCL_WAVE64_SPIN; unset, the HLSL is unchanged.

With it at 0 the LDS order tests fail as expected (no meetings; the GPU
tests read out of order), which shows the switch takes effect.

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

not-rex commented Nov 25, 2026

Copy link
Copy Markdown
Author

Rebased onto main 1a0bbe3a (head c4832004). The conflicts were only neighbours:

  • the ADDTID branch's GDS check, which main now makes once for every LDS form;
  • img_writes next to x64_lds / block_starts in Em;
  • XCL_DXIL_NO_OPT next to XCL_WAVE64_LDS_ORDER in the cache-bypass list and its test.

The change itself is the same (+306/-5).

RTX 5070 Ti, cargo test -p xcl --lib --locked -- gpu::recomp: 373 passed, 0 failed, 19 ignored (the SKIPPED lines are the wave64-hardware tests).

not-rex and others added 3 commits November 26, 2026 02:34
On a 32-lane GPU a console wave64 program runs as two 32-lane halves. The split
form orders cross-lane exchanges between the halves but not LDS accesses, so a
half could read LDS before the other half's earlier write (or after its later
one) landed. The new GPU test gpu_split_wave64_lds_follows_instruction_order
(upper half writes, lower half reads, and the reverse; 1,024 groups) failed
60 of 60 runs on an RTX 5070 Ti (26,048-50,688 of 65,536 threads wrong, in the
spin form, with XCL_WAVE64_SPIN=0, and under load) and passed 60 of 60 with
this change. Those runs were of its first form, groups of one console wave.
It now also runs groups of four (256 threads, the counter-paired form):
without the meetings 237,824-239,936 of 262,144 threads were wrong there in
5 of 5 runs; with them the split_wave64 tests pass 5 of 5 runs.

The halves now meet (xcl_x_meet(), nothing exchanged) before each LDS access
in kernel / compute / mesh mode, once the access is known to be translated.
The meeting orders instructions, not the lanes of one instruction. Cost: one
exchange per LDS instruction on 32-lane GPUs; the test program goes from 1
exchange to 7 (spin form 0.046 -> 0.120 ms for 16,384 groups, barrier form
unchanged). Native wave64 HLSL is unchanged. docs/wave64-on-wave32.md states
the rule.

split_wave64_meets_before_each_lds_access checks the emitted HLSL without a
GPU: six meetings for the test program in the split form, none natively, in a
wave32 program or for an access that is not translated (GDS).

Assisted-by: Claude Code (Claude Fable 5.2)
The meeting before every LDS access (previous commit) made a heavy-LDS world
stall on an RTX 3060 (PR xcl-dev#1252). Two cases need no meeting:

- a read right after a read in the same basic block (two reads need no order;
  the meeting before the run's first read orders it after the other half's
  earlier writes, and the next write's meeting waits for this half's reads);
- an access when an exchange (ballot, readlane, readfirstlane, bpermute,
  coherent scalar load) lies between it and the block's previous LDS access:
  the exchange is a meeting. A mask kept in its half (xcl_x_ballot_local) is
  no exchange.

A block's first access, every write / atomic and a read after a write still
meet, so for any two accesses of the stream, one a write, the halves meet
between them. Em::new takes the block starts (the branch leaders), so no
caller can elide across blocks by leaving them out.

Meetings: lds_order_program stays at 6 (every access is a write or a read
after a write); the new lds_read_run_program (2 writes, 4 reads, 2 writes)
goes from 8 to 5, and to 3 with an exchange after the writes and after the
reads. split_wave64_meets_once_per_read_run, ..._lds_local_mask_is_no_meeting
and ..._lds_meets_at_loop_head check the rule without a GPU (they fail with a
local mask counted as a meeting or without the block-start reset);
gpu_split_wave64_lds_read_run_follows_instruction_order checks on the GPU that
the reads without a meeting see the other half's writes before the run and
not those after it (64 / 256-thread groups, with meetings and with exchanges).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A switch to compare a title with and without the split wave64 meetings
before LDS accesses (the RTX 3060 report on PR xcl-dev#1252). Default on: the
meetings are a correctness fix. Set, it bypasses the shader caches like
XCL_WAVE64_SPIN; unset, the HLSL is unchanged.

With it at 0 the LDS order tests fail as expected (no meetings; the GPU
tests read out of order), which shows the switch takes effect.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.