diff --git a/README.md b/README.md index 386812c599..57c63c6cc3 100644 --- a/README.md +++ b/README.md @@ -468,7 +468,7 @@ labelled as missing; it does not infer significance or percentages. ## Tests ```powershell -.\scripts\test.ps1 # cargo build --workspace + cargo test --workspace +.\scripts\test.ps1 # build + benchmark smoke + all workspace tests .\scripts\perf-run.tests.ps1 # cold/warm runner fixture (no game is run) .\scripts\perf-compare.tests.ps1 # comparison fixture (synthetic artifacts) cargo bench -p xcl # synthetic performance benchmarks diff --git a/crates/xcl/benches/gpu_cpu.rs b/crates/xcl/benches/gpu_cpu.rs index 7bdf2079df..e249d9d434 100644 --- a/crates/xcl/benches/gpu_cpu.rs +++ b/crates/xcl/benches/gpu_cpu.rs @@ -47,6 +47,53 @@ fn branch_program(blocks: usize) -> Vec { code } +fn graphics_program(instructions: usize, spills: bool) -> Vec { + let mut code = Vec::new(); + let mut count = 0usize; + if spills { + for lane in 0..48u64 { + code.extend(instruction( + "V_WRITELANE_B32", + "ENC_VOP3", + &[("VDST", 30), ("SRC0", 32 + lane), ("SRC1", 128 + lane)], + )); + count += 1; + } + for lane in 0..48u64 { + code.extend(instruction( + "V_READLANE_B32", + "ENC_VOP3", + &[("VDST", lane), ("SRC0", VGPR0 + 30), ("SRC1", 128 + lane)], + )); + count += 1; + } + } + let add = instruction( + "V_ADD_NC_U32", + "ENC_VOP2", + &[("VDST", 1), ("SRC0", VGPR0 + 2), ("VSRC1", 3)], + ); + for _ in count..instructions { + code.extend(&add); + } + code.extend(instruction("S_ENDPGM", "ENC_SOPP", &[])); + code +} + +fn graphics_options(split_wave64: bool) -> recomp::Options { + recomp::Options { + mode: recomp::Mode::Pixel(recomp::PsInterface { + inputs: Vec::new(), + outputs: Vec::new(), + input_ena: 0, + attrs: None, + }), + wave64: true, + split_wave64, + ..Default::default() + } +} + fn rdna2_frontend(c: &mut Criterion) { let code = arithmetic_program(1024); let mesh_control_flow = branch_program(256); @@ -117,6 +164,27 @@ fn translate(c: &mut Criterion) { }, ); } + let plain = graphics_program(256, false); + let spills = graphics_program(256, true); + let native = graphics_options(false); + let split = graphics_options(true); + for (name, code, options) in [ + ("plain", &plain, &native), + ("spills_native", &spills, &native), + ("spills_split", &spills, &split), + ] { + group.throughput(Throughput::Elements(257)); + group.bench_with_input( + BenchmarkId::new("wave64_graphics", name), + &(code, options), + |b, (code, options)| { + b.iter(|| { + let translated = recomp::translate(black_box(code), black_box(options)).unwrap(); + black_box((translated.hlsl.len(), translated.instructions, translated.blocks)) + }) + }, + ); + } group.finish(); } diff --git a/scripts/test.ps1 b/scripts/test.ps1 index 8bf6dca1e7..3a00be2445 100644 --- a/scripts/test.ps1 +++ b/scripts/test.ps1 @@ -10,6 +10,9 @@ $null = Get-Command cargo -ErrorAction Stop $ErrorActionPreference = 'Continue' cargo build --workspace if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } +# Compile every custom benchmark target and execute each closure once without timing samples. +cargo bench -p xcl --bench '*' -- --test +if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } # GPU tests that cannot run on this adapter pass too: each prints "SKIPPED : " # to stderr (XCL_REQUIRE_GPU=wave64 / =mesh makes them fail); counted at the end $skipped = @()