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/validate.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 / validate.rs` 426 lines ยท 16461 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 //! Strict validation of one implementation run against the canonical result. 17 use super::exec::Executed; 18 use super::reference::{self, Diff}; 19 use super::REPORT_SCHEMA; 20 use serde_json::Value; 21 22 #[derive(Debug, Clone, PartialEq)] 23 pub struct Line { 24 pub label: String, 25 pub passes: u64, 26 pub elapsed_text: String, 27 pub elapsed: f64, 28 pub threads: u64, 29 pub algorithm: String, 30 pub faithful: String, 31 pub bits: u64, 32 } 33 34 #[derive(Debug, Clone, PartialEq)] 35 pub struct Tags { 36 pub algorithm: String, 37 pub faithful: String, 38 pub bits: u64, 39 pub threads: Option, 40 } 41 42 impl Tags { 43 /// "algorithm=base,faithful=yes,bits=1[,threads=1]" 44 pub fn parse(text: &str) -> Result { 45 let (mut a, mut f, mut b, mut t) = (None, None, None, None); 46 for kv in text.split(',') { 47 let (k, v) = kv.split_once('=').ok_or_else(|| format!("bad tag {kv}"))?; 48 match k { 49 "algorithm" => a = Some(v.to_string()), 50 "faithful" => f = Some(v.to_string()), 51 "bits" => b = Some(v.parse::().map_err(|_| format!("bad bits {v}"))?), 52 "threads" => t = Some(v.parse::().map_err(|_| format!("bad threads {v}"))?), 53 _ => return Err(format!("unknown tag {k}")), 54 } 55 } 56 Ok(Tags { 57 algorithm: a.ok_or("missing algorithm")?, 58 faithful: f.ok_or("missing faithful")?, 59 bits: b.ok_or("missing bits")?, 60 threads: t, 61 }) 62 } 63 } 64 65 #[derive(Debug, Clone)] 66 pub struct Expect { 67 /// Implementation name N: the stdout label must be `aien-N`, report impl must be N. 68 pub name: String, 69 pub limit: u64, 70 pub min_seconds: f64, 71 pub audit: Option, 72 pub tags: Tags, 73 } 74 75 impl Expect { 76 pub fn line_label(&self) -> String { 77 format!("aien-{}", self.name) 78 } 79 } 80 81 #[derive(Debug, Clone, PartialEq)] 82 pub enum Reject { 83 Spawn(String), 84 ExitCode(Option), 85 NoStdoutLine, 86 AuditStdoutLine, 87 MultipleStdoutLines(usize), 88 MalformedLine(String), 89 ReportMissing, 90 BadReport(String), 91 StatusNotComplete(String), 92 LabelMismatch(String), 93 LineReportMismatch(String), 94 PassesZero, 95 ElapsedBelowMin { elapsed: f64, min: f64 }, 96 /// The runner's own monotonic wall clock contradicts the implementation's report. 97 WallClockShort { wall: f64, elapsed: f64, min: f64 }, 98 AuditPassCount { got: u64, want: u32 }, 99 BitmapMissing, 100 BitmapLength { got: usize, want: usize }, 101 BitmapDiff(Diff), 102 AuditPassDiff { pass: usize, diff: Diff }, 103 } 104 105 impl Reject { 106 pub fn kind(&self) -> &'static str { 107 match self { 108 Reject::Spawn(_) => "spawn_error", 109 Reject::ExitCode(_) => "exit_code", 110 Reject::NoStdoutLine => "no_stdout_line", 111 Reject::AuditStdoutLine => "audit_stdout_line", 112 Reject::MultipleStdoutLines(_) => "multiple_stdout_lines", 113 Reject::MalformedLine(_) => "malformed_line", 114 Reject::ReportMissing => "report_missing", 115 Reject::BadReport(_) => "bad_report", 116 Reject::StatusNotComplete(_) => "status_not_complete", 117 Reject::LabelMismatch(_) => "label_mismatch", 118 Reject::LineReportMismatch(_) => "line_report_mismatch", 119 Reject::PassesZero => "passes_zero", 120 Reject::ElapsedBelowMin { .. } => "elapsed_below_min", 121 Reject::WallClockShort { .. } => "wall_clock_short", 122 Reject::AuditPassCount { .. } => "audit_pass_count", 123 Reject::BitmapMissing => "bitmap_missing", 124 Reject::BitmapLength { .. } => "bitmap_length", 125 Reject::BitmapDiff(_) => "bitmap_diff", 126 Reject::AuditPassDiff { .. } => "audit_pass_diff", 127 } 128 } 129 } 130 131 impl std::fmt::Display for Reject { 132 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 133 write!(f, "{}: ", self.kind())?; 134 match self { 135 Reject::Spawn(e) | Reject::MalformedLine(e) | Reject::BadReport(e) | Reject::LabelMismatch(e) 136 | Reject::LineReportMismatch(e) | Reject::StatusNotComplete(e) => write!(f, "{e}"), 137 Reject::ExitCode(c) => write!(f, "exit code {c:?}, expected 0"), 138 Reject::NoStdoutLine => write!(f, "no result line on stdout"), 139 Reject::AuditStdoutLine => write!(f, "audit mode printed a stdout line; audit runs make no timing claim"), 140 Reject::MultipleStdoutLines(n) => write!(f, "{n} lines on stdout, expected exactly one"), 141 Reject::ReportMissing => write!(f, "report file not written"), 142 Reject::PassesZero => write!(f, "passes is 0"), 143 Reject::ElapsedBelowMin { elapsed, min } => write!(f, "elapsed {elapsed} is below min_seconds {min}"), 144 Reject::WallClockShort { wall, elapsed, min } => { 145 write!(f, "runner wall time {wall} is below reported elapsed {elapsed} or min_seconds {min}") 146 } 147 Reject::AuditPassCount { got, want } => write!(f, "audit passes {got}, wanted {want}"), 148 Reject::BitmapMissing => write!(f, "bitmap file not written"), 149 Reject::BitmapLength { got, want } => write!(f, "bitmap is {got} bytes, expected {want}"), 150 Reject::BitmapDiff(d) => write!(f, "{d}"), 151 Reject::AuditPassDiff { pass, diff } => write!(f, "audit pass {pass}: {diff}"), 152 } 153 } 154 } 155 156 #[derive(Debug, Clone)] 157 pub struct Validated { 158 pub passes: u64, 159 pub elapsed: f64, 160 /// The upstream line; `None` in audit mode, which prints no line. 161 pub line: Option, 162 pub report: Value, 163 } 164 165 /// Strict parse of `