pub struct Library { /* private fields */ }Expand description
A shared CUDA library and its retained lookup context.
Clones, kernels, and modules share ownership.
The native library is unloaded when its last owner is dropped, unless ownership has been transferred with Self::into_raw.
Implementations§
Source§impl Library
impl Library
Sourcepub unsafe fn from_raw(raw: RawLibrary) -> Result<Self>
pub unsafe fn from_raw(raw: RawLibrary) -> Result<Self>
Sourcepub fn kernel(&self, name: &str) -> Result<LibraryKernel>
pub fn kernel(&self, name: &str) -> Result<LibraryKernel>
Returns the handle of the kernel with the given name located in this library.
If kernel handle is not found, the call returns crate::error::Status::NotFound.
§Errors
Returns an error if name contains an interior NUL byte, if the CUDA context cannot be bound, if CUDA Driver cannot find the kernel, or if it returns a null handle.
Sourcepub fn kernel_count(&self) -> Result<usize>
pub fn kernel_count(&self) -> Result<usize>
Returns the number of kernels in this library.
§Errors
Returns an error if the CUDA context cannot be bound or if CUDA Driver cannot report the kernel count.
Sourcepub fn module(&self) -> Result<Module>
pub fn module(&self) -> Result<Module>
Returns the module handle associated with the current context located in this library.
If module handle is not found, the call returns crate::error::Status::NotFound.
§Errors
Returns an error if the CUDA context cannot be bound, if CUDA Driver cannot find the module, or if it returns a null handle.
Sourcepub fn global(&self, name: &str) -> Result<LibraryGlobal<'_>>
pub fn global(&self, name: &str) -> Result<LibraryGlobal<'_>>
Returns the base pointer and size of the global with the given name for the requested library and the current context.
If no global for the requested name exists, the call returns crate::error::Status::NotFound.
§Errors
Returns an error if name contains an interior NUL byte, if the CUDA context cannot be bound, or if CUDA Driver cannot find the global.
Sourcepub fn managed(&self, name: &str) -> Result<LibraryGlobal<'_>>
pub fn managed(&self, name: &str) -> Result<LibraryGlobal<'_>>
Returns the base pointer and size of the managed memory with the given name for the requested library.
If no managed memory with the requested name exists, the call returns crate::error::Status::NotFound.
Managed memory for the library is shared across devices and is registered when the library is loaded into at least one context.
§Errors
Returns an error if name contains an interior NUL byte, if the CUDA context cannot be bound, or if CUDA Driver cannot find the managed allocation.
Sourcepub fn as_raw(&self) -> CUlibrary
pub fn as_raw(&self) -> CUlibrary
Returns the borrowed native library handle without transferring ownership.
Sourcepub fn into_raw(self) -> StdResult<RawLibrary, Self>
pub fn into_raw(self) -> StdResult<RawLibrary, Self>
Consumes the library and returns the raw CUDA library handle without unloading it.
The caller becomes responsible for eventually unloading the returned handle with CUDA while retaining the returned context. Returns the unchanged wrapper while kernels, modules, graphs or other clones retain this library.
§Errors
Returns Err(self) if another library clone, kernel, module, or retained graph owner still shares the library.
The returned wrapper remains usable and retains ownership.