cuLite v0.3.1
A lite CUDA C++ Interface
Loading...
Searching...
No Matches
culite::Grid2D Class Reference

2D CUDA kernel grid configuration. More...

Inheritance diagram for culite::Grid2D:

Public Member Functions

 Grid2D ()
 Default constructor.
 Grid2D (std::size_t m, std::size_t n, std::size_t blockSizeX=16, std::size_t blockSizeY=16)
 Constructs a 2D grid configuration with explicit block dimensions.
 ~Grid2D ()
 Default destructor.
Public Member Functions inherited from culite::GridXD
 GridXD ()
 Default constructor.
 GridXD (dim3 numBlocks, dim3 threadsPerBlock)
 Constructs a GridXD with explicit grid and block dimensions.
 ~GridXD ()
 Default destructor.
const dim3 & numBlocks () const
 Gets the number of blocks in the grid.
const dim3 & threadsPerBlock () const
 Gets the number of threads per block.

Additional Inherited Members

Protected Types inherited from culite::GridXD
using cudaInt = unsigned int
 Type used by CUDA dim3 dimensions.

Detailed Description

2D CUDA kernel grid configuration.

Grid2D simplifies configuration for 2D kernels (e.g., matrix operations) by automatically calculating the number of blocks needed to cover m×n elements with the specified block dimensions. Optimized for column-major matrices.

Constructor & Destructor Documentation

◆ Grid2D() [1/2]

culite::Grid2D::Grid2D ( )

Default constructor.

Creates a Grid2D with default-initialized dimensions.

◆ Grid2D() [2/2]

culite::Grid2D::Grid2D ( std::size_t m,
std::size_t n,
std::size_t blockSizeX = 16,
std::size_t blockSizeY = 16 )

Constructs a 2D grid configuration with explicit block dimensions.

Automatically calculates the number of blocks needed in X and Y dimensions to cover m×n elements with the given block sizes. Performs overflow and validation checks.

Parameters
mNumber of elements in the X dimension (rows).
nNumber of elements in the Y dimension (columns).
blockSizeXNumber of threads per block in X dimension (default: 16).
blockSizeYNumber of threads per block in Y dimension (default: 16).
Exceptions
err::CudaExceptionif block sizes are zero, if arithmetic overflow occurs, or if calculated values exceed unsigned int maximum.