GrPPI  0.2
Generic and Reusable Parallel Pattern Interface
poly/stream_reduce.h
Go to the documentation of this file.
1 
21 #ifndef GRPPI_POLY_STREAM_REDUCE_H
22 #define GRPPI_POLY_STREAM_REDUCE_H
23 
24 #include "polymorphic_execution.h"
25 #include "../common/support.h"
26 
27 namespace grppi {
28 
29 template <typename Identity, typename Combiner, typename Consumer, typename Generator>
30 void stream_reduce_multi_impl(polymorphic_execution & ex, int window_size, int offset,
31  Identity identity, Generator && generate_op,
32  Combiner && combine_op, Consumer && consume_op)
33 {
34 }
35 
36 template <typename E, typename ... O, typename Identity,
37  typename Generator, typename Combiner, typename Consumer,
39 void stream_reduce_multi_impl(polymorphic_execution & ex, int windowsize, int offset,
40  Identity identity, Generator && gen,
41  Combiner && comb, Consumer && cons)
42 {
43  stream_reduce_multi_impl<O...>(ex,
44  windowsize, offset, identity,
45  std::forward<Generator>(gen),
46  std::forward<Combiner>(comb),
47  std::forward<Consumer>(cons)
48  );
49 }
50 
51 template <typename E, typename ... O, typename Identity,
52  typename Generator, typename Combiner, typename Consumer,
54 void stream_reduce_multi_impl(polymorphic_execution & ex, int windowsize, int offset,
55  Identity identity, Generator && gen,
56  Combiner && comb, Consumer && cons)
57 {
58  if (typeid(E) == ex.type()) {
59  stream_reduce(*ex.execution_ptr<E>(),
60  windowsize, offset, identity,
61  std::forward<Generator>(gen),
62  std::forward<Combiner>(comb),
63  std::forward<Consumer>(cons)
64  );
65  }
66  else {
67  stream_reduce_multi_impl<O...>(ex,
68  windowsize, offset, identity,
69  std::forward<Generator>(gen),
70  std::forward<Combiner>(comb),
71  std::forward<Consumer>(cons)
72  );
73  }
74 }
75 
99 template <typename Identity, typename Generator, typename Combiner, typename Consumer>
101  int windowsize, int offset, Identity identity,
102  Generator && gen, Combiner && comb, Consumer && cons)
103 {
109  >(ex, windowsize, offset, identity,
110  std::forward<Generator>(gen),
111  std::forward<Combiner>(comb),
112  std::forward<Consumer>(cons)
113  );
114 }
115 
121 } // end namespace grppi
122 
123 #endif
Definition: callable_traits.h:24
Native parallel execution policy. This policy uses ISO C++ threads as implementation building block a...
Definition: parallel_execution_native.h:136
const std::type_info & type() const noexcept
Definition: polymorphic_execution.h:77
std::enable_if_t< is_supported< E >(), int > requires_execution_supported
Definition: support.h:32
OpenMP parallel execution policy.
Definition: parallel_execution_omp.h:40
TBB parallel execution policy.
Definition: parallel_execution_tbb.h:37
E * execution_ptr()
Get the execution pointer for a given type.
Definition: polymorphic_execution.h:91
Sequential execution policy.
Definition: sequential_execution.h:31
Definition: polymorphic_execution.h:63
std::enable_if_t<!is_supported< E >(), int > requires_execution_not_supported
Definition: support.h:36
void stream_reduce(parallel_execution_native &ex, int window_size, int offset, Identity identity, Generator &&generate_op, Combiner &&combine_op, Consumer &&consume_op)
Invoke Stream reduction pattern on a stream with native parallel execution.
Definition: native/stream_reduce.h:56
void stream_reduce_multi_impl(polymorphic_execution &ex, int window_size, int offset, Identity identity, Generator &&generate_op, Combiner &&combine_op, Consumer &&consume_op)
Definition: poly/stream_reduce.h:30