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/benchmarks-mv/blob/main/prime-drag-race/src/main.rs # benchmarks-mv Measurement harnesses and evidence bundles for AIEN on the NVIDIA DGX Spark GB10. Speed is reported against the machine's physical limit and my own previous run. Attachment of AienOS. 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 `benchmarks-mv / prime-drag-race / src / main.rs` 151 lines ยท 5601 bytes Raw Blame History 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 use prime_race::runner::{reference_count, run, verify, ImplSpec, RunArgs}; 17 use prime_race::sweep::{default_sweep, parse_limits}; 18 use prime_race::validate::Tags; 19 use clap::{Parser, Subcommand}; 20 use std::collections::BTreeMap; 21 use std::path::PathBuf; 22 23 #[derive(Parser)] 24 #[command(name = "prime_race", about = "AIEN Prime Drag Race suite runner (contract version 1)")] 25 struct Cli { 26 #[command(subcommand)] 27 cmd: Cmd, 28 } 29 30 #[derive(Subcommand)] 31 enum Cmd { 32 /// Correctness sweep of one implementation. 33 Verify { 34 #[arg(long = "impl")] 35 imp: PathBuf, 36 #[arg(long)] 37 name: String, 38 /// Declared tags, e.g. algorithm=base,faithful=yes,bits=1,threads=1 39 #[arg(long)] 40 declare: String, 41 /// Comma list with a..b ranges. Default: the contract sweep. 42 #[arg(long)] 43 limits: Option, 44 #[arg(long, default_value_t = 3)] 45 audit_passes: u32, 46 }, 47 /// Trial protocol with receipt. 48 Run { 49 /// NAME=PATH, repeatable 50 #[arg(long = "impl", required = true)] 51 imps: Vec, 52 /// NAME=algorithm=..,faithful=..,bits=..[,threads=..], one per impl 53 #[arg(long = "declare", required = true)] 54 declares: Vec, 55 /// NAME=REPO@COMMIT, repeatable 56 #[arg(long = "source")] 57 sources: Vec, 58 /// NAME=build command and flags, repeatable 59 #[arg(long = "build")] 60 builds: Vec, 61 #[arg(long, default_value_t = 10)] 62 trials: u32, 63 #[arg(long, default_value_t = 1)] 64 warmup: u32, 65 #[arg(long, default_value_t = 1_000_000)] 66 limit: u64, 67 #[arg(long, default_value_t = 5.0)] 68 min_seconds: f64, 69 #[arg(long, default_value_t = 5)] 70 audit_passes: u32, 71 #[arg(long)] 72 evidence_dir: PathBuf, 73 #[arg(long)] 74 runner_commit: Option, 75 #[arg(long)] 76 quiet_flag_file: Option, 77 }, 78 } 79 80 fn kv(s: &str) -> Result<(String, String), String> { 81 s.split_once('=').map(|(a, b)| (a.to_string(), b.to_string())).ok_or_else(|| format!("expected NAME=VALUE, got {s}")) 82 } 83 84 fn main() { 85 let code = match real_main() { 86 Ok(c) => c, 87 Err(e) => { 88 eprintln!("error: {e}"); 89 64 90 } 91 }; 92 std::process::exit(code); 93 } 94 95 fn real_main() -> Result { 96 let argv: Vec = std::env::args().collect(); 97 match Cli::parse().cmd { 98 Cmd::Verify { imp, name, declare, limits, audit_passes } => { 99 let limits = match limits { 100 Some(t) => parse_limits(&t)?, 101 None => default_sweep(), 102 }; 103 let spec = ImplSpec { name, path: imp, tags: Tags::parse(&declare)? }; 104 let out = verify(&spec, &limits, audit_passes); 105 println!( 106 "verify {}: {} limits, audit passes {}, {} failures{}", 107 spec.name, 108 out.checked, 109 audit_passes, 110 out.failures.len(), 111 if out.failures.is_empty() { " -> PASS" } else { " -> FAIL" } 112 ); 113 if let Some(l) = limits.iter().find(|&&l| l == 1_000_000) { 114 println!("reference pi({l}) = {}", reference_count(*l)); 115 } 116 Ok(if out.failures.is_empty() { 0 } else { 1 }) 117 } 118 Cmd::Run { imps, declares, sources, builds, trials, warmup, limit, min_seconds, audit_passes, evidence_dir, runner_commit, quiet_flag_file } => { 119 let decl: BTreeMap = declares.iter().map(|s| kv(s)).collect::>()?; 120 let mut specs = vec![]; 121 for s in &imps { 122 let (name, path) = kv(s)?; 123 let tags = Tags::parse(decl.get(&name).ok_or(format!("no --declare for {name}"))?)?; 124 specs.push(ImplSpec { name, path: path.into(), tags }); 125 } 126 let home = std::env::var("HOME").unwrap_or_default(); 127 let args = RunArgs { 128 impls: specs, 129 trials, 130 warmup, 131 limit, 132 min_seconds, 133 audit_passes, 134 evidence_dir, 135 sources: sources.iter().map(|s| kv(s)).collect::>()?, 136 builds: builds.iter().map(|s| kv(s)).collect::>()?, 137 runner_commit, 138 quiet_file: quiet_flag_file.unwrap_or_else(|| PathBuf::from(home).join("workspace/.spark-quiet")), 139 argv, 140 }; 141 let r = run(&args)?; 142 for l in &r.upstream_lines { 143 println!("{l}"); 144 } 145 println!("\n{}", r.summary); 146 println!("verdict: {}", if r.pass { "PASS" } else { "FAIL" }); 147 println!("receipt: {} (sha256 {})", r.receipt_path.display(), r.receipt_sha); 148 Ok(if r.pass { 0 } else { 1 }) 149 } 150 } 151 }