Recompiler: compact cases share code whose branch targets differ #1448
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1448
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1448"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Pipodi on GitHub · 2026-11-24 16:14 UTC · original
Pipodi:compact-shared-targets→main· +2173 −55 · 8 files · 5 commits · openStacked on #1316 (
5328b15, onmainafc5ee8); only the top commit (80fac65) belongs here.#1316's compact form keys a block's case on its text, and the text includes the branch offset (
xcl_b ± K). So blocks with the same code but different targets get different cases. The retail title'sActivateRays(95cc13288a27a96e, 19,949 blocks) gets 11,909 cases. Its table is then overMAX_TABLE_WORDS, and the program falls back to the normal form. This PR keys a case on the block's code and branch condition, and treats the target as data:xcl_b ± K.xcl_t = select(xcl_b == k, target, xcl_t).MAX_SELECTS(32) of them. Past that,[branch] if (xcl_b < pivot)splits the list until each leaf has at most 32 (xcl_bis wave-uniform, so the branch is too). Without it, a case that 1,799 blocks share ran 1,799 selects on every visit: @milesah3ad's probe found the dispatch up to 80 % slower than on #1316 (report); on this GPU I measured 37 % (table below). Cases with 32 or fewer differing targets emit the same text as before.MAX_TABLE_WORDSis now packed across words:bitsbits from bitxcl_b * bits, two reads, and one word of padding.ActivateRaysfits in 7,482 words. Tables under the cap are packed as before.compact_wantedalready counted distinct texts without the branch bytes, so the same programs are routed to the compact backend. One more of them now takes the compact form instead of falling back:ActivateRays. The two others below were already compact. Part of #1269.What is in it
crates/xcl/src/gpu/recomp/compact.rs:pick_targets,MAX_SELECTS);compact()takes the packing threshold, so tests can force it.crates/xcl/src/gpu/recomp/tests_compact.rs:Dispatch::ofreads the packed table;Dispatch::targetfollows a case's selects and branches for one block;shared_targets: the same block branches forward from one copy and backward from the other;gpu_compact_shared_targets: one case, oneselect, results identical totranslatein every form this adapter runs;many_targets: 64 copies of one block with different targets.compact_many_targets_take_a_bounded_path(CPU) checks every block reaches its target with at mostMAX_SELECTSselects; it fails with the bound removed (checked by passingusize::MAX).gpu_compact_many_targetscompares the results withtranslate;gpu_compact_dense_table: the packed table gives every block the case the usual packing gives it, with results identical totranslate, on 5 programs.Tested
rustc 1.100.0, DXC 1.9.2602.17.80fac65(on #13165328b15, onmainafc5ee8), debug:cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4gave 1292 passed, 0 failed, 46 ignored, in 23 result blocks. The commit's patch is the same as at7fadd08and57d7574; only the base moved. The measurements below were taken at57d7574and not rerun.lower_dxilper-lane f16/f32 cases (refused by the per-lane form, as onmain); 3 cases that need the D3D12 debug layer / SDK layers, which this machine does not have;heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).crates/xcl/examples/cmp1448.rsfroma8eebfd, copied in locally, not part of this PR), release,--rounds 3600 --vary 1 --dispatch 30, median of 30 dispatches:964f5ed--heap 0)--heap 1)[branch] ifselect/br i1DXC keeps the branches. With
--vary 0(all copies share targets), the HLSL and DXIL are byte-identical with and without the bound; dispatch #1316 9.92 ms, this PR 9.88 ms.xcl shaders <records> --precompile --only cs, then the same with--pipelines(release), on records of the retail title's three screen-probe programs. Each run had a freshXCL_DXIL_CACHEand a new exe path, so the NVIDIA driver cache missed (each log:pipelines made on the GPU 1, refused 0,loaded from the driver cache 0):ActivateRays's driver time and the bound: interleaved with the runs above, the same build without the bound (2.85 MB) took 162, 162, 164 and 201 s, and bound 64 took 200, 202 and 216 s. The means are 172 s (no bound), 203 s (32) and 206 s (64); the spread of each overlaps the others, so with 3–4 runs each I can't separate them. Bound 64 gives no gain in driver time and only a small one in the probe with heap windows (12.04 against 12.52 ms), so the PR keeps 32.490ccbb, as in the earlier revision of this description.Regression run
The retail title, 60 s,
XCL_PRESS_AT=16:A(the title takes A at its title screen 16 s in and loads for the rest of the run), no other variables. Both runs on this machine, back to back, with nothing else running.main06c9f55:This PR, head
80fac65:The PR's run got 112.5 % of
main's frames and 102.4 % of its peak commit.Not tested
translateon the GPU; only the small programs above were compared.translate's form ofActivateProbes(28.7 MB DXIL) was still in the driver after 33 minutes, so that comparison has no reference to run against.ActivateRays(in earlier runs neither log had acompact backendline), so the smoke pair is a regression check of the rest only.ActivateRaysin this form (87 GB of private memory in about 150 s). @DTsordas reports the same driver needs over 55 GB for it as 3.3 MB of direct DXIL too.ActivateRaysis 1.04 MB and built in 39 s in a title run on this GPU.AI use
eb1f131and5328b15. A second agent of the same model reviewed the change before the bound, and another reviewed7fadd08with the bound and the packing across words: nothing blocking (it noted that the tests do not reach a select tree deeper than one split). Subagents on Claude Sonnet 5.5 ran the smoke pairs (this one included) and did earlier rebases.🤖 Generated with Claude Code
@nnonno91 on GitHub · 2026-11-24 16:18 UTC · original
AMD native-wave64 test report for
6c7bb05Tested clean head
6c7bb05baa6f3bcb278f156e3473d377e42163b7on the Ryzen 7 9800X3D’s integrated Radeon graphics. The shared-branch-target and dense-table tests produced byte-for-byte identical results to the standard translator in native wave64 and wave32, with structured and unstructured control flow. The dense-table test covered 28 entries that cross a word boundary.Tested
XCL_ADAPTERselecting AMD,cargo build --workspace --lockedandcargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-outputpassed with 775 passed, 0 failed, 41 ignored, and no reported hardware skips. The synthetic end-to-end title passed.cargo test --locked -p xcl --lib gpu_compact_ -- --nocapture --test-threads=1reported 18 passed, 0 failed, 0 ignored on each adapter. I setXCL_REQUIRE_GPU=wave64on the AMD run. The NVIDIA run exercised split wave64 and reported one hardware skip,gpu_compact_native_wave64_form, which Cargo included in its pass count.Not tested
XCL_SAMPLE_BIG_CSfixture, retail shader equivalence, retail-title smoke runs, and performance. The checks above used the project’s synthetic test programs.AI use
@t4l03 on GitHub · 2026-11-24 16:22 UTC · original
Thanks for posting the exact stack. I tested the
ActivateRaysoutput from clean head6c7bb05baa6f3bcb278f156e3473d377e42163b7on the RTX 4070 Ti. This adds a lower-memory-budget data point for the four-switch-window form.Tested
translate_compacton the retail record with four switch windows and the original compute interface and static samplers. It emitted 2,516 cases and 2,275,162 B HLSL. An independent count found 10,096 target overrides. DXCcs_6_6 -HV 2021 -O1took 18.64 s and emitted 2,848,780 B DXIL, which passed validation.Not tested
AI use
Codex via T3 Code (
gpt-6.2-sol) pinned the head, wrote the external extractor, ran these checks and wrote the report. No game data or generated shaders attached.@vitor127wt on GitHub · 2026-11-24 16:46 UTC · original
Linux / Wine test of
ActivateRaysat6c7bb05I tested clean head
6c7bb05baa6f3bcb278f156e3473d377e42163b7in a Windows MSVC release cross-build. The isolated Series 1.0.2.1CS_ScreenProbes_ActivateRaysrecord (15ec6daefb19a780in XCL) took the compact route withXCL_COMPACT_CS=auto. Translation and DXC took 12.0 s with 1 compiled and 0 errors. The outputs were 2,275,162 B HLSL and 2,848,780 B DXIL, the same sizes reported in the exact-head Windows test. Windows comparisonI ran
xcl shaders <isolated folder> --precompile --only cs --windows 4 --split 1and then the same command with--pipelinesin a fresh process for each mode. One DXC worker and one PSO worker, XCL PSO and vkd3d-proton and NVIDIA disk caches disabled, and an 8 GiB cgroup with no swap. The PSO runs usedVKD3D_CONFIG=pipeline_library_logandVKD3D_CONFIG=legacy_structurizer,pipeline_library_log. Both logged an empty pipeline cache and shader hashcc7047005a5c7dca. The cached DXIL SHA-256 was unchanged.RTX 5070 Ti (16 GB), NVIDIA Linux driver
620.73.04, Ryzen 7 9700X, CachyOS x86-64 kernel7.3.5-2-cachyos, Wine 11.22, vkd3d-protonec20719452e916bwith dxil-spirv7c04863, Windows DXC1.9.2609.5. This is one offline PSO attempt per mode, without shader dispatch or a title run. Earlier Wine result for the same shader with #1316 and #1321AI use — Codex (GPT-6 family, exact variant unavailable) cross-built the exact head, ran the measurements, and drafted this report.
@Pipodi on GitHub · 2026-11-24 16:46 UTC · original
@t4l03 thanks, that is a bigger lever than the one I was measuring. On an RTX 4090, a build of the same
ActivateRaysinput that drops all 10,096 overrides (wrong output, a ceiling only) cuts the DXIL by only 6 % (2,848,780 → 2,672,544 B, DXC 21–25 s → 14 s). Together with your grouping result, the overrides look like a small part of the cost; sharing immediates goes at the case count itself. The driver timing of that ceiling build is not run yet.Two points before anyone writes it:
MAX_TABLE_WORDS= 8,192 (compact.rs:27-31). The comment there saysCreateComputePipelineStatetook 12,288 words on an RTX 5070 Ti and failed withE_OUTOFMEMORYat 15,360, for a single array. It is not known whether the limit is per array or for all static data together, which decides whether your parameter arrays fit.AI use: Claude Code (Claude Opus 5.5) wrote this comment; the 4090 numbers come from its own DXC runs on
98191af, a local build of #1448 with the overrides removed.@t4l03 on GitHub · 2026-11-24 16:45 UTC · original · edited 2026-11-24 16:53 UTC
Immediate-operand sharing follow-up on exact #1448 input
I used the
ActivateRaysHLSL emitted by6c7bb05baa6f3bcb278f156e3473d377e42163b7as input to a local prototype. Sharing case templates that differ at supported unsigned literal positions reduced the case count from 2,516 to 1,214. Decode-and-substitute matched all 19,949 input block bodies and their target expressions. The additional parameter arrays and repacked dispatch table take 11,078 routing words, up from 7,482. The emitted prototype retained 12-bit case IDs. Using 11 bits would bring the projected total to 10,455 words.RTX 4070 Ti driver 617.14, Windows 11 26300, Ryzen 7 7800X3D, DXC/validator 1.9.2609.5,
-O1. Same standalone compute ABI probe and static samplers, separate empty XCL caches and executable names. NVIDIA global DXCache stayed enabled.The immediate-sharing variants passed DXIL validation and each successful run saved a driver blob. The combined form uses the accessor block emitted by the local #1448 + #680 stack and the immediate-sharing dispatcher. Compared with heap windows alone it cut mean wall time and peak commit by about 67% each. The exact baseline and combined form each hit the 6 GiB process cap in a separate one-run check on the 7800X3D's AMD iGPU, with no blob.
I also tried grouping existing overrides by absolute target without adding tables. The mapping still matched all 10,096 overrides, and the code emitted 5,208 selects. DXIL grew to 2,868,640 B and the first NVIDIA run hit the 6 GiB cap, so I set that form aside.
This is a local compilation and pipeline-creation result. Compatibility of the extra static data, runtime heap binding, and retail dispatch output are still open.
AI use: GLM-5.3 via T3 Code built and tested the local HLSL adapter. Codex via T3 Code (
gpt-6.2-sol) verified the artifacts, ran the capped PSO checks and wrote this report. The prototype stays local.@Pipodi on GitHub · 2026-11-24 16:54 UTC · original
@t4l03 understood, it's yours; I've stopped my side of it. When you have a branch, I can run its GPU equivalence tests and a
--pipelinestiming ofActivateRayson an RTX 4090 with driver 617.42, in both window forms.AI use: Claude Code (Claude Opus 5.5) wrote this comment.
@t4l03 on GitHub · 2026-11-24 16:52 UTC · original · edited 2026-11-24 16:55 UTC
Thanks for checking the override cost and raising the table limit. I’m taking the immediate-sharing follow-up for now, so please hold off on a parallel implementation. I’m starting with the routing-data budget and GPU equivalence before deciding what is ready to stack on #1448.
The measured layout used 11,078 routing words in four arrays: 7,482 case words and 2,660, 624 and 312 parameter words. The 10,455-word figure was a projection using narrower case IDs.
For provenance, Codex (gpt-6.2-sol) planned and reviewed the experiments and ran the GPU pipeline benchmarks. GLM-5.3 wrote the local HLSL prototype. Any further implementation from my side will be written with GPT and will credit the prototype as prior work.
11-bit follow-up: Codex (gpt-6.2-sol) wrote and ran a scratch repacker on the combined heap variant. All 19,949 case IDs matched independently after repacking. The 10,455-word layout passed DXIL validation and built twice on the same RTX 4070 Ti, in 23.94 / 23.71 s at 1.425 GiB peak process commit in both runs. Both saved a 1,252,974-byte driver blob. The same isolated XCL cache setup was used, with NVIDIA global DXCache enabled. This removes 623 routing words from the measured 12-bit form. The total still exceeds 8,192 words, and retail dispatch correctness is still open.
@mastrr9 on GitHub · 2026-11-24 17:05 UTC · original
Verified head
6c7bb05baa6f3bcb278f156e3473d377e42163b7on Windows 11 / NVIDIA RTX 5080 (Blackwell, split-wave64):cargo test -p xcl --lib -- gpu::recomp --test-threads=4: 213 passed, 0 failed, 18 ignored (0 new compiler warnings).Clean pass on RTX 5080.
@kesku on GitHub · 2026-11-24 17:19 UTC · original
This gets
ActivateRays(95cc13288a27a96e) compiling on my 5080 now!!With #1316 the table needed 9,975 words and fell back to the old translator. With
6c7bb05it builds to 2.85 MB of DXIL, the driver accepts it, and the next run no longer waits on that pipeline.Tested on
b7aa9f3with #1316 and local storage/scheduling changes. Driver 621.01, DXC 1.9.2602.17 :)@imnicho on GitHub · 2026-11-24 17:21 UTC · original
Test report at
6c7bb05from a small machine (4 cores, 16 GB RAM):15ec6daefb19a780takes the compact form, its pipeline is built inside a title run, and the process no longer runs out of commit. This is the follow-up to my report on #1316 (https://github.com/ivall/xcl/pull/1316#issuecomment-7136355438), where that program's fallback ended every run.Tested
mainb7aa9f3+ #266 + #684 + #1288 + #680 (heap windows on, so sizes differ a little from the switch form's), and this PR at6c7bb05merged into it. One conflict, with #680 ingpu/recomp/mod.rs, resolved by hand as before.XCL_NETWORK=0, scripted pad, binds waiting (noXCL_PSO_WAIT_MS),XCL_COMPACT_CSunset, inside a job with a 50 GB commit cap, on the cache folder of the earlier runs.5e312d5(the earlier report)6c7bb0515ec6daefb19a780(76,699 instructions)0xc0000409at 125.8 s, before the world's set-upd122faa48eb0afdc(88,863 instructions) also takes the compact form here, at 733,609 B of HLSL.Not tested
AI use
@Pipodi on GitHub · 2026-11-24 17:26 UTC · original
@t4l03 the 4090 run of
235a71f. Your switch form was the one you asked about; it gets 1.4 GB smaller here, but not faster.Tested: RTX 4090 24 GB, driver 617.42, 32 GB RAM, Windows 11 Pro (26300), release build. Tree:
235a71fmerged locally with #680's final headdeb4b92(local5e48c35; I resolved two conflicts inrecomp/mod.rsby hand: both test modules kept, and the heap-window normalisation ofOptionsat the top ofprepare).xcl shaders <pack> --precompile --only cs --pipelinesonActivateRays(95cc13288a27a96e) alone, a new XCL cache per arm. NVIDIA's global DXCache is on: an arm whose DXIL was built before on this machine comes back from it in about 1 s, so the controls are my earlier cold runs. One run per arm.XCL_COMPACT_IMMEDIATES=1+XCL_HEAP_WINDOWS=16c7bb05+ #68095f34c1, heap (earlier cold run)XCL_COMPACT_IMMEDIATES=1, switch form6c7bb05, switch form (earlier cold runs)(immediate sharing)and made the pipeline, with 0 refused. DXC took about 20 s in each.cargo test --release -p xcl --lib gpu_compact_immediates_match_translate -- --test-threads=4on this tree: 1 passed, 0 failed, not skipped.Not tested: repeat runs (needed before the time difference means anything), the full suite on this tree, a title run, AMD.
AI use: Claude Code (Claude Opus 5.5) ran the builds and measurements and wrote this report.
@t4l03 on GitHub · 2026-11-24 17:29 UTC · original
Thanks for running both forms. The switch result is a useful cross-check: it completed above our 6 GiB cap, used less commit than your earlier control, and stayed within its timing range. I’ve added the 4090 result to the draft with the historical-control caveat. Git access has recovered and the tested fork SHA still matches.
@DavidM1911 on GitHub · 2026-11-24 18:54 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.@Pipodi on GitHub · 2026-11-24 18:55 UTC · original
@DavidM1911 thanks. #1316 was rebased onto
mainc160d86, and #1448 is now rebased onto it: headb370923(on #13165749171), no conflicts. The suite passed on the same files: 884 passed, 0 failed, 42 ignored, on the RTX 4090. A new smoke pair againstc160d86is running, and the description gets updated with it.AI use: Claude Code (Claude Opus 5.5) did the rebase and wrote this reply.
@t4l03 on GitHub · 2026-11-24 18:55 UTC · original
@Pipodi #1316 is now mergeable at
5749171. I’ll rebase #1548 and rerun its GPU tests and smoke check once #1448 is restacked, so the 3060 Ti retest can also use your updated head.@Pipodi on GitHub · 2026-11-24 18:56 UTC · original
@t4l03 it is restacked: #1448's head is
b370923, on #13165749171. Nothing in #1448's own commit changed from4cbb6b6, so #1548 should rebase onto it without trouble.AI use: Claude Code (Claude Opus 5.5) wrote this reply.
@WillyboPeep on GitHub · 2026-11-24 20:13 UTC · original
Test report:
b370923with #1321 on an RTX 4090,XCL_HEAP_WINDOWS=1. Both screen-probe programs the title uses are built and kept, and a title run loads them from the driver cache in 0.2 – 0.3 s. The world load still ends at the title's watchdog, now behind the other pipelines being built. Counts and timings only.Setup: NVIDIA GeForce RTX 4090 (driver 621.01, 32-lane waves), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro 26300, Rust 1.98.1 MSVC, release, DXC 1.9.2602.17, retail 1.0.2.1. Tree:
main9039900+ this PR (b370923, with #1316 / #1315) + #1321 (0936337, its head when I built; it is at69a892cnow) + two approved VFS / script PRs (#1170, #1229).XCL_HEAP_WINDOWS=1throughout.recomp/mod.rs. After #1316'sprepare()split, #1321'slet program = code;belongs at the top oftranslate; git put it inprepare, where nothing uses it, andtranslatethen does not build. With that line moved it builds.cargo test --release -p xcl --lib -- --test-threads=4on that tree: 836 passed, 0 failed, 22 ignored. SKIPPED:gpu_compact_native_wave64_form(no wave64).The two programs offline:
xcl shaders <pack> --precompile --only cs --pipelines, limited by a local filter to the title'sused-pipelines.txt, everything else already in the driver cache, one driver compile at a time.CreateComputePipelineState56c0cd3b82a00c6e)95cc13288a27a96e)Your 199.3 s for ActivateRays on a 4090 above was without heap windows, as far as I can tell. ActivateProbesTarget is not in this title's
used-pipelines.txthere, so it was not built.A title run on that cache: A pressed every 4 s from 15 s, page file grown beforehand.
+0x23cf683) came at 116.9 s.bind::execute_indirect→pso_async::resolve_wait, with 4 threads in DXC and 6 innvgpucomp64.dllwhile graphics pipelines were being built (the 2001st at 109 s).nvgpucomp64.dll. One run each, so the times say little; what changed is that the screen-probe programs are no longer what is waited for.Not tested: a title run of this PR without #1321 or without heap windows; ActivateProbesTarget; AMD.
AI use: Claude Code (Claude Opus 5.5) ran the builds and runs on my PC and wrote this report.
@Pipodi on GitHub · 2026-11-24 20:13 UTC · original
@WillyboPeep thanks. You're right: my 199.3 s for ActivateRays was without heap windows. With them and this PR, 69.4 s at 4.8 GB on the same GPU is a useful number. Two notes:
XCL_COMPACT_NEST=32, on top of this PR) cut the same program to 31.8 s in the driver on @brothernog's RTX 3050 in the heap form. If you rerun, it is one variable away.This PR is rebased onto #1316's new head (
f207df1). The new head goes up once its suite and smoke runs are done, so yourb370923result stays on the record for the old head.AI use: Claude Code (Claude Opus 5.5) wrote this reply.
@Pipodi on GitHub · 2026-11-24 20:20 UTC · original
Rebased onto #1316's new head
f207df1(onmain85e3826, after #1524). The new head is42b2f11. The commit's patch is the same asb370923's; only the base moved.main85e3826reached 98.6 % ofmain's frames and 96.6 % of its peak commit, with no crash or device removal.The description has the new counts and both blocks. The new
pso_measurement_compiles_an_exact_synthetic_recordtest from #1524 is SKIPPED here, because it needs Windows Developer Mode.AI use: Claude Code (Claude Opus 5.5) rebased and wrote this comment. A Claude Sonnet 5.5 subagent ran the suite and the smoke runs.
@milesah3ad on GitHub · 2026-11-24 20:52 UTC · original
A synthetic case that this change makes slower to run, not only bigger: when many blocks of one case jump by a minority offset, the per-block
selectchain grows with the program, and since it sits inside the case, it runs every time the case does. On an RTX 5080 that cost +80 % GPU time on the larger program. The suite passes.Setup: RTX 5080 16 GB, driver 621.24, Ryzen 7 9800X3D, 64 GB, Windows 11 Pro 26300, rustc 1.100.0, DXC 1.9.2609.5. This commit at
b370923(same patch as42b2f11) against its base, #13165749171; release for the probe, debug for the suite.Probe:
cmp1448(a8eebfd, local tooling, not for merging) callscompact::translate_compacton a synthetic program (128 threads, wave64 + split wave64, 4 windows). Every round is the same code (an LCG step, a load + store, then anifheader:v_cmp/s_and_saveexec/s_cbranch_execz). The header jumps over a one-block body in even rounds and a three-block body (a nestedif) in odd rounds, so identical headers jump by two different block counts. It's deliberately adversarial: half of that case's blocks are at the minority offset.compact_wantedis true for both sizes.Tested
cargo build --workspacethencargo test --workspace --no-fail-fast -- --test-threads=4onb370923: 884 passed, 0 failed, 42 ignored. SKIPPED:gpu_compact_native_wave64_formand the two wave64-only tests (no wave64), andheap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--vary 0, every header jumps the same way, 32k / 65k instructions): byte-identical DXIL on #1316 and here, both forms.--vary 1:xcl_t = selectlinesrunner::dispatch_timed, 2 salted variants each. Min and max are within 0.3 % of the median. #1316's time doubles with the program (4.05 → 8.11 ms); this commit's grows 3.3× (4.38 → 14.63 ms).Reading: for the retail programs in the description, this is a win (ActivateRays becomes buildable). The cost shows up when a case has many blocks at minority offsets: one
selectper such block, all evaluated on every execution of the case. Counting thexcl_t = selectlines per case inActivateRays' HLSL would show whether retail programs get near this. If they can, a cap on the minority blocks per case (above it, keep the targets apart as #1316 did) or the target in the block table instead of a select chain would bound it.Not tested
AI use
@Pipodi on GitHub · 2026-11-24 20:56 UTC · original
@milesah3ad thank you. The probe is right, and the retail program gets there. I counted the
xcl_t = selectlines in #1448's own HLSL for ActivateRays: the same patch as42b2f11, the dump whose DXIL is the description's 2,848,780 B. Counts only:I'll bound it in this PR. The selects stay where a text has few minority blocks; above a cap, those blocks get their target from data instead of the chain, at a constant cost per execution. I'll come back with the design and its numbers: case count, table words, DXIL and driver time for ActivateRays, and your probe's GPU time.
Until then I'm moving this PR and #1692, which is stacked on it, back to draft, because a fix is pending.
AI use: Claude Code (Claude Opus 5.5) counted the dump and wrote this comment.
@t4l03 on GitHub · 2026-11-24 20:57 UTC · original
@Pipodi one budget detail for the data-backed version: on ActivateRays the current block table is 7,482 words, and #1548 adds a 708-word literal table. That leaves two words under #1548’s combined 8,192-word cap. When I restack #1548, I’ll check that its optional literal sharing accounts for the new target data and that the standard compact route still works when there’s no room for literals.
AI use
Codex (gpt-6.2-sol) checked the emitted table sizes and drafted this note.
@Pipodi on GitHub · 2026-11-24 21:16 UTC · original
Two corrections to my comment above, and where the design stands. @t4l03 this changes your budget.
XCL_BTis 7,482 of 8,192 words, so 710 are free (2 beside #1548's 708-word literal table), and the 1,347-select chain alone needs 1,264 words in the most compact layout I counted. So the fix adds no table words and leavesXCL_BTunchanged. It bounds the chain inside the case's code. For #1548 that means a recount, not a new budget.AI use: Claude Code. A Claude Fable 5.2 subagent counted the dump and the table layouts. Claude Opus 5.5 (the main session) checked the counts against the plan and wrote this comment.
@milesah3ad on GitHub · 2026-11-24 22:27 UTC · original
@Pipodi thanks. So the candidates can be compared with the numbers above, here is how they were made. The probe is the single file
crates/xcl/examples/cmp1448.rsfroma8eebfd. Copy it into any tree that hascompact::translate_compactandcompact::compact_wanted, thencargo build --release --example cmp1448.Each line prints the cases, HLSL / DXIL size and DXC time.
--dispatch 30runs the program 30 times on the GPU (64 groups, addresses in window 0) and prints the median. The GPU times in my table are those medians. The trees were #13165749171and #1448b370923, RTX 5080, driver 621.24, release:--roundsSeeds 1 and 2 agree to within 0.02 ms. I can run it on the candidate branches here too if that saves you a step. Push them and tag me.
AI use: Claude Code (Claude Opus 5.5) wrote this. The numbers are from the run logs behind my report above.
@Pipodi on GitHub · 2026-11-24 22:48 UTC · original
@milesah3ad thanks for the probe and the exact commands: they found a real problem. The new head
57d7574(still stacked on #1316964f5ed) bounds the select list: a case evaluates at most 32 selects, and past that[branch] if (xcl_b < pivot)splits the list (xcl_bis wave-uniform). Cases with 32 or fewer differing targets emit the same text as before.Your probe from
a8eebfd, copied in locally,--rounds 3600 --vary 1 --dispatch 30, release, RTX 4090 (driver 617.42), median of 30 dispatches:964f5ed57d7574(bound 32)--heap 0)--heap 1)DXC keeps the branches (92 conditional branches in the DXIL against 36 without the bound). With
--vary 0the HLSL and DXIL are byte-identical with and without the bound.The cost of the bound is in the driver: a cold build of the screen-probe
ActivateRaysprogram took 175–233 s (mean 203 s, 4 runs) against 162–201 s (mean 172 s, 4 runs) without it, interleaved. The spreads overlap. A bound of 64 was no better (200–216 s). The PR description has the full tables, the suite (986 passed, 0 failed, 42 ignored) and the smoke pair againstmain689f2db.You offered to run the probe on the new head. On your RTX 5080 that would be welcome, especially
--rounds 1800and3600with--heap 0and1.AI use: Claude Code with Claude Opus 5.5 made the change and the measurements and wrote this comment.
@milesah3ad on GitHub · 2026-11-24 22:56 UTC · original
@Pipodi the bound holds on Blackwell as well: on the RTX 5080 the adversarial case is back at the parent's time, or under it in the switch form.
Tested: RTX 5080 16 GB, driver 621.24, Ryzen 7 9800X3D, Windows 11 Pro 26300, rustc 1.100.0, DXC 1.9.2609.5, release. The probe at
a8eebfdbuilt on #1316964f5edand on this head57d7574.--vary 1 --dispatch 30, two seeds per row, trees interleaved per configuration. GPU dispatch medians:--rounds964f5ed57d7574(bound 32)--heap 0)--heap 1)--vary 0 --rounds 3600): byte-identical DXIL on both trees.5749171. The parent's times here (8.10 / 7.95 ms) match that run's (8.11 / 7.94 ms), so the columns are comparable.Not tested: cold driver builds of
ActivateRays(no title here), the suite on this head, AMD.AI use: Claude Code (Claude Opus 5.5) ran the builds and measurements on the machine above and wrote this report. I checked the numbers against the logs.
@Pipodi on GitHub · 2026-11-25 00:05 UTC · original
Back to draft: since
mainmerged #1836, #1316 (which this PR is stacked on) conflicts withmaininpso.rs(details). This PR's own commits don't touch that code. I'll rebase onto #1316's new head once it's rebased, rerun the suite and smoke, and mark it ready again.AI use: Claude Code with Claude Opus 5.5.
@t4l03 on GitHub · 2026-11-24 17:16 UTC · original · edited 2026-11-25 08:04 UTC
@Pipodi the GPT-written Rust follow-up is available in #1548. The version tested here was stacked on your then-current #1448 head. Set
XCL_COMPACT_IMMEDIATES=1to try it with the usualxcl shaders … --precompile --only cs --pipelinescommand.XCL_COMPACT_CSstill controls eligibility and the translated cache has a separate_cientry.On
ActivateRaysit emits 2,281 cases (was 2,516), with 7,482 dispatch words and 708 operand words. An independent decode check matched all 19,949 emitted block bodies and branch mappings. The synthetic GPU equivalence test passed on RTX 4070 Ti and AMD iGPU with native or split wave64 as available:cargo test --locked -p xcl --lib gpu_compact_immediates_match_translate -- --nocapture.On the 4070 Ti (617.14), the new output with #680's heap accessors built twice in 64.76 / 63.26 s at 3.509 / 3.492 GiB. The matching #1448 + #680 control was 81.49 / 78.11 s at 4.340 / 4.338 GiB. The new switch form still hit the 6 GiB process cap in one run. These were standalone PSOs with separate XCL caches and NVIDIA global DXCache enabled. The 4090 comparison you offered would be useful, particularly the switch form. The heap arm needs #680 on top of this stack.
AI use: Codex (
gpt-6.2-sol) wrote and tested the Rust implementation and wrote this report. The earlier GLM-5.3 HLSL prototype motivated the work.@t4l03 on GitHub · 2026-11-24 17:23 UTC · original · edited 2026-11-25 08:04 UTC
Quick status on the test branch after the repository transfer: GitHub’s API still shows the test branch on the fork, but Git fetches of both the fork and
xcl-dev/xclcurrently return HTTP 403 with a repository-disabled message. The branch may be unavailable to clone for now. The release CLI check and both 60-second smoke runs are complete. I’m keeping the patch ready while Git access and draft PR creation are blocked.@t4l03 on GitHub · 2026-11-24 20:55 UTC · original · edited 2026-11-25 08:04 UTC
@milesah3ad I counted the branch-target selects in the retail ActivateRays record
95cc13288a27a96e. I exported it with four memory windows and--split 0from the #1548 revision stacked on42b2f11, togglingXCL_COMPACT_IMMEDIATES. Both switch and heap windows gave the same counts.The longest retail chain is between the 899- and 1,799-select synthetic probes. These are emitted HLSL counts. We still need to know how often that retail case executes and what it costs on the GPU. If #1448 changes how it emits target selection, I’ll carry that through to #1548 when I restack it.
AI use
Codex (gpt-6.2-sol) ran the exports, counted the selects, and drafted this reply.
@itsSio on GitHub · 2026-11-25 10:13 UTC · original
Tested
Independent check requested in #1269, on clean PR head
7fadd08829e3713cdef26829e81356920b9866e4, no local patches or merge. Both systems: Windows 11 Pro 26200, x64 MSVC, unoptimized dev/test with debug info off.cargo build --workspace --lockedsucceeded on both.cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --nocapturecompleted all 21 test result blocks on each:32.0.16.108832.0.16.1088Both logged 21 native-wave64 skips, three per-lane f16/f32 refusals, unavailable driver-cache control and unavailable heap windows. The RTX 2080 SUPER also skipped two D3D12 debug-layer tests (
test_title_draws_with_a_root_signature_under_the_debug_layer,uploads_start_from_each_subresources_state).cargo test -p xcl --lib --locked gpu::recomp::tests_compact -- --test-threads=1 --nocapture: 21 / 0 / 0 on the Radeon RDNA2 iGPU (32.0.21043.5001, same Ryzen 7 system) with no runtime skips; 21 / 0 / 0 on the RTX 2080 SUPER with one native-wave64 skip. The shared-branch-target check matched the reference output. The RTX 2080 SUPER results were recovered from the two completed on-disk logs because the runner did not return a terminal response.Not tested
Retail smoke or samples, full AMD workspace, RADV, Intel, or compile and execution performance.
AI use
Ran via Samaritan:
openai/gpt-6.2-sol): ran the checks, recovered and verified the logs, and wrote this report.@DavidM1911 on GitHub · 2026-11-26 00:26 UTC · original
Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current
mainon the new head — needs another rebase before it can be tested.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.Merge
Merge the changes and update on Forgejo.