11#include <Kokkos_Macros.hpp>
13#include "detail/macros.hpp"
15#include "discrete_vector.hpp"
22
23
24
25
26
27
28
29
34 class BinaryReductionOp,
35 class UnaryTransformOp,
37T host_transform_reduce_serial(
38 Support
const& domain,
39 std::array<DiscreteVectorElement, N>
const& size,
40 [[maybe_unused]] T
const neutral,
41 BinaryReductionOp
const& reduce,
42 UnaryTransformOp
const& transform,
43 Is
const&... is)
noexcept
45 DDC_IF_NVCC_THEN_PUSH_AND_SUPPRESS(implicit_return_from_non_void_function)
46 static constexpr std::size_t I =
sizeof...(Is);
47 if constexpr (I == N) {
48 return transform(domain(
typename Support::discrete_vector_type(is...)));
51 for (DiscreteVectorElement ii = 0; ii < size[I]; ++ii) {
53 host_transform_reduce_serial(
69
70
71
72
73
74
75
76
81 class BinaryReductionOp,
82 class UnaryTransformOp,
84KOKKOS_FUNCTION T device_transform_reduce_serial(
85 Support
const& domain,
86 std::array<DiscreteVectorElement, N>
const& size,
87 [[maybe_unused]] T
const neutral,
88 BinaryReductionOp
const& reduce,
89 UnaryTransformOp
const& transform,
90 Is
const&... is)
noexcept
92 DDC_IF_NVCC_THEN_PUSH_AND_SUPPRESS(implicit_return_from_non_void_function)
93 static constexpr std::size_t I =
sizeof...(Is);
94 if constexpr (I == N) {
95 return transform(domain(
typename Support::discrete_vector_type(is...)));
98 for (DiscreteVectorElement ii = 0; ii < size[I]; ++ii) {
100 device_transform_reduce_serial(
117#if defined(DDC_BUILD_DEPRECATED_CODE)
119
120
121
122
123
124
125
127[[
deprecated(
"Use host_transform_reduce instead")]]
143
144
145
146
147
148
149
150template <
class Support,
class T,
class BinaryReductionOp,
class UnaryTransformOp>
152 Support
const& domain,
154 BinaryReductionOp&& reduce,
155 UnaryTransformOp&& transform)
noexcept
157 return detail::host_transform_reduce_serial(
159 detail::array(domain.extents()),
161 std::forward<BinaryReductionOp>(reduce),
162 std::forward<UnaryTransformOp>(transform));
166
167
168
169
170
171
172
173template <
class Support,
class T,
class BinaryReductionOp,
class UnaryTransformOp>
175 Support
const& domain,
177 BinaryReductionOp&& reduce,
178 UnaryTransformOp&& transform)
noexcept
180 return detail::device_transform_reduce_serial(
182 detail::array(domain.extents()),
184 std::forward<BinaryReductionOp>(reduce),
185 std::forward<UnaryTransformOp>(transform));
The top-level namespace of DDC.
T host_transform_reduce(Support const &domain, T neutral, BinaryReductionOp &&reduce, UnaryTransformOp &&transform) noexcept
A reduction over a nD domain in serial.
KOKKOS_FUNCTION T device_transform_reduce(Support const &domain, T neutral, BinaryReductionOp &&reduce, UnaryTransformOp &&transform) noexcept
A reduction over a nD domain in serial.