21 #ifndef GRPPI_OMP_MAPREDUCE_H 22 #define GRPPI_OMP_MAPREDUCE_H 53 template <
typename InputIt,
typename Transformer,
typename Result,
56 InputIt first, InputIt last, Result identity,
57 Transformer && transform_op,
58 Combiner && combine_op)
61 Result result{identity};
66 #pragma omp single nowait 68 int num_elements = distance(first,last);
73 #pragma omp task firstprivate(i) 75 auto begin = next(first, elements_per_thread * i);
77 next(first, elements_per_thread * (i+1));
79 begin, end, partial_results[i],
80 std::forward<Transformer>(transform_op),
81 std::forward<Combiner>(combine_op));
86 first, first+elements_per_thread, partial_results[0],
87 std::forward<Transformer>(transform_op),
88 std::forward<Combiner>(combine_op));
93 for (
auto && p : partial_results){
94 result = combine_op(result, p);
Definition: callable_traits.h:24
Result map_reduce(parallel_execution_native &ex, InputIt first, InputIt last, Result identity, Transformer &&transform_op, Combiner &&combine_op)
Invoke Map/reduce pattern on a data sequence with native parallel execution.
Definition: native/mapreduce.h:53
OpenMP parallel execution policy.
Definition: parallel_execution_omp.h:40
Sequential execution policy.
Definition: sequential_execution.h:31
int concurrency_degree() const noexcept
Get number of grppi trheads.
Definition: parallel_execution_omp.h:85