Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/xcl/src/gpu/dxil/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,10 +429,10 @@ fn translate_on_this_thread(
None => super::compact::emit(&mut lw, &cfg, p, h0, exit)?,
}
}
// Per-region loop budgets target compute spin-wait passes (PR #2793); keep graphics/mesh
// stages on the single-budget CFG so AMD LLPC does not trip on multi-PHI mesh loop headers.
// Keep real compute/graphics/mesh plain-form CFGs on the single-budget counter so AMD LLPC
// (`amdxc64.dll+0xd2a411`, #2874) does not crash on multi-PHI per-region loop headers.
let loops = crate::gpu::recomp::loop_ranges(&cfg.insts);
let regions = if compute || kernel {
let regions = if kernel {
crate::gpu::recomp::budget_regions(&loops)
} else {
Vec::new()
Expand Down
6 changes: 3 additions & 3 deletions crates/xcl/src/gpu/recomp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1874,9 +1874,9 @@ pub fn translate(code: &[u8], opt: &Options) -> Result<Translation, String> {
// (optimising one big dispatcher loop took minutes on large retail programs).
let leaders: Vec<u64> = leaders.into_iter().filter(|l| starts.contains(l)).collect();
let loops = loop_ranges(&insts);
// Per-region loop budgets target compute spin-wait passes (PR #2793); keep graphics/mesh
// stages on the single-budget CFG.
let regions = if matches!(opt.mode, Mode::Compute(_) | Mode::Kernel) {
// Keep real compute/graphics/mesh shaders on the single-budget CFG so AMD LLPC
// (`amdxc64.dll+0xd2a411`, #2874) does not crash on multi-PHI per-region loop headers.
let regions = if matches!(opt.mode, Mode::Kernel) {
budget_regions(&loops)
} else {
Vec::new()
Expand Down
16 changes: 7 additions & 9 deletions crates/xcl/src/gpu/recomp/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1552,9 +1552,9 @@ fn gpu_an_endless_long_loop_stops_after_the_budget_by_its_cost() {
assert_eq!(r.sgpr[0], (1 << 16) / 2);
}

/// Per-region loop budgets (`xcl_bown` / `xcl_btotal`) are compute-only: Compute and Kernel
/// modes emit them for multi-region loops, while Pixel and Mesh stages keep the single-budget
/// CFG (avoiding multi-PHI mesh loop headers that crash AMD LLPC).
/// Per-region loop budgets (`xcl_bown` / `xcl_btotal`) stay on `Mode::Kernel` while real
/// Compute, Pixel, and Mesh stages keep the single-budget CFG (avoiding multi-PHI loop headers
/// that crash AMD LLPC at `amdxc64.dll+0xd2a411`, #2874).
#[test]
fn per_region_loop_budgets_are_compute_only() {
let mut list: Vec<(&str, &str, &[(&str, u64)], Option<u32>)> = Vec::new();
Expand All @@ -1569,13 +1569,11 @@ fn per_region_loop_budgets_are_compute_only() {
let ps = super::PsInterface::default();
let ms = super::MsInterface { threads: 64, max_vertices: 64, max_primitives: 64, ..Default::default() };

for mode in [Mode::Kernel, Mode::Compute(cs.clone())] {
let tk = translate(&code, &Options { mode: Mode::Kernel, ..Default::default() }).unwrap();
assert!(tk.hlsl.contains("xcl_bown") && tk.hlsl.contains("xcl_btotal"), "kernel should emit per-region budgets");
for mode in [Mode::Compute(cs.clone()), Mode::Pixel(ps), Mode::Mesh(ms.clone())] {
let t = translate(&code, &Options { mode, ..Default::default() }).unwrap();
assert!(t.hlsl.contains("xcl_bown") && t.hlsl.contains("xcl_btotal"), "compute/kernel should emit per-region budgets");
}
for mode in [Mode::Pixel(ps), Mode::Mesh(ms.clone())] {
let t = translate(&code, &Options { mode, ..Default::default() }).unwrap();
assert!(!t.hlsl.contains("xcl_bown") && !t.hlsl.contains("xcl_btotal"), "pixel/mesh must not emit per-region budgets");
assert!(!t.hlsl.contains("xcl_bown") && !t.hlsl.contains("xcl_btotal"), "compute/pixel/mesh must not emit per-region budgets");
}

// Direct DXIL compute & mesh both translate cleanly for a multi-region loop program.
Expand Down
Loading