Repository navigation
Conversation
…duccion min en onda parcial) Nuevo test que dibuja un triangulo pequeno (3 quads = 6 pixeles, onda parcial) y reduce V_MIN_U32 sobre los pixeles impares. Reproduce el bug: las lanes no lanzadas se leen como 0 en vez de la identidad -1, y el min devuelve 0 en vez del minimo real (2).
…veActive* La reduccion de onda (seed v_cndmask_b32 + DPP8 xor 1/2/4 + DPP16 row_mirror + v_permlanex16 + v_readlane 32/0) se reconoce en translate() y el seed se reduce con WaveActiveMin/Max/BitOr sobre las lanes lanzadas; los pasos DPP/readlane se suprimen (leian las lanes no lanzadas como 0 en vez de la identidad, rompiendo min). Antes: gpu_wave64_ps_partial_wave_min daba min=0 (want 2.0). Despues: da 2.0. Regresion: gpu_wave64_ps_whole_wave_reductions, gpu_wave64_ps_spill_slots y 104 tests GPU pasan.
|
Checked on Ampere: RTX 3070 8 GB (32-lane waves, so wave64 compute is split over two host waves), driver 616.56, Windows 11, debug.
A regression in split-wave64 compute.
969 is the minimum of lanes 0..31 only. A wave64 PS on these GPUs has no populated upper half ( Test (add next to
|
|
Regression run for this PR: head main this PR: No device removals or crashes; 102 % of main's frames, 74 % of its peak commit. Peak commit on Not tested: the whole suite; whether the title reaches the changed reductions in these 60 s. Written with Claude Code (Claude Opus 5.5) from runs on this machine. |
|
Full-suite run, since this PR has no test report yet. Tested exact head Tested
Not tested
AI use
|
|
Scoped fix for the split-wave64 compute regression that @upipibi found on #1857, verified on an RTX 3090 at exact head Tested — native Windows 10 19045, RTX 3090 driver 591.74, Rust 1.98.1 MSVC,
No commit or competing PR from me; please incorporate the small guard and regression if useful: Two-file patch (40 insertions, one deletion)diff --git a/crates/xcl/src/gpu/recomp/mod.rs b/crates/xcl/src/gpu/recomp/mod.rs
index f36cf65..a19931d 100644
--- a/crates/xcl/src/gpu/recomp/mod.rs
+++ b/crates/xcl/src/gpu/recomp/mod.rs
@@ -1559,7 +1559,15 @@ pub fn translate(code: &[u8], opt: &Options) -> Result<Translation, String> {
}
}
let mut em = emit::Em::new(opt.clone());
- let (reductions, skip) = recognize_whole_wave_reductions(&insts);
+ // A split wave64 compute/mesh/geometry wave spans two host wave32s. WaveActive*
+ // only reduces one half, while the original readlane steps join both halves.
+ let split_x64 = opt.wave64 && opt.split_wave64
+ && matches!(opt.mode, Mode::Kernel | Mode::Compute(_) | Mode::Mesh(_) | Mode::Geometry(_));
+ let (reductions, skip) = if split_x64 {
+ (BTreeMap::new(), BTreeSet::new())
+ } else {
+ recognize_whole_wave_reductions(&insts)
+ };
em.reductions = reductions;
em.skip = skip;
em.configure_round_modes(&insts, branches == 0);
diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs
index 27a8a9f..a59abbc 100644
--- a/crates/xcl/src/gpu/recomp/tests.rs
+++ b/crates/xcl/src/gpu/recomp/tests.rs
@@ -2285,6 +2285,37 @@ fn gpu_wave64_ps_partial_wave_min() {
}
}
+/// A reduction over a wave64 compute program must include both wave32 halves when the
+/// adapter runs the console wave in the split form. Reproducer from @upipibi on #1857.
+#[test]
+fn gpu_wave64_cs_whole_wave_min_spans_both_halves() {
+ if !gpu_ready() {
+ return;
+ }
+ use super::{dxc, CsInterface};
+ let code = program_of(&[
+ ins("V_SUB_NC_U32", "ENC_VOP2", &[("VDST", 13), ("SRC0", 255), ("VSRC1", 0)], Some(1000)),
+ ins("S_MOV_B64", "ENC_SOP1", &[("SDST", 18), ("SSRC0", 126)], None),
+ whole_wave_reduce("V_MIN_U32", 193, 40),
+ ins("V_LSHLREV_B32", "ENC_VOP2", &[("VDST", 1), ("SRC0", 130), ("VSRC1", 0)], None),
+ ins("V_ADD_NC_U32", "ENC_VOP2", &[("VDST", 7), ("SRC0", 0), ("VSRC1", 1)], None),
+ ins("V_MOV_B32", "ENC_VOP1", &[("VDST", 5), ("SRC0", 40)], None),
+ ins("GLOBAL_STORE_DWORD", "ENC_FLAT_GLBL", &[("ADDR", 7), ("DATA", 5), ("SADDR", 0x7D)], None),
+ ]);
+ let cs = CsInterface { threads: [64, 1, 1], user_sgprs: 2, tgid: [false, false, false], tg_size: false, tid_components: 1 };
+ let opt = on_gpu(Options { mode: Mode::Compute(cs), wave64: true, ..Default::default() });
+ let t = translate(&code, &opt).unwrap();
+ assert!(t.complete(), "{:?}", t.unsupported_why);
+ let dxil = dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).unwrap_or_else(|e| panic!("{e}\n{}", t.hlsl));
+ let base = 0x100usize;
+ let mut io = vec![0u32; 128];
+ io[0] = base as u32;
+ let out = runner::dispatch(&dxil, [1, 1, 1], &io, &vec![0u32; (base + 64 * 4) / 4]).unwrap();
+ let got: Vec<u32> = (0..64).map(|tid| out[(base + tid * 4) / 4]).collect();
+ eprintln!("adapter={} split={} WaveActiveMin={} lanes 0..31: {:?}, lanes 32..63: {:?}", runner::adapter().unwrap(), opt.split_wave64, t.hlsl.contains("WaveActiveMin"), &got[..4], &got[32..36]);
+ assert!(got.iter().all(|&v| v == 937), "whole-wave min: {got:?}");
+}
+
/// SGPR spill slots in lanes 0..47 of a VGPR (`spill_slots`) in a wave64 PS: slots ≥ 32 do
/// not exist in a 32-lane wave, and a slot in a lane that was not launched is lost in a
/// partial wave (a primitive's edge). Drawn over the whole target and as a 6-pixel triangle.Not tested: current-main integration, retail smoke/gameplay, driver compile cost, peak memory, AMD native-wave64, or other reduction idioms. This does not establish merge readiness; the PR description check is still red. AI use: Codex desktop (GPT-6) adapted @upipibi's fixture, prepared the local patch, ran the Windows tests and drafted this report from the retained logs. |
…s (v_readlane 32 + op) El reconocedor ahora suprime solo la reduccion dentro de cada mitad (3x DPP8 + DPP16 + v_permlanex16 + op) y CONSERVA v_readlane lane32 + op + v_readlane lane0, que combinan las dos mitades wave32 en la reduccion wave64 global. Antes (skip de 8) suprimia el readlane32 y la reduccion quedaba por-mitad (WaveActive* solo cubre la wave fisica de 32 lanes). Regresion: gpu_wave64_ps_partial_wave_min, gpu_wave64_ps_whole_wave_reductions, gpu_wave64_ps_spill_slots y 104 tests GPU pasan.
…/2/4, DPP16 row_mirror y lanes de readlane 32/0 Los campos DPP se leen de la codificacion de extension (emit::ext_encoding), no de d.enc. Ahora el reconocedor solo acepta la secuencia exacta de reduccion de onda (DPP8 xor 1/2/4, DPP16 row_mirror ctrl 0x140, v_readlane lane 32 y 0), reduciendo falsos positivos (riesgos A/B).
|
Verification on RTX 3060 Ti (Windows 11): merge conflict with current |
…ocedor - El seed v_cndmask_b32 debe leer exactamente 1 VGPR (el valor); asi la identidad queda forzada a ser una constante, no un registro. - Test recognize_rejects_wrong_reduction_variants: verifica que el reconocedor acepta la reduccion canonica y RECHAZA variantes con selectores DPP8 (xor3), DPP16 (row_half_mirror), lane de readlane (16/1) o identidad como VGPR. Suite completa: 842 passed, 0 failed, 22 ignored.
Adopta el refactor del upstream (em.emit_insts con try_emit_x64_reduction_tail) y conserva mi reconocimiento de reduccion (recognize_whole_wave_reductions + WaveActive* + skip), que cubre la onda parcial dentro de la mitad (bug que main aun tiene). El skip se movio a emit_insts. Tests: 1060 passed; 4 fuzz_validate_and_gpu_* fallan por OOM de GPU (0x8007000E, preexistente, no relacionado con el fix). gpu_wave64_ps_* y recognize_rejects_wrong_reduction_variants PASS.
|
Review note on |
|
Re-checked AI-assisted (Claude Code). |
What is in it
v_cndmask_b32+ 3× DPP8 xor 1/2/4 + DPP16 row_mirror +v_permlanex16+v_readlane32/0) and emitWaveActiveMin/WaveActiveMax/WaveActiveBitOrover the launched lanes, suppressing only the within-half DPP steps.v_readlanelane 32 + op + lane 0 steps that combine the two 32-lane halves of a wave64 (cross-half).gpu_wave64_ps_partial_wave_min(synthetic, no game data) and negative tests for the recogniser.Tested
cargo test --workspace -- --test-threads=4: 1060 passed, 4 failed, 26 ignored. The 4 failures arefuzz_validate_and_gpu_*failing withCreateComputePipelineState: 0x8007000E(out of memory) — pre-existing, unrelated to this change.Regression run
scripts/smoke.ps1needs a real title (no title data in this environment).Not tested
scripts/smoke.ps1) on a real title.AI use
WaveActive*emission, and wrote and ran the synthetic tests.