Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/crates/allen-reflex-kernel/examples/host_route.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / crates / allen-reflex-kernel / examples / host_route.rs` 39 lines ยท 1922 bytes Raw Blame History 1 //! Host harness of the pi5-allen route stage (aienos#399): the same route card, the same 2 //! compiled-in pool, the same runner code and the same capabilities as the image (none: no Store, 3 //! no owner desk, no local model, no Spark link), so its `ALLEN_P` lines must equal the Pi's byte 4 //! for byte. 5 //! usage: cargo run --release --example host_route -- [caps, default 0] 6 //! stdout: the proposal lines (reflex, nearest, perceptron; card order). stderr: timings on this machine. 7 use allen_reflex::Mode; 8 use allen_reflex_kernel::{card, runner}; 9 use std::time::Instant; 10 11 fn main() { 12 let args: Vec = std::env::args().skip(1).collect(); 13 let path = args.first().expect("usage: host_route [caps]"); 14 let caps: u32 = args.get(1).map(|c| c.parse().expect("caps")).unwrap_or(0); 15 let buf = std::fs::read(path).unwrap_or_else(|e| panic!("{path}: {e}")); 16 let reqs = card::parse_route(&buf).unwrap_or_else(|e| panic!("{path}: refused ({e})")); 17 let mut line = String::new(); 18 for mode in [Mode::Reflex, Mode::Nearest, Mode::Perceptron] { 19 let sess = runner::Session::train(mode).expect("train"); 20 let mut ns = Vec::with_capacity(reqs.len()); 21 for (i, r) in reqs.iter().enumerate() { 22 let id = std::str::from_utf8(&buf[r.id.0..r.id.1]).unwrap(); 23 let turns = std::str::from_utf8(&buf[r.turns.0..r.turns.1]).unwrap(); 24 let t = Instant::now(); 25 let (json, _) = sess.propose_json(r, turns, i as u64 + 1, caps); 26 ns.push(t.elapsed().as_nanos()); 27 runner::route_line(&mut line, mode, id, &json); 28 println!("{line}"); 29 } 30 ns.sort_unstable(); 31 eprintln!( 32 "host {}: n={} p50_ns={} max_ns={} (this machine, not the Pi)", 33 mode.name(), 34 ns.len(), 35 ns[(ns.len() - 1) / 2], 36 ns[ns.len() - 1] 37 ); 38 } 39 }