code wiki / _hdl_build / nx_clbg_fannkuch.nx

nx_clbg_fannkuch.nx

buildroot/runtime/_hdl_build/nx_clbg_fannkuch.nx

5292 B150 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_clbg_fannkuch.nx -- struct-free, pure-integer fannkuch-redux(N). Canonical Computer Language Benchmarks Game integer hot loop. Enumerates all N! permutations of {0..N-1} via the "rotations" odometer (NOT lexicographic), reversing the perm[0]+1 prefix until perm[0]==0 (counting flips) for each. Outputs (written into a caller-owned 2-slot i64 buffer): out[0] = checksum (sum of flips with alternating sign +,-,+,- in gen order) out[1] = maxflips (max flip count over all permutations) Golden (verified vs gcc -O2 C ref, 2026-06-13): N=7 -> checksum 228 maxflips 16 N=10 -> checksum 73196 maxflips 38 (X-PERF-003a fixed N) N=11 -> checksum 556355 maxflips 51 Sovereign-compiled (nx_cc_sovereign -> nxasm_x86_main, NO gcc); this is the runtime measured by _xperf003a_gate. spec: knowledge/specs/2026-06-13-clbg-fannkuch-throughput.md genealogy_id: clbg_fannkuch_redux lineage_id: function

dependencies 2 imports · 0 importers

nx_clock.nx nx_itoa_lib.nx nx_clbg_fannkuch.nx

imports: nx_clock.nxnx_itoa_lib.nx

imported by: nobody (leaf or entry point)

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

main nx_clock_monotonic_ns sys_mmap sys_clock_gettime_mono fannkuch_redux fk_puts fk_putn nxi_out nxi_fd sys_mmap ↻ ccz_cat_num sys_write sys_munmap

structs

none

consts

24const FK_MAXN: i64 = 32 // perm arrays sized for N up to 32 (golden uses 10)
25const FK_INTSZ: i64 = 8 // i64 per array slot
26const FK_DEFAULT_N: i64 = 10 // X-PERF-003a fixed N (golden checksum 73196 / maxflips 38)
27const FK_REPEAT: i64 = 5 // run the enumeration this many times -> stable timing floor

functions

32func fannkuch_redux(n: i64, out: *i64) -> i64
called by 1: main
119func fk_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
124func fk_putn(v: i64) -> i64 { nxi_out(v); return 0 }
called by 1: main calls 1: nxi_out
126func main() -> i64