pub struct LaunchParams {
pub grid: Dim3,
pub block: Dim3,
pub shared_mem_bytes: u32,
}Expand description
Parameters for a GPU kernel launch.
Specifies the execution configuration: grid size (number of blocks), block size (threads per block), and dynamic shared memory allocation.
§Examples
use oxicuda_launch::{LaunchParams, Dim3};
let params = LaunchParams::new(Dim3::x(256), Dim3::x(256));
assert_eq!(params.grid, Dim3::x(256));
assert_eq!(params.block, Dim3::x(256));
assert_eq!(params.shared_mem_bytes, 0);Fields§
§grid: Dim3Grid dimensions (number of thread blocks in each dimension).
block: Dim3Block dimensions (number of threads per block in each dimension).
Dynamic shared memory allocation in bytes (default 0).
Implementations§
Source§impl LaunchParams
impl LaunchParams
Sourcepub fn new(grid: impl Into<Dim3>, block: impl Into<Dim3>) -> Self
pub fn new(grid: impl Into<Dim3>, block: impl Into<Dim3>) -> Self
Creates new launch parameters with the given grid and block dimensions.
Shared memory defaults to 0 bytes. Use with_shared_mem
to specify dynamic shared memory.
Both grid and block accept anything that converts to Dim3,
including u32, (u32, u32), and (u32, u32, u32).
Sets the dynamic shared memory allocation in bytes.
Returns self for method chaining.
Sourcepub fn builder() -> LaunchParamsBuilder
pub fn builder() -> LaunchParamsBuilder
Returns a LaunchParamsBuilder for incremental configuration.
Sourcepub fn total_threads(&self) -> u64
pub fn total_threads(&self) -> u64
Total number of threads in the launch (grid total * block total).
Returns a u64 to avoid overflow when grid and block totals
are both large u32 values.
Sourcepub fn validate(&self, device: &Device) -> Result<(), Box<dyn Error>>
pub fn validate(&self, device: &Device) -> Result<(), Box<dyn Error>>
Validates launch parameters against device hardware limits.
Checks that:
- All block and grid dimensions are non-zero.
- The total threads per block does not exceed the device maximum.
- Each block dimension does not exceed its per-axis device maximum.
- Each grid dimension does not exceed its per-axis device maximum.
- The dynamic shared memory does not exceed the device maximum per block.
§Errors
Returns a LaunchError describing the first constraint violation
found, or a CudaError if device
attribute queries fail.
§Examples
use oxicuda_launch::{LaunchParams, Dim3};
use oxicuda_driver::device::Device;
oxicuda_driver::init()?;
let dev = Device::get(0)?;
let params = LaunchParams::new(256u32, 256u32);
params.validate(&dev)?;Trait Implementations§
Source§impl Clone for LaunchParams
impl Clone for LaunchParams
Source§fn clone(&self) -> LaunchParams
fn clone(&self) -> LaunchParams
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more