Skip to main content

Module

Struct Module 

Source
pub struct Module { /* private fields */ }
Expand description

A shared CUDA module and its retained loading context.

Clones, functions, and retained graph owners keep the module alive. An owned native module is unloaded when its last owner is dropped. Library-backed modules instead retain their library; externally borrowed modules rely on the external owner.

Implementations§

Source§

impl Module

Source

pub fn artifact_metadata(&self) -> Option<&ArtifactMetadata>

Returns the retained producer metadata, or None for modules loaded without it.

Source

pub unsafe fn prepare<K: KernelSignature>( &self, symbol: &str, config: LaunchConfig, ) -> Result<PreparedLaunch<K>>

Binds an existing image entry to the ordinary typed launch contract.

§Safety

K must describe this symbol’s ABI, indexing and semantic requirements. Producer entry metadata does not prove field layout, bounds, initialization or alias permission.

§Errors

Propagates errors from looking up symbol and validating the typed launch. Validation can fail if native parameter sizes or offsets disagree with K, parameter layout overflows, the launch violates the signature’s requirements or device limits, or CUDA cannot query the required kernel or device attributes.

Source§

impl Module

Source

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

Takes ownership of a native module and its context association.

§Safety

raw.handle must be a live module loaded in raw.context and must not be unloaded elsewhere.

§Errors

Returns Error::NullHandle if the handle is null.

Source

pub unsafe fn from_borrowed_raw(handle: CUmodule, context: Arc<Context>) -> Self

Borrows an externally owned module.

§Safety

handle must belong to context and stay loaded until every clone, function, prepared launch and graph retaining this wrapper has been released.

Source

pub fn function(&self, name: &str) -> Result<KernelFunction>

Returns the kernel function with the given name from the module.

§Errors

Returns crate::error::Status::NotFound if the module has no kernel function named name. Also returns an error if name contains an interior NUL byte, the module context cannot be bound, CUDA rejects the lookup, or a previous asynchronous launch reports an error.

Source

pub fn function_count(&self) -> Result<usize>

Returns the number of functions in this module.

§Errors

Returns an error if CUDA Driver cannot report the function count.

Source

pub fn as_raw(&self) -> CUmodule

Returns the borrowed native module handle without transferring ownership.

Source

pub fn into_raw(self) -> StdResult<RawModule, Self>

Consumes the module and returns the raw CUDA module 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 if functions, graphs or other clones retain this module, or if its native handle is externally owned or owned by a library.

§Errors

Returns Err(self) if the module is externally owned, owned by a library, or still shared with another clone, function, or graph owner. The returned wrapper remains usable and retains its ownership mode.

Source

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

Returns the CUDA context in which this module was loaded.

Source

pub fn global(&self, name: &str) -> Result<Global<'_>>

Returns the base pointer and size of the global with the given name located in the module.

The returned Global borrows this module, so the module remains loaded for at least as long as the global reference is usable.

§Errors

Returns crate::error::Status::NotFound if the module has no global variable named name. Also returns an error if name contains an interior NUL byte, the module context cannot be bound, CUDA rejects the lookup, or a previous asynchronous launch reports an error.

Trait Implementations§

Source§

impl Clone for Module

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 Module

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Module

§

impl !UnwindSafe for Module

§

impl Forget for Module

§

impl Freeze for Module

§

impl Move for Module

§

impl Send for Module

§

impl Sync for Module

§

impl Unpin for Module

§

impl UnsafeUnpin for Module

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.