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>{::blockIdx.z, ::blockIdx.y, ::blockIdx.x}.template rshrink<dim>();
36 return mapToND(m_optimizedThreadSpec.getNumBlocks(),
static_cast<IdxType
>(::blockIdx.x));
40 constexpr auto count()
const
42 if constexpr(dim <= 3u)
44 return Vec<IdxType, 3u>{::gridDim.z, ::gridDim.y, ::gridDim.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>{::threadIdx.z, ::threadIdx.y, ::threadIdx.x}.template rshrink<dim>();
73 return mapToND(m_optimizedThreadSpec.getNumThreads(),
static_cast<IdxType
>(::threadIdx.x));
77 constexpr auto count()
const
79 if constexpr(dim <= 3u)
81 return Vec<IdxType, 3u>{::blockDim.z, ::blockDim.y, ::blockDim.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.