code wiki / (root) / nx_swarm_pack.nx

nx_swarm_pack.nx

buildroot/runtime/nx_swarm_pack.nx

21863 B451 linesdepth 4pulls 4 transitivereach 0 importersview sourcekind tooltopic swarm
docsdependenciesstructsconstsfunctions

about

nx_swarm_pack.nx -- SWARM FABRIC heterogeneous MAX-UTILIZATION scheduler (SF-R-PACK): get the MOST out of EVERY participant by exploiting ALL of its resources at once -- RAM, CPU cores, GPU, VRAM -- not routing a job to one class (operator 2026-07-15: "gpu was just an example ... use the ram cpu gpu whatever is available to get the most out of what participates in the supercomputer", the NIST/heterogeneous-compute model). A single participant can host MANY demands using DIFFERENT resources concurrently; work spreads to fill every participant's spare capacity. RESOURCE VECTOR (aligned to the beacon telemetry = the FEED): per participant pcpu = spare CPU milli-cores (beacon: (1000-lpc)*ncpu) · pram = free RAM MB (beacon mem_avail_mb) pgpu = GPU present 0/1 · pvram = free VRAM MB (the axis to wire from a GPU collector) DEMAND VECTOR: per chunk dcpu (milli-cores) · dram (MB) · dgpu (needs GPU 0/1) · dvram (MB) COMPOSES (check-before-build 2026-07-15): nx_resource_arbiter ALREADY models VRAM/RAM/CPU/GPU/net/disk as first-class allocatable kinds with fairness+preempt -- but is "fed by nothing". This packer IS that feed + the placement loop; the fairness/preempt/treaty LAYER wires to nx_resource_arbiter (nx_ra_request/grant) as the allocation policy SSOT. Hard-constraint classify = nx_swarm_coord. Telemetry = nx_node_beacon. ★★THE LIAR-KILLERS (the operator's principle, mechanized): (1) NO participant is ever over-allocated on ANY resource (sum assigned <= supply, per axis). (2) a demand is NEVER placed on a participant that lacks its REQUIRED resource -- a needs-GPU chunk never lands on a GPU-less node (GPU generalized to "whatever it requires"). (3) packing beats naive round-robin on placed-count (measured). (4) HETEROGENEOUS EXPLOITATION proven: one participant hosts DIFFERENT resource-type demands at once; no participant sits idle while a demand it could serve is queued. pack <poolfile> <jobsfile> -- pool line "name cpu_milli ram_mb gpu vram_mb"; job line "id cpu ram gpu vram" [gate] -- self-gate: the heterogeneous scenario + all four liar-killers license_tier: ORIGINAL expect_exit:0

dependencies 1 imports · 0 importers

nx_swarm_lib.nx nx_swarm_pack.nx

imports: nx_swarm_lib.nx

imported by: nobody (leaf or entry point)

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

main sk_puts fa_len sb_path_ok fa_len ↻ sk_live sk_load_pool sb_read sys_openat_rd sys_read sys_close sb_fields sys_mmap sb_validate sys_mmap ↻ sb_pint sb_pint ↻ sb_validate ↻ sk_roster_has fa_len ↻ sk_puts ↻ sk_load_jobs sb_read ↻ sk_skipsp sb_pint ↻ sk_pack sk_place_one sk_report fa_cat fa_catn sys_mmap ↻ fa_cat ↻ fa_catn ↻ sk_gate sk_pack ↻ sk_puts ↻ sk_report ↻ sk_types_on sk_naive fa_catn ↻

structs

none

consts

29const SK_MAGIC_8000: i64 = 8000
30const SK_MAGIC_16000: i64 = 16000
31const SK_MAGIC_12000: i64 = 12000
32const SK_MAGIC_3000: i64 = 3000
33const SK_MAGIC_32000: i64 = 32000
34const SK_MAGIC_4000: i64 = 4000
35const SK_MAGIC_5000: i64 = 5000
36const SK_MAGIC_20000: i64 = 20000
37const SK_MAGIC_2000: i64 = 2000
38const SK_MAGIC_65536: i64 = 65536
39const SK_MAGIC_8192: i64 = 8192
40const SK_MAGIC_1000000: i64 = 1000000
42const SK_MAXP: i64 = 256
43const SK_MAXD: i64 = 4096

functions

45func sk_puts(s: *u8) -> i64 { sys_write(1, s, fa_len(s)); return 0 }
called by 3: sk_gatesk_livemain calls 1: fa_len
51func sk_place_one(pcpu: *i64, pram: *i64, pgpu: *i64, pvram: *i64, n: i64, dcpu: i64, dram: i64, dgpu: i64, dvram: i64) -> i64
called by 1: sk_pack
79func sk_pack(pcpu: *i64, pram: *i64, pgpu: *i64, pvram: *i64, n: i64,
called by 2: sk_gatesk_live calls 1: sk_place_one
118func sk_naive(pcpu: *i64, pram: *i64, pgpu: *i64, pvram: *i64, n: i64,
called by 1: sk_gate
140func sk_report(names: *i64, pcpu0: *i64, pram0: *i64, pgpu: *i64, pcpu: *i64, pram: *i64, n: i64,
called by 2: sk_gatesk_live calls 2: fa_catfa_catn
170func sk_types_on(part: i64, dram: *i64, dgpu: *i64, m: i64, assign: *i64) -> i64
called by 1: sk_gate
184func sk_gate() -> i64
301func sk_skipsp(buf: *u8, n: i64, p: i64) -> i64
called by 1: sk_load_jobs
309func sk_roster_has(roster: *u8, name: *u8, nl: i64) -> i64
called by 1: sk_load_pool calls 1: fa_len
331func sk_load_pool(snap: *u8, roster: *u8, names: *i64, pcpu: *i64, pram: *i64, pgpu: *i64, pvram: *i64, maxn: i64) -> i64
375func sk_load_jobs(jobs: *u8, dcpu: *i64, dram: *i64, dgpu: *i64, dvram: *i64, maxm: i64) -> i64
called by 1: sk_live calls 3: sb_readsk_skipspsb_pint
400func sk_live(snap: *u8, jobs: *u8, roster: *u8) -> i64
437func main(argc: i64, argv: *i64) -> i64