33 #ifndef _GLIBCXX_PARALLEL_PAR_LOOP_H
34 #define _GLIBCXX_PARALLEL_PAR_LOOP_H 1
62 template<
typename RandomAccessIterator,
69 RandomAccessIterator end,
70 Op o, Fu& f, Red r, Result base,
73 <RandomAccessIterator>::
74 difference_type bound)
77 typedef typename traits_type::difference_type difference_type;
78 const difference_type length = end - begin;
79 Result *thread_results;
83 __gnu_parallel::min<difference_type>(get_max_threads(), length);
85 # pragma omp parallel num_threads(num_threads)
89 num_threads = omp_get_num_threads();
90 thread_results =
static_cast<Result*
>(
91 ::operator
new(num_threads *
sizeof(Result)));
92 constructed =
new bool[num_threads];
98 Result* reduct =
static_cast<Result*
>(::operator
new(
sizeof(Result)));
106 new(reduct) Result(f(o, begin + start));
108 constructed[iam] =
true;
111 constructed[iam] =
false;
113 for (; start < stop; ++start)
114 *reduct = r(*reduct, f(o, begin + start));
116 thread_results[iam] = *reduct;
121 output = r(output, thread_results[i]);
125 f.finish_iterator = begin + length;
127 delete[] thread_results;
128 delete[] constructed;
Runtime settings and tuning parameters, heuristics to decide whether to use parallelized algorithms...
GNU parallel code for public use.
Sequential helper functions. This file is a GNU parallel extension to the Standard C++ Library...
difference_type equally_split_point(difference_type n, thread_index_t num_threads, thread_index_t thread_no)
Function to split a sequence into parts of almost equal size.
Op for_each_template_random_access_ed(RandomAccessIterator begin, RandomAccessIterator end, Op o, Fu &f, Red r, Result base, Result &output, typename std::iterator_traits< RandomAccessIterator >::difference_type bound)
Embarrassingly parallel algorithm for random access iterators, using hand-crafted parallelization by ...
uint16 thread_index_t
Unsigned integer to index a thread number. The maximum thread number (for each processor) must fit in...