9#include "detail/macros.hpp"
11#include "discrete_element.hpp"
18
19
20
21
22
23
24
25
31 class BinaryReductionOp,
32 class UnaryTransformOp,
34T host_transform_reduce_serial(
35 Support
const& domain,
36 std::array<Element, N>
const& size,
37 [[maybe_unused]] T
const neutral,
38 BinaryReductionOp
const& reduce,
39 UnaryTransformOp
const& transform,
40 Is
const&... is)
noexcept
42 DDC_IF_NVCC_THEN_PUSH_AND_SUPPRESS(implicit_return_from_non_void_function)
43 static constexpr std::size_t I =
sizeof...(Is);
44 if constexpr (I == N) {
45 return transform(domain(
typename Support::discrete_vector_type(is...)));
48 for (Element ii = 0; ii < size[I]; ++ii) {
50 host_transform_reduce_serial(
66
67
68
69
70
71
72
73
79 class BinaryReductionOp,
80 class UnaryTransformOp,
82KOKKOS_FUNCTION T device_transform_reduce_serial(
83 Support
const& domain,
84 std::array<Element, N>
const& size,
85 [[maybe_unused]] T
const neutral,
86 BinaryReductionOp
const& reduce,
87 UnaryTransformOp
const& transform,
88 Is
const&... is)
noexcept
90 DDC_IF_NVCC_THEN_PUSH_AND_SUPPRESS(implicit_return_from_non_void_function)
91 static constexpr std::size_t I =
sizeof...(Is);
92 if constexpr (I == N) {
93 return transform(domain(
typename Support::discrete_vector_type(is...)));
96 for (Element ii = 0; ii < size[I]; ++ii) {
98 device_transform_reduce_serial(
115#if defined(DDC_BUILD_DEPRECATED_CODE)
117
118
119
120
121
122
123
125[[
deprecated(
"Use host_transform_reduce instead")]]
141
142
143
144
145
146
147
148template <
class Support,
class T,
class BinaryReductionOp,
class UnaryTransformOp>
150 Support
const& domain,
152 BinaryReductionOp&& reduce,
153 UnaryTransformOp&& transform)
noexcept
155 return detail::host_transform_reduce_serial(
157 detail::array(domain.extents()),
159 std::forward<BinaryReductionOp>(reduce),
160 std::forward<UnaryTransformOp>(transform));
164
165
166
167
168
169
170
171template <
class Support,
class T,
class BinaryReductionOp,
class UnaryTransformOp>
173 Support
const& domain,
175 BinaryReductionOp&& reduce,
176 UnaryTransformOp&& transform)
noexcept
178 return detail::device_transform_reduce_serial(
180 detail::array(domain.extents()),
182 std::forward<BinaryReductionOp>(reduce),
183 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.