Skip to main content

auto_grid_2d

Function auto_grid_2d 

Source
pub fn auto_grid_2d(
    func: &Function,
    width: usize,
    height: usize,
) -> CudaResult<(Dim3, Dim3)>
Expand description

Computes optimal grid and block dimensions for a 2D problem.

Given a kernel function and problem dimensions (width, height), this function determines a 2D block size and the corresponding grid dimensions. The block is sized as a square (or near-square) tile whose total thread count respects the occupancy-optimal value.

Returns (grid_dim, block_dim) as 2D Dim3 values.

§Errors

Returns a CudaError if the occupancy query fails.

§Examples

use oxicuda_launch::grid::auto_grid_2d;

let func = module.get_function("my_kernel_2d")?;
let (grid, block) = auto_grid_2d(&func, 1920, 1080)?;