code wiki / _hdl_build / nx_cost_oracle.nx
nx_cost_oracle.nx
buildroot/runtime/_hdl_build/nx_cost_oracle.nx
about
nx_cost_oracle.nx -- bits-up DETERMINISTIC measurement for fair performance head-to-heads (operator:
"avoid the pitfalls of emulators and all the other stuff"). The emulator/timing pitfall: wall-clock
and emulated cycle counts are NON-deterministic (vary by machine, emulator, cache, frequency scaling),
so judging speed by time is BIASED -- the same two programs can flip winners across runs. The fix,
from the hardware up: judge by a COUNTED INVARIANT that is identical every run -- retired instruction
count, gate-toggle (switching) activity, or bytes moved. The cost oracle REFUSES to render a verdict
on a non-deterministic metric. This is the performance arm of the Referee's DETERMINISM gate.
license_tier: ORIGINAL Pairs with nx_referee (fair judging) + nx_gate_energy (toggles) + nx_uops_cost.
dependencies 1 imports · 2 importers
imports: nx_syscalls.nx
imported by: nx_boolsynth4.nxnx_cost_oracle_test.nx
structs
| none |
consts
| 12 | const CO_WALLCLOCK: i64 = 0 // wall-clock / emulated time -- NON-deterministic -> UNFAIR to judge on |
| 13 | const CO_INSN: i64 = 1 // retired instruction count -- deterministic |
| 14 | const CO_TOGGLES: i64 = 2 // gate switching activity -- deterministic, hardware-portable |
| 15 | const CO_BYTES: i64 = 3 // memory bytes moved -- deterministic |
| 17 | const CO_REJECT: i64 = 0 - 1 // refuse to judge (non-deterministic metric) |
| 18 | const CO_TIE: i64 = 0 |
| 19 | const CO_A_FASTER: i64 = 1 |
| 20 | const CO_B_FASTER: i64 = 2 |
functions
| 23 | func co_metric_deterministic(kind: i64) -> i64 { if kind == CO_WALLCLOCK { return 0 } return 1 } |
| 26 | func co_reproducible(samples: *i64, n: i64) -> i64 called by 1: main |
| 33 | func co_abs(x: i64) -> i64 { if x < 0 { return 0 - x } return x } called by 1: co_fair_verdict |
| 36 | func co_fair_verdict(kind: i64, cost_a: i64, cost_b: i64, margin: i64) -> i64 |
| 44 | func co_wallclock_flips(a_samples: *i64, b_samples: *i64, n: i64) -> i64 called by 1: main |