1 #ifndef HeterogeneousCore_AlpakaInterface_interface_workdivision_h 2 #define HeterogeneousCore_AlpakaInterface_interface_workdivision_h 6 #include <alpaka/alpaka.hpp> 23 template <
typename TAcc,
26 #ifdef ALPAKA_ACC_GPU_CUDA_ENABLED 27 if constexpr (std::is_same_v<TAcc, alpaka::AccGpuCudaRt<Dim1D, Idx>>) {
33 #endif // ALPAKA_ACC_GPU_CUDA_ENABLED 34 #if ALPAKA_ACC_GPU_HIP_ENABLED 35 if constexpr (std::is_same_v<TAcc, alpaka::AccGpuHipRt<Dim1D, Idx>>) {
41 #endif // ALPAKA_ACC_GPU_HIP_ENABLED 51 template <
typename TAcc,
typename = std::enable_if_t<cms::alpakatools::is_accelerator_v<TAcc>>>
54 using Dim = alpaka::Dim<TAcc>;
55 #ifdef ALPAKA_ACC_GPU_CUDA_ENABLED 56 if constexpr (std::is_same_v<TAcc, alpaka::AccGpuCudaRt<Dim, Idx>>) {
62 #endif // ALPAKA_ACC_GPU_CUDA_ENABLED 63 #ifdef ALPAKA_ACC_GPU_HIP_ENABLED 64 if constexpr (std::is_same_v<TAcc, alpaka::AccGpuHipRt<Dim, Idx>>) {
70 #endif // ALPAKA_ACC_GPU_HIP_ENABLED 79 template <
typename TAcc,
84 : elements_{alpaka::getWorkDiv<alpaka::Thread, alpaka::Elems>(acc)[0u]},
85 first_{alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc)[0u] * elements_},
86 stride_{alpaka::getWorkDiv<alpaka::Grid, alpaka::Threads>(acc)[0u] * elements_},
90 : elements_{alpaka::getWorkDiv<alpaka::Thread, alpaka::Elems>(acc)[0u]},
91 first_{alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc)[0u] * elements_},
92 stride_{alpaka::getWorkDiv<alpaka::Grid, alpaka::Threads>(acc)[0u] * elements_},
117 first_ += stride_ * elements_;
119 last_ =
std::min(first_ + elements_, extent_);
120 if (index_ < extent_)
138 return (index_ ==
other.index_) and (first_ ==
other.first_);
165 template <
typename TAcc,
169 using Dim = alpaka::Dim<TAcc>;
170 using Vec = alpaka::Vec<Dim, Idx>;
173 : elements_{alpaka::getWorkDiv<alpaka::Thread, alpaka::Elems>(acc)},
174 first_{alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc) * elements_},
175 stride_{alpaka::getWorkDiv<alpaka::Grid, alpaka::Threads>(acc) * elements_},
179 : elements_{alpaka::getWorkDiv<alpaka::Thread, alpaka::Elems>(acc)},
180 first_{alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc) * elements_},
181 stride_{alpaka::getWorkDiv<alpaka::Grid, alpaka::Threads>(acc) * elements_},
202 ++index_[last_dimension];
203 if (index_[last_dimension] < last_)
207 first_[last_dimension] += stride_[last_dimension] * elements_[last_dimension];
208 index_[last_dimension] = first_[last_dimension];
209 last_ =
std::min(first_[last_dimension] + elements_[last_dimension], extent_[last_dimension]);
210 if (index_[last_dimension] < extent_[last_dimension])
214 if constexpr (last_dimension > 0)
225 last_ = extent_[last_dimension];
237 return (index_ ==
other.index_) and (first_ ==
other.first_);
266 #endif // HeterogeneousCore_AlpakaInterface_interface_workdivision_h
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC constexpr auto elementwise_min(Vec< TDim, TVal > const &p, Vecs const &... qs) -> Vec< TDim, TVal >
alpaka::WorkDivMembers< TDim, Idx > WorkDiv
alpaka::Vec< TDim, Idx > Vec
uint32_t dimension(pat::CandKinResolution::Parametrization parametrization)
Returns the number of free parameters in a parametrization (3 or 4)