nx_compute_opt2.nx
buildroot/runtime/nx_compute_opt2.nx
about
nx_compute_opt2.nx -- compute wall, step 2: stack the SAFE levers (cache locality + more cores).
The naive GEMM inner loop reads B[l*n+j] -- a COLUMN walk, stride n, a cache miss per access. Transpose
B once (Bt[j*k+l]=B[l*n+j]) so the inner loop reads CONTIGUOUSLY (stride 1) = the cache-blocking lever.
Then run that cache-friendly kernel across all cores (fork + shared mem). Both pure-NishiLang, no compiler
surgery. Measures naive-1-thread vs transposed-1-thread (the cache lever alone) vs transposed-multicore
(cache + cores), proves every variant is bit-identical, and reports the cumulative gap reduction toward
the silicon f32 peak. Sovereign: nx_f32_hw SSE + sys_fork/sys_mmap_shared/sys_wait4.
KAT: all variants bit-identical; transposed faster than naive; multicore faster still.
HONEST: cache + cores levers only; packed-SIMD (4-8x) + FMA (2x) still remain (compiler-side).
No hw writes (Rule 26). expect_exit: 0 license_tier: ORIGINAL
dependencies 2 imports · 0 importers
imports: nx_f32_hw.nxnx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 13 | const K_MAGIC_1842560: i64 = 1842560 |
functions
| 15 | func o2_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 16 | func o2_num(v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 } |
| 19 | func mm_naive(a: *i64, b: *i64, c: *i64, sz: i64) -> i64 called by 1: main |
| 25 | func mm_band_t(a: *i64, bt: *i64, c: *i64, sz: i64, w: i64, nw: i64) -> i64 called by 1: main |
| 33 | func main() -> i64 |