Skip to main content

Executor

Struct Executor 

Source
pub struct Executor<'a> { /* private fields */ }
Expand description

Runner of batches of one model, with its lane pools built once.

Implementations§

Source§

impl<'a> Executor<'a>

Source

pub fn new( entry: &'a ModelEntry, gpu: Option<&'a GpuContext>, measure: Arc<MeasurePlan>, layout: ExecutionLayout, control: SweepControl, ) -> Result<Self, ExecutionError>

Returns an executor for entry sampled as measure specifies, with a pool for each lane of layout.

A single lane gets its own pool as well, even a lane as wide as rayon’s global pool. Note that a target that cannot spawn threads builds no pool, and runs a CPU model in a single lane on the calling thread, whatever layout requests.

§Errors

Returns ExecutionError::NoDevice for a GPU model with no device in gpu, and ExecutionError::Pool when a lane’s pool cannot be built.

Source

pub fn with_timeout(self, timeout: Option<Duration>) -> Self

Returns the executor with each run abandoned once its stepping and sampling pass timeout.

The timeout is checked between slices of steps. A GPU run counts its share of the wall time since its build. The time spent visiting the tracks is split evenly between the live runs, and the time the batch spent paused is left out.

Source

pub fn with_active_runs(self, active_runs: Option<ActiveRuns>) -> Self

Returns the executor with each run listed in active_runs from its build to its end.

Source

pub fn with_gpu_memory_budget(self, budget: Option<u64>) -> Self

Returns the executor with a budget of budget bytes of device memory for the live GPU runs, as gpu_memory_budget interprets it.

A run is built once its demand fits the budget beside the demand of the live runs. A run larger than the budget is built once no other run is live, and runs alone.

Source

pub fn with_track_depth(self, depth: GpuTrackDepth) -> Self

Returns the executor with each GPU track keeping depth on the device.

§Panics

Panics when depth holds no command buffer or no step, or more steps than one submission can hold.

Source

pub fn layout(&self) -> ExecutionLayout

Layout the executor runs on, after Self::new adjusted it to the target.

Source

pub fn control(&self) -> &SweepControl

Control the executor reads between slices of steps.

Source

pub fn run_batch( &self, requests: &[RunRequest<'_>], sink: &mut dyn RunSink, ) -> Result<BatchEnd, ExecutionError>

Runs every request and commits each outcome to sink in request order.

Runs that finish early wait in memory until every earlier request is committed. Note that on wasm32 a pause panics on a thread that cannot wait, as SweepControl::proceed describes.

§Errors

Returns ExecutionError when a lane’s thread cannot start or panics outside a run, or sink rejects a run.

Trait Implementations§

Source§

impl<'a> Debug for Executor<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Executor<'a>

§

impl<'a> !UnwindSafe for Executor<'a>

§

impl<'a> Freeze for Executor<'a>

§

impl<'a> Send for Executor<'a>

§

impl<'a> Sync for Executor<'a>

§

impl<'a> Unpin for Executor<'a>

§

impl<'a> UnsafeUnpin for Executor<'a>

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

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WasmNotSync for T
where T: Sync,