nx_swarm_pack_units_t70.nx
buildroot/runtime/nx_swarm_pack_units_t70.nx
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 3 imports · 1 importers
imports: nx_swarm_lib.nxnx_swarm_gpu.nxnx_readcap_lib.nx
imported by: nx_swarm_pack_units_gate_t70.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 31 | const SK_MAGIC_8000: i64 = 8000 |
| 32 | const SK_MAGIC_16000: i64 = 16000 |
| 33 | const SK_MAGIC_12000: i64 = 12000 |
| 34 | const SK_MAGIC_3000: i64 = 3000 |
| 35 | const SK_MAGIC_32000: i64 = 32000 |
| 36 | const SK_MAGIC_4000: i64 = 4000 |
| 37 | const SK_MAGIC_5000: i64 = 5000 |
| 38 | const SK_MAGIC_20000: i64 = 20000 |
| 39 | const SK_MAGIC_2000: i64 = 2000 |
| 40 | const SK_MAGIC_65536: i64 = 65536 |
| 41 | const SK_MAGIC_8192: i64 = 8192 |
| 42 | const SK_MAGIC_1000000: i64 = 1000000 |
| 44 | const SK_MAXP: i64 = 256 |
| 45 | const SK_MAXD: i64 = 4096 |
| 440 | const SK2_VERSION:i64=2 |
| 441 | const SK2_FIELDS:i64=10 |
| 442 | const SK2_NAME:i64=32 |
| 443 | const SK2_MAX:i64=9223372036854775807 |
| 444 | const SK2_UNIT:i64=1000000 |
| 445 | const SK2_UNKNOWN:i64=0 |
| 446 | const SK2_FRESH:i64=1 |
| 447 | const SK2_STALE:i64=2 |
| 448 | const SK2_REFUSED:i64=3 |
| 449 | const SK2_IO:i64=0-40 |
| 450 | const SK2_TRUNCATED:i64=0-41 |
| 451 | const SK2_FRAME:i64=0-42 |
| 452 | const SK2_ROW:i64=0-43 |
| 453 | const SK2_DUPLICATE:i64=0-44 |
| 454 | const SK2_CAPACITY:i64=0-45 |
| 455 | const SK2_POLICY:i64=0-46 |
| 456 | const SK2_MISSING:i64=0-47 |
functions
| 47 | func sk_puts(s: *u8) -> i64 { sys_write(1, s, fa_len(s)); return 0 } |
| 53 | func 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 |
| 81 | func sk_pack(pcpu: *i64, pram: *i64, pgpu: *i64, pvram: *i64, n: i64, |
| 120 | func sk_naive(pcpu: *i64, pram: *i64, pgpu: *i64, pvram: *i64, n: i64, called by 1: sk_gate |
| 142 | func sk_report(names: *i64, pcpu0: *i64, pram0: *i64, pgpu: *i64, pcpu: *i64, pram: *i64, n: i64, |
| 172 | func sk_types_on(part: i64, dram: *i64, dgpu: *i64, m: i64, assign: *i64) -> i64 called by 1: sk_gate |
| 186 | func sk_gate() -> i64 |
| 303 | func sk_skipsp(buf: *u8, n: i64, p: i64) -> i64 called by 1: sk_load_jobs |
| 311 | func sk_roster_has(roster: *u8, name: *u8, nl: i64) -> i64 called by 1: sk_load_pool |
| 333 | func sk_load_pool(snap: *u8, roster: *u8, names: *i64, pcpu: *i64, pram: *i64, pgpu: *i64, pvram: *i64, maxn: i64) -> i64 |
| 377 | func sk_load_jobs(jobs: *u8, dcpu: *i64, dram: *i64, dgpu: *i64, dvram: *i64, maxm: i64) -> i64 |
| 402 | func sk_live(snap: *u8, jobs: *u8, roster: *u8) -> i64 |
| 458 | func sk2_int(b:*u8,n:i64,p:i64,out:*i64)->i64 |
| 465 | func sk2_row(b:*u8,n:i64,prefix:*u8,numbers:i64,values:*i64,name:*i64)->i64 |
| 475 | func sk2_read(path:*u8,b:*u8)->i64 |
| 481 | func sk2_fresh(ts:i64,now:i64,window:i64,skew:i64)->i64 called by 1: sk2_pool |
| 485 | func sk2_name_equal(a:*u8,b:*u8,n:i64)->i64{var i:i64=0;while i<n{if a[i]!=b[i]{return 0};i=i+1};if a[n]!=(0 as u8){return 0};return 1} called by 1: sk2_pool |
| 486 | func sk2_copyname(b:*u8,start:i64,n:i64)->*u8{let p:*u8=sys_mmap(SK2_NAME+1);var i:i64=0;while i<n{p[i]=b[start+i];i=i+1};p[n]=0 as u8;return p} called by 1: sk2_pool |
| 489 | func sk2_pool(nodes:*u8,gpus:*u8,now:i64,nwin:i64,gwin:i64,skew:i64,out:*i64,cap:i64,meta:*i64)->i64 called by 3: kg_casemainsk2_live calls 8: sk2_readsk2_rowsb_fieldssk2_name_equalsk2_copynamesk2_fresh+2 |
| 529 | func sk2_state(v:i64)->*u8{if v==SK2_FRESH{return "fresh" as *u8};if v==SK2_STALE{return "stale" as *u8};if v==SK2_REFUSED{return "refused" as *u8};return "unknown" as *u8} called by 1: sk2_live |
| 530 | func sk2_jobs(path:*u8,cpu:*i64,ram:*i64,gpu:*i64,vram:*i64,cap:i64)->i64 |
| 539 | func sk2_live(nodes:*u8,gpus:*u8,jobs:*u8,now:i64,nwin:i64,gwin:i64,skew:i64)->i64 |
| 557 | func main(argc: i64, argv: *i64) -> i64 |