pub struct CachedBackend<T: 'static> { /* private fields */ }Expand description
Probe the CUDA backend for label and run a backend-specific build
step on the resolved handles.
This is probe_cuda_backend plus the one piece that genuinely
differs between backends: the NVRTC compile (and any per-backend cache
construction). The runtime resolution, context creation, and stream
selection — together with their uniform, label-attributed error
messages — live in the shared probe; build receives the resolved
CudaBackendParts (so it can clone the Arc<CudaContext> /
Arc<CudaStream> it needs) and returns the backend’s own state T.
A process-wide backend for one kernel family: the context and stream
from probe_cuda_backend plus whatever the family builds on top of
them (compiled modules, device limits), probed and built once and then
shared by every caller for the life of the process. A failed probe is
cached too, so a host without a usable device answers every later call
with the same refusal instead of re-probing.
Declare one per family as a static and read it through
CachedBackend::get_or_probe; five kernel families used to spell this
OnceLock<Result<_, GpuError>> protocol out by hand (#2470).
Implementations§
Source§impl<T: 'static> CachedBackend<T>
impl<T: 'static> CachedBackend<T>
pub const fn new() -> Self
Sourcepub fn get_or_probe<F>(
&'static self,
label: &'static str,
build: F,
) -> Result<&'static T, GpuError>
pub fn get_or_probe<F>( &'static self, label: &'static str, build: F, ) -> Result<&'static T, GpuError>
The shared backend, probing and building it on first use.
Trait Implementations§
Auto Trait Implementations§
impl<T> !Freeze for CachedBackend<T>
impl<T> RefUnwindSafe for CachedBackend<T>
impl<T> Send for CachedBackend<T>
impl<T> Sync for CachedBackend<T>
impl<T> Unpin for CachedBackend<T>
impl<T> UnsafeUnpin for CachedBackend<T>
impl<T> UnwindSafe for CachedBackend<T>
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> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
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