code wiki / (root) / nx_par_pool.nx

nx_par_pool.nx

buildroot/runtime/nx_par_pool.nx

6792 B147 linesdepth 3pulls 5 transitivereach 0 importersview sourcekind tooltopic par
docsdependenciesstructsconstsfunctions

about

nx_par_pool.nx -- SOVEREIGN persistent worker POOL via PIPES (robust fix; busy-spin deadlocked on LICM, ledger #21). Forks PP_NW workers ONCE; dispatches MANY matmuls via per-worker go/done PIPES -- kernel- BLOCKING read/write (no busy-spin, no LICM hazard, no idle CPU burn). Data (A/B/C) in sys_mmap_shared (set up BEFORE fork). Dispatch = write 1 byte to a worker's go-pipe; the worker computes its fixed range then writes 1 byte to its done-pipe; shutdown = close the go-pipe (read returns 0 -> worker exits). Pure syscalls (pipe2/fork/read/write/close/wait4) -- NO libvulkan/CUDA/pthread. Proves: fork-once + blocking dispatch => N-core speedup that HOLDS across many calls without per-call fork. license_tier: ORIGINAL

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_itoa_lib.nx nx_f32.nx nx_f32_hw.nx nx_par_pool.nx

imports: nx_syscalls.nxnx_itoa_lib.nxnx_f32.nxnx_f32_hw.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap_shared sys_mmap f32_of sys_pipe2 pp_puts sys_write sys_now_ms sys_mmap ↻ sys_clock_gettime_mono pp_mm_range sys_fork sys_close pp_worker sys_mmap ↻ sys_read pp_mm_range ↻ sys_write ↻ sys_exit sys_write ↻ sys_read ↻ sys_wait4 pp_putn nxi_out nxi_fd sys_mmap ↻ ccz_cat_num sys_write ↻ sys_munmap

structs

none

consts

13const PP_M: i64 = 256
14const PP_K: i64 = 256
15const PP_N: i64 = 256
16const PP_NW: i64 = 8
17const PP_ITERS: i64 = 20

functions

19func pp_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 1: main calls 1: sys_write
24func pp_putn(v: i64) -> i64 { nxi_out(v); return 0 }
called by 1: main calls 1: nxi_out
26func pp_mm_range(A: *i64, B: *i64, C: *i64, K: i64, N: i64, lo: i64, hi: i64) -> i64
called by 2: pp_workermain
41func pp_worker(w: i64, go_rd: i64, done_wr: i64, A: *i64, B: *i64, C: *i64, M: i64, K: i64, N: i64) -> i64
57func main() -> i64