21 #ifndef GRPPI_NATIVE_STENCIL_H 22 #define GRPPI_NATIVE_STENCIL_H 25 #include "../common/iterator.h" 51 template <
typename InputIt,
typename OutputIt,
typename StencilTransformer,
52 typename Neighbourhood>
54 InputIt first, InputIt last, OutputIt first_out,
55 StencilTransformer transform_op, Neighbourhood neighbour_op)
60 int size = distance(first,last);
64 auto begin = first + (elements_per_thread * i);
67 next(first, elements_per_thread * (i+1));
69 auto out = first_out + (elements_per_thread * i);
71 tasks.emplace_back([&](InputIt begin, InputIt end, OutputIt out) {
75 *out = transform_op(begin, neighbour_op(begin));
83 auto end = first + elements_per_thread;
85 *first_out = transform_op(first, neighbour_op(first));
90 for (
auto && t : tasks) { t.join(); }
109 template <
typename InputIt,
typename OutputIt,
typename StencilTransformer,
110 typename Neighbourhood,
typename ... OtherInputIts>
112 InputIt first, InputIt last, OutputIt first_out,
113 StencilTransformer transform_op, Neighbourhood neighbour_op,
114 OtherInputIts ... other_firsts )
118 vector<thread> tasks;
119 int size = last - first;
123 auto begin = first + (elements_per_thread * i);
126 first + elements_per_thread * (i+1);
128 auto out = first_out + (elements_per_thread * i);
131 [&](InputIt begin, InputIt end, OutputIt out,
int i,
int n, OtherInputIts ... other_firsts){
136 *out = transform_op(begin, neighbour_op(begin,other_firsts...));
142 begin, end, out, i, elements_per_thread,other_firsts ...);
145 auto end = first + elements_per_thread;
147 *first_out = transform_op(*first, neighbour_op(first,other_firsts...));
154 for (
auto && t : tasks) { t.join(); }
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
int concurrency_degree() const noexcept
Get number of grppi trheads.
Definition: parallel_execution_native.h:178
Native parallel execution policy. This policy uses ISO C++ threads as implementation building block a...
Definition: parallel_execution_native.h:136
native_thread_manager thread_manager()
Get a manager object for registration/deregistration in the thread index table for current thread...
Definition: parallel_execution_native.h:199
void advance_iterators(size_t delta, InputIt &...in)
Definition: iterator.h:29