From 348f345238000ccf479330a4805b880c4be92ffa Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Tue, 1 Apr 2025 10:45:00 -0500 Subject: [PATCH] nak: Put the cycle count assert behind a debug flag Fixes: c1d64053f2c8 ("nak: Assert instr_sched matches calc_instr_deps") Part-of: --- src/nouveau/compiler/nak/api.rs | 6 ++++++ src/nouveau/compiler/nak/calc_instr_deps.rs | 15 ++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/nouveau/compiler/nak/api.rs b/src/nouveau/compiler/nak/api.rs index b20ef2baff9..28e9c5fb797 100644 --- a/src/nouveau/compiler/nak/api.rs +++ b/src/nouveau/compiler/nak/api.rs @@ -25,6 +25,7 @@ enum DebugFlags { Spill, Annotate, NoUgpr, + Cycles, } pub struct Debug { @@ -49,6 +50,7 @@ impl Debug { "spill" => flags |= 1 << DebugFlags::Spill as u8, "annotate" => flags |= 1 << DebugFlags::Annotate as u8, "nougpr" => flags |= 1 << DebugFlags::NoUgpr as u8, + "cycles" => flags |= 1 << DebugFlags::Cycles as u8, unk => eprintln!("Unknown NAK_DEBUG flag \"{}\"", unk), } } @@ -78,6 +80,10 @@ pub trait GetDebugFlags { fn no_ugpr(&self) -> bool { self.debug_flags() & (1 << DebugFlags::NoUgpr as u8) != 0 } + + fn cycles(&self) -> bool { + self.debug_flags() & (1 << DebugFlags::Cycles as u8) != 0 + } } pub static DEBUG: OnceLock = OnceLock::new(); diff --git a/src/nouveau/compiler/nak/calc_instr_deps.rs b/src/nouveau/compiler/nak/calc_instr_deps.rs index 074134506c6..aa0a6da76ef 100644 --- a/src/nouveau/compiler/nak/calc_instr_deps.rs +++ b/src/nouveau/compiler/nak/calc_instr_deps.rs @@ -512,11 +512,16 @@ impl Shader<'_> { min_num_static_cycles += calc_delays(f, self.sm); } - // Check that this file's model matches up with the model in - // opt_instr_sched_postpass. postpass includes an estimate of - // variable latency delays in its count, so we expect it to be >= - // the estimate here - assert!(self.info.num_static_cycles >= min_num_static_cycles); + if DEBUG.cycles() { + // This is useful for debugging differences in the scheduler + // cycle count model and the calc_delays() model. However, it + // isn't totally valid since assign_barriers() can add extra + // dependencies for barrier re-use and those may add cycles. + // The chances of it doing this are low, thanks to our LRU + // allocation strategy, but it's still not an assert we want + // running in production. + assert!(self.info.num_static_cycles >= min_num_static_cycles); + } } } }