21 #ifndef GRPPI_NATIVE_MAP_H 22 #define GRPPI_NATIVE_MAP_H 25 #include "../common/iterator.h" 49 template <
typename InputIt,
typename OutputIt,
typename Transformer>
51 InputIt first, InputIt last, OutputIt first_out,
52 Transformer && transf_op)
54 std::vector<std::thread> tasks;
55 int numElements = last - first;
59 auto begin = first + (elemperthr * i);
60 auto end = first + (elemperthr * (i+1));
64 auto out = first_out + (elemperthr * i);
65 tasks.emplace_back([&](InputIt begin, InputIt end, OutputIt out) {
69 *out = transf_op(*begin);
76 auto end = first+elemperthr;
78 *first_out = transf_op(*first);
103 template <
typename InputIt,
typename OutputIt,
typename Transformer,
104 typename ... OtherInputIts>
106 InputIt first, InputIt last, OutputIt first_out,
107 Transformer && transf_op,
108 OtherInputIts ... more_inputs)
110 std::vector<std::thread> tasks;
113 int numElements = last - first;
119 auto begin = first + (elemperthr * i);
120 auto end = first + (elemperthr * (i+1));
122 auto out = first_out + (elemperthr * i);
124 tasks.emplace_back([&](InputIt begin, InputIt end, OutputIt out,
125 int tid,
int nelem, OtherInputIts ... more_inputs) {
129 *out = transf_op(*begin, *more_inputs ...);
134 }, begin, end, out, i, elemperthr, more_inputs...);
139 auto end = first + elemperthr;
141 *first_out = transf_op(*first, *more_inputs ...);
Definition: callable_traits.h:24
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
void map(parallel_execution_native &ex, InputIt first, InputIt last, OutputIt first_out, Transformer &&transf_op)
Invoke Map pattern on a data sequence with native paralell execution.
Definition: native/map.h:50