Skip to content

Tests: time DXC on generated RDNA2 programs and write JSON / CSV (#1269) - #2100

Draft
BetterJdue wants to merge 3 commits into
xcl-dev:mainfrom
BetterJdue:compile-bench-dxc
Draft

BetterJdue wants to merge 3 commits into
xcl-dev:mainfrom
BetterJdue:compile-bench-dxc

Conversation

@BetterJdue

Copy link
Copy Markdown

Stacked on #1763; only the top commit (cc131b2) belongs here.

Times the HLSL → DXIL compile of the programs #1763 generates, so the compile-time work in #1269 gets numbers that need no game data and can run in CI. Shader and pipeline compile time is the biggest obstacle to getting past world loading (#1833). Test-only: nothing in crates/xcl/src.

Part of #1269

What is in it

  • crates/xcl/tests/compile_bench/measure.rs: each program is translated (recomp::translate) and compiled with dxc::compile, one at a time; it records the HLSL and DXIL sizes and the DXC times (a repeat must give the same HLSL and DXIL size). A small set of 6 programs runs in every test run; XCL_COMPILE_BENCH=full runs 44: five shapes at 500 to 20 000 operations, the four wave64 ones also in the split form (a GPU with only 32-lane waves) with 4 memory windows, and two controls. XCL_COMPILE_BENCH_OUT writes JSON and CSV with the commit, DXC version, build profile and CPU.
  • crates/xcl/tests/compile_bench/gen.rs: buffer, image and compute knobs. At zero they give Tests: generate RDNA2 programs for compile-time measurements (#1269) #1763's programs unchanged (a golden-hash test).
  • crates/xcl/tests/compile_bench/main.rs: tests of the new knobs, of the JSON / CSV and the DXC run (SKIPPED without DXC).

Tested

  • AMD Radeon RX 6700 (RDNA2), driver 32.0.21045.29003; Ryzen 5 3600; 32 GB RAM; Windows 11 Pro 26300; Rust 1.100.0 MSVC; DXC 1.9.2602.17.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on cc131b2 (debug): 761 passed, 3 failed, 41 ignored. The failures are not from this PR: placed_title_textures_share_vram_and_preserve_pixels, transitions_apply_when_their_list_is_submitted, d32s8_targets_take_their_own_size_of_video_memory; the first ("3D 64x64x64 4 mips: subresource 2 mismatch") also fails alone on main b9b6ea6, and the other two fail on the lock it poisons (PoisonError). D3D12.X: map and unmap 3D texture mips separately #1028 is about the same failure. SKIPPED: none.
  • cargo test -p xcl --test compile_bench: 13 passed, 0 failed.
  • Negative control: six changes to the code (a buffer, image or compute knob ignored, Tests: generate RDNA2 programs for compile-time measurements (#1269) #1763's programs changed, the CSV separator, the knobs not flattened into a row) each make one or two of the tests fail.
  • The full set, release, 3 compiles per program, on ae43075 (this commit before its rebase onto 0f257d1, plus one that adds scripts and a README section), 44 programs; 0f257d1 only refuses loops out of the branch range, so the programs are the same (the golden-hash test passes on both). Their medians add up to 693 s; the 5 slowest programs take 70 % of it. The split form (a 32-lane GPU) against the native one, DXC median:
program ops HLSL native / split DXIL native / split DXC native / split
base 2000 407 kB / 468 kB 64 kB / 171 kB 0.7 s / 1.9 s
base 8000 1.6 MB / 1.7 MB 252 kB / 698 kB 3.3 s / 11.9 s
base 20000 3.9 MB / 4.4 MB 662 kB / 1.8 MB 10.4 s / 54.9 s
divergent 2000 1.2 MB / 1.3 MB 200 kB / 702 kB 1.9 s / 12.3 s
divergent 8000 5.0 MB / 5.3 MB 860 kB / 3.0 MB 9.1 s / 133.7 s
divergent 20000 12.6 MB / 13.1 MB 5.5 MB / 16.1 MB 24.2 s / 135.2 s
loops 2000 440 kB / 499 kB 71 kB / 175 kB 0.8 s / 2.0 s
loops 8000 1.7 MB / 1.9 MB 261 kB / 709 kB 3.8 s / 12.1 s
loops 20000 4.3 MB / 4.7 MB 673 kB / 1.8 MB 11.0 s / 55.5 s
resources 2000 522 kB / 639 kB 82 kB / 217 kB 1.1 s / 3.0 s
resources 8000 2.0 MB / 2.4 MB 325 kB / 893 kB 5.7 s / 21.0 s
resources 20000 5.1 MB / 6.1 MB 830 kB / 2.3 MB 20.4 s / 106.6 s

Sources over 1 MiB get -O1 and over 8 MiB -O0 from dxc.rs, so the 20 000-operation divergent programs are compiled at -O0.

Not tested

  • Game data and scripts/smoke.ps1: none used; the change is test-only.
  • Other CPUs and DXC versions: the times are wall-clock and only comparable on one machine.
  • NVIDIA and Intel; macOS and Linux (not built).

AI use

  • Claude Code (Claude Opus 5.5) wrote the code, the tests and this description, and ran the tests and the measurement.

BetterJdue and others added 3 commits November 24, 2026 16:05
…#1269)

The synthetic compile-time benchmark of xcl-dev#1269 needs console programs that
anyone can build, CI included, without game data. This adds the generator
it will measure: deterministic RDNA2 programs, assembled with
rdna2::encode, from a seed and knobs for the number of operations,
divergent ifs (v_cmp, s_and_saveexec, s_cbranch_execz) and how deep they
nest, uniform loops (SGPR counter, backward s_cbranch_scc1) and how deep
they nest, wave32 or wave64, the VGPR and SGPR pools, and the share of LDS
and memory accesses. Knobs that would give more operations than asked for
(fewer than two per loop level) are refused. Nothing is timed yet; that
comes next, with DXC.

The tests count what each knob does in the disassembly of the program,
not in the generator: the operations, how deep the ifs and loops nest,
that every s_cbranch_execz lands on its EXEC restore and every loop
branch on the instruction after its counter is set, the EXEC instructions
of each wave size, the LDS and memory shares, the highest VGPR. Every
knob combination the tests use translates completely, structured and as
the guarded block chain, with as many instructions as the disassembly.

Negative control: ten mutations of the generator (seed ignored, loops
not nested, loop and execz branch offsets off by one, wave32 using the
64-bit EXEC instructions, if depth ignored, VGPR pool one too large, LDS
share ignored, operations miscounted, the operation-count check removed)
each make at least one test fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Large synthetic loop bodies can exceed the signed SOPP displacement. The narrowing cast silently wraps the back edge and produces a different program. Check the displacement before encoding it; cover rejection and a large representable loop.
…-dev#1269)

The compile-time benchmark of xcl-dev#1269 measures what DXC does with the
recompiler's HLSL without game data. Each generated program is
translated and compiled with DXC one at a time; its instructions,
blocks, code, HLSL and DXIL bytes, translation time and DXC times go
into compile_bench.json (with the commit, whether the tree was dirty,
the DXC toolchain, the build profile and the CPU) and compile_bench.csv.

Every test run compiles a small set of six programs, so CI goes through
the same code; XCL_COMPILE_BENCH=full runs five shapes at four sizes up
to 20 000 operations, each in the native form and in the split wave64 /
4-window form, plus controls whose effect is known (the guarded block
chain, 1 against 4 memory windows). XCL_COMPILE_BENCH_OUT,
_REPS and _DXC_ARGS set the output folder, the compiles per program and
extra DXC arguments; without the latter dxc.rs picks the optimisation
level from the source size, as it does for a title. Without DXC the
test calls skip_test("no DXC"). A program that does not translate
completely, that DXC refuses, or whose HLSL or DXIL differs between
repeats fails the test; the times are recorded, not judged.

The generator gets buffer (V#) and image (T#, S#) access knobs and a
compute mode (64 threads, 4 user SGPRs). At zero they draw nothing, so
the programs of the first version stay byte for byte the same, which a
test checks against hashes computed with the generator of 5ae62c5.

Negative control: six mutations (buffer or image share ignored, compute
ignored, the draws changed, the CSV time separator, the knobs not
flattened into the row) each make at least one test fail.

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

Copy link
Copy Markdown
Contributor

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

Thanks!

@BetterJdue
BetterJdue marked this pull request as ready for review November 25, 2026 08:17
@BetterJdue
BetterJdue marked this pull request as draft November 25, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants