-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Kokkos execution policies on DDC algorithms #254
Comments
No new execution policy for this issue |
I added few modifications on a first file for_each_kokkos.hpp. Main changes on the fileNo more namespace policiesnamespace policies {
inline constexpr serial_host_policy serial_host;
inline constexpr parallel_host_policy parallel_host;
inline constexpr parallel_device_policy parallel_device;
template <typename ExecSpace>
constexpr auto policy([[maybe_unused]] ExecSpace exec_space)
{
if constexpr (std::is_same_v<ExecSpace, Kokkos::Serial>) {
return ddc::policies::serial_host;
#ifdef KOKKOS_ENABLE_OPENMP
} else if constexpr (std::is_same_v<ExecSpace, Kokkos::OpenMP>) {
return ddc::policies::parallel_host;
#endif
#if defined(KOKKOS_ENABLE_CUDA) || defined(KOKKOS_ENABLE_HIP)
} else {
return ddc::policies::parallel_device;
#endif
}
}
} // namespace policies The goal for me is to replace this namespace and to explicit the Kokkos execution spaces. "for_each" functionsIn the original version, there are 3 for_each functions. Each one is executed on a different execution space:
template <class ExecSpace, class... DDims, class Functor>
inline void for_each(
DiscreteDomain<DDims...> const& domain,
Functor&& f) noexcept
{
detail::for_each_kokkos<ExecSpace>(domain, std::forward<Functor>(f));
} With the ExecSpace template, the user will just have to use:
I also deleted the for_each_serial function because for me it is the same as for_each_kokkos with the use of Kokkos::Serial as a template. Have to check with somebody on that. We see a consequence of this change in the next change I present. "for_each_n" functionThe initial function: template <class... DDims, class Functor>
inline void for_each_n(
serial_host_policy,
DiscreteVector<DDims...> const& extent,
Functor&& f) noexcept
{
DiscreteVector<DDims...> const ddc_begin {};
DiscreteVector<DDims...> const ddc_end = extent;
std::array const begin = detail::array(ddc_begin);
std::array const end = detail::array(ddc_end);
detail::for_each_serial<DiscreteVector<DDims...>>(begin, end, std::forward<Functor>(f));
} My function: template <class... DDims, class Functor>
inline void for_each_n(
DiscreteVector<DDims...> const& extent,
Functor&& f) noexcept
{
DiscreteVector<DDims...> const ddc_begin {};
DiscreteVector<DDims...> const ddc_end = extent;
std::array const begin = detail::array(ddc_begin);
std::array const end = detail::array(ddc_end);
detail::for_each_kokkos<Kokkos::Serial, DiscreteVector<DDims...>>(begin, end, std::forward<Functor>(f));
} I was thinking the "for_each_serial" function could be replaced like that. |
Regarding the difference between To be discussed with @tpadioleau , but I would keep a specialized Maybe the best would be to split it in two versions:
|
Actually the only difference between |
Totally agree |
Done through different MR |
No description provided.
The text was updated successfully, but these errors were encountered: