pub struct KernelRegistry { /* private fields */ }Expand description
Instance-scoped kernel registry.
Implementations§
Source§impl KernelRegistry
impl KernelRegistry
Sourcepub fn register(&self, entry: KernelEntry) -> Result<KernelId, AbiError>
pub fn register(&self, entry: KernelEntry) -> Result<KernelId, AbiError>
Register a new kernel and return its assigned KernelId.
Returns AbiError::QuotaExceeded if either the per-instance kernel
count cap (MAX_KERNELS_PER_INSTANCE) or the aggregate PTX-bytes
cap (MAX_TOTAL_PTX_BYTES) would be exceeded.
Sourcepub fn lookup(
&self,
id: KernelId,
owner: InstanceId,
) -> Result<KernelHandle, AbiError>
pub fn lookup( &self, id: KernelId, owner: InstanceId, ) -> Result<KernelHandle, AbiError>
Look up a kernel by id and return an independent handle.
Returns Err(AbiError::InvalidKernel) if the id is unknown or belongs
to a different instance. The returned KernelHandle holds an
Arc<Module> on CUDA builds, so callers may drop any borrowed
dashmap entry before performing the launch — eliminating the UAF
that the previous dashmap::Ref-derived raw-pointer scheme had.
Sourcepub fn remove(&self, id: KernelId) -> Option<KernelEntry>
pub fn remove(&self, id: KernelId) -> Option<KernelEntry>
Remove a kernel from the registry (caller releases its handle).
On CUDA builds the underlying cust::module::Module is held inside
an Arc; dropping the registry entry only decrements the strong
count. If a concurrent launch is still holding a clone of the
Arc, the module is not actually unloaded until that launch returns
— eliminating the UAF window that existed when the registry owned
the module by value.
Sourcepub fn total_ptx_bytes(&self) -> u64
pub fn total_ptx_bytes(&self) -> u64
Aggregate PTX bytes currently retained by the registry. Visible for metrics and tests.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for KernelRegistry
impl !RefUnwindSafe for KernelRegistry
impl Send for KernelRegistry
impl Sync for KernelRegistry
impl Unpin for KernelRegistry
impl UnsafeUnpin for KernelRegistry
impl UnwindSafe for KernelRegistry
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> 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