cuda::experimental::get_launch_dimensions

Defined in /home/runner/work/cccl/cccl/cudax/include/cuda/experimental/__hierarchy/hierarchy_dimensions.cuh

template<typename ...Levels>
constexpr auto cuda::experimental::get_launch_dimensions(const hierarchy_dimensions<Levels...> &hierarchy)

Returns a tuple of dim3 compatible objects that can be used to launch a kernel.

This function returns a tuple of hierarchy_query_result objects that contain dimensions from the supplied hierarchy, that can be used to launch that hierarchy. It is meant to allow for easy usage of hierarchy dimensions with the <<<>>> launch syntax or cudaLaunchKernelEx in case of a cluster launch. Contained hierarchy_query_result objects are results of extents() member function on the hierarchy passed in. The returned tuple has three elements if cluster_level is present in the hierarchy (extents(block, grid), extents(cluster, block), extents(thread, block)). Otherwise it contains only two elements, without the middle one related to the cluster.

Snippet

#include <cudax/hierarchy_dimensions.cuh>

using namespace cuda::experimental;

auto hierarchy = make_hierarchy(grid_dims(256), cluster_dims<4>(), block_dims<8, 8, 8>());
auto [grid_dimensions, cluster_dimensions, block_dimensions] = get_launch_dimensions(hierarchy);
assert(grid_dimensions.x == 256);
assert(cluster_dimensions.x == 4);
assert(block_dimensions.x == 8);
assert(block_dimensions.y == 8);
assert(block_dimensions.z == 8);

Parameters

hierarchy – Hierarchy that the launch dimensions are requested for