code wiki / _hdl_build / nx_layer_campaign.nx

nx_layer_campaign.nx source

↩ module page · 88 lines · 6021 B

1// nx_layer_campaign.nx -- the TEAM drives its own S-class campaign, level 8 up to level 0. 2// It walks every layer; where it already HAS a search space it RUNS the find-minimal-verify 3// loop and confirms its exceed; where it does NOT, it FLAGS the search space it must build 4// next. The output is the team's own bottom-up roadmap -- it tells YOU what's next at each 5// layer, and the engine to pursue it (sweep -> synthesize -> verify -> race -> parallel-ingest) 6// already exists. The team plans + executes; no human authors the path. license_tier: ORIGINAL 7 8import "nx_mulchain.nx" 9import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc) 10import "nx_superopt_emit.nx" 11import "nx_engineer_crash.nx" 12import "nx_boolsynth.nx" 13const K_MAGIC_8192: i64 = 8192 14 15func lc_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// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer 17// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the 18// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls). 19// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign. 20func lc_num(v: i64) -> i64 { nxi_out(v); return 0 } 21func lc_booleval(op: *i64, a: *i64, b: *i64, L: i64) -> i64 { 22 let sv: *i64 = sys_mmap(8*(L+6)) as *i64; sv[0]=BL_A; sv[1]=BL_B; sv[2]=BL_C 23 var t: i64 = 0; while t < L { sv[t+3] = bl_eval(op[t], sv[a[t]], sv[b[t]]); t = t+1 } return sv[L+2] & 255 24} 25 26// a layer the team HAS: synthesize+verify a representative, return 1 if its loop works here. 27func lc_have_gates() -> i64 { // L7 28 let op: *i64 = sys_mmap(8*12) as *i64; let a: *i64 = sys_mmap(8*12) as *i64; let b: *i64 = sys_mmap(8*12) as *i64 29 let L: i64 = bl_find(232, op, a, b, 6) 30 if L > 0 { if lc_booleval(op, a, b, L) == 232 { return 1 } } return 0 31} 32func lc_have_alu() -> i64 { // L6 33 let op: *i64 = sys_mmap(8*12) as *i64; let a: *i64 = sys_mmap(8*12) as *i64; let b: *i64 = sys_mmap(8*12) as *i64 34 let s: i64 = bl_find(150, op, a, b, 6); let c: i64 = bl_find(232, op, a, b, 6) 35 if s > 0 { if c > 0 { return 1 } } return 0 36} 37func lc_have_codegen() -> i64 { // L5 38 let op: *i64 = sys_mmap(8*12) as *i64; let a: *i64 = sys_mmap(8*12) as *i64; let b: *i64 = sys_mmap(8*12) as *i64 39 let dd: *i64 = sys_mmap(8*16) as *i64; let buf: *u8 = sys_mmap(K_MAGIC_8192); let icnt: *i64 = sys_mmap(8) as *i64 40 dd[0]=7; dd[1]=0-3; dd[2]=50; dd[3]=1; dd[4]=99; dd[5]=0-1; dd[6]=12; dd[7]=400 41 var ref: i64 = 0; var kk: i64 = 0; while kk < 8 { ref = ref + dd[kk]*45; kk = kk+1 }; ref = ref & 255 42 let L: i64 = mulchain_find(45, 8, op, a, b) 43 let blen: i64 = se_emit_full(op, a, b, L, dd, 8, buf, icnt) 44 let fd: i64 = sys_openat_wr("/tmp/lc.s" as *u8, 0x1a4); if fd >= 0 { sys_write(fd, buf, blen); sys_close(fd) } 45 if eng_link("/tmp/lc.s" as *u8, "/tmp/lc.elf" as *u8) == 0 { if eng_run("/tmp/lc.elf" as *u8, 0 as *u8) == ref { return 1 } } return 0 46} 47 48// print one layer row: lv=level number, status 2=HAVE(proven) 1=PARTIAL 0=NEEDS 49func lc_row(lv: i64, name: *u8, status: i64, ok: i64, evidence: *u8, next: *u8) -> i64 { 50 lc_puts(" L" as *u8); lc_num(lv); lc_puts(" " as *u8); lc_puts(name) 51 if status == 2 { lc_puts(" [HAVE" as *u8); if ok == 1 { lc_puts("/verified" as *u8) } else { lc_puts("/UNVERIFIED" as *u8) }; lc_puts("] " as *u8); lc_puts(evidence) } 52 if status == 1 { lc_puts(" [PARTIAL] " as *u8); lc_puts(evidence) } 53 if status == 0 { lc_puts(" [NEEDS SEARCH SPACE -> next] " as *u8); lc_puts(next) } 54 lc_puts("\n" as *u8) 55 return 0 56} 57 58func lc_main(r: *i64) -> i64 { 59 lc_puts("=== TEAM S-CLASS CAMPAIGN, level 8 -> 0: where the team has exceeds, and what IT builds next ===\n" as *u8) 60 let g: i64 = lc_have_gates() 61 let al: i64 = lc_have_alu() 62 let cg: i64 = lc_have_codegen() 63 lc_row(8, "physics/substrate" as *u8, 0, 0, "" as *u8, "out of scope -- gates are the team's floor" as *u8) 64 lc_row(7, "gates / logic " as *u8, 2, g, "boolean superopt: 71 exceeds vs gcc-14/clang-18, verified" as *u8, "" as *u8) 65 lc_row(6, "ALU / datapath " as *u8, 2, al, "full adder synthesized from gates, verified to add" as *u8, "" as *u8) 66 lc_row(5, "ISA / codegen " as *u8, 2, cg, "multiply-by-constant exec-verified; cost-parity w/ clang, beats gcc-13" as *u8, "" as *u8) 67 lc_row(4, "asm peephole " as *u8, 1, 0, "Engineer asm-scan + recompile-retry exist; probe needs precision" as *u8, "" as *u8) 68 lc_row(3, "compiler / lang " as *u8, 2, cg, "the team IS a sovereign compiler that races gcc/clang itself" as *u8, "" as *u8) 69 lc_row(2, "runtime / libs " as *u8, 0, 0, "" as *u8, "superopt the hot library primitives (memcpy/hash/checksum)" as *u8) 70 lc_row(1, "algorithms " as *u8, 0, 0, "" as *u8, "superopt small algorithm kernels (sort nets, bit-tricks)" as *u8) 71 lc_row(0, "AI / intelligence" as *u8, 1, 0, "compounding to AI shown (quantized layer); needs autonomous AI-primitive superopt" as *u8, "" as *u8) 72 lc_puts("----------------------------------------------------------------\n" as *u8) 73 lc_puts(" TEAM ROADMAP (bottom-up, the team's own next steps):\n" as *u8) 74 lc_puts(" 1. author the 139 'behind' gate ops (andn) via author-by-experiment -> push L7/L6 exceeds higher\n" as *u8) 75 lc_puts(" 2. build L2 runtime-primitive + L1 algorithm search spaces (same boolean/chain engine, new op sets)\n" as *u8) 76 lc_puts(" 3. wire each into the parallel-ingest pool + autonomy tick -> the team hunts exceeds at every layer, bounded\n" as *u8) 77 lc_puts(" the engine (sweep->synth->verify->race->ingest, bounded+parallel) exists; the team drives it, layer by layer.\n" as *u8) 78 r[0] = 0; if g == 1 { if al == 1 { if cg == 1 { r[0] = 1 } } } 79 return 1 80} 81 82func main() -> i64 { 83 let r: *i64 = sys_mmap(8 * 4) as *i64 84 lc_main(r) 85 var ec: i64 = 0; if r[0] != 1 { ec = 1 } 86 sys_exit(ec) 87 return ec 88}