From 4bce94e84b0ce9705bf582fbe0428c144a0f4725 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Fri, 1 Aug 2025 22:12:14 +0200 Subject: [PATCH] nak: use logarithmic scaling in estimate_block_weight Instead of causing a +7000000% estimated cycles across a fossil-db run, this reduses that increase down to roughly +730%. With this a 6 level deep loop get's an estimated block weight of 385. The worst impacted shader gets its static cycle count increased by 240x, whish is 6 level deep and a huge loop body. Part-of: --- src/nouveau/compiler/nak/opt_instr_sched_common.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/nouveau/compiler/nak/opt_instr_sched_common.rs b/src/nouveau/compiler/nak/opt_instr_sched_common.rs index d5378c5bc72..ffee16619cc 100644 --- a/src/nouveau/compiler/nak/opt_instr_sched_common.rs +++ b/src/nouveau/compiler/nak/opt_instr_sched_common.rs @@ -241,7 +241,8 @@ pub fn side_effect_type(op: &Op) -> SideEffect { } pub fn estimate_block_weight(cfg: &CFG, block_idx: usize) -> u64 { - 10_u64.pow(cfg.loop_depth(block_idx).try_into().unwrap()) + let loop_depth = cfg.loop_depth(block_idx) as f32; + 10_f32.powf((loop_depth + 1.0).log2()) as u64 } /// Try to guess how many cycles a variable latency instruction will take