Repository navigation
Recompiler: bridge non-native DPP16/DPP8 VALU ops in the per-lane form - #1845
emirduran707 wants to merge 1 commit into
Conversation
|
I checked the NVIDIA gap in this PR on exact head I made a test-only overlay in This answers the PR's stated wave32-only NVIDIA coverage gap for this synthetic DPP fixture. It does not establish retail rendering, the full workspace suite on this head, or other DPP encodings. The overlay changes only the test; no runtime code was committed or pushed. The small patch is below for integration into this PR if useful. diff --git a/crates/xcl/src/gpu/recomp/lower_dxil.rs b/crates/xcl/src/gpu/recomp/lower_dxil.rs
index ad258ef..eb81453 100644
--- a/crates/xcl/src/gpu/recomp/lower_dxil.rs
+++ b/crates/xcl/src/gpu/recomp/lower_dxil.rs
@@ -788,13 +788,14 @@ mod tests {
runner::skip_test("no DXC");
return;
}
- let wave64_ok = runner::wave64_supported() == Ok(true);
+ let wave64_ok = runner::wave64_programs_supported() == Ok(true);
for w64 in [false, true] {
let lanes = if w64 { 64 } else { 32 };
if w64 && !wave64_ok {
runner::skip_test("bridged_dpp, wave64: no wave64");
continue;
}
+ let split = w64 && runner::split_wave64();
let saveexec = if w64 { "S_AND_SAVEEXEC_B64" } else { "S_AND_SAVEEXEC_B32" };
let movexec = if w64 { "S_MOV_B64" } else { "S_MOV_B32" };
let lines: &[I] = &[
@@ -830,12 +831,14 @@ mod tests {
st.vgpr[l][..regs.len()].copy_from_slice(regs);
}
let bytes: Vec<u8> = lines.iter().flat_map(encode_line).collect();
- let t = translate(&bytes, &Options { wave64: w64, ..Default::default() }).unwrap();
+ let t = translate(&bytes, &Options { wave64: w64, split_wave64: split, ..Default::default() }).unwrap();
assert!(t.complete(), "wave{lanes}: {:?}", t.unsupported_why);
let hlsl = runner::run(&dxc::compile(&t.hlsl, "main", "cs_6_6", &["-Gis"]).unwrap(), &st, &[]).unwrap();
let insts = decode(lines);
- let (dxil, _) = super::kernel(&insts, w64).unwrap_or_else(|e| panic!("wave{lanes}: {e}"));
+ let (dxil, _) = if split { super::kernel_split(&insts) } else { super::kernel(&insts, w64) }
+ .unwrap_or_else(|e| panic!("wave{lanes} split={split}: {e}"));
let direct = runner::run(&dxil, &st, &[]).unwrap();
+ println!("bridged DPP: wave{lanes} split={split}");
for l in 0..lanes {
for r in 1..=7 {
assert_eq!(direct.vgpr[l][r], hlsl.vgpr[l][r], "wave{lanes}: lane {l} v{r}: {:#x} vs {:#x}", direct.vgpr[l][r], hlsl.vgpr[l][r]); |
|
NVIDIA test report for Tested
Regression run ( base ( this PR: Not tested: this code in the title: it is on the opt-in direct-DXIL path ( AI use: Claude Code (Claude Opus 5.5) built and ran the tests and smoke runs on my machine and wrote this report; I checked it. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
7898971 to
0f2344c
Compare
Arc A770 verification for PR #1845Tested open PR head Tested
& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test {
& 'L:/XclTooling/pr1778-2e2ee55-20261125-020159/target/debug/build/xcl/97fdf2b9ff8e1482/out/xcl-97fdf2b9ff8e1482.exe' --exact gpu::recomp::lower_dxil::tests::bridged_dpp_agrees_with_hlsl_on_the_gpu --test-threads=1 --nocapture
}
Not tested
AI use
|
|
Independent Windows run on 0f2344c. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC, DXC 1.8.2502.11, debug.
A scratch extension of the checked-in fixture ran both native wave32 and split wave64. HLSL and per-lane Direct DXIL matched across 864 register values. Two additional DPP16/DPP8 fetch-inactive instructions ran with only even lanes in EXEC. Both instruction encodings matched LLVM MC 23.1.6 for gfx1030. All 192 output words for those two instructions matched the CPU reference, including preserved inactive destinations.
|
|
Split wave64 run on a 32-lane NVIDIA card (listed under Not tested). Setup: RTX 3060 12 GB (32-lane waves, driver 32.0.16.2101), Ryzen 5 5600X, 32 GB RAM, Windows 11 build 26300, Rust 1.100.0, DXC 1.9.2609.5, debug build. Head 0f2344c. Result: cargo test --workspace -- --test-threads=4: 1138 passed, 0 failed, 46 ignored. SKIPPED: 19 GPU tests for no wave64 (expected on this card); the per-lane f16 arithmetic / f16 packed / f32 conversions cases (per-lane form: refused); heap windows; driver cache cannot be disabled. Not tested: native wave64; a title run. AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report. |
0f2344c to
7385722
Compare
bmjask
left a comment
There was a problem hiding this comment.
No source-level blocker found. DPP fallback/bridge EXEC handling and inactive-lane semantics look correct; differential GPU coverage is meaningful. Gap: no DPP8 SRC0=0xEA or DPP16 FI=1 case, which takes all_lanes path—add especially for split wave64. Current Windows CI is red from an apparently unrelated pre-existing bridged-mask barrier test; rerun/triage to establish clean merge evidence.
In the per-lane direct DXIL backend (xcl-dev#1745), non-native VALU instructions with DPP16 or DPP8 modifiers (such as float wave reductions with v_add_f32_dpp, v_max_f32_dpp, or DPP source modifiers SRC0_ABS/SRC0_NEG) failed to lower: `valu()` eagerly ran `self.dpp()`, DPP source modifiers hard-refused without the `unsupported ` prefix, and `bridge()` called `Lw::inst_guarded` with `mask = None`, causing `Lw::exec_mask()` to read SSA EXEC (register 126) and fail the per-lane register check. `Ir::foreign` now forwards an optional active-lane mask to `Lw::inst_guarded`. For bridged DPP16/DPP8 instructions, `bridge()` checks `all_lanes` when fetch-inactive (`FI`) is set and passes the half-wave EXEC ballot (`exec_words(b, true)`). `Lw::sources` also clamps inactive DPP16/DPP8 source lane indices to `self.lane` before `read_lane_half` so `WaveReadLaneAt` never reads an inactive lane. Assisted-by: Antigravity (Gemini 4 Neon)
7385722 to
f65c9d5
Compare
|
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
Thanks! — Devin |
|
RTX 5070 / current-head synthetic follow-up to the FI coverage suggestion, complementing the earlier RTX 3080 Ti scratch report on What was checked Runtime head The fixture executes both native wave32 and split wave64 on wave32 hardware: HLSL explicitly sets With EXEC narrowed to even lanes and
Actual results
That is 576 expected output words per backend / 1,152 bitwise CPU checks in total. Both FI-on/off assertions also distinguish the two behaviors. This uses explicit CPU arithmetic and inactive/boundary rules, rather than only comparing the two backends with each other. Parent control: the identical fixture on official main The six instruction pairs were also repacked independently from AMD's RDNA2 ISA tables 76,90-92: raw FI bit50, raw bound bit51, DPP8FI source234. They match the bytes logged by both forms. This was a manual-spec bit check, not an LLVM-MC or native-RDNA execution result. Head archive SHA256 Not tested Native wave64 hardware, a full suite on this head, release-host builds, retail/smoke/gameplay, performance, other DPP patterns/modifiers, and FI inside partial control-flow blocks. One process per tree for the final fixture; earlier development runs are not included in these counts. This is focused scratch coverage, not merge approval. AI use OpenAI Codex (GPT-6; exact serving variant unavailable) wrote the test-only fixture/CPU expectations, independently checked instruction fields against the AMD reference, ran the parent/head tests, verified original-source restoration, and prepared this report. Complete test-only patch on f65c9d5 (no runtime changes)--- a/crates/xcl/src/gpu/recomp/lower_dxil.rs
+++ b/crates/xcl/src/gpu/recomp/lower_dxil.rs
@@ -1002,6 +1002,94 @@
}
}
+ /// Scratch coverage for review #1845: inactive sources must remain readable with FI,
+ /// while inactive destinations and out-of-row sources retain their separate rules.
+ #[test]
+ fn gpu_probe_bridged_dpp_fi_wave32_and_split64() {
+ if !gpu() { return; }
+ if dxc::location().is_err() {
+ runner::skip_test("no DXC");
+ return;
+ }
+ println!("PROBE adapter={}", runner::adapter().unwrap());
+ for w64 in [false, true] {
+ let lanes = if w64 { 64 } else { 32 };
+ let saveexec = if w64 { "S_AND_SAVEEXEC_B64" } else { "S_AND_SAVEEXEC_B32" };
+ let movexec = if w64 { "S_MOV_B64" } else { "S_MOV_B32" };
+ let lines: &[I] = &[
+ ("V_ADD_NC_U32", "ENC_VOP2", &[("VDST", 1), ("SRC0", 129), ("VSRC1", 0)]),
+ ("V_CVT_F32_U32", "ENC_VOP1", &[("VDST", 1), ("SRC0", 257)]),
+ ("V_AND_B32", "ENC_VOP2", &[("VDST", 8), ("SRC0", 129), ("VSRC1", 0)]),
+ ("V_CMP_EQ_U32", "ENC_VOPC", &[("SRC0", 128), ("VSRC1", 8)]),
+ (saveexec, "ENC_SOP1", &[("SDST", 4), ("SSRC0", 106)]),
+ // Quad reversal sends each active even destination to an inactive odd source.
+ ("V_ADD_F32", "VOP2_VOP_DPP16", &[("VDST", 2), ("SRC0", 0xFA), ("VSRC0", 1), ("VSRC1", 1), ("DPP_CTRL", 0x1B), ("ROW_MASK", 0xF), ("BANK_MASK", 0xF), ("BOUND_CTRL", 1), ("FI", 1)]),
+ // DPP8FI is SRC0=234; the non-FI negative control below is SRC0=233.
+ ("V_ADD_F32", "VOP2_VOP_DPP8", &[("VDST", 3), ("SRC0", 0xEA), ("VSRC0", 1), ("VSRC1", 1), ("LANE_SEL_0", 7), ("LANE_SEL_1", 6), ("LANE_SEL_2", 5), ("LANE_SEL_3", 4), ("LANE_SEL_4", 3), ("LANE_SEL_5", 2), ("LANE_SEL_6", 1), ("LANE_SEL_7", 0)]),
+ ("V_ADD_F32", "VOP2_VOP_DPP16", &[("VDST", 4), ("SRC0", 0xFA), ("VSRC0", 1), ("VSRC1", 1), ("DPP_CTRL", 0x1B), ("ROW_MASK", 0xF), ("BANK_MASK", 0xF), ("BOUND_CTRL", 1), ("FI", 0)]),
+ ("V_ADD_F32", "VOP2_VOP_DPP8", &[("VDST", 5), ("SRC0", 0xE9), ("VSRC0", 1), ("VSRC1", 1), ("LANE_SEL_0", 7), ("LANE_SEL_1", 6), ("LANE_SEL_2", 5), ("LANE_SEL_3", 4), ("LANE_SEL_4", 3), ("LANE_SEL_5", 2), ("LANE_SEL_6", 1), ("LANE_SEL_7", 0)]),
+ // FI does not make an out-of-row lane valid: bound=0 preserves, bound=1 uses 0.
+ ("V_ADD_F32", "VOP2_VOP_DPP16", &[("VDST", 6), ("SRC0", 0xFA), ("VSRC0", 1), ("VSRC1", 1), ("DPP_CTRL", 0x111), ("ROW_MASK", 0xF), ("BANK_MASK", 0xF), ("BOUND_CTRL", 0), ("FI", 1)]),
+ ("V_ADD_F32", "VOP2_VOP_DPP16", &[("VDST", 7), ("SRC0", 0xFA), ("VSRC0", 1), ("VSRC1", 1), ("DPP_CTRL", 0x111), ("ROW_MASK", 0xF), ("BANK_MASK", 0xF), ("BOUND_CTRL", 1), ("FI", 1)]),
+ (movexec, "ENC_SOP1", &[("SDST", 126), ("SSRC0", 4)]),
+ ("S_ENDPGM", "ENC_SOPP", &[]),
+ ];
+ let insts = decode(lines);
+ let dpp: Vec<_> = insts.iter().filter(|d| matches!(d.variant,
+ crate::gpu::rdna2::Variant::Dpp16 | crate::gpu::rdna2::Variant::Dpp8)).collect();
+ assert_eq!(dpp.len(), 6);
+ let ext = super::super::emit::ext_encoding(dpp[0]).unwrap();
+ assert_eq!(crate::gpu::rdna2::field_value(ext, &dpp[0].words, "FI"), Some(1));
+ assert_eq!(crate::gpu::rdna2::field_value(dpp[1].enc, &dpp[1].words, "SRC0"), Some(0xEA));
+ println!("PROBE wave{lanes} split={w64} DPP words={:?}",
+ dpp.iter().map(|d| &d.words).collect::<Vec<_>>());
+
+ let (s, v) = state(lanes);
+ let mut st = runner::KernelState::default();
+ st.sgpr.copy_from_slice(&s);
+ let sentinel = (-99.0f32).to_bits();
+ for (l, regs) in v.iter().enumerate() {
+ st.vgpr[l][..regs.len()].copy_from_slice(regs);
+ for r in 2..=7 { st.vgpr[l][r] = sentinel; }
+ }
+ let bytes: Vec<u8> = lines.iter().flat_map(encode_line).collect();
+ let tr = translate(&bytes, &Options { wave64: w64, split_wave64: w64, ..Default::default() }).unwrap();
+ assert!(tr.complete(), "wave{lanes}: {:?}", tr.unsupported_why);
+ let hlsl_dxil = dxc::compile(&tr.hlsl, "main", "cs_6_6", &["-Gis"]).unwrap();
+ let hlsl = runner::run(&hlsl_dxil, &st, &[]).unwrap();
+ let (dxil, _) = if w64 { super::kernel_split(&insts) } else { super::kernel(&insts, false) }
+ .unwrap_or_else(|e| panic!("wave{lanes}: {e}"));
+ if crate::gpu::dxil::validate::validator_supported() {
+ crate::gpu::dxil::validate::validate(&dxil).unwrap();
+ }
+ let direct = runner::run(&dxil, &st, &[]).unwrap();
+ let mut comparisons = 0usize;
+ for l in 0..lanes {
+ let x = (l + 1) as f32;
+ let mut expected = [sentinel; 6];
+ if l % 2 == 0 {
+ let q = (l & !3) + 3 - (l & 3);
+ let e = (l & !7) + 7 - (l & 7);
+ expected[0] = (x + (q + 1) as f32).to_bits();
+ expected[1] = (x + (e + 1) as f32).to_bits();
+ expected[2] = x.to_bits();
+ expected[3] = x.to_bits();
+ expected[4] = if l % 16 == 0 { sentinel } else { (x + l as f32).to_bits() };
+ expected[5] = if l % 16 == 0 { x.to_bits() } else { (x + l as f32).to_bits() };
+ }
+ for (r, want) in (2..=7).zip(expected) {
+ assert_eq!(hlsl.vgpr[l][r], want, "HLSL wave{lanes} lane{l} v{r}");
+ assert_eq!(direct.vgpr[l][r], want, "per-lane wave{lanes} lane{l} v{r}");
+ comparisons += 1;
+ }
+ }
+ assert_ne!(direct.vgpr[0][2], direct.vgpr[0][4], "DPP16 FI must matter");
+ assert_ne!(direct.vgpr[0][3], direct.vgpr[0][5], "DPP8 FI must matter");
+ println!("PROBE wave{lanes} split={w64}: {comparisons} CPU-expected words per backend, both passed");
+ }
+ }
+
+
/// With the runtime's four memory windows (`compute_with`), the memory instructions go
/// through #1426's window switch (blocks of its own in the `Ir` block) and the program
/// still gives the CPU lowering's memory. |
In the per-lane direct DXIL backend (#1745), non-native VALU instructions with DPP16 or DPP8 modifiers (such as float wave reductions with
v_add_f32_dpp/v_max_f32_dpp, or DPP16 source modifiersSRC0_ABS/SRC0_NEG) failed to lower:valu()eagerly ranself.dpp(), DPP source modifiers returned a hard error without theunsupportedprefix, andbridge()calledLw::inst_guardedwithmask = None, soLw::exec_mask()read SSA EXEC (register 126) and failed the per-lane register check. Part of #1269.Ir::foreignnow passes an optional active-lane mask through toLw::inst_guarded. For bridged DPP16/DPP8 instructions,bridge()checksall_laneswhen fetch-inactive (FI) is set and passes the half-wave EXEC ballot (exec_words(b, true)).Lw::sourcesalso clamps inactive DPP16/DPP8 source lane indices toself.lanebeforeread_lane_halfsoWaveReadLaneAtnever reads an inactive lane.What is in it
crates/xcl/src/gpu/recomp/lower.rs: addmask: Option<(Self::V, Self::V)>toIr::foreign; skip eagerself.dpp()for non-native VALU opcodes (keepingV_CMP*_dpprefused); inbridge(), enforceall_lanesforFI=1and passexec_words(b, true)for DPP16/DPP8.crates/xcl/src/gpu/recomp/lower/wave.rs: makeall_lanesandexec_wordspub(super); prefix DPP modifier refusal withunsupportedso it can bridge.crates/xcl/src/gpu/recomp/lower_dxil.rs: forwardmasktoself.lw.inst_guarded, and add GPU parity testbridged_dpp_agrees_with_hlsl_on_the_gpu(wave32 and wave64, DPP16, DPP16SRC0_NEG+ROW_MASK, DPP8, and narrowed EXEC withBOUND_CTRL=0andBOUND_CTRL=1).crates/xcl/src/gpu/dxil/lower_valu.rs: clamp inactive DPP16/DPP8 source lanes toself.lanebeforeread_lane_half.Tested
cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4onf65c9d5b(rebased ontomain08db8020):1428 passed, 2 failed, 47 ignored; 8 SKIPPED(6 inlower_dxil::tests::{f16,f32}_programs_on_the_gpu;heap_window_out_of_memory_falls_back_to_the_switch_form;pso_measurement_compiles_an_exact_synthetic_record)gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1seed 722 andfuzz_validate_and_gpu_3seed 1599) are pre-existing on unmodifiedmainon this GPU.bridged_dpp_agrees_with_hlsl_on_the_gpubefore the change failed (wave32: unsupported V_ADD_F32 (it reads register 126 the per-lane form did not pass)); passes on both wave32 and native wave64 afterRegression run
main (
b49be183):this PR (
f65c9d5b):Not tested
WaveSize(32)) GPUs (NVIDIA / Intel / wave32-only).V_CMP*_dpp(still refused, sincedxil/lower_valu.rsonly appliesdpp_enableto VGPR destinations).AI use
main08db8020and reran the full workspace suite and smoke pair.main2aa2d1a(resolving a test conflict incrates/xcl/src/gpu/recomp/lower_dxil.rs).