11#include <Kokkos_Macros.hpp>
13#include "discrete_vector.hpp"
19template <
class Support, std::size_t N,
class Functor,
class... Is>
20void host_for_each_serial(
21 Support
const& domain,
22 std::array<DiscreteVectorElement, N>
const& size,
24 Is
const&... is)
noexcept
26 static constexpr std::size_t I =
sizeof...(Is);
27 if constexpr (I == N) {
28 f(domain(
typename Support::discrete_vector_type(is...)));
30 for (DiscreteVectorElement ii = 0; ii < size[I]; ++ii) {
31 host_for_each_serial(domain, size, f, is..., ii);
36template <
class Support, std::size_t N,
class Functor,
class... Is>
37KOKKOS_FUNCTION
void device_for_each_serial(
38 Support
const& domain,
39 std::array<DiscreteVectorElement, N>
const& size,
41 Is
const&... is)
noexcept
43 static constexpr std::size_t I =
sizeof...(Is);
44 if constexpr (I == N) {
45 f(domain(
typename Support::discrete_vector_type(is...)));
47 for (DiscreteVectorElement ii = 0; ii < size[I]; ++ii) {
48 device_for_each_serial(domain, size, f, is..., ii);
55#if defined(DDC_BUILD_DEPRECATED_CODE)
57
58
59
69
70
71
72template <
class Support,
class Functor>
73void host_for_each(Support
const& domain, Functor&& f)
noexcept
75 detail::host_for_each_serial(domain, detail::array(domain.extents()), std::forward<Functor>(f));
79
80
81
82template <
class Support,
class Functor>
85 detail::device_for_each_serial(
87 detail::array(domain.extents()),
88 std::forward<Functor>(f));
The top-level namespace of DDC.
void host_for_each(Support const &domain, Functor &&f) noexcept
iterates over a nD domain in serial
KOKKOS_FUNCTION void device_for_each(Support const &domain, Functor &&f) noexcept
iterates over a nD domain in serial