Repository navigation
Conversation
The direct DXIL spec's testing strategy asks for every recompiler kernel test to run through both backends with identical results; the runner picked one backend by XCL_DIRECT_DXIL. With XCL_DXIL_DIFF=1, runner::run_code, run_code_with and run_program (through run_code) translate the program with HLSL + DXC and with the direct translator, run both kernels with the same inputs and compare SGPRs, SCC, every lane's VGPRs, exports, flat memory and the UAV test textures. A difference is an error naming the field, the first 8 differing slots (lane/register decoded, HLSL and direct value in hex) and the count; a program the direct translator refuses keeps the HLSL result (counted, each distinct reason logged once), so the existing suite runs unchanged in this mode. Panics, validation and builder failures of the direct translator are errors, not refusals. Tests that compile the HLSL kernel themselves (kernel_wave, run_wave and kernel-mode direct_or in recomp/tests.rs) pair the container with its direct translation (diff_kernel::pair); every later runner::run* of that container on the same thread runs both and compares, so a test that runs one kernel from many states is compared for each. Compute-mode programs from direct_or are paired too: runner::dispatch then compares the flat memory both dispatches leave (dispatch_timed stays one run). Each backend stores only the registers it uses, so a register one side leaves unstored (0) while the other stores its unchanged input value is not a difference: an SGPR on its own, a VGPR only when that holds in every lane that ran. The comparison lives in the new recomp/diff_kernel.rs; runner.rs gains early returns in run_code, run_code_with, run_with_statics and dispatch, tests.rs one pairing line in kernel_wave, kernel- and compute-mode branches in direct_or, and diff_pair for two compute tests that compile their own HLSL (the safe-barrier test's multi-warp loop only: main's direct s_barrier does not handle early-exited waves). Without the variable nothing changes. With XCL_DXIL_DIFF_TABLE=<path> as well, each paired program appends one line to <path> (test thread name, FNV-1a hash of the program, matched / mismatched / refused / failed, its distinct RDNA2 mnemonics), one append-mode write per line and once per program and outcome, so the per-opcode parity table needs no exit hook. The new recomp/diff_table.rs holds the recording and summarise/table, which count per opcode the distinct programs containing it by their worst outcome; with XCL_DXIL_DIFF_SUMMARY=<path> its summary test prints that table and writes it to <path>.summary.tsv.
|
Built and ran, since the description says the head wasn't yet: RTX 3070 8 GB (32-lane waves, split wave64), driver 616.56, Windows 11, debug,
I'll open a small PR for the TG_SIZE one. The ulp cases might want a tolerance option in the comparison, so a known-inexact op doesn't hide a real difference in the same test. AI-assisted (Claude Code). Synthetic tests only. |
The direct translator set TG_SIZE's wave count to threads / lanes, so a group of 96 threads in wave64 read 1 wave where the console (and the HLSL path) give 2. It is now threads.div_ceil(lanes). The existing test gpu_compute_tg_size_counts_a_partial_last_wave now runs through direct_or, so XCL_DIRECT_DXIL=1 covers this path; it fails without the fix (left: 1, right: 2 for 96 threads in wave64). Found with #1934's XCL_DXIL_DIFF=1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Verification on RTX 3060 Ti (Windows 11): merge conflict with current |
|
Second run with
For the comparison, it might help to compare the destinations of returning atomics as multisets, or let a test mark them as unordered. Compare NaNs by class or by payload, as a test chooses. Otherwise the noise hides a real difference in the same test. AI-assisted (Claude Code). Synthetic tests only. |
XCL_DXIL_DIFF=1runs the recompiler's kernel tests through both HLSL + DXC and the direct DXIL translator and fails on any difference.XCL_DXIL_DIFF_TABLE=<path>also records each paired program, for a per-opcode parity table. This is the proof the direct DXIL spec asks for before phase 7 (default-on). With the variable unset the tests run as before.Draft: the head commit has not been built or tested yet.
What is in it
gpu/recomp/diff_kernel.rs: pairing, comparison and mismatch report, with testsgpu/recomp/diff_table.rs: the per-program log and per-opcode summary, with testsgpu/recomp/runner.rs,mod.rs: early returns taken only when the mode is on or a container was pairedgpu/recomp/tests.rs: pairs the tests that compile their own HLSLdocs/specs/2026-11-24-direct-dxil.md: 9 lines describing the switch (can be dropped if you prefer the spec untouched)Tested
These runs are from before the final rebase, on a combined branch (
376f968, based on main689f2db; it holds this change, the other half of the differential mode, and six direct-translator parity fixes), not on this PR's head commit.cargo testdebug build. Driver, CPU and Rust versions were not recorded.cargo test -p xcl --lib recomp::diff_kernel -- --nocapture --test-threads=1: passed.XCL_DXIL_DIFF=1(withXCL_DXIL_DIFF_TABLE,XCL_DIRECT_DXILunset),cargo test -p xcl --lib recomp:: -- --test-threads=1: 285 tests ran, 279 passed, 6 reported HLSL / direct mismatches. Not all of the 285 run both backends (some only translate). The combined tree had direct-translator fixes that this PR does not, so this PR alone may report differently.gpu_compute_tg_size_counts_a_partial_last_wave(HLSL2, direct1) and two 1–5 ULP floating-point differences in BVH ray intersection. Three more were wave64 VS / PS draws, found by the graphics half (separate PR).Regression run
Not run: there are no
xcl-smokeblocks for this change.Not tested
f5136a6) has not been built or tested: it was rebased on macOS, with no Rust toolchain.cargo test --workspacewas not run for this change on its own.gpu_safe_s_barrier_multi_warp_and_early_endpgmis deliberately not paired (see Direct DXIL: make multi-wave Compute and Mesh s_barrier early-exit-safe #1793).AI use