omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / apps / omega-wattd / watt_cbf.om
| 1 | note apps/omega-wattd/watt_cbf.om |
| 2 | note Pure seeded OM-2 fixed-point Joules-per-bit allocator, Arboris anticipatory pre-cooling |
| 3 | note planner, and discrete 2-node thermal Control Barrier Function (CBF) safety filter. |
| 4 | note Exact 1:1 fixed-point mirror of seed/helix/proofs/WattCBF.lean. |
| 5 | note Compose after si/directives/om2.om and apps/omega-wattd/watt_sense.om. |
| 6 | |
| 7 | const WATT_P_GPU_HARD_MAX long 80000 |
| 8 | const WATT_P_TOTAL_HARD_MAX long 140000 |
| 9 | const WATT_P_UNC_HARD_MAX long 25000 |
| 10 | const WATT_T_CRIT_MC long 104800 |
| 11 | const WATT_T_CEIL_DEFAULT long 85000 |
| 12 | const WATT_T_CEIL_TRAIN long 78000 |
| 13 | const WATT_T_CEIL_ABS_MAX long 90000 |
| 14 | const WATT_FAN_MIN long 20 |
| 15 | const WATT_FAN_MAX long 100 |
| 16 | |
| 17 | const WATT_THERMAL_SCALE long 1000 |
| 18 | const WATT_K_GPU_HEAT long 25 |
| 19 | const WATT_K_CPU_HEAT long 5 |
| 20 | const WATT_K_DS_COND long 100 |
| 21 | const WATT_K_SINK_IN long 10 |
| 22 | const WATT_K_FAN_BASE long 2 |
| 23 | const WATT_K_FAN_SLOPE long 8 |
| 24 | const WATT_SINK_SCALE long 100000 |
| 25 | |
| 26 | const WATT_MODE_IDLE long 0 |
| 27 | const WATT_MODE_DECODE long 1 |
| 28 | const WATT_MODE_TRAIN long 2 |
| 29 | |
| 30 | fn wc_min a long b long to long |
| 31 | if le a b |
| 32 | ret a |
| 33 | end |
| 34 | ret b |
| 35 | end |
| 36 | |
| 37 | fn wc_max a long b long to long |
| 38 | if ge a b |
| 39 | ret a |
| 40 | end |
| 41 | ret b |
| 42 | end |
| 43 | |
| 44 | note Exact mirror of WattCBF.clampNonNeg |
| 45 | fn wc_clamp_nonneg x long hi long to long |
| 46 | if le hi 0 |
| 47 | ret 0 |
| 48 | end |
| 49 | if le x 0 |
| 50 | ret 0 |
| 51 | end |
| 52 | if ge x hi |
| 53 | ret hi |
| 54 | end |
| 55 | ret x |
| 56 | end |
| 57 | |
| 58 | note Exact mirror of WattCBF.ceilDiv: rounds toward +infinity for b > 0, overflow-free across i64 |
| 59 | fn wc_ceil_div a long b long to long |
| 60 | requires gt b 0 |
| 61 | if lt a 0 |
| 62 | ret div a b |
| 63 | end |
| 64 | q = div a b |
| 65 | r = rem a b |
| 66 | if gt r 0 |
| 67 | ret add q 1 |
| 68 | end |
| 69 | ret q |
| 70 | end |
| 71 | |
| 72 | note Exact mirror of WattCBF.barrierH: h = T_ceil - T_die - tau * dT |
| 73 | fn wc_barrier_h t_ceil long t_die long tau long dt long to long |
| 74 | ret sub sub t_ceil t_die mul tau dt |
| 75 | end |
| 76 | |
| 77 | note Exact mirror of WattCBF.dieHeat |
| 78 | fn wc_die_heat p_gpu long p_cpu long p_unc long to long |
| 79 | ret add mul WATT_K_GPU_HEAT p_gpu mul WATT_K_CPU_HEAT add p_cpu p_unc |
| 80 | end |
| 81 | |
| 82 | note Exact mirror of WattCBF.dieCoolDs |
| 83 | fn wc_die_cool_ds st view WattThermal to long |
| 84 | ret mul WATT_K_DS_COND sub get st t_die get st t_sink |
| 85 | end |
| 86 | |
| 87 | note Exact mirror of WattCBF.nextDieDelta |
| 88 | fn wc_next_die_delta st view WattThermal p_gpu long p_cpu long p_unc long to long |
| 89 | heat = wc_die_heat p_gpu p_cpu p_unc |
| 90 | cool = wc_die_cool_ds st |
| 91 | ret wc_ceil_div sub heat cool WATT_THERMAL_SCALE |
| 92 | end |
| 93 | |
| 94 | note Exact mirror of WattCBF.nextSinkDelta |
| 95 | fn wc_next_sink_delta st view WattThermal fan_pct long to long |
| 96 | td = get st t_die |
| 97 | ts = get st t_sink |
| 98 | ta = get st t_amb |
| 99 | heat_in = mul mul WATT_K_SINK_IN 100 sub td ts |
| 100 | fan_g = add mul WATT_K_FAN_BASE 100 mul WATT_K_FAN_SLOPE fan_pct |
| 101 | cool_amb = mul fan_g sub ts ta |
| 102 | ret wc_ceil_div sub heat_in cool_amb WATT_SINK_SCALE |
| 103 | end |
| 104 | |
| 105 | note Exact mirror of WattCBF.stepThermal |
| 106 | fn wc_step_thermal st view WattThermal cmd view WattCmd nxt edit WattThermal to void |
| 107 | dt_die = wc_next_die_delta st get cmd p_gpu get cmd p_cpu get cmd p_unc |
| 108 | dt_sink = wc_next_sink_delta st get cmd fan_pct |
| 109 | put nxt t_die add get st t_die dt_die |
| 110 | put nxt t_sink add get st t_sink dt_sink |
| 111 | put nxt t_amb get st t_amb |
| 112 | end |
| 113 | |
| 114 | note Exact mirror of WattCBF.policyValid |
| 115 | fn wc_policy_valid pol view WattPolicy to bool |
| 116 | if le get pol p_budget 0 |
| 117 | ret false |
| 118 | end |
| 119 | if lt get pol p_gpu_budget 0 |
| 120 | ret false |
| 121 | end |
| 122 | if le get pol t_ceil 0 |
| 123 | ret false |
| 124 | end |
| 125 | if gt get pol t_ceil WATT_T_CEIL_ABS_MAX |
| 126 | ret false |
| 127 | end |
| 128 | if lt get pol tau 0 |
| 129 | ret false |
| 130 | end |
| 131 | ret true |
| 132 | end |
| 133 | |
| 134 | note Exact mirror of WattCBF.rawHeatBudget |
| 135 | fn wc_raw_heat_budget st view WattThermal pol view WattPolicy to long |
| 136 | tau = get pol tau |
| 137 | if lt tau 0 |
| 138 | ret 0 |
| 139 | end |
| 140 | headroom = sub get pol t_ceil get st t_die |
| 141 | dt_max = div headroom add tau 1 |
| 142 | ret add mul WATT_THERMAL_SCALE dt_max wc_die_cool_ds st |
| 143 | end |
| 144 | |
| 145 | note Exact mirror of WattCBF.maxHeatSafe |
| 146 | fn wc_max_heat_safe st view WattThermal pol view WattPolicy to long |
| 147 | tc = get pol t_ceil |
| 148 | if ge get st t_die tc |
| 149 | ret 0 |
| 150 | end |
| 151 | if ge get st t_sink tc |
| 152 | ret 0 |
| 153 | end |
| 154 | if lt get pol tau 0 |
| 155 | ret 0 |
| 156 | end |
| 157 | raw = wc_raw_heat_budget st pol |
| 158 | if le raw 0 |
| 159 | ret 0 |
| 160 | end |
| 161 | ret raw |
| 162 | end |
| 163 | |
| 164 | note Exact mirror of WattCBF.mustFailClosed |
| 165 | fn wc_must_fail_closed st view WattThermal pol view WattPolicy to bool |
| 166 | if not wc_policy_valid pol |
| 167 | ret true |
| 168 | end |
| 169 | tc = get pol t_ceil |
| 170 | if ge get st t_die tc |
| 171 | ret true |
| 172 | end |
| 173 | if ge get st t_sink tc |
| 174 | ret true |
| 175 | end |
| 176 | if lt wc_raw_heat_budget st pol 0 |
| 177 | ret true |
| 178 | end |
| 179 | ret false |
| 180 | end |
| 181 | |
| 182 | note Exact mirror of WattCBF.safeFanFloor |
| 183 | fn wc_safe_fan_floor headroom long therm_clamped long to long |
| 184 | if or ne therm_clamped 0 le headroom 5000 |
| 185 | ret WATT_FAN_MAX |
| 186 | end |
| 187 | if le headroom 10000 |
| 188 | ret 85 |
| 189 | end |
| 190 | if le headroom 18000 |
| 191 | ret 65 |
| 192 | end |
| 193 | if le headroom 28000 |
| 194 | ret 45 |
| 195 | end |
| 196 | ret WATT_FAN_MIN |
| 197 | end |
| 198 | |
| 199 | note Stage A helper: power-budget & Trap-14 80 W ceiling clamp (Uncore -> CPU -> GPU) |
| 200 | fn wc_power_clamp pol view WattPolicy prop view WattProp r edit WattProp to void |
| 201 | p_bud = wc_min get pol p_budget WATT_P_TOTAL_HARD_MAX |
| 202 | p_gcap = wc_min WATT_P_GPU_HARD_MAX wc_min get pol p_gpu_budget p_bud |
| 203 | p_unc1 = wc_clamp_nonneg get prop p_unc wc_min WATT_P_UNC_HARD_MAX p_bud |
| 204 | rem1 = sub p_bud p_unc1 |
| 205 | p_cpu1 = wc_clamp_nonneg get prop p_cpu rem1 |
| 206 | rem2 = sub rem1 p_cpu1 |
| 207 | p_gpu1 = wc_clamp_nonneg get prop p_gpu wc_min p_gcap rem2 |
| 208 | put r p_unc p_unc1 |
| 209 | put r p_cpu p_cpu1 |
| 210 | put r p_gpu p_gpu1 |
| 211 | put r fan_pct get prop fan_pct |
| 212 | end |
| 213 | |
| 214 | note Stage B helper: discrete thermal CBF water-fill clamp (dieHeat <= maxHeat) |
| 215 | fn wc_thermal_clamp r view WattProp max_heat long res edit WattCmd to void |
| 216 | h_unc = wc_min mul WATT_K_CPU_HEAT get r p_unc max_heat |
| 217 | p_unc2 = div h_unc WATT_K_CPU_HEAT |
| 218 | rem1 = sub max_heat h_unc |
| 219 | h_cpu = wc_min mul WATT_K_CPU_HEAT get r p_cpu rem1 |
| 220 | p_cpu2 = div h_cpu WATT_K_CPU_HEAT |
| 221 | rem2 = sub rem1 h_cpu |
| 222 | h_gpu = wc_min mul WATT_K_GPU_HEAT get r p_gpu rem2 |
| 223 | p_gpu2 = div h_gpu WATT_K_GPU_HEAT |
| 224 | put res p_unc p_unc2 |
| 225 | put res p_cpu p_cpu2 |
| 226 | put res p_gpu p_gpu2 |
| 227 | end |
| 228 | |
| 229 | note Exact 1:1 mirror of WattCBF.cbfFilter |
| 230 | fn wc_cbf_filter st view WattThermal pol view WattPolicy prop view WattProp res edit WattCmd to void |
| 231 | r1 = new WattProp 0 0 0 0 |
| 232 | if wc_must_fail_closed st pol |
| 233 | put res p_gpu 0 |
| 234 | put res p_cpu 0 |
| 235 | put res p_unc 0 |
| 236 | put res fan_pct WATT_FAN_MAX |
| 237 | put res fail_closed 1 |
| 238 | put res clamped 1 |
| 239 | ret |
| 240 | end |
| 241 | wc_power_clamp pol prop r1 |
| 242 | max_h = wc_max_heat_safe st pol |
| 243 | wc_thermal_clamp r1 max_h res |
| 244 | tc = long 0 |
| 245 | if lt get res p_unc get r1 p_unc |
| 246 | tc = 1 |
| 247 | end |
| 248 | if lt get res p_cpu get r1 p_cpu |
| 249 | tc = 1 |
| 250 | end |
| 251 | if lt get res p_gpu get r1 p_gpu |
| 252 | tc = 1 |
| 253 | end |
| 254 | headroom = sub get pol t_ceil get st t_die |
| 255 | ffloor = wc_safe_fan_floor headroom tc |
| 256 | fan_req_c = wc_max WATT_FAN_MIN get prop fan_pct |
| 257 | fan_out = wc_min WATT_FAN_MAX wc_max ffloor fan_req_c |
| 258 | put res fan_pct fan_out |
| 259 | put res fail_closed 0 |
| 260 | cl = long 0 |
| 261 | if ne get res p_gpu get prop p_gpu |
| 262 | cl = 1 |
| 263 | end |
| 264 | if ne get res p_cpu get prop p_cpu |
| 265 | cl = 1 |
| 266 | end |
| 267 | if ne get res p_unc get prop p_unc |
| 268 | cl = 1 |
| 269 | end |
| 270 | if ne fan_out get prop fan_pct |
| 271 | cl = 1 |
| 272 | end |
| 273 | put res clamped cl |
| 274 | end |
| 275 | |
| 276 | note Overflow-free exact floor((r * 1000) / m) for 0 <= r < m < 2^63 via 10-bit double-and-add |
| 277 | fn wc_mul1000_div_u64 r ulong m ulong to ulong |
| 278 | acc_q = ulong 0 |
| 279 | acc_r = ulong 0 |
| 280 | for k ulong 10 |
| 281 | acc_q = add acc_q acc_q |
| 282 | acc_r = add acc_r acc_r |
| 283 | if ge acc_r m |
| 284 | acc_r = sub acc_r m |
| 285 | acc_q = add acc_q 1 |
| 286 | end |
| 287 | bit = and shr ulong 1000 sub 9 k 1 |
| 288 | if eq bit 1 |
| 289 | acc_r = add acc_r r |
| 290 | if ge acc_r m |
| 291 | acc_r = sub acc_r m |
| 292 | acc_q = add acc_q 1 |
| 293 | end |
| 294 | end |
| 295 | end |
| 296 | ret acc_q |
| 297 | end |
| 298 | |
| 299 | note Fixed-point Joules-per-bit metric: TuringYield_J = delta_bits / delta_J = floor((delta_bits * 1000) / delta_mj) |
| 300 | fn wc_turing_yield_bpj delta_bits long delta_mj long to long |
| 301 | if or le delta_bits 0 le delta_mj 0 |
| 302 | ret 0 |
| 303 | end |
| 304 | q = div delta_bits delta_mj |
| 305 | r = rem delta_bits delta_mj |
| 306 | if ge q 9000000000000000 |
| 307 | ret 9000000000000000000 |
| 308 | end |
| 309 | frac = long wc_mul1000_div_u64 ulong r ulong delta_mj |
| 310 | ret add mul q 1000 frac |
| 311 | end |
| 312 | |
| 313 | note Mode-aware Watt-budget allocator with TuringYield_J efficiency tilting |
| 314 | fn wc_allocate_watts p_budget long mode long delta_bits long delta_mj long plan edit WattPlan to void |
| 315 | bpj = wc_turing_yield_bpj delta_bits delta_mj |
| 316 | put plan bpj bpj |
| 317 | put plan precool_active 0 |
| 318 | put plan precool_fan 0 |
| 319 | put plan trough_mw 0 |
| 320 | if le p_budget 0 |
| 321 | put plan p_gpu_req 0 |
| 322 | put plan p_cpu_req 0 |
| 323 | put plan p_unc_req 0 |
| 324 | put plan fan_req WATT_FAN_MAX |
| 325 | ret |
| 326 | end |
| 327 | bud = wc_min p_budget WATT_P_TOTAL_HARD_MAX |
| 328 | p_unc = long 0 |
| 329 | p_cpu = long 0 |
| 330 | p_gpu = long 0 |
| 331 | fan = long 35 |
| 332 | if eq mode WATT_MODE_IDLE |
| 333 | p_unc = wc_min 5000 div mul bud 25 100 |
| 334 | p_cpu = wc_min 8000 div mul bud 45 100 |
| 335 | p_gpu = wc_min 5000 sub sub bud p_unc p_cpu |
| 336 | if lt p_gpu 0 |
| 337 | p_gpu = 0 |
| 338 | end |
| 339 | fan = 25 |
| 340 | else |
| 341 | if eq mode WATT_MODE_TRAIN |
| 342 | p_unc = wc_max 5000 div mul bud 8 100 |
| 343 | p_unc = wc_min p_unc wc_min 15000 bud |
| 344 | rem_t = sub bud p_unc |
| 345 | p_cpu = div mul bud 17 100 |
| 346 | if gt p_cpu rem_t |
| 347 | p_cpu = rem_t |
| 348 | end |
| 349 | p_gpu = wc_min WATT_P_GPU_HARD_MAX sub rem_t p_cpu |
| 350 | fan = 60 |
| 351 | else |
| 352 | note MODE_DECODE (default): C2C/LPDDR5X + Grace APU + Blackwell GPU balanced split |
| 353 | p_unc = wc_max 6000 div mul bud 12 100 |
| 354 | p_unc = wc_min p_unc wc_min 18000 bud |
| 355 | rem_d = sub bud p_unc |
| 356 | p_cpu = div mul bud 22 100 |
| 357 | if gt p_cpu rem_d |
| 358 | p_cpu = rem_d |
| 359 | end |
| 360 | p_gpu = wc_min WATT_P_GPU_HARD_MAX sub rem_d p_cpu |
| 361 | fan = 45 |
| 362 | end |
| 363 | end |
| 364 | note TuringYield_J tilt: reward high bits/J compute density; shift low bits/J toward C2C/CPU |
| 365 | if and ne mode WATT_MODE_IDLE gt bpj 0 |
| 366 | if ge bpj 1000 |
| 367 | shift = div mul p_cpu 15 100 |
| 368 | if gt add p_gpu shift WATT_P_GPU_HARD_MAX |
| 369 | shift = sub WATT_P_GPU_HARD_MAX p_gpu |
| 370 | end |
| 371 | if gt shift 0 |
| 372 | p_cpu = sub p_cpu shift |
| 373 | p_gpu = add p_gpu shift |
| 374 | end |
| 375 | else |
| 376 | if lt bpj 200 |
| 377 | shift2 = div mul p_gpu 10 100 |
| 378 | if gt add p_unc shift2 WATT_P_UNC_HARD_MAX |
| 379 | shift2 = sub WATT_P_UNC_HARD_MAX p_unc |
| 380 | end |
| 381 | if gt shift2 0 |
| 382 | p_gpu = sub p_gpu shift2 |
| 383 | p_unc = add p_unc shift2 |
| 384 | end |
| 385 | end |
| 386 | end |
| 387 | end |
| 388 | put plan p_gpu_req p_gpu |
| 389 | put plan p_cpu_req p_cpu |
| 390 | put plan p_unc_req p_unc |
| 391 | put plan fan_req fan |
| 392 | end |
| 393 | |
| 394 | fn wc_precool_trough t_ceil long t_die long pc_fan long trough_pct long plan edit WattPlan to void |
| 395 | put plan precool_active 1 |
| 396 | put plan precool_fan pc_fan |
| 397 | if gt pc_fan get plan fan_req |
| 398 | put plan fan_req pc_fan |
| 399 | end |
| 400 | cur_g = get plan p_gpu_req |
| 401 | tr = div mul cur_g trough_pct 100 |
| 402 | new_g = sub cur_g tr |
| 403 | floor_g = wc_min cur_g 15000 |
| 404 | if ge sub t_ceil t_die 4000 |
| 405 | if lt new_g floor_g |
| 406 | new_g = floor_g |
| 407 | tr = sub cur_g new_g |
| 408 | end |
| 409 | end |
| 410 | put plan p_gpu_req new_g |
| 411 | put plan trough_mw tr |
| 412 | end |
| 413 | |
| 414 | note Arboris anticipatory pre-cooling planner: burst lookahead -> pre-cool fan floor + pre-burst trough |
| 415 | fn wc_apply_precool st view WattThermal pol view WattPolicy burst_mw long burst_sec long plan edit WattPlan to void |
| 416 | put plan precool_active 0 |
| 417 | put plan precool_fan 0 |
| 418 | put plan trough_mw 0 |
| 419 | if not wc_policy_valid pol |
| 420 | ret |
| 421 | end |
| 422 | if or le burst_mw 0 le burst_sec 0 |
| 423 | ret |
| 424 | end |
| 425 | b_gpu = wc_min burst_mw WATT_P_GPU_HARD_MAX |
| 426 | dt_b = wc_next_die_delta st b_gpu get plan p_cpu_req get plan p_unc_req |
| 427 | t_die = get st t_die |
| 428 | t_ceil = get pol t_ceil |
| 429 | t_proj = add t_die mul wc_min burst_sec 60 wc_max 0 dt_b |
| 430 | h_burst = wc_barrier_h t_ceil t_die get pol tau dt_b |
| 431 | need_pc = false |
| 432 | if ge t_proj sub t_ceil 4000 |
| 433 | need_pc = true |
| 434 | end |
| 435 | if lt h_burst 4000 |
| 436 | need_pc = true |
| 437 | end |
| 438 | if ge t_die sub t_ceil 10000 |
| 439 | need_pc = true |
| 440 | end |
| 441 | if not need_pc |
| 442 | ret |
| 443 | end |
| 444 | if or ge t_proj t_ceil le h_burst 0 |
| 445 | wc_precool_trough t_ceil t_die WATT_FAN_MAX 35 plan |
| 446 | else |
| 447 | wc_precool_trough t_ceil t_die 85 20 plan |
| 448 | end |
| 449 | end |
| 450 | |
| 451 | note Filter a WattPlan through the formally verified CBF shield into WattCmd |
| 452 | fn wc_filter_plan st view WattThermal pol view WattPolicy plan view WattPlan cmd edit WattCmd to void |
| 453 | pr = new WattProp get plan p_gpu_req get plan p_cpu_req get plan p_unc_req get plan fan_req |
| 454 | wc_cbf_filter st pol pr cmd |
| 455 | end |
| 456 | |
| 457 | note Shared self-verification gate messages (used by both omega-wattd gate and gate_wattd) |
| 458 | text wg_m_pass "PASS " |
| 459 | text wg_m_fail "FAIL " |
| 460 | text wg_m_t1 "T1_live_spark_sense" |
| 461 | text wg_m_t2 "T2_trap14_88w_90w_lean_match" |
| 462 | text wg_m_t3 "T3_tgpu_spike_and_overtemp" |
| 463 | text wg_m_t4 "T4_over_budget_total_clamped" |
| 464 | text wg_m_t5 "T5_invalid_policy_fail_closed" |
| 465 | text wg_m_t6 "T6_turing_yield_allocator_modes" |
| 466 | text wg_m_t7 "T7_arboris_anticipatory_precool" |
| 467 | text wg_m_t8 "T8_closed_loop_120tick_invariance" |
| 468 | text wg_m_t9 "T9_live_silicon_full_plan_pipeline" |
| 469 | text wg_m_t1_det " zones=7/7 cpus=20/20 cppc=20/20 hw_writes=0 tgpu_mc=" |
| 470 | text wg_m_t2_det " raw_90w_h=-700 cbf_gpu_mw=62640 cbf_h=668 fan=100" |
| 471 | text wg_m_t3_det " raw_tdie_next=78375 raw_h=-1250 cbf_tdie_next<=78000 overtemp_fail_closed=1" |
| 472 | text wg_m_t4_det " raw_120w>100w cbf_total_mw=" |
| 473 | text wg_m_t5_det " neg_budget=0 zero_budget=0 bad_ceil=0 bad_tau=0 hot_sink=0 infeas_bar=0 fan=100" |
| 474 | text wg_m_t6_det " bpj_hi=" |
| 475 | text wg_m_t6_det2 " bpj_lo=" |
| 476 | text wg_m_t7_det " precool_sink_mc=" |
| 477 | text wg_m_t7_det2 " base_sink_mc=" |
| 478 | text wg_m_t7_det3 " burst_gpu_pc=" |
| 479 | text wg_m_t7_det4 " burst_gpu_base=" |
| 480 | text wg_m_t8_det " ticks=120 max_tdie_mc=" |
| 481 | text wg_m_t8_det2 " max_tsink_mc=" |
| 482 | text wg_m_t8_det3 " idempotent=1" |
| 483 | text wg_m_t9_det " decode_gpu_mw=" |
| 484 | text wg_m_t9_det2 " train_gpu_mw=" |
| 485 | text wg_m_t9_det3 " idle_gpu_mw=" |
| 486 | text wg_m_sum_pass "GATE PASS omega-wattd checks=" |
| 487 | text wg_m_sum_fail "GATE FAIL omega-wattd passed=" |
| 488 | text wg_m_sum_of "/" |
| 489 | text wg_m_sum_tail " hw_writes=0\n" |
| 490 | |
| 491 | fn wg_report ok bool name view uchar * to long |
| 492 | if ok |
| 493 | wd_puts wg_m_pass |
| 494 | wd_puts name |
| 495 | wd_puts ws_lbl_nl |
| 496 | ret 1 |
| 497 | end |
| 498 | wd_puts wg_m_fail |
| 499 | wd_puts name |
| 500 | wd_puts ws_lbl_nl |
| 501 | ret 0 |
| 502 | end |
| 503 | |
| 504 | fn wg_t1_live_sense to bool |
| 505 | ws_sense_all |
| 506 | ok = true |
| 507 | if ne get g_wmeta 0 7 |
| 508 | ok = false |
| 509 | end |
| 510 | if ne get g_wmeta 13 1 |
| 511 | ok = false |
| 512 | end |
| 513 | if ne get g_wmeta 1 20 |
| 514 | ok = false |
| 515 | end |
| 516 | if ne get g_wmeta 2 20 |
| 517 | ok = false |
| 518 | end |
| 519 | for z ulong 7 |
| 520 | zt = get g_tz_mc z |
| 521 | if or le zt 10000 ge zt 100000 |
| 522 | ok = false |
| 523 | end |
| 524 | if ne get g_tz_crit z WATT_T_CRIT_MC |
| 525 | ok = false |
| 526 | end |
| 527 | end |
| 528 | tgpu = get g_wmeta 5 |
| 529 | aavg = get g_wmeta 3 |
| 530 | xavg = get g_wmeta 4 |
| 531 | if or lt aavg 338000 gt aavg 2808000 |
| 532 | ok = false |
| 533 | end |
| 534 | if or lt xavg 1378000 gt xavg 3900000 |
| 535 | ok = false |
| 536 | end |
| 537 | if or le get g_wmeta 10 0 le get g_wmeta 11 0 |
| 538 | ok = false |
| 539 | end |
| 540 | if ne get g_wmeta 12 0 |
| 541 | ok = false |
| 542 | end |
| 543 | if ok |
| 544 | wd_puts wg_m_pass |
| 545 | wd_puts wg_m_t1 |
| 546 | wd_puts wg_m_t1_det |
| 547 | wd_put_i64 tgpu |
| 548 | wd_puts ws_lbl_nl |
| 549 | else |
| 550 | wd_puts wg_m_fail |
| 551 | wd_puts wg_m_t1 |
| 552 | wd_puts ws_lbl_nl |
| 553 | end |
| 554 | ret ok |
| 555 | end |
| 556 | |
| 557 | fn wg_t2a_88w to bool |
| 558 | st_cool = new WattThermal 44000 40000 25000 |
| 559 | pol_cool = new WattPolicy 120000 120000 85000 2 |
| 560 | pr88 = new WattProp 88000 15000 5000 40 |
| 561 | cmd88 = new WattCmd 0 0 0 0 0 0 |
| 562 | wc_cbf_filter st_cool pol_cool pr88 cmd88 |
| 563 | if ne get cmd88 p_gpu 80000 |
| 564 | ret false |
| 565 | end |
| 566 | if ne get cmd88 clamped 1 |
| 567 | ret false |
| 568 | end |
| 569 | if ne get cmd88 fail_closed 0 |
| 570 | ret false |
| 571 | end |
| 572 | ret true |
| 573 | end |
| 574 | |
| 575 | fn wg_t2b_90w_lean to bool |
| 576 | st90 = new WattThermal 76000 66000 25000 |
| 577 | pol90 = new WattPolicy 110000 80000 78000 2 |
| 578 | pr90 = new WattProp 90000 15000 5000 40 |
| 579 | dt_raw = wc_next_die_delta st90 90000 15000 5000 |
| 580 | if ne wc_barrier_h 78000 76000 2 dt_raw -700 |
| 581 | ret false |
| 582 | end |
| 583 | cmd90 = new WattCmd 0 0 0 0 0 0 |
| 584 | wc_cbf_filter st90 pol90 pr90 cmd90 |
| 585 | if ne get cmd90 p_gpu 62640 |
| 586 | ret false |
| 587 | end |
| 588 | if ne get cmd90 p_cpu 15000 |
| 589 | ret false |
| 590 | end |
| 591 | if ne get cmd90 p_unc 5000 |
| 592 | ret false |
| 593 | end |
| 594 | if ne get cmd90 fan_pct 100 |
| 595 | ret false |
| 596 | end |
| 597 | if ne get cmd90 clamped 1 |
| 598 | ret false |
| 599 | end |
| 600 | dt_cbf = wc_next_die_delta st90 get cmd90 p_gpu get cmd90 p_cpu get cmd90 p_unc |
| 601 | if ne wc_barrier_h 78000 76000 2 dt_cbf 668 |
| 602 | ret false |
| 603 | end |
| 604 | nxt90 = new WattThermal 0 0 0 |
| 605 | wc_step_thermal st90 cmd90 nxt90 |
| 606 | if ne get nxt90 t_die 76666 |
| 607 | ret false |
| 608 | end |
| 609 | ret true |
| 610 | end |
| 611 | |
| 612 | fn wg_t2_trap14 to bool |
| 613 | ok = true |
| 614 | if not wg_t2a_88w |
| 615 | ok = false |
| 616 | end |
| 617 | if not wg_t2b_90w_lean |
| 618 | ok = false |
| 619 | end |
| 620 | if ok |
| 621 | wd_puts wg_m_pass |
| 622 | wd_puts wg_m_t2 |
| 623 | wd_puts wg_m_t2_det |
| 624 | wd_puts ws_lbl_nl |
| 625 | else |
| 626 | wd_puts wg_m_fail |
| 627 | wd_puts wg_m_t2 |
| 628 | wd_puts ws_lbl_nl |
| 629 | end |
| 630 | ret ok |
| 631 | end |
| 632 | |
| 633 | fn wg_t3a_spike to bool |
| 634 | st = new WattThermal 77500 68000 25000 |
| 635 | pol = new WattPolicy 100000 80000 78000 2 |
| 636 | pr = new WattProp 70000 10000 5000 50 |
| 637 | dt_raw = wc_next_die_delta st 70000 10000 5000 |
| 638 | if ne add 77500 dt_raw 78375 |
| 639 | ret false |
| 640 | end |
| 641 | if ne wc_barrier_h 78000 77500 2 dt_raw -1250 |
| 642 | ret false |
| 643 | end |
| 644 | cmd = new WattCmd 0 0 0 0 0 0 |
| 645 | wc_cbf_filter st pol pr cmd |
| 646 | nxt = new WattThermal 0 0 0 |
| 647 | wc_step_thermal st cmd nxt |
| 648 | dt_c = wc_next_die_delta st get cmd p_gpu get cmd p_cpu get cmd p_unc |
| 649 | if gt get nxt t_die 78000 |
| 650 | ret false |
| 651 | end |
| 652 | if lt wc_barrier_h 78000 77500 2 dt_c 0 |
| 653 | ret false |
| 654 | end |
| 655 | if ne get cmd fan_pct 100 |
| 656 | ret false |
| 657 | end |
| 658 | if ge get cmd p_gpu 70000 |
| 659 | ret false |
| 660 | end |
| 661 | ret true |
| 662 | end |
| 663 | |
| 664 | fn wg_t3b_overtemp to bool |
| 665 | st_hot = new WattThermal 80000 68000 25000 |
| 666 | pol = new WattPolicy 100000 80000 78000 2 |
| 667 | pr = new WattProp 70000 10000 5000 50 |
| 668 | cmd_hot = new WattCmd 0 0 0 0 0 0 |
| 669 | wc_cbf_filter st_hot pol pr cmd_hot |
| 670 | if ne get cmd_hot fail_closed 1 |
| 671 | ret false |
| 672 | end |
| 673 | if ne get cmd_hot fan_pct 100 |
| 674 | ret false |
| 675 | end |
| 676 | if ne get cmd_hot p_gpu 0 |
| 677 | ret false |
| 678 | end |
| 679 | if ne get cmd_hot p_cpu 0 |
| 680 | ret false |
| 681 | end |
| 682 | if ne get cmd_hot p_unc 0 |
| 683 | ret false |
| 684 | end |
| 685 | ret true |
| 686 | end |
| 687 | |
| 688 | fn wg_t3_tgpu_spike to bool |
| 689 | ok = true |
| 690 | if not wg_t3a_spike |
| 691 | ok = false |
| 692 | end |
| 693 | if not wg_t3b_overtemp |
| 694 | ok = false |
| 695 | end |
| 696 | if ok |
| 697 | wd_puts wg_m_pass |
| 698 | wd_puts wg_m_t3 |
| 699 | wd_puts wg_m_t3_det |
| 700 | wd_puts ws_lbl_nl |
| 701 | else |
| 702 | wd_puts wg_m_fail |
| 703 | wd_puts wg_m_t3 |
| 704 | wd_puts ws_lbl_nl |
| 705 | end |
| 706 | ret ok |
| 707 | end |
| 708 | |
| 709 | fn wg_t4_over_budget to bool |
| 710 | ok = true |
| 711 | st = new WattThermal 44000 40000 25000 |
| 712 | pol = new WattPolicy 100000 80000 85000 2 |
| 713 | pr = new WattProp 75000 35000 10000 40 |
| 714 | cmd = new WattCmd 0 0 0 0 0 0 |
| 715 | wc_cbf_filter st pol pr cmd |
| 716 | tot = add add get cmd p_gpu get cmd p_cpu get cmd p_unc |
| 717 | if gt tot 100000 |
| 718 | ok = false |
| 719 | end |
| 720 | if or ne get cmd p_gpu 55000 ne get cmd clamped 1 |
| 721 | ok = false |
| 722 | end |
| 723 | if ok |
| 724 | wd_puts wg_m_pass |
| 725 | wd_puts wg_m_t4 |
| 726 | wd_puts wg_m_t4_det |
| 727 | wd_put_i64 tot |
| 728 | wd_puts ws_lbl_nl |
| 729 | else |
| 730 | wd_puts wg_m_fail |
| 731 | wd_puts wg_m_t4 |
| 732 | wd_puts ws_lbl_nl |
| 733 | end |
| 734 | ret ok |
| 735 | end |
| 736 | |
| 737 | fn wg_check_fail_closed st view WattThermal pol view WattPolicy pr view WattProp to bool |
| 738 | cmd = new WattCmd 0 0 0 0 0 0 |
| 739 | wc_cbf_filter st pol pr cmd |
| 740 | if ne get cmd fail_closed 1 |
| 741 | ret false |
| 742 | end |
| 743 | if or ne get cmd p_gpu 0 or ne get cmd p_cpu 0 ne get cmd p_unc 0 |
| 744 | ret false |
| 745 | end |
| 746 | if ne get cmd fan_pct 100 |
| 747 | ret false |
| 748 | end |
| 749 | ret true |
| 750 | end |
| 751 | |
| 752 | fn wg_t5b_hot_sink_and_infeas to bool |
| 753 | pr = new WattProp 75000 17000 8000 60 |
| 754 | pr0 = new WattProp 0 0 0 30 |
| 755 | st_150 = new WattThermal 48700 150000 25000 |
| 756 | pol85 = new WattPolicy 100000 80000 85000 2 |
| 757 | if not wg_check_fail_closed st_150 pol85 pr |
| 758 | ret false |
| 759 | end |
| 760 | st_inf = new WattThermal 77000 77900 25000 |
| 761 | pol78_20 = new WattPolicy 100000 80000 78000 20 |
| 762 | if not wg_check_fail_closed st_inf pol78_20 pr0 |
| 763 | ret false |
| 764 | end |
| 765 | st_rev = new WattThermal 77500 86000 25000 |
| 766 | pol78_2 = new WattPolicy 100000 80000 78000 2 |
| 767 | if not wg_check_fail_closed st_rev pol78_2 pr |
| 768 | ret false |
| 769 | end |
| 770 | st_eq = new WattThermal 44000 40000 25000 |
| 771 | p_neg_g = new WattPolicy 100000 -1 85000 2 |
| 772 | if not wg_check_fail_closed st_eq p_neg_g pr |
| 773 | ret false |
| 774 | end |
| 775 | ret true |
| 776 | end |
| 777 | |
| 778 | fn wg_t5_invalid_refused to bool |
| 779 | ok = true |
| 780 | st = new WattThermal 44000 40000 25000 |
| 781 | pr = new WattProp 50000 15000 5000 30 |
| 782 | p_neg = new WattPolicy -10000 80000 85000 2 |
| 783 | p_zero = new WattPolicy 0 80000 85000 2 |
| 784 | p_hi_ceil = new WattPolicy 100000 80000 95000 2 |
| 785 | p_lo_ceil = new WattPolicy 100000 80000 0 2 |
| 786 | p_neg_tau = new WattPolicy 100000 80000 85000 -1 |
| 787 | if not wg_check_fail_closed st p_neg pr |
| 788 | ok = false |
| 789 | end |
| 790 | if not wg_check_fail_closed st p_zero pr |
| 791 | ok = false |
| 792 | end |
| 793 | if not wg_check_fail_closed st p_hi_ceil pr |
| 794 | ok = false |
| 795 | end |
| 796 | if not wg_check_fail_closed st p_lo_ceil pr |
| 797 | ok = false |
| 798 | end |
| 799 | if not wg_check_fail_closed st p_neg_tau pr |
| 800 | ok = false |
| 801 | end |
| 802 | if not wg_t5b_hot_sink_and_infeas |
| 803 | ok = false |
| 804 | end |
| 805 | if ok |
| 806 | wd_puts wg_m_pass |
| 807 | wd_puts wg_m_t5 |
| 808 | wd_puts wg_m_t5_det |
| 809 | wd_puts ws_lbl_nl |
| 810 | else |
| 811 | wd_puts wg_m_fail |
| 812 | wd_puts wg_m_t5 |
| 813 | wd_puts ws_lbl_nl |
| 814 | end |
| 815 | ret ok |
| 816 | end |
| 817 | |
| 818 | fn wg_t6_allocator to bool |
| 819 | ok = true |
| 820 | pl_hi = new WattPlan 0 0 0 0 0 0 0 0 |
| 821 | pl_lo = new WattPlan 0 0 0 0 0 0 0 0 |
| 822 | pl_id = new WattPlan 0 0 0 0 0 0 0 0 |
| 823 | wc_allocate_watts 90000 WATT_MODE_TRAIN 500000 100000 pl_hi |
| 824 | wc_allocate_watts 90000 WATT_MODE_TRAIN 10000 100000 pl_lo |
| 825 | wc_allocate_watts 25000 WATT_MODE_IDLE 0 0 pl_id |
| 826 | if ne get pl_hi bpj 5000 |
| 827 | ok = false |
| 828 | end |
| 829 | if ne get pl_lo bpj 100 |
| 830 | ok = false |
| 831 | end |
| 832 | note Exact huge-bit TuringYield_J boundaries (zero truncation or i64 overflow) |
| 833 | if ne wc_turing_yield_bpj 9000000000000001 500 18000000000000002 |
| 834 | ok = false |
| 835 | end |
| 836 | if ne wc_turing_yield_bpj 9000000000000001 1999 4502251125562781 |
| 837 | ok = false |
| 838 | end |
| 839 | if ne wc_turing_yield_bpj 9000000000000001 1 9000000000000000000 |
| 840 | ok = false |
| 841 | end |
| 842 | if le get pl_hi p_gpu_req get pl_lo p_gpu_req |
| 843 | ok = false |
| 844 | end |
| 845 | tot_hi = add add get pl_hi p_gpu_req get pl_hi p_cpu_req get pl_hi p_unc_req |
| 846 | tot_id = add add get pl_id p_gpu_req get pl_id p_cpu_req get pl_id p_unc_req |
| 847 | if or gt tot_hi 90000 gt get pl_hi p_gpu_req WATT_P_GPU_HARD_MAX |
| 848 | ok = false |
| 849 | end |
| 850 | if or gt tot_id 25000 gt get pl_id p_gpu_req 5000 |
| 851 | ok = false |
| 852 | end |
| 853 | if ok |
| 854 | wd_puts wg_m_pass |
| 855 | wd_puts wg_m_t6 |
| 856 | wd_puts wg_m_t6_det |
| 857 | wd_put_i64 get pl_hi bpj |
| 858 | wd_puts wg_m_t6_det2 |
| 859 | wd_put_i64 get pl_lo bpj |
| 860 | wd_puts ws_lbl_nl |
| 861 | else |
| 862 | wd_puts wg_m_fail |
| 863 | wd_puts wg_m_t6 |
| 864 | wd_puts ws_lbl_nl |
| 865 | end |
| 866 | ret ok |
| 867 | end |
| 868 | |
| 869 | fn wg_t7_step_pc st edit WattThermal pol view WattPolicy to void |
| 870 | pl = new WattPlan 0 0 0 0 0 0 0 0 |
| 871 | cmd = new WattCmd 0 0 0 0 0 0 |
| 872 | nxt = new WattThermal 0 0 0 |
| 873 | wc_allocate_watts 100000 WATT_MODE_TRAIN 0 0 pl |
| 874 | wc_apply_precool st pol 75000 5 pl |
| 875 | wc_filter_plan st pol pl cmd |
| 876 | wc_step_thermal st cmd nxt |
| 877 | put st t_die get nxt t_die |
| 878 | put st t_sink get nxt t_sink |
| 879 | end |
| 880 | |
| 881 | fn wg_t7_step_bs st edit WattThermal pol view WattPolicy to void |
| 882 | pr = new WattProp 65000 15000 8000 45 |
| 883 | cmd = new WattCmd 0 0 0 0 0 0 |
| 884 | nxt = new WattThermal 0 0 0 |
| 885 | wc_cbf_filter st pol pr cmd |
| 886 | wc_step_thermal st cmd nxt |
| 887 | put st t_die get nxt t_die |
| 888 | put st t_sink get nxt t_sink |
| 889 | end |
| 890 | |
| 891 | fn wg_t7_precool to bool |
| 892 | ok = true |
| 893 | pol = new WattPolicy 100000 80000 78000 2 |
| 894 | st_pc = new WattThermal 75500 66000 25000 |
| 895 | st_bs = new WattThermal 75500 66000 25000 |
| 896 | pl_pc = new WattPlan 0 0 0 0 0 0 0 0 |
| 897 | wc_allocate_watts 100000 WATT_MODE_TRAIN 0 0 pl_pc |
| 898 | wc_apply_precool st_pc pol 75000 5 pl_pc |
| 899 | if ne get pl_pc precool_active 1 |
| 900 | ok = false |
| 901 | end |
| 902 | if lt get pl_pc precool_fan 85 |
| 903 | ok = false |
| 904 | end |
| 905 | if le get pl_pc trough_mw 0 |
| 906 | ok = false |
| 907 | end |
| 908 | for t ulong 5 |
| 909 | wg_t7_step_pc st_pc pol |
| 910 | wg_t7_step_bs st_bs pol |
| 911 | end |
| 912 | if ge get st_pc t_sink get st_bs t_sink |
| 913 | ok = false |
| 914 | end |
| 915 | if ge get st_pc t_die get st_bs t_die |
| 916 | ok = false |
| 917 | end |
| 918 | pr_burst = new WattProp 75000 15000 8000 85 |
| 919 | cmd_pc = new WattCmd 0 0 0 0 0 0 |
| 920 | cmd_bs = new WattCmd 0 0 0 0 0 0 |
| 921 | wc_cbf_filter st_pc pol pr_burst cmd_pc |
| 922 | wc_cbf_filter st_bs pol pr_burst cmd_bs |
| 923 | if le get cmd_pc p_gpu get cmd_bs p_gpu |
| 924 | ok = false |
| 925 | end |
| 926 | if ok |
| 927 | wd_puts wg_m_pass |
| 928 | wd_puts wg_m_t7 |
| 929 | wd_puts wg_m_t7_det |
| 930 | wd_put_i64 get st_pc t_sink |
| 931 | wd_puts wg_m_t7_det2 |
| 932 | wd_put_i64 get st_bs t_sink |
| 933 | wd_puts wg_m_t7_det3 |
| 934 | wd_put_i64 get cmd_pc p_gpu |
| 935 | wd_puts wg_m_t7_det4 |
| 936 | wd_put_i64 get cmd_bs p_gpu |
| 937 | wd_puts ws_lbl_nl |
| 938 | else |
| 939 | wd_puts wg_m_fail |
| 940 | wd_puts wg_m_t7 |
| 941 | wd_puts ws_lbl_nl |
| 942 | end |
| 943 | ret ok |
| 944 | end |
| 945 | |
| 946 | fn wg_check_idemp st view WattThermal pol view WattPolicy cmd view WattCmd to bool |
| 947 | pr_re = new WattProp get cmd p_gpu get cmd p_cpu get cmd p_unc get cmd fan_pct |
| 948 | cmd2 = new WattCmd 0 0 0 0 0 0 |
| 949 | wc_cbf_filter st pol pr_re cmd2 |
| 950 | if ne get cmd2 p_gpu get cmd p_gpu |
| 951 | ret false |
| 952 | end |
| 953 | if ne get cmd2 p_cpu get cmd p_cpu |
| 954 | ret false |
| 955 | end |
| 956 | if ne get cmd2 p_unc get cmd p_unc |
| 957 | ret false |
| 958 | end |
| 959 | if ne get cmd2 fan_pct get cmd fan_pct |
| 960 | ret false |
| 961 | end |
| 962 | if ne get cmd2 fail_closed get cmd fail_closed |
| 963 | ret false |
| 964 | end |
| 965 | if eq get cmd fail_closed 0 |
| 966 | if ne get cmd2 clamped 0 |
| 967 | ret false |
| 968 | end |
| 969 | end |
| 970 | ret true |
| 971 | end |
| 972 | |
| 973 | fn wg_t8_step_check st edit WattThermal pol view WattPolicy pr_adv view WattProp to bool |
| 974 | cmd = new WattCmd 0 0 0 0 0 0 |
| 975 | nxt = new WattThermal 0 0 0 |
| 976 | wc_cbf_filter st pol pr_adv cmd |
| 977 | pg = get cmd p_gpu |
| 978 | pc = get cmd p_cpu |
| 979 | pu = get cmd p_unc |
| 980 | if gt pg 80000 |
| 981 | ret false |
| 982 | end |
| 983 | if gt add add pg pc pu 110000 |
| 984 | ret false |
| 985 | end |
| 986 | if lt get cmd fan_pct 20 |
| 987 | ret false |
| 988 | end |
| 989 | if gt get cmd fan_pct 100 |
| 990 | ret false |
| 991 | end |
| 992 | dt = wc_next_die_delta st pg pc pu |
| 993 | h = wc_barrier_h 78000 get st t_die 2 dt |
| 994 | if lt h 0 |
| 995 | ret false |
| 996 | end |
| 997 | if not wg_check_idemp st pol cmd |
| 998 | ret false |
| 999 | end |
| 1000 | wc_step_thermal st cmd nxt |
| 1001 | put st t_die get nxt t_die |
| 1002 | put st t_sink get nxt t_sink |
| 1003 | if gt get st t_die 78000 |
| 1004 | ret false |
| 1005 | end |
| 1006 | if gt get st t_sink 78000 |
| 1007 | ret false |
| 1008 | end |
| 1009 | ret true |
| 1010 | end |
| 1011 | |
| 1012 | fn wg_t8_closed_loop to bool |
| 1013 | ok = true |
| 1014 | note Hot-start right near 78 C ceiling so thermal CBF actively clamps against barrier wall |
| 1015 | st = new WattThermal 76500 68000 25000 |
| 1016 | pol = new WattPolicy 110000 80000 78000 2 |
| 1017 | pr_adv = new WattProp 120000 50000 20000 0 |
| 1018 | max_td = long 0 |
| 1019 | max_ts = long 0 |
| 1020 | for tick ulong 120 |
| 1021 | if not wg_t8_step_check st pol pr_adv |
| 1022 | ok = false |
| 1023 | end |
| 1024 | if gt get st t_die max_td |
| 1025 | max_td = get st t_die |
| 1026 | end |
| 1027 | if gt get st t_sink max_ts |
| 1028 | max_ts = get st t_sink |
| 1029 | end |
| 1030 | end |
| 1031 | if ok |
| 1032 | wd_puts wg_m_pass |
| 1033 | wd_puts wg_m_t8 |
| 1034 | wd_puts wg_m_t8_det |
| 1035 | wd_put_i64 max_td |
| 1036 | wd_puts wg_m_t8_det2 |
| 1037 | wd_put_i64 max_ts |
| 1038 | wd_puts wg_m_t8_det3 |
| 1039 | wd_puts ws_lbl_nl |
| 1040 | else |
| 1041 | wd_puts wg_m_fail |
| 1042 | wd_puts wg_m_t8 |
| 1043 | wd_puts ws_lbl_nl |
| 1044 | end |
| 1045 | ret ok |
| 1046 | end |
| 1047 | |
| 1048 | fn wg_t9_eval st view WattThermal budget long mode long ceil_mc long burst_mw long to long |
| 1049 | pol = new WattPolicy budget WATT_P_GPU_HARD_MAX ceil_mc 2 |
| 1050 | pl = new WattPlan 0 0 0 0 0 0 0 0 |
| 1051 | cmd = new WattCmd 0 0 0 0 0 0 |
| 1052 | wc_allocate_watts budget mode 240000 100000 pl |
| 1053 | if gt burst_mw 0 |
| 1054 | wc_apply_precool st pol burst_mw 5 pl |
| 1055 | end |
| 1056 | wc_filter_plan st pol pl cmd |
| 1057 | if ne get cmd fail_closed 0 |
| 1058 | ret -1 |
| 1059 | end |
| 1060 | if gt get cmd p_gpu WATT_P_GPU_HARD_MAX |
| 1061 | ret -1 |
| 1062 | end |
| 1063 | if gt add add get cmd p_gpu get cmd p_cpu get cmd p_unc budget |
| 1064 | ret -1 |
| 1065 | end |
| 1066 | ret get cmd p_gpu |
| 1067 | end |
| 1068 | |
| 1069 | fn wg_t9_live_pipeline to bool |
| 1070 | st = new WattThermal 0 0 0 |
| 1071 | live_ok = ws_fill_thermal_state st |
| 1072 | gd = wg_t9_eval st 90000 WATT_MODE_DECODE 85000 0 |
| 1073 | g_tr = wg_t9_eval st 100000 WATT_MODE_TRAIN 78000 75000 |
| 1074 | gi = wg_t9_eval st 25000 WATT_MODE_IDLE 85000 0 |
| 1075 | ok = live_ok |
| 1076 | if lt gd 0 |
| 1077 | ok = false |
| 1078 | end |
| 1079 | if lt g_tr 0 |
| 1080 | ok = false |
| 1081 | end |
| 1082 | if lt gi 0 |
| 1083 | ok = false |
| 1084 | end |
| 1085 | if ne get g_wmeta 12 0 |
| 1086 | ok = false |
| 1087 | end |
| 1088 | if ok |
| 1089 | wd_puts wg_m_pass |
| 1090 | wd_puts wg_m_t9 |
| 1091 | wd_puts wg_m_t9_det |
| 1092 | wd_put_i64 gd |
| 1093 | wd_puts wg_m_t9_det2 |
| 1094 | wd_put_i64 g_tr |
| 1095 | wd_puts wg_m_t9_det3 |
| 1096 | wd_put_i64 gi |
| 1097 | wd_puts ws_lbl_nl |
| 1098 | else |
| 1099 | wd_puts wg_m_fail |
| 1100 | wd_puts wg_m_t9 |
| 1101 | wd_puts ws_lbl_nl |
| 1102 | end |
| 1103 | ret ok |
| 1104 | end |
| 1105 | |
| 1106 | fn wc_run_core_gate to int |
| 1107 | passed = long 0 |
| 1108 | if wg_t1_live_sense |
| 1109 | passed = add passed 1 |
| 1110 | end |
| 1111 | if wg_t2_trap14 |
| 1112 | passed = add passed 1 |
| 1113 | end |
| 1114 | if wg_t3_tgpu_spike |
| 1115 | passed = add passed 1 |
| 1116 | end |
| 1117 | if wg_t4_over_budget |
| 1118 | passed = add passed 1 |
| 1119 | end |
| 1120 | if wg_t5_invalid_refused |
| 1121 | passed = add passed 1 |
| 1122 | end |
| 1123 | if wg_t6_allocator |
| 1124 | passed = add passed 1 |
| 1125 | end |
| 1126 | if wg_t7_precool |
| 1127 | passed = add passed 1 |
| 1128 | end |
| 1129 | if wg_t8_closed_loop |
| 1130 | passed = add passed 1 |
| 1131 | end |
| 1132 | if wg_t9_live_pipeline |
| 1133 | passed = add passed 1 |
| 1134 | end |
| 1135 | if eq passed 9 |
| 1136 | wd_puts wg_m_sum_pass |
| 1137 | wd_put_i64 passed |
| 1138 | wd_puts wg_m_sum_of |
| 1139 | wd_put_i64 9 |
| 1140 | wd_puts wg_m_sum_tail |
| 1141 | wd_flush |
| 1142 | ret 0 |
| 1143 | end |
| 1144 | wd_puts wg_m_sum_fail |
| 1145 | wd_put_i64 passed |
| 1146 | wd_puts wg_m_sum_of |
| 1147 | wd_put_i64 9 |
| 1148 | wd_puts wg_m_sum_tail |
| 1149 | wd_flush |
| 1150 | ret 1 |
| 1151 | end |