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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36528>
This commit is contained in:
Karol Herbst 2025-08-01 22:12:14 +02:00 committed by Marge Bot
parent 8cf91a4853
commit 4bce94e84b

View file

@ -241,7 +241,8 @@ pub fn side_effect_type(op: &Op) -> SideEffect {
}
pub fn estimate_block_weight(cfg: &CFG<BasicBlock>, 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