pub struct KernelLoader<T: CompilationTarget> { /* private fields */ }Expand description
Every kernel a device has loaded, in front of the backend that compiles and loads the ones it has not.
A kernel it does not hold is read from the compilation store, or failing
that compiled and stored, then loaded — in that order on every backend, and
recorded the same way: what differs between backends is the
CompilationTarget it is generic over.
Kernels can also be queued and compiled together: the half of the work any thread can do then runs on as many threads as there are kernels, up to the configured parallelism, each taking the next kernel as it finishes one. However long the queue, it compiles in one phase that lasts about as long as its slowest kernel.
Implementations§
Source§impl<T: CompilationTarget> KernelLoader<T>
impl<T: CompilationTarget> KernelLoader<T>
Sourcepub fn new(target: T) -> Self
pub fn new(target: T) -> Self
A loader holding nothing yet, bound to the active environment exactly
when target persists what it compiles.
Sourcepub fn load(
&mut self,
kernel: &dyn CubeKernel,
id: &ArtifactId<VariantOf<T>>,
logger: &ServerLogger,
) -> Result<T::Loaded, LaunchError>
pub fn load( &mut self, kernel: &dyn CubeKernel, id: &ArtifactId<VariantOf<T>>, logger: &ServerLogger, ) -> Result<T::Loaded, LaunchError>
The kernel loaded for kernel, under id, loading it first if it is
not. A kernel is about to execute, so every queued kernel is compiled
first — together with this one when it needs compiling.
id is kernel’s, with what the launch adds to it: the launch already
built the kernel’s id, and building it again on every launch costs. A
kernel already loaded, with nothing queued, costs one lookup and a
clone of what was loaded; id is only cloned to compile.
§Errors
The validation, compilation or load of kernel that failed, now or
when it was queued. The failure is reported once and not kept, so the
next launch of the kernel tries again.
Sourcepub fn compile_queued(&mut self, logger: &ServerLogger)
pub fn compile_queued(&mut self, logger: &ServerLogger)
Compiles every queued kernel now, rather than inside the next
load, so the launch that follows pays for its own
kernel only. A queued kernel that fails reports it when it is launched.
Sourcepub fn enqueue(&mut self, kernel: Box<dyn CubeKernel>, variant: VariantOf<T>)
pub fn enqueue(&mut self, kernel: Box<dyn CubeKernel>, variant: VariantOf<T>)
Queues kernel under variant, to be compiled with the others when the
next kernel is loaded for a launch, and only then. One
already loaded or queued is left alone; one that failed is tried again,
its failure dropped.
The queue does not compile on its own when it grows: one phase over everything queued lasts about as long as its slowest kernel, where two phases would each wait on theirs.
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for KernelLoader<T>
impl<T> !UnwindSafe for KernelLoader<T>
impl<T> Freeze for KernelLoader<T>where
T: Freeze,
CompilationCache<ArtifactId<<<T as CompilationTarget>::Compiler as ArtifactCompiler>::Variant>, <T as CompilationTarget>::Loaded>: Freeze,
KernelQueue<<<T as CompilationTarget>::Compiler as ArtifactCompiler>::Variant>: Freeze,
HashMap<ArtifactId<<<T as CompilationTarget>::Compiler as ArtifactCompiler>::Variant>, LaunchError>: Freeze,
impl<T> Send for KernelLoader<T>where
T: Send,
CompilationCache<ArtifactId<<<T as CompilationTarget>::Compiler as ArtifactCompiler>::Variant>, <T as CompilationTarget>::Loaded>: Send,
KernelQueue<<<T as CompilationTarget>::Compiler as ArtifactCompiler>::Variant>: Send,
HashMap<ArtifactId<<<T as CompilationTarget>::Compiler as ArtifactCompiler>::Variant>, LaunchError>: Send,
impl<T> Sync for KernelLoader<T>where
T: Sync,
CompilationCache<ArtifactId<<<T as CompilationTarget>::Compiler as ArtifactCompiler>::Variant>, <T as CompilationTarget>::Loaded>: Sync,
KernelQueue<<<T as CompilationTarget>::Compiler as ArtifactCompiler>::Variant>: Sync,
HashMap<ArtifactId<<<T as CompilationTarget>::Compiler as ArtifactCompiler>::Variant>, LaunchError>: Sync,
impl<T> Unpin for KernelLoader<T>where
T: Unpin,
CompilationCache<ArtifactId<<<T as CompilationTarget>::Compiler as ArtifactCompiler>::Variant>, <T as CompilationTarget>::Loaded>: Unpin,
KernelQueue<<<T as CompilationTarget>::Compiler as ArtifactCompiler>::Variant>: Unpin,
HashMap<ArtifactId<<<T as CompilationTarget>::Compiler as ArtifactCompiler>::Variant>, LaunchError>: Unpin,
impl<T> UnsafeUnpin for KernelLoader<T>where
T: UnsafeUnpin,
CompilationCache<ArtifactId<<<T as CompilationTarget>::Compiler as ArtifactCompiler>::Variant>, <T as CompilationTarget>::Loaded>: UnsafeUnpin,
KernelQueue<<<T as CompilationTarget>::Compiler as ArtifactCompiler>::Variant>: UnsafeUnpin,
HashMap<ArtifactId<<<T as CompilationTarget>::Compiler as ArtifactCompiler>::Variant>, LaunchError>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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