Struct CpuBatchThresholds
#[non_exhaustive]pub struct CpuBatchThresholds {
pub item_overhead_ns: f64,
pub muladds_per_ns: f64,
pub min_work_per_lane_ns: f64,
pub min_items: usize,
pub min_items_per_lane: usize,
}Expand description
The cost and fan-out model CpuBatchStrategy::Auto applies.
This is tcontract_exec::WorkModel; the old vendor-dimension cutoff is not
part of it.
§Examples
use tenferro_cpu::CpuBatchThresholds;
assert_eq!(CpuBatchThresholds::default().min_items, 2);The cost and fan-out model BatchStrategy::Auto applies.
The item rate is the serial GEMM throughput of the host class (host::muladds_per_ns: 27
multiply-adds per nanosecond on aarch64-apple and the generic row, 15.6 on x86_64-avx512;
see crates/tcontract-exec/src/host.rs and docs/design/thresholds.md of threadteam-rs);
the width a team pays for comes from the token, not from this model.
The three item-cost fields follow tenferro’s restored
CpuBatchThresholds: one item costs roughly item_overhead_ns plus one
nanosecond per muladds_per_ns multiply-adds, a lane needs
min_work_per_lane_ns of estimated work, and a fan-out needs min_items
items, at least min_items_per_lane per lane.
§Examples
use tcontract_exec::batch::WorkModel;
let model = WorkModel::default().with_min_items(4).with_muladds_per_ns(32.0);
assert_eq!(model.min_items, 4);
assert_eq!(model.muladds_per_ns, 32.0);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.item_overhead_ns: f64Estimated fixed cost of one item, in nanoseconds.
The default is zero so that Default reproduces the packed
ns_per_flop() estimate.
muladds_per_ns: f64Estimated multiply-adds per nanosecond on one lane.
1.0 / ns_per_flop() / 2.0 (27 on aarch64-apple and the
generic row, 15.6 on x86_64-avx512) reproduces
2 * macs * ns_per_flop(): the packed driver counts two flops per
multiply-add. A value <= 0 is treated as one multiply-add per
nanosecond.
min_work_per_lane_ns: f64Least estimated work a lane must receive, in nanoseconds; 0 disables
the work gate (the packed default).
min_items: usizeFewest items for which Auto fans out at all.
min_items_per_lane: usizeFewest items each lane must receive.
Implementations§
§impl WorkModel
impl WorkModel
pub fn with_item_overhead_ns(self, nanoseconds: f64) -> WorkModel
pub fn with_item_overhead_ns(self, nanoseconds: f64) -> WorkModel
Return this model with a different per-item overhead.
pub fn with_muladds_per_ns(self, muladds_per_ns: f64) -> WorkModel
pub fn with_muladds_per_ns(self, muladds_per_ns: f64) -> WorkModel
Return this model with a different lane throughput.
§Examples
use tcontract_exec::batch::WorkModel;
assert_eq!(WorkModel::default().with_muladds_per_ns(16.0).muladds_per_ns, 16.0);pub fn with_min_work_per_lane_ns(self, nanoseconds: f64) -> WorkModel
pub fn with_min_work_per_lane_ns(self, nanoseconds: f64) -> WorkModel
Return this model with a different minimum work per lane.
§Examples
use tcontract_exec::batch::WorkModel;
assert_eq!(WorkModel::default().with_min_work_per_lane_ns(8_000.0).min_work_per_lane_ns, 8_000.0);pub fn with_min_items(self, items: usize) -> WorkModel
pub fn with_min_items(self, items: usize) -> WorkModel
Return this model with a different minimum fan-out item count.
pub fn with_min_items_per_lane(self, items: usize) -> WorkModel
pub fn with_min_items_per_lane(self, items: usize) -> WorkModel
Return this model with a different minimum item count per lane.
Trait Implementations§
impl Copy for WorkModel
impl StructuralPartialEq for WorkModel
Auto Trait Implementations§
impl Freeze for WorkModel
impl RefUnwindSafe for WorkModel
impl Send for WorkModel
impl Sync for WorkModel
impl Unpin for WorkModel
impl UnsafeUnpin for WorkModel
impl UnwindSafe for WorkModel
Blanket Implementations§
impl<T> Boilerplate for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more