Skip to main content

SweepRun

Struct SweepRun 

Source
pub struct SweepRun { /* private fields */ }
Expand description

Handle on a running sweep or search.

Dropping the handle aborts the sweep. On native it then waits for the sweep’s thread to write its files.

Implementations§

Source§

impl SweepRun

Source

pub fn start( entry: ModelEntry, gpu: Option<GpuContext>, spec: SweepSpec, output: SweepOutput, options: SweepRunOptions, ) -> Result<Self, SweepStartError>

Plans spec against entry and starts the sweep, or the search when spec has a [search] table, writing its files to output.

gpu is a device the host shares with the sweep, its FaultSink included. Note that the sink holds one fault, and whichever side reads it first takes it. A fault that the sweep takes first ends every live run, whichever side raised it, and a fault that the host takes first leaves the runs going. When gpu is None, the sweep acquires a device on its own thread for a GPU model, sized to the entry’s gpu_needs, and builds entry on it. The manifest records the adapter of a shared device only when its context carries RuntimeInfo, as GpuContext::with_runtime_info attaches it.

Planning happens before this returns. The probe build and the runs happen after it, on native on the sweep’s own thread and in a browser in Self::update.

§Errors

Returns SweepStartError when spec specifies a different model, cannot be planned, or targets a GPU model in a browser, when output is a directory that holds results, or when the sweep’s thread cannot start. A device the sweep cannot acquire fails the sweep with a SweepEvent::Failed.

Source

pub fn resume_directory( entry: ModelEntry, gpu: Option<GpuContext>, dir: &Path, options: SweepRunOptions, ) -> Result<Self, SweepStartError>

Available on non-WebAssembly only.

Resumes the sweep whose results the directory dir holds, running only the runs it lacks.

The spec, source and shard come from the directory’s manifest, and the sweep runs as crate::sweep::run_spec resumes a sweep. Note that the execution settings come from options alone. The [execution] table the manifest records is not applied. gpu is the device a GPU model runs on, as in Self::start.

§Errors

Returns SweepStartError when another sweep, search or merge is writing to dir, the manifest or its spec cannot be read, the spec specifies a different model or cannot be planned, or the sweep’s thread cannot start. A directory whose runs do not fit the plan, or a device the sweep cannot acquire, fails the sweep with a SweepEvent::Failed.

Source

pub fn plan(&self) -> &Arc<Plan> ⓘ

Plan of the sweep’s configs and runs, or of a search’s fixed values and actions alone.

Source

pub fn search_plan(&self) -> Option<&Arc<SearchPlan>>

Plan of a search, None for a sweep.

A search’s configs are chosen as it runs. Each config arrives in a SweepEvent::SearchBatchTold, and SearchPlan::replay rebuilds any of its runs.

Source

pub fn pause(&mut self)

Holds every run at its next slice of steps.

Source

pub fn resume(&mut self)

Lets a paused sweep continue.

Source

pub fn abort(&mut self)

Ends the sweep at its next slice of steps, paused runs included. The runs written so far stay in its files.

Source

pub fn is_paused(&self) -> bool

Returns whether the sweep is paused.

Source

pub fn is_ended(&self) -> bool

Returns whether the last event, SweepEvent::Finished or SweepEvent::Failed, has been received.

Source

pub fn update(&mut self, _dt: f64)

Available on non-WebAssembly only.

Steps the sweep within a frame’s budget in a browser. On native the sweep runs on its own thread.

Source

pub fn try_recv(&mut self) -> Option<SweepEvent>

Returns the next event, or None when no event is waiting.

Source

pub fn progress(&self) -> SweepProgress

Returns the progress of the sweep as it stands.

Trait Implementations§

Source§

impl Debug for SweepRun

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for SweepRun

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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
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,