cuda::experimental::distribute

Defined in include/cuda/experimental/__hierarchy/hierarchy_dimensions.cuh

template<int _ThreadsPerBlock>
constexpr auto cuda::experimental::distribute(int numElements) noexcept

A shorthand for creating a hierarchy of CUDA threads by evenly distributing elements among blocks and threads.

Snippet

#include <cudax/hierarchy_dimensions.cuh>
using namespace cuda::experimental;

constexpr int threadsPerBlock = 256;
auto dims = distribute<threadsPerBlock>(numElements);

// Equivalent to:
constexpr int threadsPerBlock = 256;
int blocksPerGrid = (numElements + threadsPerBlock - 1) / threadsPerBlock;
auto dims = make_hierarchy(grid_dims(blocksPerGrid), block_dims<threadsPerBlock>());