cuda-api-wrappers
Thin C++-flavored wrappers for the CUDA Runtime API
cuda::grid::dimensions_t Struct Reference

A richer (kind-of-a-)wrapper for CUDA's dim3 class, used to specify dimensions for blocks (in terms of threads) and of grids(in terms of blocks, or overall). More...

#include <types.hpp>

Public Member Functions

constexpr __host__ __device__ dimensions_t (dimension_t x_=1, dimension_t y_=1, dimension_t z_=1) noexcept
 
constexpr __host__ __device__ dimensions_t (const uint3 &v) noexcept
 
constexpr __host__ __device__ dimensions_t (const dim3 &dims) noexcept
 
constexpr __host__ __device__ dimensions_t (dim3 &&dims) noexcept
 
constexpr __host__ __device__ operator uint3 (void) const
 
__host__ __device__ operator dim3 (void) const noexcept
 
constexpr __host__ __device__ size_t volume () const noexcept
 The number of total elements in a 3D object with these dimensions.
 
constexpr __host__ __device__ dimensionality_t dimensionality () const noexcept
 Number of dimensions in which this dimension structure is non-trivial, i.e. More...
 
constexpr dimension_t operator[] (int i) const noexcept
 Provides array-like access to the dimensions in different axes. More...
 
CPP14_CONSTEXPR dimension_toperator[] (int i) noexcept
 

Static Public Member Functions

static constexpr __host__ __device__ dimensions_t cube (dimension_t x) noexcept
 Dimensions of an equi-lateral 3D cube.
 
static constexpr __host__ __device__ dimensions_t square (dimension_t x) noexcept
 Dimensions of an equi-lateral 2D square, with a trivial third dimension.
 
static constexpr __host__ __device__ dimensions_t line (dimension_t x) noexcept
 Dimensions of a 1D line, with the last two dimensions trivial.
 
static constexpr __host__ __device__ dimensions_t point () noexcept
 Dimensions of a single point - trivial in all axes.
 
static constexpr bool divides (dimensions_t lhs, dimensions_t rhs)
 

Public Attributes

dimension_t x
 
dimension_t y
 
dimension_t z
 

Detailed Description

A richer (kind-of-a-)wrapper for CUDA's dim3 class, used to specify dimensions for blocks (in terms of threads) and of grids(in terms of blocks, or overall).

Note
Unlike 3D dimensions in general, grid dimensions cannot actually be empty: A grid must have some threads. Thus, the value in each axis must be positive when an instance of this class is used in a kernel launch configuration.

Member Function Documentation

◆ dimensionality()

constexpr __host__ __device__ dimensionality_t cuda::grid::dimensions_t::dimensionality ( ) const
inlinenoexcept

Number of dimensions in which this dimension structure is non-trivial, i.e.

coordinates can have more than a single value

◆ divides()

static constexpr bool cuda::grid::dimensions_t::divides ( dimensions_t  lhs,
dimensions_t  rhs 
)
inlinestatic
Returns
true if the dimensions on the left-hand side divide, elementwise, those on the right-hand side

◆ operator[]()

constexpr dimension_t cuda::grid::dimensions_t::operator[] ( int  i) const
inlinenoexcept

Provides array-like access to the dimensions in different axes.

Note
Behavior only defined for i between 0 and 2

The documentation for this struct was generated from the following file: