15 #ifndef STXXL_PARALLEL_HEADER
16 #define STXXL_PARALLEL_HEADER
30 #if defined(_GLIBCXX_PARALLEL)
32 #define _STXXL_FORCE_SEQUENTIAL , __gnu_parallel::sequential_tag()
34 #define _STXXL_FORCE_SEQUENTIAL
39 #define _STXXL_SORT_TRIGGER_FORCE_SEQUENTIAL _STXXL_FORCE_SEQUENTIAL
42 #define _STXXL_SORT_TRIGGER_FORCE_SEQUENTIAL
46 #undef STXXL_PARALLEL_MULTIWAY_MERGE
47 #define STXXL_PARALLEL_MULTIWAY_MERGE 0
50 #if defined(STXXL_PARALLEL_MODE) && ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) < 40400)
51 #undef STXXL_PARALLEL_MULTIWAY_MERGE
52 #define STXXL_PARALLEL_MULTIWAY_MERGE 0
55 #if !defined(STXXL_PARALLEL_MULTIWAY_MERGE)
56 #define STXXL_PARALLEL_MULTIWAY_MERGE 1
59 #if !defined(STXXL_NOT_CONSIDER_SORT_MEMORY_OVERHEAD)
60 #define STXXL_NOT_CONSIDER_SORT_MEMORY_OVERHEAD 0
63 #if STXXL_WITH_GNU_PARALLEL
64 #include <parallel/algorithm>
75 #if STXXL_PARALLEL && !STXXL_NOT_CONSIDER_SORT_MEMORY_OVERHEAD && defined(STXXL_PARALLEL_MODE)
76 return (__gnu_parallel::_Settings::get().sort_algorithm == __gnu_parallel::MWMS && omp_get_max_threads() > 1) ? 2 : 1;
84 #if STXXL_PARALLEL && defined(STXXL_PARALLEL_MODE) && !defined(STXXL_NO_WARN_OMP_NESTED)
85 static bool did_warn =
false;
87 if (__gnu_parallel::_Settings::get().sort_algorithm != __gnu_parallel::MWMS) {
88 if (omp_get_max_threads() <= 2) {
91 else if (!omp_get_nested()) {
92 STXXL_ERRMSG(
"Inefficient settings detected. To get full potential from your CPU it is recommended to set OMP_NESTED=TRUE in the environment.");
104 #if STXXL_PARALLEL_MULTIWAY_MERGE && defined(STXXL_PARALLEL_MODE)
114 namespace potentially_parallel {
116 #if STXXL_WITH_GNU_PARALLEL
141 template <
typename RandomAccessIteratorPairIterator,
142 typename RandomAccessIterator3,
typename DiffType,
typename Comparator>
143 RandomAccessIterator3
145 RandomAccessIteratorPairIterator seqs_end,
146 RandomAccessIterator3 target, DiffType length,
151 seqs_begin, seqs_end, target, length, comp);
153 return stxxl::parallel::sequential_multiway_merge<false, false>(
154 seqs_begin, seqs_end, target, length, comp);
166 template <
typename RandomAccessIteratorPairIterator,
167 typename RandomAccessIterator3,
typename DiffType,
typename Comparator>
168 RandomAccessIterator3
170 RandomAccessIteratorPairIterator seqs_end,
171 RandomAccessIterator3 target, DiffType length,
176 seqs_begin, seqs_end, target, length, comp);
178 return stxxl::parallel::sequential_multiway_merge<true, false>(
179 seqs_begin, seqs_end, target, length, comp);
192 template <
typename RandomAccessIteratorPairIterator,
193 typename RandomAccessIterator3,
typename DiffType,
typename Comparator>
194 RandomAccessIterator3
196 RandomAccessIteratorPairIterator seqs_end,
197 RandomAccessIterator3 target, DiffType length,
202 seqs_begin, seqs_end, target, length, comp);
204 return stxxl::parallel::sequential_multiway_merge<false, true>(
205 seqs_begin, seqs_end, target, length, comp);
218 template <
typename RandomAccessIteratorPairIterator,
219 typename RandomAccessIterator3,
typename DiffType,
typename Comparator>
220 RandomAccessIterator3
222 RandomAccessIteratorPairIterator seqs_end,
223 RandomAccessIterator3 target, DiffType length,
228 seqs_begin, seqs_end, target, length, comp);
230 return stxxl::parallel::sequential_multiway_merge<true, true>(
231 seqs_begin, seqs_end, target, length, comp);
239 #endif // !STXXL_PARALLEL_HEADER
RandomAccessIterator3 multiway_merge_stable_sentinels(RandomAccessIteratorPairIterator seqs_begin, RandomAccessIteratorPairIterator seqs_end, RandomAccessIterator3 target, DiffType length, Comparator comp)
Multi-way merging front-end.
unsigned sort_memory_usage_factor()
void sort(ExtIterator first, ExtIterator last, StrictWeakOrdering cmp, unsigned_type M)
Sort records comparison-based, see stxxl::sort -- Sorting Comparison-Based.
RandomAccessIterator3 multiway_merge(RandomAccessIteratorPairIterator seqs_begin, RandomAccessIteratorPairIterator seqs_end, RandomAccessIterator3 target, DiffType length, Comparator comp)
Multi-way merging dispatcher.
void check_sort_settings()
RandomAccessIterator3 multiway_merge_sentinels(RandomAccessIteratorPairIterator seqs_begin, RandomAccessIteratorPairIterator seqs_end, RandomAccessIterator3 target, DiffType length, Comparator comp)
Multi-way merging front-end.
void random_shuffle(ExtIterator first, ExtIterator last, RandomNumberGenerator &rand, unsigned_type M, AllocStrategy AS=STXXL_DEFAULT_ALLOC_STRATEGY())
External equivalent of std::random_shuffle.
RandomAccessIterator3 multiway_merge_stable(RandomAccessIteratorPairIterator seqs_begin, RandomAccessIteratorPairIterator seqs_end, RandomAccessIterator3 target, DiffType length, Comparator comp)
Multi-way merging dispatcher.
#define STXXL_BEGIN_NAMESPACE
Provides a static class to store runtime tuning parameters.
#define STXXL_END_NAMESPACE