14 namespace unifiedCudaHip
16 template<
typename T_OptimizedThreadSpec>
19 T_OptimizedThreadSpec
const& m_optimizedThreadSpec;
20 static constexpr uint32_t dim = T_OptimizedThreadSpec::dim();
21 using IdxType =
typename T_OptimizedThreadSpec::NumBlocksVecType::type;
23 constexpr BlockLayer(T_OptimizedThreadSpec
const& optimizedThreadSpec)
24 : m_optimizedThreadSpec(optimizedThreadSpec)
28 constexpr auto idx()
const
30 if constexpr(dim <= 3u)
32 return Vec<IdxType, 3u>{hipBlockIdx_z, hipBlockIdx_y, hipBlockIdx_x}.template rshrink<dim>();
36 return mapToND(m_optimizedThreadSpec.getNumBlocks(),
static_cast<IdxType
>(hipBlockIdx_x));
40 constexpr auto count()
const
42 if constexpr(dim <= 3u)
44 return Vec<IdxType, 3u>{hipGridDim_z, hipGridDim_y, hipGridDim_x}.template rshrink<dim>();
48 return m_optimizedThreadSpec.getNumBlocks();
53 template<
typename T_OptimizedThreadSpec>
56 T_OptimizedThreadSpec
const& m_optimizedThreadSpec;
57 static constexpr uint32_t dim = T_OptimizedThreadSpec::dim();
58 using IdxType =
typename T_OptimizedThreadSpec::NumThreadsVecType::type;
60 constexpr ThreadLayer(T_OptimizedThreadSpec
const& optimizedThreadSpec)
61 : m_optimizedThreadSpec(optimizedThreadSpec)
65 constexpr auto idx()
const
67 if constexpr(dim <= 3u)
69 return Vec<IdxType, 3u>{hipThreadIdx_z, hipThreadIdx_y, hipThreadIdx_x}.template rshrink<dim>();
73 return mapToND(m_optimizedThreadSpec.getNumThreads(),
static_cast<IdxType
>(hipThreadIdx_x));
77 constexpr auto count()
const
79 if constexpr(dim <= 3u)
81 return Vec<IdxType, 3u>{hipBlockDim_z, hipBlockDim_y, hipBlockDim_x}.template rshrink<dim>();
85 return m_optimizedThreadSpec.getNumThreads();
89 constexpr auto count() const
90 requires alpaka::concepts::CVector<typename T_OptimizedThreadSpec::NumThreadsVecType>
92 return typename T_OptimizedThreadSpec::NumThreadsVecType{};
functionality which is usable on the accelerator compute device from within a kernel.
constexpr Vec< T_IntegralType, T_dim > mapToND(Vec< T_IntegralType, T_dim, T_Storage > const &extents, T_IntegralType linearIdx)
Maps a linear index to an N-dimensional index.