Skip to main content

CpuBatchThresholds

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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§item_overhead_ns: f64

Estimated fixed cost of one item, in nanoseconds.

The default is zero so that Default reproduces the packed ns_per_flop() estimate.

§muladds_per_ns: f64

Estimated 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: f64

Least estimated work a lane must receive, in nanoseconds; 0 disables the work gate (the packed default).

§min_items: usize

Fewest items for which Auto fans out at all.

§min_items_per_lane: usize

Fewest items each lane must receive.

Implementations§

§

impl 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

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

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

Return this model with a different minimum fan-out item count.

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 Clone for WorkModel

§

fn clone(&self) -> WorkModel

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Copy for WorkModel

§

impl Debug for WorkModel

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Default for WorkModel

§

fn default() -> WorkModel

Returns the “default value” for a type. Read more
§

impl PartialEq for WorkModel

§

fn eq(&self, other: &WorkModel) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
§

impl StructuralPartialEq for WorkModel

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Boilerplate for T
where T: Copy + Send + Sync + Debug + PartialEq + 'static,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.