strided_perm/host.rs
1//! Host class and the serial copy rate of each class.
2//!
3//! The rates of the strided stack are keyed by the kernel dispatch the machine
4//! takes, not by the CPU model. [`HostClass`] is [`threadteam::HostClass`]
5//! re-exported, so the class this crate reports is the one the placement token
6//! uses; only the copy rate below is local (`strided-basic` reuses it for its own
7//! table, which sits above this crate).
8
9/// The class of the machine, keyed by the kernel dispatch it will take.
10///
11/// [`threadteam::HostClass`] re-exported, so the enum and its `detect` are the
12/// ones the placement token uses and cannot drift from them. The upstream doc
13/// below still names `strided-rs` among the crates that keep a hand-synced copy;
14/// this crate no longer does.
15///
16/// # Compatibility
17///
18/// This is a **type-identity change**, not a rename: `strided_perm::HostClass`
19/// is now the same type as `threadteam::HostClass` instead of a distinct copy.
20/// A downstream crate that implemented its own trait for both types compiles
21/// against the old pair and fails with `E0119` (conflicting implementations)
22/// against this one. Code that names the type, compares it, or matches on its
23/// variants is unaffected.
24pub use threadteam::HostClass;
25
26/// Serial throughput of a copy in nanoseconds per element, of a host class.
27///
28/// * `x86_64-avx512`: 0.171, the median of `seq` time per element of the strided
29/// `copy` probe at 16384, 32768 and 65536 elements (L2 resident; 0.171, 0.131,
30/// 0.201) on an AMD Ryzen AI 9 HX 470 at 2.0 GHz (boost off), `faer-benchmark`
31/// `data/probes/20261026-awake-team-linux/tables-confirm-exec3.md`.
32/// * `aarch64-apple`: 0.090, Apple M5 Max (thresholds.md section 3.2).
33/// * every other class: the `generic` row, the fastest known value (the minimum
34/// over the measured classes), which keeps work serial: 0.090.
35///
36/// A row's rates and the dispatch costs of the same class in `threadteam` come
37/// from the same machine in the same clock state (boost on or off moves both by
38/// about 1.66x and keeps their ratio within a few percent).
39pub const fn copy_ns_per_element_of(class: HostClass) -> f64 {
40 match class {
41 HostClass::X86_64Avx512 => 0.171,
42 HostClass::Aarch64Apple => 0.090,
43 HostClass::X86_64Avx2
44 | HostClass::X86_64Scalar
45 | HostClass::Aarch64
46 | HostClass::Generic => 0.090,
47 }
48}
49
50/// Serial throughput of a copy in nanoseconds per element on this host
51/// ([`copy_ns_per_element_of`] of [`HostClass::detect`]).
52///
53/// The `Copy` class of the strided stack (`strided_basic::execution::KernelClass`
54/// holds the class table; this crate sits below it and owns the one rate it
55/// needs). `copy_into*` multiply it by the element count and ask the token
56/// whether one section pays.
57pub fn copy_ns_per_element() -> f64 {
58 copy_ns_per_element_of(HostClass::detect())
59}
60
61#[cfg(test)]
62mod tests;