14 #ifndef STXXL_PARALLEL_HEADER
15 #define STXXL_PARALLEL_HEADER
20 #undef STXXL_PARALLEL_MODE
22 #if defined(_GLIBCXX_PARALLEL) || STXXL_PARALLEL_MODE_EXPLICIT
23 #define STXXL_PARALLEL_MODE
26 #if defined(STXXL_PARALLEL_MODE)
27 #define STXXL_PARALLEL 1
29 #define STXXL_PARALLEL 0
34 #ifdef STXXL_PARALLEL_MODE
47 #if defined(_GLIBCXX_PARALLEL)
49 #define _STXXL_FORCE_SEQUENTIAL , __gnu_parallel::sequential_tag()
51 #define _STXXL_FORCE_SEQUENTIAL
56 #define _STXXL_SORT_TRIGGER_FORCE_SEQUENTIAL _STXXL_FORCE_SEQUENTIAL
59 #define _STXXL_SORT_TRIGGER_FORCE_SEQUENTIAL
63 #undef STXXL_PARALLEL_MULTIWAY_MERGE
64 #define STXXL_PARALLEL_MULTIWAY_MERGE 0
67 #if defined(STXXL_PARALLEL_MODE) && ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) < 40400)
68 #undef STXXL_PARALLEL_MULTIWAY_MERGE
69 #define STXXL_PARALLEL_MULTIWAY_MERGE 0
72 #if !defined(STXXL_PARALLEL_MULTIWAY_MERGE)
73 #define STXXL_PARALLEL_MULTIWAY_MERGE 1
76 #if !defined(STXXL_NOT_CONSIDER_SORT_MEMORY_OVERHEAD)
77 #define STXXL_NOT_CONSIDER_SORT_MEMORY_OVERHEAD 0
80 #if STXXL_PARALLEL_MODE_EXPLICIT
81 #include <parallel/algorithm>
91 #if STXXL_PARALLEL && !STXXL_NOT_CONSIDER_SORT_MEMORY_OVERHEAD && defined(STXXL_PARALLEL_MODE)
92 return (__gnu_parallel::_Settings::get().sort_algorithm == __gnu_parallel::MWMS && omp_get_max_threads() > 1) ? 2 : 1;
100 #if STXXL_PARALLEL && defined(STXXL_PARALLEL_MODE) && !defined(STXXL_NO_WARN_OMP_NESTED)
101 static bool did_warn =
false;
103 if (__gnu_parallel::_Settings::get().sort_algorithm != __gnu_parallel::MWMS) {
104 if (omp_get_max_threads() <= 2) {
106 }
else if (!omp_get_nested()) {
107 STXXL_ERRMSG(
"Inefficient settings detected. To get full potential from your CPU it is recommended to set OMP_NESTED=TRUE in the environment.");
119 #if STXXL_PARALLEL_MULTIWAY_MERGE && defined(STXXL_PARALLEL_MODE)
127 namespace potentially_parallel {
129 #if STXXL_PARALLEL_MODE_EXPLICIT
151 template <
typename RandomAccessIteratorPairIterator,
152 typename RandomAccessIterator3,
typename DiffType,
typename Comparator>
153 RandomAccessIterator3
154 multiway_merge(RandomAccessIteratorPairIterator seqs_begin,
155 RandomAccessIteratorPairIterator seqs_end,
156 RandomAccessIterator3 target,
160 #if defined(STXXL_PARALLEL_MODE) && ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40400)
161 return __gnu_parallel::multiway_merge(seqs_begin, seqs_end, target, length, comp);
162 #elif defined(STXXL_PARALLEL_MODE)
163 return __gnu_parallel::multiway_merge(seqs_begin, seqs_end, target, comp, length);
165 #error "no implementation found for multiway_merge()"
178 template <
typename RandomAccessIteratorPairIterator,
179 typename RandomAccessIterator3,
typename DiffType,
typename Comparator>
180 RandomAccessIterator3
181 multiway_merge_sentinel(RandomAccessIteratorPairIterator seqs_begin,
182 RandomAccessIteratorPairIterator seqs_end,
183 RandomAccessIterator3 target,
187 #if defined(STXXL_PARALLEL_MODE) && ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40400)
188 return __gnu_parallel::multiway_merge_sentinels(seqs_begin, seqs_end, target, length, comp);
189 #elif defined(STXXL_PARALLEL_MODE)
190 return __gnu_parallel::multiway_merge_sentinels(seqs_begin, seqs_end, target, comp, length);
192 #error "no implementation found for multiway_merge_sentinel()"
202 #endif // !STXXL_PARALLEL_HEADER
unsigned sort_memory_usage_factor()
void random_shuffle(ExtIterator_ first, ExtIterator_ last, RandomNumberGenerator_ &rand, unsigned_type M, AllocStrategy_ AS=STXXL_DEFAULT_ALLOC_STRATEGY())
External equivalent of std::random_shuffle.
void sort(ExtIterator first, ExtIterator last, StrictWeakOrdering cmp, unsigned_type M)
Sort records comparison-based, see stxxl::sort -- Sorting Comparison-Based.
void check_sort_settings()
#define STXXL_BEGIN_NAMESPACE
Provides a static class to store runtime tuning parameters.
#define STXXL_END_NAMESPACE