macro_rules! launch {
($kernel:expr, grid($g:expr), block($b:expr), shared($s:expr), $stream:expr, $args:expr) => { ... };
($kernel:expr, grid($g:expr), block($b:expr), $stream:expr, $args:expr) => { ... };
}Expand description
Launch a GPU kernel with a concise syntax.
This macro constructs LaunchParams from the
provided grid and block dimensions, then calls Kernel::launch.
§Syntax
launch!(kernel, grid(G), block(B), shared(S), stream, args)?;
launch!(kernel, grid(G), block(B), stream, args)?; // shared_mem = 0Where:
kernel— aKernelinstance.G— grid dimensions (anything convertible toDim3).B— block dimensions (anything convertible toDim3).S— dynamic shared memory in bytes (u32).stream— a reference to aStream.args— a reference to a tuple implementingKernelArgs.
§Returns
CudaResult<()> — use ? to propagate errors.
§Examples
let n: u32 = 1024;
let a_ptr: u64 = 0;
let b_ptr: u64 = 0;
let c_ptr: u64 = 0;
// With explicit shared memory
launch!(kernel, grid(4u32), block(256u32), shared(0), &stream, &(a_ptr, b_ptr, c_ptr, n))?;
// Without shared memory (defaults to 0)
launch!(kernel, grid(4u32), block(256u32), &stream, &(a_ptr, b_ptr, c_ptr, n))?;