41template <
typename ExecSpace,
typename Functor,
42 std::enable_if_t<std::is_same_v<ExecSpace, NektarSpaces::Serial> ||
43 std::is_same_v<ExecSpace, NektarSpaces::AVX>,
47 const Functor &functor)
49 for (
size_t i = begin; i < end; ++i)
56template <
typename ExecSpace,
bool init,
typename Reduction,
typename Functor,
57 std::enable_if_t<std::is_same_v<ExecSpace, NektarSpaces::Serial> ||
58 std::is_same_v<ExecSpace, NektarSpaces::AVX>,
62 const Functor &functor,
63 typename Reduction::value_type *red)
67 *red = reduce_identity<Reduction>();
70 for (
size_t i = begin; i < end; ++i)
72 *red = reduce_join<Reduction>(*red, functor(i));
77template <
typename ExecSpace,
typename Reduction,
typename Functor,
78 std::enable_if_t<std::is_same_v<ExecSpace, NektarSpaces::Serial> ||
79 std::is_same_v<ExecSpace, NektarSpaces::AVX>,
83 const Functor &functor,
84 typename Reduction::value_type &red)
86 parallel_reduce<ExecSpace, true, Reduction>(begin, end, functor, &red);
93template <
typename ExecSpace,
bool init,
typename Reduction,
unsigned int nred,
95 std::enable_if_t<std::is_same_v<ExecSpace, NektarSpaces::Serial> ||
96 std::is_same_v<ExecSpace, NektarSpaces::AVX>,
100 const Functor &functor,
101 typename Reduction::value_type *red)
103 using TData =
typename Reduction::value_type;
106 "parallel_reduce: too many values.");
109 for (
unsigned int s = 0; s < nred; ++s)
111 acc[s] = reduce_identity<Reduction>();
114 for (
size_t i = begin; i < end; ++i)
118 for (
unsigned int s = 0; s < nred; ++s)
120 acc[s] = reduce_join<Reduction>(acc[s], vals[s]);
124 for (
unsigned int s = 0; s < nred; ++s)
126 red[s] = init ? acc[s] : reduce_join<Reduction>(red[s], acc[s]);
void parallel_for(const size_t begin, const size_t end, const Functor &functor)
void parallel_reduce(const size_t begin, const size_t end, const Functor &functor, typename Reduction::value_type *red)
constexpr unsigned int internalReductionMaxValues