cuda::experimental::hierarchy::extents

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

template<typename Unit, typename Level>
auto cuda::experimental::hierarchy::extents(const Unit&, const Level&)

Returns extents of multi-dimensional index space of a CUDA hierarchy level.

Returned extents are in line with intrinsic CUDA dimensions vectors like blockDim and gridDim, extentded to more unit/level combinations. Returns hierarchy_query_result, which can be used like cuda::std::extents or dim3. Unit and Level need to be a core CUDA hierarchy levels, for example grid_level or block_level. This function is also available as a level type member function, in that case it only takes a unit argument.

Snippet

#include <cudax/hierarchy_dimensions.cuh>
#include <cassert>

using namespace cuda::experimental;

__global__ void kernel()
{
    // Can be called with the instances of level types
    auto block_dims = hierarchy::extents(thread, block);
    assert(block_dims == blockDim);
    auto grid_dims = grid.extents(block);
    assert(grid_dims == gridDim);

    // Or using the level types as template arguments
    auto grid_dims_in_threads = hierarchy::extents<thread_level, grid_level>();
}

Template Parameters
  • Unit – Specifies the unit of the index space

  • Level – Specifies at what CUDA hierarchy level the extents are requested