Recompiler: XCL_OUTLINE_EXCHANGE=0 keeps the split-wave64 rendezvous inline #2210

Open
github-bot wants to merge 2 commits from github-bot/gh-2210 into main AGit
Owner

@⁠brandostrong on GitHub · 2026-11-25 09:53 UTC · original
brandostrong:narrow-exchange → main · +211 −32 · 3 files · 2 commits · draft

Stacked on #1901; only the top commit belongs here.

What changes and why. #1901 decides one thing for three groups of helpers: from 1 024 instructions the memory-window accessors, the split-wave64 rendezvous and the typed-format conversions all become [noinline]. The reports on that PR show the three groups do not behave alike — the build win comes from the accessors and the format conversions, while the dispatch-time cost (@⁠CharlyRien's 1.7 – 2.7× on Ampere, reproduced here at 1.73× on an RTX 4090) is entirely in the rendezvous helpers, and their "keeping the exchange inline and outlining only the accessors and the format helpers … would keep most of the build gain; I have not measured those variants" is exactly this. This splits the decision in two and puts the exchange group behind XCL_OUTLINE_EXCHANGE=0, which keeps it inline, so the variant can be measured without editing the emitter. Nothing changes by default.

What is in it

  • crates/xcl/src/gpu/recomp/emit.rs: outline_exchange() (XCL_OUTLINE_EXCHANGE=0 → keep inline), and Em::finish passes outline && outline_exchange() to x64_prelude instead of outline. The accessor and format thresholds are untouched.

Why this is the shape to keep. A retail title's ten largest compute programs that have no driver blob, measured on this rig: eight of the ten have no lane-exchange sites at all (0 xcl_x_ballot, xcl_x_meet, xcl_x_rla_*) and 318 – 467 window-accessor sites, so for them the accessor and format outlining is the whole win and the exchange group is not in the program. The two that do have exchanges (1 030 and 982 ballot sites, both of one shadow-cascade family) are exactly the programs that would pay the dispatch cost. So the two decisions need to be separable, and one build with the switch measures both. Measured both ways the split is real in both directions: for the eight the DXIL is byte-identical between the settings, and for the two that read lanes the inline form costs 21 % of DXIL and 8 % of driver time over main while giving back the 1.73× dispatch cost. The default stays what #1901 chose; the switch is what makes the other side measurable and what a title that reads lanes per iteration can be run with.

Tested

  • hardware: RTX 4090 24 GB (32-lane waves, so split wave64), driver 32.0.16.1664, i9-13900K, 64 GB, Windows 11 Pro 26200, rustc 1.100.0, DXC 1.9.2602.17 (SDK 10.0.26100.0), release, Developer Mode on.
  • commands and counts: cargo build --release --offline --workspace then cargo test --release --offline --workspace -- --test-threads=4 on this branch: 1155 passed, 0 failed, 46 ignored, exit 0, 24 SKIPPED lines (no wave64, no heap windows, the direct path's refused f16 / f32 forms) — the same counts and the same skip set as afbc413 alone on this adapter, which is what "nothing changes by default" should produce.
  • one scripts/smoke.ps1 -Seconds 180 run of a retail title with XCL_OUTLINE_EXCHANGE=0 on this branch, on a wiped per-tree cache: 1719 frames shown, 0 device removals, 0 crashes, peak commit 30 327 MB, worst single compute compile 11 017 ms. main and #1901 under the same procedure give 1539 / 29 491 MB / 8 072 ms and 1488 / 30 008 MB / 8 993 ms; all three stop presenting between 90 and 102 s, so the frame counts compare the same screen and this is one run per tree, not a pacing result.
  • with XCL_OUTLINE_EXCHANGE=0 vs 1 on the same build, GPU time of a 32 768-iteration exchange loop (2^18 threads, median of 9, RTX 4090): the split-wave64 form that reads a lane every iteration goes 42.909 ms → 24.894 ms, i.e. 1.015× main's 24.522 ms instead of 1.75×; the mask-only split form 8.480 → 7.632 ms (main 7.954); the two wave32 forms 7.058 → 7.235 and 7.781 → 7.940 ms (main 7.323 / 8.188).
  • the same two legs on four compute programs of a retail title that have no lane-exchange site: the DXIL is byte-identical between the two settings (917 068 / 1 131 876 / 270 684 / 196 096 B, same instruction, phi and dx.op counts), so for programs without exchanges the switch changes nothing the driver sees. Cold CreateComputePipelineState of those four, exchange inline: 20.668 / 36.926 / 5.391 / 3.178 s, against 28.608 / 26.553 / 3.066 / 3.474 s for the identical bytes in the other leg — that spread is this machine's run-to-run variance, not a difference between the settings. main compiles the same four in 75.525 / 132.446 / 8.020 / 4.932 s.
  • the same two legs on the one program of those ten that does read lanes (73fb752d7f62c3a5, 1 030 ballot + 109 lane-read sites), cold driver each leg: =1 1 706 500 B / 219 360 instructions / 6 787 phis / 12 198 dx.op calls at 55.401 s and 60.075 s (identical bytes, two legs), =0 2 075 296 B / 260 182 / 12 066 / 18 951 at 68.295 s, and 568e7db 1 933 172 B / 236 547 / 16 902 / 30 602 at 63.400 s. On that class the switch is a trade, not a free win: 21 % more DXIL and 14 – 24 % more driver time than the outlined form, 7 % more DXIL and 8 % more driver time than main, and 2.5× its DXC time (138.8 s against 55.8 s). It buys the dispatch time there and pays for it in the build.
  • SKIPPED GPU tests on this adapter: the no wave64 set and the direct path's refused f16 / f32-conversion forms, same as main.

Not tested

  • AMD (the RDNA3 unsupported → 0x887A0005 and the RDNA4 ParseAddress failures reported on #1901 are about the outlined switch-form window accessors — #1867's reporter shows the same program builds with XCL_HEAP_WINDOWS=1, where the accessors stay inline and the DXIL is the base's, and the RX 7800 XT report on #1901 finds the suspension follows any remaining [noinline] internal function. This switch only removes the outlined exchange helpers, so it neither fixes nor reproduces those, and I did not test AMD.)
  • In-world milestone timing: the run above stops presenting before the in-world HUD, so it does not say what the switch does to frame pacing in the world.
  • Heap windows, and any threshold other than "all or none".
  • Native wave64 GPUs, where the split-wave64 exchange helpers are not emitted at all and this switch is a no-op.

AI use

  • Claude Code (Claude Opus 5.5): wrote the change, ran the measurements and wrote this description.

🤖 Generated with Claude Code

**@⁠brandostrong** on GitHub · 2026-11-25 09:53 UTC · [original](https://github.com/xcl-dev/xcl/pull/2210) `brandostrong:narrow-exchange` → `main` · +211 −32 · 3 files · 2 commits · draft > Stacked on #1901; only the top commit belongs here. **What changes and why.** #1901 decides one thing for three groups of helpers: from 1 024 instructions the memory-window accessors, the split-wave64 rendezvous and the typed-format conversions all become `[noinline]`. The reports on that PR show the three groups do not behave alike — the build win comes from the accessors and the format conversions, while the dispatch-time cost (@⁠CharlyRien's 1.7 – 2.7× on Ampere, reproduced here at 1.73× on an RTX 4090) is entirely in the rendezvous helpers, and their "keeping the exchange inline and outlining only the accessors and the format helpers … would keep most of the build gain; I have not measured those variants" is exactly this. This splits the decision in two and puts the exchange group behind `XCL_OUTLINE_EXCHANGE=0`, which keeps it inline, so the variant can be measured without editing the emitter. Nothing changes by default. **What is in it** - `crates/xcl/src/gpu/recomp/emit.rs`: `outline_exchange()` (`XCL_OUTLINE_EXCHANGE=0` → keep inline), and `Em::finish` passes `outline && outline_exchange()` to `x64_prelude` instead of `outline`. The accessor and format thresholds are untouched. **Why this is the shape to keep.** A retail title's ten largest compute programs that have no driver blob, measured on this rig: eight of the ten have no lane-exchange sites at all (0 `xcl_x_ballot`, `xcl_x_meet`, `xcl_x_rla_*`) and 318 – 467 window-accessor sites, so for them the accessor and format outlining is the whole win and the exchange group is not in the program. The two that do have exchanges (1 030 and 982 ballot sites, both of one shadow-cascade family) are exactly the programs that would pay the dispatch cost. So the two decisions need to be separable, and one build with the switch measures both. Measured both ways the split is real in both directions: for the eight the DXIL is byte-identical between the settings, and for the two that read lanes the inline form costs 21 % of DXIL and 8 % of driver time over `main` while giving back the 1.73× dispatch cost. The default stays what #1901 chose; the switch is what makes the other side measurable and what a title that reads lanes per iteration can be run with. **Tested** - hardware: RTX 4090 24 GB (32-lane waves, so split wave64), driver 32.0.16.1664, i9-13900K, 64 GB, Windows 11 Pro 26200, rustc 1.100.0, DXC 1.9.2602.17 (SDK 10.0.26100.0), release, Developer Mode on. - commands and counts: `cargo build --release --offline --workspace` then `cargo test --release --offline --workspace -- --test-threads=4` on this branch: **1155 passed, 0 failed, 46 ignored**, exit 0, 24 `SKIPPED` lines (`no wave64`, `no heap windows`, the direct path's refused f16 / f32 forms) — the same counts and the same skip set as `afbc413` alone on this adapter, which is what "nothing changes by default" should produce. - one `scripts/smoke.ps1 -Seconds 180` run of a retail title with `XCL_OUTLINE_EXCHANGE=0` on this branch, on a wiped per-tree cache: 1719 frames shown, 0 device removals, 0 crashes, peak commit 30 327 MB, worst single compute compile 11 017 ms. `main` and #1901 under the same procedure give 1539 / 29 491 MB / 8 072 ms and 1488 / 30 008 MB / 8 993 ms; all three stop presenting between 90 and 102 s, so the frame counts compare the same screen and this is one run per tree, not a pacing result. - with `XCL_OUTLINE_EXCHANGE=0` vs `1` on the same build, GPU time of a 32 768-iteration exchange loop (2^18 threads, median of 9, RTX 4090): the split-wave64 form that reads a lane every iteration goes 42.909 ms → 24.894 ms, i.e. 1.015× `main`'s 24.522 ms instead of 1.75×; the mask-only split form 8.480 → 7.632 ms (`main` 7.954); the two wave32 forms 7.058 → 7.235 and 7.781 → 7.940 ms (`main` 7.323 / 8.188). - the same two legs on four compute programs of a retail title that have no lane-exchange site: the DXIL is **byte-identical** between the two settings (917 068 / 1 131 876 / 270 684 / 196 096 B, same instruction, phi and `dx.op` counts), so for programs without exchanges the switch changes nothing the driver sees. Cold `CreateComputePipelineState` of those four, exchange inline: 20.668 / 36.926 / 5.391 / 3.178 s, against 28.608 / 26.553 / 3.066 / 3.474 s for the identical bytes in the other leg — that spread is this machine's run-to-run variance, not a difference between the settings. `main` compiles the same four in 75.525 / 132.446 / 8.020 / 4.932 s. - the same two legs on the one program of those ten that does read lanes (`73fb752d7f62c3a5`, 1 030 ballot + 109 lane-read sites), cold driver each leg: `=1` 1 706 500 B / 219 360 instructions / 6 787 phis / 12 198 `dx.op` calls at 55.401 s and 60.075 s (identical bytes, two legs), `=0` 2 075 296 B / 260 182 / 12 066 / 18 951 at 68.295 s, and `568e7db` 1 933 172 B / 236 547 / 16 902 / 30 602 at 63.400 s. On that class the switch is a trade, not a free win: 21 % more DXIL and 14 – 24 % more driver time than the outlined form, 7 % more DXIL and 8 % more driver time than `main`, and 2.5× its DXC time (138.8 s against 55.8 s). It buys the dispatch time there and pays for it in the build. - `SKIPPED` GPU tests on this adapter: the `no wave64` set and the direct path's refused f16 / f32-conversion forms, same as `main`. **Not tested** - AMD (the RDNA3 `unsupported` → `0x887A0005` and the RDNA4 `ParseAddress` failures reported on #1901 are about the outlined switch-form window accessors — #1867's reporter shows the same program builds with `XCL_HEAP_WINDOWS=1`, where the accessors stay inline and the DXIL is the base's, and the RX 7800 XT report on #1901 finds the suspension follows any remaining `[noinline]` internal function. This switch only removes the outlined exchange helpers, so it neither fixes nor reproduces those, and I did not test AMD.) - In-world milestone timing: the run above stops presenting before the in-world HUD, so it does not say what the switch does to frame pacing in the world. - Heap windows, and any threshold other than "all or none". - Native wave64 GPUs, where the split-wave64 exchange helpers are not emitted at all and this switch is a no-op. **AI use** - Claude Code (Claude Opus 5.5): wrote the change, ran the measurements and wrote this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
DXC inlines every helper before it optimises, so a large compute program
gets a copy of the memory-window switch, the split-wave64 exchange and
the typed-format conversions at every use, and the driver compiles all
of them. From 1 024 instructions (256 for the format helpers) these stay
[noinline] with scalar parameters, which SM 6.6 DXIL keeps as calls.
Heap windows keep their single access. The EXEC bit test stays inline:
as a call it made the driver slower.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#1901 decides one thing for three groups of helpers: from 1 024 instructions the memory-window
accessors, the split-wave64 exchange helpers and the typed-format conversions all become
`[noinline]`. The reports on that PR show the groups do not behave alike. The build win comes from the
accessors and the format conversions; the dispatch-time cost is in the rendezvous helpers — 1.7 – 2.7×
on an RTX 3090 (@CharlyRien), reproduced here at 1.73× on an RTX 4090 for a 32 768-iteration loop that
reads a lane every iteration (42.9 ms outlined, 24.9 ms inline, 24.5 ms on `main`), and 1.02× for the
same loop when it only reads a mask. Keeping the exchange inline gives the run time back. For four
compute programs of a retail title that have no lane-exchange site it changes nothing the driver sees:
the DXIL is byte-identical between the two settings (917 068 / 1 131 876 / 270 684 / 196 096 B, same
instruction, phi and `dx.op` counts), so the switch only touches programs that actually read lanes. On
the one program of that title's ten largest that does (1 030 ballot + 109 lane-read sites) it is a
trade, not a free win: inline 2 075 296 B at 68.3 s cold against outlined 1 706 500 B at 55.4 – 60.1 s
and `main`'s 1 933 172 B at 63.4 s, so there it buys the dispatch time and pays in the build.

The variant is @CharlyRien's ("keeping the exchange inline and outlining only the accessors and the
format helpers … would keep most of the build gain; I have not measured those variants"); this puts it
behind a switch so it can be measured without editing the emitter. Default behaviour is unchanged:
`cargo test --release --offline --workspace -- --test-threads=4` gives 1155 passed, 0 failed, 46
ignored on both this branch and #1901 alone, with the same 24 `SKIPPED` lines.

Not measured: AMD (the RDNA3 / RDNA4 failures on #1901 are in the outlined switch-form accessors, which
this switch does not touch), native wave64 GPUs (no split form, so the switch is a no-op), and the
title's own programs' exchange counts per iteration.

Co-Authored-By: Claude Code <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:23:21 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 16:07 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 16:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/2210#issuecomment-7167609582) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/gpu/recomp/emit.rs
  • crates/xcl/src/gpu/recomp/tests.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2210/head:github-bot/gh-2210'
git switch 'github-bot/gh-2210'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2210'
git switch 'github-bot/gh-2210'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2210'
git switch 'github-bot/gh-2210'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2210'
git switch 'main'
git merge --squash 'github-bot/gh-2210'
git switch 'main'
git merge --ff-only 'github-bot/gh-2210'
git switch 'main'
git merge 'github-bot/gh-2210'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.