Proposal: a GPU interpreter of RDNA2 compute code as the stand-in while a compute pipeline compiles #1455
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#1455
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@brothernog on GitHub · 2026-11-24 16:20 UTC · original
Proposal, no code yet. I'm opening it as an issue so the work can be split, not as a claim.
The problem it targets
Everything in #1269 makes the compile faster. This targets the wait instead. Today, a graphics pipeline that isn't built yet gets a stand-in that draws nothing, but a compute pipeline is waited for at its first bind, because a skipped dispatch would corrupt what it computes (
hle/d3d12x/pso_async.rs, module comment). Those waits are what stall the render thread at loading fades and trip the title's watchdog. Even with the heap windows (~3–5× less driver time on NVIDIA) and #1316 for the giant programs, a cold compute PSO still costs seconds to minutes, and the title creates them while it loads.The idea
One compute shader that executes RDNA2 machine code: it fetches the program's dwords from a buffer, decodes, and runs them instruction by instruction, with the register file in memory.
Why it may be cheaper than it sounds
vreg/sreg/code32/write32ingpu/recomp/emit.rs. The per-opcode semantics (salu,valu,valu64, …) are format strings over operand strings. A generator could emit each opcode's body once, with operands as runtime fetches from the register file, so the interpreter's coverage follows the translator's instead of being a second implementation.What I don't know (each could kill it)
sampler_ref,constant_samplers). An interpreter needs them at run time, through bindless heap access from the T#/V# in SGPRs.Pieces anyone can take (each stands alone and gives a number)
s_load,buffer_load/store, branches, EXEC) as a local GPU test. It runs synthetic programs and compares against the translated form, as the recompiler's GPU tests already do.CreateComputePipelineStatetime and memory for the interpreter at 50 / 200 / all opcodes, on NVIDIA and AMD.emit.rs, so a new opcode in the translator lands in the interpreter too.pso_asyncpoints at the interpreter with the program's dwords and the same root signature as the translated CS, so the swap stays invisible to the title.If B or C comes out bad, the idea is dead, and that is a useful result too. I can take B on an RTX 3050 8 GB once a subset exists, and help with A.
AI-assisted.
@phalstead on GitHub · 2026-11-24 18:17 UTC · original
I've been experimenting with the GPU-interpreter approach proposed here and have completed two standalone feasibility spikes on an RTX 4080 (Windows 11, D3D12).
Workstream B — Compilation/PSO cost
Workstream A — Interpreter prototype
Important limitations: This is not raw in-shader RDNA2 decoding or an XCL-integrated interpreter. MUBUF handling is simplified, wavefront semantics are incomplete, and the performance comparison is not yet instruction-equivalent.
The early results suggest synthetic PSO creation cost isn't an immediate blocker on this NVIDIA configuration. The remaining questions are semantic coverage and interpreter execution performance.
I have the source, build instructions, and raw results available for reproduction. Would a standalone test harness be useful to the project before attempting tighter integration with XCL's decoder and GPU tests?
@brothernog on GitHub · 2026-11-24 18:27 UTC · original
@phalstead thanks, this is exactly the kind of number the issue was waiting for. Yes, please publish the standalone harness (a branch or repo link here is enough). A spike that anyone can rerun on their own GPU is worth more right now than an early integration.
Two things would make B conclusive before we lean on it:
gpu/recomp/runner.rs), would give the first real slowdown factor.Once the harness is up, I'll run B on an RTX 3050 8 GB (driver 610.88) for a second NVIDIA data point, with the shader cache cold.
This comment was AI-assisted.
@phalstead on GitHub · 2026-11-24 19:03 UTC · original
Thanks, this is really helpful feedback.
Agreed on both points. The original B benchmark used synthetic switch bodies, and I didn't establish that the driver cache was cold. So the 0.8–1.5 ms PSO numbers shouldn't be treated as representative of XCL's translated shader compilation costs yet.
I'm packaging the standalone harness with build instructions and raw results so it can be reproduced on another GPU. I'll also add distinct-DXIL/cache-controlled tests and more translator-shaped instruction bodies.
For A, I'll work toward one instruction-equivalent comparison using XCL's existing GPU recompiler test infrastructure in
gpu/recomp/runner.rs, rather than relying solely on hand-written native HLSL.I'll share the repository link once the package passes its clean-build and publication checks. Appreciate the offer to test it on the RTX 3050!
Workstream C update — synthetic interpreter performance
I completed a standalone RTX 4080 performance study comparing the RDNA2-subset interpreter against native HLSL across 45 synthetic workloads (450 benchmark runs).
These are prototype microbenchmark results, not measurements of real XCL compute workloads. The native HLSL comparison is not RDNA2-ISA-equivalent, and the interpreter still uses one GPU thread to simulate a 64-lane wave.
The results suggest that execution architecture is a significant performance concern. I haven't yet validated a cooperative multi-thread wave implementation or measured representative XCL workloads.
My proposed next step is a small, correctness-verified cooperative-wave prototype to determine whether distributing simulated lanes across GPU threads materially improves execution time before expanding opcode coverage or attempting integration.
@brothernog on GitHub · 2026-11-24 19:33 UTC · original
@phalstead the C numbers are useful even as microbenchmarks, and I agree with your next step. One thought on the cooperative-wave prototype, in case it helps the design:
switchare wave-uniform: the dispatch branch doesn't diverge, and only the operation itself is per lane. VGPRv[n]of lane k lives in thread k; SGPRs, the PC and SCC/VCC are wave-uniform (one copy in groupshared, or kept uniform withWaveReadLaneFirst); EXEC becomes each thread's "active" bit. That is the same mapping XCL's translated code uses (one console lane per PC thread), which should also make the instruction-equivalent comparison more direct.ds_swizzle,v_readlane, ballots) going through groupshared, as the translator's split wave64 mode does (split_wave64ingpu/recomp).If most of the 87–4 019× comes from the 64 lanes running in series, this mapping should remove that factor, and what remains is the real interpreter overhead (decode and operand fetch). Rerunning the same 32 / 512-instruction workloads with it would show how much of the gap that is.
This comment was AI-assisted.
@phalstead on GitHub · 2026-11-24 20:18 UTC · original
Thanks, that's a really useful architectural direction, especially the wave64 mapping and VGPR allocation suggestions.
I'm going to use the one-thread-per-lane model for the cooperative-wave experiment, with explicit synchronization across the two native wave32 halves and correctness checks against the existing CPU reference.
I'm also preparing the standalone A/B/C harness for a public GitHub repository so you can reproduce the existing results on your RTX 3050. The initial release will clearly distinguish synthetic benchmarks from actual XCL-translated shader measurements, and note that the NVIDIA cold-cache behavior is not yet proven.
I'll share the repository link once the clean-build and publication checks are complete. Thanks again for the detailed feedback!
@phalstead on GitHub · 2026-11-24 20:33 UTC · original
Thanks @brothernog! The standalone harness is now published:
https://github.com/phalstead/xcl-rdna2-gpu-interpreter-bench
Commit:
ee724e3d141ada87f3d67de672ecdacf7e98cbf7It includes the RDNA2-subset GPU interpreter, benchmark sources, Windows/D3D12 build instructions, and captured results.
To reproduce:
A few important caveats:
I'd welcome your RTX 3050 results or any reproduction issues you encounter.
I'm also proceeding with the cooperative-wave prototype using your one-thread-per-lane design suggestions, including wave64 synchronization and program-specific VGPR allocation.
Thanks again for the guidance!
@CowboyBingus on GitHub · 2026-11-24 20:44 UTC · original
I'm taking the implementation of this, as two stacked PRs:
hle/d3d12x/pso_async.rs,bind.rs): when a compute bind would wait on its pipeline build past a small budget, it binds a stand-in pipeline with the same root signature and keeps building the translated one in the background; later binds use the translated pipeline once it's built. With no stand-in available, binds wait as they do today. It ships with no provider, so it changes nothing on its own.gpu/interp/) as the first provider: one program built once, running the console code from a table through XCL'srdna2::decodeand the translated pipeline's root signature, with per-instruction GPU tests against the translated path. Stacked on 1.Why compute needs an exact stand-in rather than a skip, from our runs (RTX 5070 Ti, driver 621.24):
pso_async::resolve_for_bind, waiting on or compiling compute pipelines (translated_compute_pso -> finish_pso).0x887a0006); in the two runs that waited instead (noskip-1/-2), it didn't.phalstead's bench is a standalone harness (own decoder, 29 ops, one thread per wave); the XCL version needs the title's real opcode set, LDS, wave ops and the translated root signature. Its numbers are a useful reference, and anything I use from it will be credited.
I'll post the opcode coverage of the slow programs and the interpreter's build and dispatch times when I have them.
AI use: Claude Code (Claude Opus 5.5) wrote this.
@phalstead on GitHub · 2026-11-24 20:49 UTC · original
Thanks @CowboyBingus! Glad the standalone benchmarks are useful.
I'm happy to help with independent RTX 4080 validation as the stacked PRs develop, particularly interpreter-vs-translated correctness, dispatch timing, and NVIDIA wave32/split-wave64 behavior.
I also have the standalone harness published here for reference:
https://github.com/phalstead/xcl-rdna2-gpu-interpreter-bench
I'll avoid duplicating your implementation work. Once you have opcode coverage or a testable branch, I can focus on whichever validation gaps would be most useful.Thanks @CowboyBingus! Glad the standalone benchmarks are useful.
I'm happy to help with independent RTX 4080 validation as the stacked PRs develop, particularly interpreter-vs-translated correctness, dispatch timing, and NVIDIA wave32/split-wave64 behavior.
I also have the standalone harness published here for reference:
https://github.com/phalstead/xcl-rdna2-gpu-interpreter-bench
I'll avoid duplicating your implementation work. Once you have opcode coverage or a testable branch, I can focus on whichever validation gaps would be most useful.
@phalstead on GitHub · 2026-11-24 21:07 UTC · original
Follow-up on the instruction-equivalent comparison requested by @brothernog.
I ran the
gpu_scalar_loop_and_sccloop-prefix program through XCL's translated GPU path and our standalone predecoded RDNA2 interpreter on an RTX 4080 (NVIDIA 621.24, DXC 1.8.2502.11).Correctness:
s0 = 55andv1 = 55across all 64 lanes.Preliminary GPU timings:
XCL source was pinned to
4178e888; standalone harness baseline wasee724e3.Caveat: This is a bounded, instruction-equivalent microtest, not a retail shader benchmark. The XCL dispatch timing is near the timestamp resolution, and the two harnesses have different measurement setups. The exact slowdown ratio should be treated as preliminary pending aggregated-dispatch validation.
The standalone harness is available here:
https://github.com/phalstead/xcl-rdna2-gpu-interpreter-bench
Happy to provide additional RTX 4080 correctness and timing validation as the stand-in interpreter PRs develop.
@brothernog on GitHub · 2026-11-24 21:12 UTC · original · edited 2026-11-24 22:53 UTC
@phalstead thanks for publishing it. Here is
cold-bfromee724e3on the RTX 3050 8 GB (desktop, Ryzen 7 5800XT) (NVIDIA 610.88, Windows 11 build 26300, MSVC frombuild.cmd, DXC 1.9.2602.17 from the Windows SDK 10.0.26100bin\x64),--runs 3, 36 rows, 0 incorrect.On this machine, run 0 is a cold driver compile. This harness had never run here before, and the DXIL hashes differ from the ones in your
results/for every variant, so the NVIDIA disk cache can't have held them. That covers the caveat in your first point, at least for run 0.95cc13288a27a96e) is 2.5 MB of DXIL and took 312 s cold in the driver (#1692). An interpreter built once, at this size, costs well under a second of driver time, which is the property @CowboyBingus's stand-in tier relies on.Not run here:
translatorandxcl-compare.This comment was AI-assisted.
@phalstead on GitHub · 2026-11-25 01:35 UTC · original
Independent RTX 4080 benchmark follow-up for #1455 (AI-assisted investigation, human-directed).
I repeated the earlier scalar-loop microbenchmark using aggregated GPU timestamp measurements to reduce single-dispatch timestamp quantization effects.
Both the XCL translated path and standalone interpreter produced the expected results:
s0 == 55andv1[lane] == 55across all 64 lanes.Results — batch of 1,000 dispatches, 30 trials:
Measured standalone/XCL ratio: approximately 48.1× (46.7× at batch 10,000). The earlier approximately 60× single-dispatch estimate was affected by timestamp quantization.
Environment: RTX 4080, NVIDIA 621.24, Windows 11 build 26200, DXC 1.8.2502.11.
Pinned baselines:
4178e888c0b5be50a2887eda45cdb832763b68a4ee724e3d141ada87f3d67de672ecdacf7e98cbf7The reproduction package includes instrumentation patches, raw results, logs, exact reproduction instructions, and measurement limitations:
github.com/phalstead/xcl-1455-bench-repro-package@0ba52685a8The XCL instrumentation patch also passed a fresh same-machine clone reproduction.
This is a synthetic seven-instruction scalar-loop microbenchmark, not a general shader-performance or production-viability claim. Measurements include inter-dispatch barriers and command-list overhead, exclude compilation/PSO creation, and compare different execution architectures rather than identical internal execution boundaries.
This is independent benchmark evidence only, not a competing production interpreter implementation.
@brothernog on GitHub · 2026-11-25 02:07 UTC · original
A static census of the retail pack's compute programs, to size the interpreter against the issue's unknowns. It's local and offline, numbers only:
mainc2dcef3plus a small localxcl shaders --censusthat decodes every program and counts what each one uses. It reproduces the existing totals (26 698 programs;image_gather4_lin 16 shaders, 58 occurrences).Population. 2 689 programs have a compute interface. I banded them by console instruction count, as in #1096, because only the big programs compile slowly enough to need a stand-in.
Coverage is greedy: mnemonics are taken in order of how many programs in the band use them.
What each band uses (share of programs using the feature at least once, plus its share of instructions):
recomp::detect_wave64sees it)ds_*except swizzle/permute)s_barrierWhat this says about the unknowns.
cold-bswitch was 86–91 ms cold at 400 cases on the RTX 3050, but its case bodies are trivial. Real bodies (descriptor fetches, modifiers, 64-bit ops) will cost more, so B on the real interpreter is still the measurement that decides it.v_readfirstlane42 %,v_readlane40 %,v_writelane15 %,v_permlanex163 %) and DPP are near universal, but they're about 1.4 % of instructions.Limits. These are static counts. They can't say how often an instruction runs, so they say nothing about speed (C). Instruction count stands in for compile time: #1096 found DXC time roughly proportional to it, and the slowest driver compiles there were the biggest programs. I didn't check which of these programs are the ones a run actually waits on.
@CowboyBingus I don't see the two stacked branches yet, and I don't want to step on your PR 2. Would it help if I took D (opcode bodies generated from
emit.rs), or would you rather I wait and run B and the per-instruction tests of your branch on the 3050? The census patch is 83 lines. I can open it as a PR if a--censusmode would be useful to others.This comment was AI-assisted.