Repository navigation
Tests: generate RDNA2 programs for compile-time measurements (#1269) - #1763
BetterJdue wants to merge 2 commits into
Conversation
…#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>
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
e380668 to
5ae62c5
Compare
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.
|
Large loop bodies silently wrap their SOPP back edge on exact head Patch: 0f257d1, directly on that head. It uses Tested
Not tested AI use |
|
\CI\ workflow approved for \5ae62c5\ (\crates/xcl/tests/compile_bench/{gen.rs,main.rs}). Note @anes66's finding above on |
|
Thanks @anes66: your commit is pulled into this PR unchanged, so the head is now Tested on
An independent run on NVIDIA on the new head would still help: DavidM1911's RTX 3060 Ti report above was on AI use: Claude Code (Claude Opus 5.5) ran these tests and wrote this comment. AI-assisted verification using synthetic inputs. |
|
The independent NVIDIA run asked for above, on the new head
Not run: the whole workspace. AI-assisted (Claude Code). Synthetic tests only. |
|
@BetterJdue one knob I needed for running the programs rather than only compiling them: Why. The programs let lanes race: a What it does (off by default):
With the knob off the programs are byte for byte the same as @@ pub struct Knobs {
pub lds_pct: u32,
pub mem_pct: u32,
+ /// programs whose result does not depend on the order lanes see each other's memory
+ /// accesses, for running and comparing them: global loads and scalar loads read only bytes
+ /// 0..1024, every global store writes the lane's own dword at byte 1024 + lane * 4, and the
+ /// lane's LDS dword is written before anything reads it
+ pub race_free: bool,
}
@@ impl Default for Knobs {
- Knobs { seed: 1, ops: 200, if_depth: 2, divergent_pct: 10, loops: 0, loop_depth: 1, loop_trips: 4, wave64: true, vgprs: 16, sgprs: 8, lds_pct: 5, mem_pct: 10 }
+ Knobs { seed: 1, ops: 200, if_depth: 2, divergent_pct: 10, loops: 0, loop_depth: 1, loop_trips: 4, wave64: true, vgprs: 16, sgprs: 8, lds_pct: 5, mem_pct: 10, race_free: false }
@@ fn op(&mut self) -> Vec<u8> {
- 0 => inst("GLOBAL_LOAD_DWORD", "ENC_FLAT_GLBL", &[("VDST", self.vgpr()), ("ADDR", 1), ("SADDR", 2), ("OFFSET", 4 * self.rng.below(256))], None),
- 1 => inst("GLOBAL_STORE_DWORD", "ENC_FLAT_GLBL", &[("ADDR", 1), ("DATA", self.vgpr()), ("SADDR", 2), ("OFFSET", 4 * self.rng.below(256))], None),
+ // race-free: lane * 4 + offset stays below byte 1024 (63 * 4 + 192 * 4 = 1020)
+ 0 => inst("GLOBAL_LOAD_DWORD", "ENC_FLAT_GLBL", &[("VDST", self.vgpr()), ("ADDR", 1), ("SADDR", 2), ("OFFSET", 4 * self.rng.below(if self.k.race_free { 193 } else { 256 }))], None),
+ 1 => {
+ // the data register is drawn before the offset, as before, so programs without
+ // race_free stay the same
+ let data = self.vgpr();
+ let offset = if self.k.race_free { 1024 } else { 4 * self.rng.below(256) };
+ inst("GLOBAL_STORE_DWORD", "ENC_FLAT_GLBL", &[("ADDR", 1), ("DATA", data), ("SADDR", 2), ("OFFSET", offset)], None)
+ }
@@ pub fn program(k: &Knobs) -> Vec<u8> {
let mut v = inst("V_LSHLREV_B32", "ENC_VOP2", &[("VDST", 1), ("SRC0", 130), ("VSRC1", 0)], None); // v1 = lane * 4
+ if k.race_free {
+ v.extend(inst("DS_WRITE_B32", "ENC_DS", &[("ADDR", 1), ("DATA0", 0)], None)); // the lane's LDS dword = lane id
+ }It's commit Tested: AI use: Claude Code (Claude Opus 5.5) wrote the knob and this comment. |
A generator of deterministic RDNA2 programs for the synthetic compile-time benchmark of #1269: no game data, so it runs anywhere, CI included. Test-only: one commit in
crates/xcl/tests/compile_bench/, nothing incrates/xcl/src. Nothing is timed yet; the DXC measurement is the next PR, stacked on this one.Part of #1269
What is in it
crates/xcl/tests/compile_bench/gen.rs:program(&Knobs)assembles a program withrdna2::encodefrom a seed and knobs: the number of operations, divergentifs (v_cmp→s_and_saveexec→s_cbranch_execz) and how deep they nest, uniform loops (SGPR counter, backwards_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 are refused.crates/xcl/tests/compile_bench/main.rs: 7 tests, CPU only. They check in the disassembly, not in the generator: the operation count, how deep theifs and loops nest, where every branch lands, the EXEC instructions of each wave size, the LDS and memory shares and the VGPR pool; 24 knob combinations translate completely with structured control flow on and off.Tested
cargo test -p xcl --test compile_bench: 7 passed, 0 failed, 0 ignored.cargo test --workspace --no-fail-fast -- --test-threads=4on5ae62c5: 755 passed, 3 failed, 41 ignored (20 binaries); no SKIPPED tests. The failures areplaced_title_textures_share_vram_and_preserve_pixels("3D 64x64x64 4 mips: subresource 2 mismatch") and two tests that then fail on the lock it poisons; the first fails alone onmain930e8b4too (4 of 4 runs). The same failure (same message, RDNA2, same driver) is reported fixed by D3D12.X: map and unmap 3D texture mips separately #1028 on an RX 6600, RX 6750 XT and RX 6900 XT; D3D12.X: map and unmap 3D texture mips separately #1028 was not run here.execzbranch offsets off by one, wrong EXEC width,ifdepth ignored, VGPR pool too large, LDS share ignored, operations miscounted, the operation-count check removed); each makes at least one test fail.Regression run
crates/xcl/src.Not tested
scripts/smoke.ps1or any retail title (no game data here; the change does not touch the runtime).AI use
🤖 Generated with Claude Code