Skip to main content

Library

Struct Library 

Source
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

Source

pub unsafe fn from_raw(raw: RawLibrary) -> Result<Self>

Takes ownership of a CUDA library, retaining its lookup context.

§Safety

raw.handle must be live and must not be unloaded elsewhere. raw.context must support the library’s device code.

§Errors

Returns Error::NullHandle if the handle is null.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn as_raw(&self) -> CUlibrary

Returns the borrowed native library handle without transferring ownership.

Source

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.

Source

pub fn context(&self) -> &Arc<Context> ⓘ

Returns the context used for library lookups and device attributes.

Trait Implementations§

Source§

impl Clone for Library

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Library

Source§

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

Formats the value using the given formatter. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.