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>
impl<'a> Executor<'a>
Sourcepub fn new(
entry: &'a ModelEntry,
gpu: Option<&'a GpuContext>,
measure: Arc<MeasurePlan>,
layout: ExecutionLayout,
control: SweepControl,
) -> Result<Self, ExecutionError>
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.
Sourcepub fn with_timeout(self, timeout: Option<Duration>) -> Self
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.
Sourcepub fn with_active_runs(self, active_runs: Option<ActiveRuns>) -> Self
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.
Sourcepub fn with_gpu_memory_budget(self, budget: Option<u64>) -> Self
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.
Sourcepub fn with_track_depth(self, depth: GpuTrackDepth) -> Self
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.
Sourcepub fn layout(&self) -> ExecutionLayout
pub fn layout(&self) -> ExecutionLayout
Layout the executor runs on, after Self::new adjusted it to the target.
Sourcepub fn control(&self) -> &SweepControl
pub fn control(&self) -> &SweepControl
Control the executor reads between slices of steps.
Sourcepub fn run_batch(
&self,
requests: &[RunRequest<'_>],
sink: &mut dyn RunSink,
) -> Result<BatchEnd, ExecutionError>
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§
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> 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> 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