#[non_exhaustive]pub struct WorkModel {
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,
pub width: WidthPolicy,
}Expand description
The cost and fan-out model BatchStrategy::Auto applies.
The defaults are the values tcontract used before this vocabulary existed,
not a tuned result: they reproduce the packed decision together with the
existing WidthPolicy. The shared, swept defaults are a later step.
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 exactly.
muladds_per_ns: f64Estimated multiply-adds per nanosecond on one lane.
1.0 / NS_PER_FLOP / 2.0 == 10.0 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.
width: WidthPolicyTeam-width cost model, used to narrow the budget over the whole batch.
Implementations§
Source§impl WorkModel
impl WorkModel
Sourcepub fn with_item_overhead_ns(self, nanoseconds: f64) -> Self
pub fn with_item_overhead_ns(self, nanoseconds: f64) -> Self
Return this model with a different per-item overhead.
Sourcepub fn with_muladds_per_ns(self, muladds_per_ns: f64) -> Self
pub fn with_muladds_per_ns(self, muladds_per_ns: f64) -> Self
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);Sourcepub fn with_min_work_per_lane_ns(self, nanoseconds: f64) -> Self
pub fn with_min_work_per_lane_ns(self, nanoseconds: f64) -> Self
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);Sourcepub fn with_min_items(self, items: usize) -> Self
pub fn with_min_items(self, items: usize) -> Self
Return this model with a different minimum fan-out item count.
Sourcepub fn with_min_items_per_lane(self, items: usize) -> Self
pub fn with_min_items_per_lane(self, items: usize) -> Self
Return this model with a different minimum item count per lane.
Sourcepub fn with_width(self, width: WidthPolicy) -> Self
pub fn with_width(self, width: WidthPolicy) -> Self
Return this model with a different team-width cost model.
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§
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,
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