21 #ifndef GRPPI_OMP_REDUCE_H 22 #define GRPPI_OMP_REDUCE_H 51 template <
typename InputIt,
typename Identity,
typename Combiner>
53 InputIt first, InputIt last,
55 Combiner && combine_op)
57 int numElements = last - first;
59 auto identityVal = identity;
61 std::vector<typename std::iterator_traits<InputIt>::value_type> out(ex.
concurrency_degree());
65 #pragma omp single nowait 69 auto begin = first + (elemperthr * i);
70 auto end = first + (elemperthr * (i+1));
73 #pragma omp task firstprivate (begin, end,i) 76 while( begin != end ) {
77 out[i] = combine_op(*begin, out[i] );
85 auto end = first + elemperthr;
88 out[0] = combine_op(*first , out[0]);
97 for(
unsigned int i = 1; i < out.size(); i++){
98 outVal = combine_op(outVal, out[i]);
Definition: callable_traits.h:24
OpenMP parallel execution policy.
Definition: parallel_execution_omp.h:40
int concurrency_degree() const noexcept
Get number of grppi trheads.
Definition: parallel_execution_omp.h:85
auto reduce(parallel_execution_native &ex, InputIt first, InputIt last, Identity identity, Combiner &&combine_op)
Invoke Reduce pattern with identity value on a data sequence with parallel native execution...
Definition: native/reduce.h:51