Skip to main content

LibraryKernel

Struct LibraryKernel 

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

A CUDA library kernel handle that keeps its library and lookup context alive.

Implementations§

Source§

impl LibraryKernel

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn set_shared_memory_mode(&self, mode: SharedMemoryMode) -> Result<()>

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.

Source

pub fn shared_memory_mode(&self) -> Result<SharedMemoryMode>

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.

Source

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.

Source

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:

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.

Source

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.

Source

pub const fn as_raw(&self) -> CUkernel

Returns the borrowed native kernel handle.

The handle is kept live by this kernel’s library owner; the returned pointer does not retain that owner.

Trait Implementations§

Source§

impl Clone for LibraryKernel

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 LibraryKernel

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Send for LibraryKernel

Source§

impl Sync for LibraryKernel

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.