Expand description
Type-safe GPU kernel management and argument passing.
This module provides the Kernel struct for launching GPU kernels
and the KernelArgs trait for type-safe argument passing to CUDA
kernel functions.
§Architecture
A Kernel wraps a Function handle and holds an Arc<Module>
to ensure the PTX module remains loaded for the kernel’s lifetime.
Arguments are passed via the KernelArgs trait, which converts
typed Rust values into the *mut c_void array that cuLaunchKernel
expects.
§Tuple arguments
The KernelArgs trait is implemented for tuples of Copy types
up to 24 elements. Each element must be Copy because kernel
arguments are passed by value to the GPU.
§Example
let module = Arc::new(Module::from_ptx(ptx)?);
let kernel = Kernel::from_module(module, "vector_add")?;
let stream = Stream::new(&ctx)?;
let params = LaunchParams::new(4u32, 256u32);
// Launch with typed arguments: (a_ptr, b_ptr, c_ptr, n)
let args = (0u64, 0u64, 0u64, 1024u32);
kernel.launch(¶ms, &stream, &args)?;Structs§
- Kernel
- A launchable GPU kernel with module lifetime management.
Traits§
- Kernel
Args - Trait for types that can be passed as kernel arguments.