GrPPI  0.2
Generic and Reusable Parallel Pattern Interface
poly/map.h
Go to the documentation of this file.
1 
21 #ifndef GRPPI_POLY_MAP_H
22 #define GRPPI_POLY_MAP_H
23 
24 #include "polymorphic_execution.h"
25 #include "../common/support.h"
26 
27 namespace grppi {
28 
29 template <typename InputIt, typename OutputIt, typename Transformer>
30 void map_multi_impl(polymorphic_execution & e, InputIt first, InputIt last,
31  OutputIt first_out, Transformer && op)
32 {
33 }
34 
35 template <typename InputIt, typename OutputIt, typename Transformer,
36  typename InputIt2, typename ... OtherInputIts>
37 void map_multi_impl(polymorphic_execution & e, InputIt first, InputIt last,
38  OutputIt first_out, Transformer && op, InputIt2 first2,
39  OtherInputIts ... more_firsts)
40 {
41 }
42 
43 template <typename E, typename ... O,
44  typename InputIt, typename OutputIt, typename Transformer,
46 void map_multi_impl(polymorphic_execution & e, InputIt first, InputIt last,
47  OutputIt first_out, Transformer && op)
48 {
49  map_multi_impl<O...>(e, first, last, first_out, std::forward<Transformer>(op));
50 }
51 
52 template <typename E, typename ... O,
53  typename InputIt, typename OutputIt, typename Transformer,
54  typename InputIt2, typename ... OtherInputIts,
55  internal::requires_execution_not_supported<E> = 0>
56 void map_multi_impl(polymorphic_execution & e, InputIt first, InputIt last,
57  OutputIt first_out, Transformer && op, InputIt2 first2,
58  OtherInputIts ... more_firsts)
59 {
60  map_multi_impl<O...>(e, first, last, first_out, std::forward<Transformer>(op),
61  first2, more_firsts...);
62 }
63 
64 
65 template <typename E, typename ... O,
66  typename InputIt, typename OutputIt, typename Transformer,
68 void map_multi_impl(polymorphic_execution & e, InputIt first, InputIt last,
69  OutputIt first_out, Transformer && op)
70 {
71  if (typeid(E) == e.type()) {
72  map(*e.execution_ptr<E>(),
73  first, last, first_out, std::forward<Transformer>(op));
74  }
75  else {
76  map_multi_impl<O...>(e, first, last, first_out, std::forward<Transformer>(op));
77  }
78 }
79 
80 template <typename E, typename ... O,
81  typename InputIt, typename OutputIt, typename Transformer,
82  typename InputIt2, typename ... OtherInputIts,
83  internal::requires_execution_supported<E> = 0>
84 void map_multi_impl(polymorphic_execution & e, InputIt first, InputIt last,
85  OutputIt first_out, Transformer && op, InputIt2 first2,
86  OtherInputIts ... more_firsts)
87 {
88  if (typeid(E) == e.type()) {
89  map(*e.execution_ptr<E>(),
90  first, last, first_out, std::forward<Transformer>(op), first2,
91  more_firsts...);
92  }
93  else {
94  map_multi_impl<O...>(e, first, last, first_out, std::forward<Transformer>(op),
95  first2, more_firsts...);
96  }
97 }
98 
119 template <typename InputIt, typename OutputIt, typename Transformer>
121  InputIt first, InputIt last, OutputIt first_out,
122  Transformer && transf_op)
123 {
129  >(ex, first, last, first_out, std::forward<Transformer>(transf_op));
130 }
131 
146 template <typename InputIt, typename OutputIt, typename InputIt2,
147  typename Transformer,
148  typename ... OtherInputIts>
149 void map(polymorphic_execution & ex, InputIt first, InputIt last,
150  OutputIt first_out, Transformer && op, InputIt2 first2, OtherInputIts ... more_firsts)
151 {
157  >(ex, first, last, first_out, std::forward<Transformer>(op), first2, more_firsts...);
158 }
159 
165 } // end namespace grppi
166 
167 #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
void map_multi_impl(polymorphic_execution &e, InputIt first, InputIt last, OutputIt first_out, Transformer &&op)
Definition: poly/map.h:30
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 map(parallel_execution_native &ex, InputIt first, InputIt last, OutputIt first_out, Transformer &&transf_op)
Invoke Map pattern on a data sequence with native paralell execution.
Definition: native/map.h:50