pub struct LibraryKernel { /* private fields */ }Expand description
A CUDA library kernel handle that keeps its library and lookup context alive.
Implementations§
Source§impl LibraryKernel
impl LibraryKernel
Sourcepub fn name(&self) -> Result<String>
pub fn name(&self) -> Result<String>
Returns the native kernel name, replacing invalid UTF-8 sequences.
§Errors
Returns an error if the lookup context cannot be bound, CUDA cannot query the name, or CUDA returns a null name pointer.
Sourcepub fn function(&self) -> Result<KernelFunction>
pub fn function(&self) -> Result<KernelFunction>
Returns the device function handle for this kernel and the current context.
If the 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 function, or if it returns a null handle.
Sourcepub unsafe fn add_to_graph<'a, P>(
&self,
graph: &mut Graph,
dependencies: &[GraphNode],
config: &LaunchConfig,
params: P,
) -> Result<GraphNode>where
P: KernelLaunchArgs<'a>,
pub unsafe fn add_to_graph<'a, P>(
&self,
graph: &mut Graph,
dependencies: &[GraphNode],
config: &LaunchConfig,
params: P,
) -> Result<GraphNode>where
P: KernelLaunchArgs<'a>,
Adds this kernel to graph as a kernel node.
§Safety
The caller must ensure every pointer value passed through params remains valid for every graph instantiation, update, and launch that can execute the created node.
Mutable pointer arguments must remain exclusive for the work ordered by those launches.
Arguments must match the function ABI and satisfy its value and access requirements.
Keep the graph, executable or another code owner alive until queued executions complete.
§Errors
Propagates errors from resolving this kernel’s function and module. Also returns an error if the graph belongs to another context, a dependency belongs to another graph, the context cannot be bound, CUDA rejects the node or its launch attributes.
Sourcepub unsafe fn set_graph_node_params<'a, P>(
&self,
executable: &mut ExecutableGraph,
node: &GraphNode,
geometry: &LaunchGeometry,
params: P,
) -> Result<()>where
P: KernelLaunchArgs<'a>,
pub unsafe fn set_graph_node_params<'a, P>(
&self,
executable: &mut ExecutableGraph,
node: &GraphNode,
geometry: &LaunchGeometry,
params: P,
) -> Result<()>where
P: KernelLaunchArgs<'a>,
Updates this kernel’s parameters in an executable graph node.
§Safety
The caller must ensure every pointer value passed through params remains valid for every future launch that can execute node.
Mutable pointer arguments must remain exclusive for the work ordered by those launches.
Arguments must match the function ABI and satisfy its value and access requirements.
Keep the graph, executable or another code owner alive until queued executions complete.
Launch attributes are preserved; they must remain compatible with this kernel and geometry.
§Errors
Propagates errors from resolving this kernel’s function and module. Also returns an error if the executable belongs to another context, the node does not belong to its source graph, the context cannot be bound, CUDA rejects the parameter update.
Sourcepub fn attribute(&self, attribute: FunctionAttribute) -> Result<i32>
pub fn attribute(&self, attribute: FunctionAttribute) -> Result<i32>
Returns attribute for this kernel on the library’s lookup device.
§Errors
Returns an error if the lookup context cannot be bound or CUDA rejects the attribute query for this kernel and device.
Specifies whether the kernel may use oversized shared memory configurations.
§Errors
Propagates errors from setting FunctionAttribute::SharedMemoryMode, including a context binding failure or a mode unsupported by the kernel or device.
Returns the shared memory mode configured for this kernel.
§Errors
Propagates errors from querying FunctionAttribute::SharedMemoryMode.
Returns Error::UnknownEnumValue if the returned native value is not a recognized SharedMemoryMode.
Sourcepub fn set_attribute(
&self,
attribute: FunctionAttribute,
value: i32,
) -> Result<()>
pub fn set_attribute( &self, attribute: FunctionAttribute, value: i32, ) -> Result<()>
Sets attribute to value for this kernel on the library’s lookup device.
Only attributes supported for mutation by CUDA can be set; see FunctionAttribute for attribute-specific constraints.
§Errors
Returns an error if the lookup context cannot be bound or CUDA rejects the selected attribute or value for this kernel and device.
Sourcepub fn set_cache_config(&self, config: FunctionCache) -> Result<()>
pub fn set_cache_config(&self, config: FunctionCache) -> Result<()>
Sets the preferred cache configuration for this kernel on devices where L1 cache and shared memory use the same hardware resources.
This setting is only a preference.
The driver uses the requested configuration if possible, but it may choose a different configuration if required to execute the kernel.
This per-kernel setting overrides any context-wide preference set via sys::cuCtxSetCacheConfig.
Attributes set using sys::cuFuncSetCacheConfig override this preference regardless of call order.
This setting does nothing on devices where the size of the L1 cache and shared memory are fixed.
Launching a kernel with a different preference than the most recent preference setting may insert a device-side synchronization point.
The supported cache configurations are:
FunctionCache::PreferNone: no preference for shared memory or L1 (default)FunctionCache::PreferShared: prefer larger shared memory and smaller L1 cacheFunctionCache::PreferL1: prefer larger L1 cache and smaller shared memoryFunctionCache::PreferEqual: prefer equal sized L1 cache and shared memory
This has stricter locking requirements than its legacy counterpart sys::cuFuncSetCacheConfig because the setting has device-wide semantics.
If multiple threads try to set a configuration on the same device simultaneously, the final cache configuration depends on OS scheduler interleaving and memory consistency.
§Errors
Returns an error if the CUDA context cannot be bound or if CUDA Driver rejects the cache configuration.
Sourcepub fn param_info(&self, index: usize) -> Result<KernelParamInfo>
pub fn param_info(&self, index: usize) -> Result<KernelParamInfo>
Queries the kernel parameter at the given index, returning the offset and size where the parameter resides in the device-side parameter layout. Use this information to update kernel node parameters from the device. The index must be less than the number of parameters that the kernel takes.
§Errors
Returns an error if the library context cannot be bound, index is not a valid kernel parameter index, CUDA cannot query the parameter layout, or a previous asynchronous launch reported an error.