GrPPI  0.2
Generic and Reusable Parallel Pattern Interface
poly/stencil.h
Go to the documentation of this file.
1 
21 #ifndef GRPPI_POLY_STENCIL_H
22 #define GRPPI_POLY_STENCIL_H
23 
24 #include "polymorphic_execution.h"
25 #include "../common/support.h"
26 
27 namespace grppi {
28 
29 template <typename InputIt, typename OutputIt, typename StencilTransformer, typename Neighbourhood>
30 void stencil_multi_impl(polymorphic_execution & e, InputIt first, InputIt last,
31  OutputIt first_out, StencilTransformer && op, Neighbourhood && neighbor)
32 {
33 }
34 
35 template <typename InputIt, typename OutputIt, typename StencilTransformer,
36  typename Neighbourhood, typename ... OtherInputIts>
37 void stencil_multi_impl(polymorphic_execution & e, InputIt first, InputIt last,
38  OutputIt first_out, StencilTransformer && op, Neighbourhood && neighbor,
39  OtherInputIts ... other_its)
40 {
41 }
42 
43 
44 
45 template <typename E, typename ... O,
46  typename InputIt, typename OutputIt, typename StencilTransformer, typename Neighbourhood,
48 void stencil_multi_impl(polymorphic_execution & e, InputIt first, InputIt last,
49  OutputIt first_out, StencilTransformer && op, Neighbourhood && neighbor)
50 {
51  stencil_multi_impl<O...>(e, first, last, first_out, std::forward<StencilTransformer>(op),
52  std::forward<Neighbourhood>(neighbor));
53 }
54 
55 template <typename E, typename ... O,
56  typename InputIt, typename OutputIt, typename StencilTransformer,
57  typename Neighbourhood, typename ... OtherInputIts,
58  internal::requires_execution_not_supported<E> = 0>
59 void stencil_multi_impl(polymorphic_execution & e, InputIt first, InputIt last,
60  OutputIt first_out, StencilTransformer && op, Neighbourhood && neighbor,
61  OtherInputIts ... other_its)
62 {
63  stencil_multi_impl<O...>(e, first, last, first_out, std::forward<StencilTransformer>(op),
64  std::forward<Neighbourhood>(neighbor), other_its...);
65 }
66 
67 
68 
69 template <typename E, typename ... O,
70  typename InputIt, typename OutputIt, typename StencilTransformer, typename Neighbourhood,
72 void stencil_multi_impl(polymorphic_execution & e, InputIt first, InputIt last,
73  OutputIt first_out, StencilTransformer && op, Neighbourhood && neighbor)
74 {
75  if (typeid(E) == e.type()) {
76  stencil(*e.execution_ptr<E>(),
77  first, last, first_out, std::forward<StencilTransformer>(op),
78  std::forward<Neighbourhood>(neighbor));
79  }
80  else {
81  stencil_multi_impl<O...>(e, first, last, first_out, std::forward<StencilTransformer>(op),
82  std::forward<Neighbourhood>(neighbor));
83  }
84 }
85 
86 template <typename E, typename ... O,
87  typename InputIt, typename OutputIt, typename StencilTransformer,
88  typename Neighbourhood, typename ... OtherInputIts,
89  internal::requires_execution_supported<E> = 0>
90 void stencil_multi_impl(polymorphic_execution & e, InputIt first, InputIt last,
91  OutputIt first_out, StencilTransformer && op, Neighbourhood && neighbor,
92  OtherInputIts ... other_its)
93 {
94  if (typeid(E) == e.type()) {
95  stencil(*e.execution_ptr<E>(),
96  first, last, first_out, std::forward<StencilTransformer>(op), std::forward<Neighbourhood>(neighbor),
97  other_its...);
98  }
99  else {
100  stencil_multi_impl<O...>(e, first, last, first_out, std::forward<StencilTransformer>(op),
101  std::forward<Neighbourhood>(neighbor), other_its...);
102  }
103 }
104 
127 template <typename InputIt, typename OutputIt, typename StencilTransformer,
128  typename Neighbourhood>
130  InputIt first, InputIt last, OutputIt first_out,
131  StencilTransformer && transform_op, Neighbourhood && neighbour_op)
132 {
138  >(ex, first, last, first_out,
139  std::forward<StencilTransformer>(transform_op),
140  std::forward<Neighbourhood>(neighbour_op));
141 }
142 
159 template <typename InputIt, typename OutputIt, typename StencilTransformer,
160  typename Neighbourhood, typename ... OtherInputIts>
162  InputIt first, InputIt last, OutputIt first_out,
163  StencilTransformer && transform_op, Neighbourhood && neighbour_op,
164  OtherInputIts ... other_its)
165 {
171  >(ex, first, last, first_out,
172  std::forward<StencilTransformer>(transform_op),
173  std::forward<Neighbourhood>(neighbour_op),
174  other_its...);
175 }
176 
182 } // end namespace grppi
183 
184 #endif
Definition: callable_traits.h:24
void stencil(parallel_execution_native &ex, InputIt first, InputIt last, OutputIt first_out, StencilTransformer transform_op, Neighbourhood neighbour_op)
Invoke Stencil pattern on a data sequence with native parallel execution.
Definition: native/stencil.h:53
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
void stencil_multi_impl(polymorphic_execution &e, InputIt first, InputIt last, OutputIt first_out, StencilTransformer &&op, Neighbourhood &&neighbor)
Definition: poly/stencil.h:30
std::enable_if_t<!is_supported< E >(), int > requires_execution_not_supported
Definition: support.h:36