fixed hardware_db and improved stability and robustness of generic sal

This commit is contained in:
2026-02-26 15:52:44 +01:00
parent f87efa1d24
commit 073414a25e
13 changed files with 488 additions and 225 deletions

View File

@@ -91,24 +91,30 @@ impl OptimizerEngine {
// 1. Efficiency Metric (Throughput per Watt)
// If throughput is 0 (unsupported), fallback to Frequency per Watt
let efficiency_curr = if curr.throughput > 0.0 {
curr.throughput as f32 / curr.power_w.max(0.1)
curr.throughput as f32 / curr.power_w.max(1.0)
} else {
curr.freq_mhz / curr.power_w.max(0.1)
curr.freq_mhz / curr.power_w.max(1.0)
};
let efficiency_next = if next.throughput > 0.0 {
next.throughput as f32 / next.power_w.max(0.1)
next.throughput as f32 / next.power_w.max(1.0)
} else {
next.freq_mhz / next.power_w.max(0.1)
next.freq_mhz / next.power_w.max(1.0)
};
// Diminishing returns: how much efficiency drops per additional watt
let efficiency_drop = (efficiency_curr - efficiency_next) / (next.power_w - curr.power_w).max(0.1);
let p_delta = (next.power_w - curr.power_w).max(0.5);
let efficiency_drop = (efficiency_curr - efficiency_next) / p_delta;
// 2. Thermal Acceleration (d2T/dW2)
let dt_dw_prev = (curr.temp_c - prev.temp_c) / (curr.power_w - prev.power_w).max(0.1);
let dt_dw_next = (next.temp_c - curr.temp_c) / (next.power_w - curr.power_w).max(0.1);
let temp_accel = (dt_dw_next - dt_dw_prev) / (next.power_w - prev.power_w).max(0.1);
let p_delta_prev = (curr.power_w - prev.power_w).max(0.5);
let p_delta_next = (next.power_w - curr.power_w).max(0.5);
let dt_dw_prev = (curr.temp_c - prev.temp_c) / p_delta_prev;
let dt_dw_next = (next.temp_c - curr.temp_c) / p_delta_next;
let p_total_delta = (next.power_w - prev.power_w).max(1.0);
let temp_accel = (dt_dw_next - dt_dw_prev) / p_total_delta;
// 3. Wall Detection (Any drop in absolute frequency/throughput is a hard wall)
let is_throttling = next.freq_mhz < curr.freq_mhz || (next.throughput > 0.0 && next.throughput < curr.throughput);