kernels/kernels.rs
1//! Report which kernels this CPU can execute, and optionally assert that a
2//! named set of them is present.
3//!
4//! ```text
5//! cargo run --example kernels # just list them
6//! cargo run --example kernels -- avx2-vnni # list, and fail if absent
7//! ```
8//!
9//! The assertion form exists for CI. A test that pins a kernel the CPU cannot
10//! execute passes *vacuously*: dispatch ignores an impossible pin and scores on
11//! whatever it would have chosen anyway. Running this first turns that silent
12//! no-op into a failure.
13
14use maxsim_lut::{supported_kernels, warm_up};
15
16fn main() {
17 let available: Vec<String> = supported_kernels().iter().map(|k| k.to_string()).collect();
18
19 println!("kernels this CPU can execute: {}", available.join(", "));
20 println!("calibration chose: {}", warm_up());
21
22 let required: Vec<String> = std::env::args().skip(1).collect();
23 let missing: Vec<&String> = required.iter().filter(|r| !available.contains(r)).collect();
24
25 if !missing.is_empty() {
26 eprintln!(
27 "error: required kernel(s) not available here: {}",
28 missing.iter().map(|s| s.as_str()).collect::<Vec<_>>().join(", ")
29 );
30 std::process::exit(1);
31 }
32}