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

1D CUDA kernel grid configuration. More...

Inheritance diagram for culite::Grid1D:

Public Member Functions

 Grid1D ()
 Default constructor.
 Grid1D (std::size_t n, std::size_t blockSize=256)
 Constructs a 1D grid configuration.
 ~Grid1D ()
 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

1D CUDA kernel grid configuration.

Grid1D simplifies configuration for 1D kernels by automatically calculating the number of blocks needed to cover n elements with the specified block size.

Constructor & Destructor Documentation

◆ Grid1D() [1/2]

culite::Grid1D::Grid1D ( )

Default constructor.

Creates a Grid1D with default-initialized dimensions.

◆ Grid1D() [2/2]

culite::Grid1D::Grid1D ( std::size_t n,
std::size_t blockSize = 256 )

Constructs a 1D grid configuration.

Automatically calculates the number of blocks needed to cover n elements with the given block size. Performs overflow and validation checks.

Parameters
nTotal number of elements to process.
blockSizeNumber of threads per block (default: 256).
Exceptions
err::CudaExceptionif blockSize is zero, if arithmetic overflow occurs, or if calculated values exceed unsigned int maximum.