code wiki / _hdl_build / nx_engineer_profile.nx

nx_engineer_profile.nx source

↩ module page · 30 lines · 1785 B

1// nx_engineer_profile.nx -- the ENGINEER's bottleneck-diagnosis feature (RACI: the Engineer 2// MEASURES + VERIFIES; it does not fix or decide the trade-off -- it hands a verdict to the 3// Builder). Given a kernel's flops + bytes-moved and the chip's peak flops + bandwidth, the 4// Engineer diagnoses which constraint binds (the roofline read) and reports the LEVER CLASS the 5// Builder should reach for -- data-movement (memory-bound) or compute (compute-bound). This is 6// the team's "measure before you optimise", so no one polishes a memory-bound kernel's SIMD. 7// license_tier: ORIGINAL 8 9import "nx_roofline.nx" 10 11const ENG_LEVER_NONE: i64 = 0 // could not diagnose (invalid inputs) 12const ENG_LEVER_DATA: i64 = 1 // MEMORY-bound -> reduce bytes moved (quantize/sparsify/fuse) 13const ENG_LEVER_COMPUTE: i64 = 2 // COMPUTE-bound -> optimise the inner loop (the search governor) 14 15// the Engineer's measured verdict for a kernel (just the roofline bound -- a re-export under the 16// Engineer's name so the RACI is explicit: this organ owns the diagnosis). 17func eng_diagnose_kernel(flops: i64, bytes: i64, peak_flops: i64, peak_bw: i64) -> i64 { 18 return rf_bound(flops, bytes, peak_flops, peak_bw) 19} 20 21// from the bound, which class of lever the Builder should use. The Engineer recommends; the 22// Builder decides + acts. Unknown bound -> NONE (the Engineer refuses to guess on bad input). 23func eng_recommend_lever(bound: i64) -> i64 { 24 if bound == RF_MEMORY_BOUND { return ENG_LEVER_DATA } 25 if bound == RF_COMPUTE_BOUND { return ENG_LEVER_COMPUTE } 26 return ENG_LEVER_NONE 27} 28 29// the arithmetic intensity the Engineer measured (flop/byte x1000), for the journal/Scribe. 30func eng_kernel_ai_milli(flops: i64, bytes: i64) -> i64 { return rf_ai_milli(flops, bytes) }