21 #ifndef GRPPI_TBB_STENCIL_H 22 #define GRPPI_TBB_STENCIL_H 32 template <
typename InputIt,
typename OutputIt,
typename StencilTransformer,
33 typename Neighbourhood,
typename ... OtherInputIts>
35 int elements_per_thread,
int index,
36 InputIt first, InputIt last, OutputIt first_out,
37 StencilTransformer transform_op, Neighbourhood neighbour_op,
38 OtherInputIts ... other_firsts){
39 auto begin = next(first, elements_per_thread * index);
42 next(first, elements_per_thread * (index+1));
43 auto out = next(first_out, elements_per_thread * index);
46 *out = transform_op(begin, neighbour_op(begin, other_firsts ...));
76 template <
typename InputIt,
typename OutputIt,
typename StencilTransformer,
77 typename Neighbourhood>
79 InputIt first, InputIt last, OutputIt first_out,
80 StencilTransformer transform_op,
81 Neighbourhood neighbour_op)
83 int size = last - first;
89 [&neighbour_op, &transform_op, first, first_out, elements_per_thread,
91 auto begin = first + (elements_per_thread * i);
94 next(first, elements_per_thread * (i+1));
96 auto out = next(first_out, elements_per_thread * i);
98 *out = transform_op(begin, neighbour_op(begin));
106 auto end = first + elements_per_thread;
108 *first_out = transform_op(first, neighbour_op(first));
132 template <
typename InputIt,
typename OutputIt,
typename StencilTransformer,
133 typename Neighbourhood,
typename ... OtherInputIts>
135 InputIt first, InputIt last, OutputIt first_out,
136 StencilTransformer transform_op, Neighbourhood neighbour_op,
137 OtherInputIts ... other_firsts )
139 int size = distance(first,last);
144 [neighbour_op, transform_op, first, first_out, elements_per_thread,
145 index, last, &ex, other_firsts...]()
147 stencil_impl(ex, elements_per_thread, index,
148 first, last, first_out, transform_op,
149 neighbour_op, other_firsts...);
154 auto end = next(first, elements_per_thread);
156 *first_out = transform_op(first, neighbour_op(first,other_firsts ...));
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
TBB parallel execution policy.
Definition: parallel_execution_tbb.h:37
void advance_iterators(size_t delta, InputIt &...in)
Definition: iterator.h:29
void stencil_impl(parallel_execution_tbb &ex, int elements_per_thread, int index, InputIt first, InputIt last, OutputIt first_out, StencilTransformer transform_op, Neighbourhood neighbour_op, OtherInputIts...other_firsts)
Definition: tbb/stencil.h:34
int concurrency_degree() const noexcept
Get number of grppi trheads.
Definition: parallel_execution_tbb.h:73