code wiki / _hdl_build / nx_research_strassen4_gate.nx
nx_research_strassen4_gate.nx
buildroot/runtime/_hdl_build/nx_research_strassen4_gate.nx
about
nx_research_strassen4_gate.nx -- from REPRODUCTION toward DISCOVERY: show WHY finding low-multiplication
schemes matters. Strassen's 2x2 saving (7 mults instead of 8) COMPOUNDS recursively: a 4x4 product done by
block-Strassen (2x2 blocks of 2x2 blocks) costs 7x7 = 49 scalar multiplications instead of the naive 4^3 = 64.
The TESTING-TEAM runs both, proves block-Strassen == naive bit-exact (independent KAT A*I=A and I*B=B, plus
random matrices), COUNTS the multiplications (49 vs 64 = the compounding payoff), and the VERIFIER liar-kill
rejects a deliberately-broken recursive scheme. This is the substrate an alphatensor-class search rides on:
a candidate scheme is only "discovered" once this exact-comparison gate certifies it. Exact integer, no float,
deterministic. GREEN iff 6/6. license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_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
| none |
functions
| 11 | func g_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 12 | func g_n(v: i64) -> i64 { var m: i64=v; if m<0{g_w("-");m=0-m} let t:*u8=sys_mmap(24); 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; let o:*u8=sys_mmap(24); while i<k{o[i]=t[k-1-i];i=i+1}; sys_write(1,o,k); return 0 } |
| 13 | func g_row(id: *u8, ok: i64, pass: *i64) -> i64 { g_w(" "); g_w(id); g_w(": "); if ok==1 { g_w("OK\n"); pass[0]=pass[0]+1 } else { g_w("FAIL\n") } return 0 } |
| 15 | func rs_mul(cnt: *i64, a: i64, b: i64) -> i64 { cnt[0] = cnt[0] + 1; return a * b } |
| 16 | func rs_rng(state: *i64) -> i64 { var x: i64 = state[0]; x = x ^ (x << 13); x = x ^ (x >> 7); x = x ^ (x << 17); state[0] = x; return x } called by 1: main |
| 19 | func bl_add(x: *i64, y: *i64, o: *i64) -> i64 { o[0]=x[0]+y[0]; o[1]=x[1]+y[1]; o[2]=x[2]+y[2]; o[3]=x[3]+y[3]; return 0 } called by 1: mm4_strassen |
| 20 | func bl_sub(x: *i64, y: *i64, o: *i64) -> i64 { o[0]=x[0]-y[0]; o[1]=x[1]-y[1]; o[2]=x[2]-y[2]; o[3]=x[3]-y[3]; return 0 } called by 1: mm4_strassen |
| 22 | func bl_strassen(x: *i64, y: *i64, o: *i64, cnt: *i64) -> i64 |
| 35 | func blk(sc: *i64, i: i64) -> *i64 { return ((sc as i64) + i*32) as *i64 } called by 1: mm4_strassen |
| 37 | func get_block(m16: *i64, br: i64, bc: i64, out: *i64) -> i64 called by 1: mm4_strassen |
| 41 | func set_block(m16: *i64, br: i64, bc: i64, b: *i64) -> i64 called by 1: mm4_strassen |
| 47 | func mm4_naive(a: *i64, b: *i64, c: *i64, cnt: *i64) -> i64 |
| 53 | func mm4_strassen(a: *i64, b: *i64, c: *i64, cnt: *i64, sc: *i64, bad: i64) -> i64 |
| 77 | func eq16(x: *i64, y: *i64) -> i64 { var i: i64=0; while i<16 { if x[i]!=y[i]{return 0} i=i+1 } return 1 } called by 1: main |
| 79 | func main() -> i64 |