nak: Set variable_latency=0 for !needs_scoreboard
Some checks failed
macOS-CI / macOS-CI (dri) (push) Has been cancelled
macOS-CI / macOS-CI (xlib) (push) Has been cancelled

This simplifies usage of estimate_variable_latency a little in that we
can just use it directly in our max() expressions instead of guarding it
with an if.

Reviewed-by: Mary Guillemard <mary@mary.zone>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38939>
This commit is contained in:
Mel Henning 2025-04-24 13:57:12 -04:00 committed by Marge Bot
parent b4bac84d3b
commit 01cf905c71
2 changed files with 15 additions and 13 deletions

View file

@ -253,7 +253,11 @@ pub fn estimate_block_weight(cfg: &CFG<BasicBlock>, block_idx: usize) -> u64 {
/// Memory instructions were copied from L1 data cache latencies. /// Memory instructions were copied from L1 data cache latencies.
/// For instructions not mentioned in the paper, I made up numbers. /// For instructions not mentioned in the paper, I made up numbers.
/// This could probably be improved. /// This could probably be improved.
pub fn estimate_variable_latency(sm: u8, op: &Op) -> u32 { pub fn estimate_variable_latency(sm: &dyn ShaderModel, op: &Op) -> u32 {
if !sm.op_needs_scoreboard(op) {
return 0;
}
match op { match op {
// Multi-function unit // Multi-function unit
Op::Rro(_) | Op::MuFu(_) => 15, Op::Rro(_) | Op::MuFu(_) => 15,
@ -265,7 +269,7 @@ pub fn estimate_variable_latency(sm: u8, op: &Op) -> u32 {
// Integer ALU // Integer ALU
Op::BRev(_) | Op::Flo(_) | Op::PopC(_) => 15, Op::BRev(_) | Op::Flo(_) | Op::PopC(_) => 15,
Op::IMad(_) | Op::IMul(_) => { Op::IMad(_) | Op::IMul(_) => {
assert!(sm < 70); assert!(sm.sm() < 70);
86 86
} }

View file

@ -89,12 +89,10 @@ fn generate_dep_graph(sm: &dyn ShaderModel, instrs: &[Instr]) -> DepGraph {
} else { } else {
sm.raw_latency(&instr.op, i, &instrs[r_ip].op, r_src_idx) sm.raw_latency(&instr.op, i, &instrs[r_ip].op, r_src_idx)
}; };
if sm.op_needs_scoreboard(&instr.op) {
latency = max( latency =
latency, max(latency, estimate_variable_latency(sm, &instr.op));
estimate_variable_latency(sm.sm(), &instr.op),
);
}
g.add_edge(ip, r_ip, EdgeLabel { latency }); g.add_edge(ip, r_ip, EdgeLabel { latency });
} }
}); });
@ -126,11 +124,11 @@ fn generate_dep_graph(sm: &dyn ShaderModel, instrs: &[Instr]) -> DepGraph {
.map(|i| sm.worst_latency(&instr.op, i)) .map(|i| sm.worst_latency(&instr.op, i))
.max() .max()
.unwrap_or(0); .unwrap_or(0);
if sm.op_needs_scoreboard(&instr.op) {
let var_latency = estimate_variable_latency(sm.sm(), &instr.op) let var_latency = estimate_variable_latency(sm, &instr.op)
+ sm.exec_latency(&instrs[instrs.len() - 1].op); + sm.exec_latency(&instrs[instrs.len() - 1].op);
ready_cycle = max(ready_cycle, var_latency); ready_cycle = max(ready_cycle, var_latency);
}
let label = &mut g.nodes[ip].label; let label = &mut g.nodes[ip].label;
label.exec_latency = sm.exec_latency(&instr.op); label.exec_latency = sm.exec_latency(&instr.op);
label.ready_cycle = ready_cycle; label.ready_cycle = ready_cycle;