Skip to main content

Module grid

Module grid 

Source
Expand description

Grid and block dimension types for kernel launch configuration.

CUDA kernels are launched with a grid of thread blocks. Each block contains threads organized in up to 3 dimensions.

§Dimension model

The CUDA execution model uses a two-level hierarchy:

  • Grid: A collection of thread blocks, specified as up to 3D dimensions.
  • Block: A collection of threads within a block, also up to 3D.

Both are described by Dim3, which defaults unused dimensions to 1.

§Helper function

The grid_size_for function computes the minimum grid size needed to cover a given number of elements with a given block size (ceiling division).

Structs§

Dim3
3-dimensional size specification for grids and blocks.

Functions§

auto_grid_2d
Computes optimal grid and block dimensions for a 2D problem.
auto_grid_for
Computes optimal grid and block dimensions for a 1D problem of n elements.
grid_size_for
Calculate the grid size needed to cover n elements with block_size threads.