pub struct Module { /* private fields */ }Expand description
A loaded CUDA module containing one or more kernel functions.
Modules are typically created from PTX source via Module::from_ptx
or Module::from_ptx_with_options. Individual kernel functions
are retrieved by name with Module::get_function.
The module is unloaded when this struct is dropped.
Implementations§
Source§impl Module
impl Module
Sourcepub fn from_ptx(ptx: &str) -> CudaResult<Self>
pub fn from_ptx(ptx: &str) -> CudaResult<Self>
Loads a module from PTX source with default JIT options.
The PTX string is automatically null-terminated before being passed to the driver.
§Errors
Returns CudaError::InvalidImage if
the PTX is malformed, or another CudaError if the driver
call fails (e.g. no current context).
Sourcepub fn from_ptx_with_options(
ptx: &str,
options: &JitOptions,
) -> CudaResult<(Self, JitLog)>
pub fn from_ptx_with_options( ptx: &str, options: &JitOptions, ) -> CudaResult<(Self, JitLog)>
Sourcepub fn get_function(&self, name: &str) -> CudaResult<Function>
pub fn get_function(&self, name: &str) -> CudaResult<Function>
Retrieves a kernel function by name from this module.
The returned Function is a lightweight handle. The caller
must ensure that this Module outlives any Function handles
obtained from it.
§Errors
Returns CudaError::NotFound if no
function with the given name exists in the module, or another
CudaError on driver failure.