11#include <Kokkos_Macros.hpp>
13#include "detail/macros.hpp"
15#include "discrete_element.hpp"
22
23
24
25
26
27
28
29
35 class BinaryReductionOp,
36 class UnaryTransformOp,
38T host_transform_reduce_serial(
39 Support
const& domain,
40 std::array<Element, N>
const& size,
41 [[maybe_unused]] T
const neutral,
42 BinaryReductionOp
const& reduce,
43 UnaryTransformOp
const& transform,
44 Is
const&... is)
noexcept
46 DDC_IF_NVCC_THEN_PUSH_AND_SUPPRESS(implicit_return_from_non_void_function)
47 static constexpr std::size_t I =
sizeof...(Is);
48 if constexpr (I == N) {
49 return transform(domain(
typename Support::discrete_vector_type(is...)));
52 for (Element ii = 0; ii < size[I]; ++ii) {
54 host_transform_reduce_serial(
70
71
72
73
74
75
76
77
83 class BinaryReductionOp,
84 class UnaryTransformOp,
86KOKKOS_FUNCTION T device_transform_reduce_serial(
87 Support
const& domain,
88 std::array<Element, N>
const& size,
89 [[maybe_unused]] T
const neutral,
90 BinaryReductionOp
const& reduce,
91 UnaryTransformOp
const& transform,
92 Is
const&... is)
noexcept
94 DDC_IF_NVCC_THEN_PUSH_AND_SUPPRESS(implicit_return_from_non_void_function)
95 static constexpr std::size_t I =
sizeof...(Is);
96 if constexpr (I == N) {
97 return transform(domain(
typename Support::discrete_vector_type(is...)));
100 for (Element ii = 0; ii < size[I]; ++ii) {
102 device_transform_reduce_serial(
119#if defined(DDC_BUILD_DEPRECATED_CODE)
121
122
123
124
125
126
127
129[[
deprecated(
"Use host_transform_reduce instead")]]
145
146
147
148
149
150
151
152template <
class Support,
class T,
class BinaryReductionOp,
class UnaryTransformOp>
154 Support
const& domain,
156 BinaryReductionOp&& reduce,
157 UnaryTransformOp&& transform)
noexcept
159 return detail::host_transform_reduce_serial(
161 detail::array(domain.extents()),
163 std::forward<BinaryReductionOp>(reduce),
164 std::forward<UnaryTransformOp>(transform));
168
169
170
171
172
173
174
175template <
class Support,
class T,
class BinaryReductionOp,
class UnaryTransformOp>
177 Support
const& domain,
179 BinaryReductionOp&& reduce,
180 UnaryTransformOp&& transform)
noexcept
182 return detail::device_transform_reduce_serial(
184 detail::array(domain.extents()),
186 std::forward<BinaryReductionOp>(reduce),
187 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.