10 template <
typename T,
typename Counter = std::
size_t>
12 static_assert(std::is_arithmetic_v<T>);
22 if (lowest_ <= x && x <= highest_) {
23 auto delta = (highest_ - lowest_) / n_bins_;
24 std::size_t key = (x - lowest_) / delta;
34 [](
const Counter& c1,
const Counter& c2) { return c1 + c2; });
48 value_type lowest_ = std::numeric_limits<value_type>::lowest();
70 template <
typename T,
typename BinaryOp>
85 [&](
auto&& x,
const auto& y) { x = bop_(x, y); });
99 [&](
const auto& x,
auto&& y) { y = bop_(x, y); });
108 static constexpr
auto bop_ = BinaryOp();
111 template <
typename T>
114 template <
typename T>
117 template <
typename T>
120 template <
typename T>
123 ITYR_TEST_CASE(
"[ityr::reducer] extra reducer test") {
129 int n_samples = 100000;
137 double x = (static_cast<double>(i) + 0.5) / n_bins;
138 return x - static_cast<int>(x);
154 ITYR_CHECK(count == n_samples / n_bins);
199 [=](
int x) { ITYR_CHECK(x == n * (n - 1) / 2); });
Count iterator.
Definition: count_iterator.hpp:33
Global vector to manage a global memory region.
Definition: global_vector.hpp:129
iterator begin() noexcept
Definition: global_vector.hpp:233
size_type size() const noexcept
Definition: global_vector.hpp:228
bool empty() const noexcept
Definition: global_vector.hpp:274
iterator insert(const_iterator position, const T &x)
Definition: global_vector.hpp:333
iterator end() noexcept
Definition: global_vector.hpp:234
#define ITYR_SUBCASE(name)
Definition: util.hpp:41
#define ITYR_CHECK(cond)
Definition: util.hpp:48
constexpr read_write_t read_write
Read+Write checkout mode.
Definition: checkout_span.hpp:39
constexpr read_t read
Read-only checkout mode.
Definition: checkout_span.hpp:19
constexpr parallel_policy par
Default parallel execution policy for iterator-based loop functions.
Definition: execution.hpp:89
void fini()
Definition: ito.hpp:45
void init(MPI_Comm comm=MPI_COMM_WORLD)
Definition: ito.hpp:41
void fini()
Definition: ori.hpp:49
void init(MPI_Comm comm=MPI_COMM_WORLD)
Definition: ori.hpp:45
Definition: reducer.hpp:5
monoid< T, max_functor<>, lowest< T > > max
Definition: reducer.hpp:104
ForwardIteratorD copy(const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIteratorD first_d)
Copy a range to another.
Definition: parallel_loop.hpp:856
ForwardIteratorD transform(const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIteratorD first_d, UnaryOp unary_op)
Transform elements in a given range and store them in another range.
Definition: parallel_loop.hpp:583
void for_each(const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last, Op op)
Apply an operator to each element in a range.
Definition: parallel_loop.hpp:136
auto root_exec(Fn &&fn, Args &&... args)
Spawn the root thread (collective).
Definition: root_exec.hpp:47
Reducer::accumulator_type transform_reduce(const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last, Reducer reducer, UnaryTransformOp unary_transform_op)
Calculate reduction while transforming each element.
Definition: parallel_reduce.hpp:167
Reducer::accumulator_type reduce(const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last, Reducer reducer)
Calculate reduction.
Definition: parallel_reduce.hpp:340
global_iterator< T, Mode > make_global_iterator(ori::global_ptr< T > gptr, Mode)
Make a global iterator to enable/disable automatic checkout.
Definition: global_iterator.hpp:158
global_move_iterator< global_iterator< T, internal::src_checkout_mode_t< T > > > make_move_iterator(ori::global_ptr< T > gptr)
Make a global iterator for moving objects.
Definition: global_iterator.hpp:258
ForwardIteratorD move(const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIteratorD first_d)
Move a range to another.
Definition: parallel_loop.hpp:934
Parallel execution policy for iterator-based loop functions.
Definition: execution.hpp:36
Serial execution policy for iterator-based loop functions.
Definition: execution.hpp:16
Options for ityr::global_vector.
Definition: global_vector.hpp:18
Definition: reducer.hpp:56
Definition: reducer_extra.hpp:11
histogram(std::size_t n_bins, const value_type &lowest, const value_type &highest)
Definition: reducer_extra.hpp:18
T value_type
Definition: reducer_extra.hpp:14
histogram(std::size_t n_bins)
Definition: reducer_extra.hpp:17
void operator()(accumulator_type &acc, const value_type &x) const
Definition: reducer_extra.hpp:21
void operator()(accumulator_type &acc_l, const accumulator_type &acc_r) const
Definition: reducer_extra.hpp:30
accumulator_type operator()() const
Definition: reducer_extra.hpp:42
void operator()(const accumulator_type &acc_l, accumulator_type &acc_r) const
Definition: reducer_extra.hpp:37
Definition: reducer.hpp:47
Definition: reducer_extra.hpp:53
accumulator_type operator()() const
Definition: reducer_extra.hpp:65
void operator()(accumulator_type &&acc_l, accumulator_type &acc_r) const
Definition: reducer_extra.hpp:61
void operator()(accumulator_type &acc_l, accumulator_type &&acc_r) const
Definition: reducer_extra.hpp:57
Definition: reducer_extra.hpp:71
void operator()(accumulator_type &&acc_l, accumulator_type &acc_r) const
Definition: reducer_extra.hpp:89
void operator()(accumulator_type &acc_l, value_type &&acc_r) const
Definition: reducer_extra.hpp:75
accumulator_type operator()() const
Definition: reducer_extra.hpp:103