GrPPI  0.3.1
Generic and Reusable Parallel Pattern Interface
stencil.h
Go to the documentation of this file.
1 
21 #ifndef GRPPI_STENCIL_H
22 #define GRPPI_STENCIL_H
23 
24 #include <tuple>
25 #include <utility>
26 
28 #include "common/iterator_traits.h"
29 
30 namespace grppi {
31 
55 template <typename Execution, typename ...InputIterators, typename OutputIt,
56  typename StencilTransformer, typename Neighbourhood,
57  requires_iterators<InputIterators...> = 0,
58  requires_iterator<OutputIt> = 0>
59 void stencil(
60  const Execution & ex,
61  std::tuple<InputIterators...> firsts, std::size_t size, OutputIt out,
62  StencilTransformer && transform_op,
63  Neighbourhood && neighbour_op)
64 {
65  static_assert(supports_stencil<Execution>(),
66  "stencil not supported for execution type");
67  ex.stencil(firsts, out, size,
68  std::forward<StencilTransformer>(transform_op),
69  std::forward<Neighbourhood>(neighbour_op));
70 }
71 
88 template <typename Execution, typename ...InputIterators,
89  typename InputIt, typename OutputIt,
90  typename StencilTransformer, typename Neighbourhood,
91  requires_iterators<InputIterators...> = 0,
94 void stencil(
95  const Execution & ex,
96  std::tuple<InputIterators...> firsts, InputIt last, OutputIt out,
97  StencilTransformer && transform_op,
98  Neighbourhood && neighbour_op)
99 {
100  static_assert(supports_stencil<Execution>(),
101  "stencil not supported for execution type");
102  ex.stencil(firsts, out,
103  std::distance(std::get<0>(firsts),last),
104  std::forward<StencilTransformer>(transform_op),
105  std::forward<Neighbourhood>(neighbour_op));
106 }
107 
123 template <typename Execution, typename InputIt, typename OutputIt,
124  typename StencilTransformer, typename Neighbourhood,
127 void stencil(
128  const Execution & ex,
129  InputIt first, InputIt last, OutputIt out,
130  StencilTransformer && transform_op,
131  Neighbourhood && neighbour_op)
132 {
133  static_assert(supports_stencil<Execution>(),
134  "stencil not supported for execution type");
135  ex.stencil(std::make_tuple(first), out,
136  std::distance(first,last),
137  std::forward<StencilTransformer>(transform_op),
138  std::forward<Neighbourhood>(neighbour_op));
139 }
140 
158 template <typename Execution, typename InputIt, typename OutputIt,
159  typename StencilTransformer, typename Neighbourhood,
160  typename ... OtherInputIts,
161  requires_iterator<InputIt> = 0,
163 [[deprecated("This version of the interface is deprecated.\n"
164  "If you want to use multiple inputs, use a tuple instead.")]]
165 void stencil(
166  const Execution & ex,
167  InputIt first, InputIt last, OutputIt out,
168  StencilTransformer && transform_op,
169  Neighbourhood && neighbour_op,
170  OtherInputIts ... other_firsts)
171 {
172  static_assert(supports_stencil<Execution>(),
173  "stencil not supported for execution type");
174  ex.stencil(std::make_tuple(first,other_firsts...), out,
175  std::distance(first,last),
176  std::forward<StencilTransformer>(transform_op),
177  std::forward<Neighbourhood>(neighbour_op));
178 }
179 
185 }
186 
187 #endif
Definition: callable_traits.h:26
void stencil(const Execution &ex, std::tuple< InputIterators... > firsts, std::size_t size, OutputIt out, StencilTransformer &&transform_op, Neighbourhood &&neighbour_op)
Invoke Stencil pattern on a data sequence with sequential execution.
Definition: stencil.h:59
std::enable_if_t< are_iterators< T... >, int > requires_iterators
Definition: iterator_traits.h:64
std::enable_if_t< is_iterator< T >, int > requires_iterator
Definition: iterator_traits.h:58