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
46 #if defined(_GLIBCXX_PARALLEL)
48 #define _STXXL_FORCE_SEQUENTIAL , __gnu_parallel::sequential_tag()
50 #define _STXXL_FORCE_SEQUENTIAL
55 #define _STXXL_SORT_TRIGGER_FORCE_SEQUENTIAL _STXXL_FORCE_SEQUENTIAL
58 #define _STXXL_SORT_TRIGGER_FORCE_SEQUENTIAL
62 #undef STXXL_PARALLEL_MULTIWAY_MERGE
63 #define STXXL_PARALLEL_MULTIWAY_MERGE 0
66 #if defined(STXXL_PARALLEL_MODE) && ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) < 40400)
67 #undef STXXL_PARALLEL_MULTIWAY_MERGE
68 #define STXXL_PARALLEL_MULTIWAY_MERGE 0
71 #if !defined(STXXL_PARALLEL_MULTIWAY_MERGE)
72 #define STXXL_PARALLEL_MULTIWAY_MERGE 1
75 #if !defined(STXXL_NOT_CONSIDER_SORT_MEMORY_OVERHEAD)
76 #define STXXL_NOT_CONSIDER_SORT_MEMORY_OVERHEAD 0
79 #if STXXL_PARALLEL_MODE_EXPLICIT
80 #include <parallel/algorithm>
89 #if STXXL_PARALLEL && !STXXL_NOT_CONSIDER_SORT_MEMORY_OVERHEAD && defined(STXXL_PARALLEL_MODE)
90 return (__gnu_parallel::_Settings::get().sort_algorithm == __gnu_parallel::MWMS && omp_get_max_threads() > 1) ? 2 : 1;
98 #if STXXL_PARALLEL && defined(STXXL_PARALLEL_MODE) && !defined(STXXL_NO_WARN_OMP_NESTED)
99 static bool did_warn =
false;
101 if (__gnu_parallel::_Settings::get().sort_algorithm != __gnu_parallel::MWMS) {
102 if (omp_get_max_threads() <= 2) {
104 }
else if (!omp_get_nested()) {
105 STXXL_ERRMSG(
"Inefficient settings detected. To get full potential from your CPU it is recommended to set OMP_NESTED=TRUE in the environment.");
117 #if STXXL_PARALLEL_MULTIWAY_MERGE && defined(STXXL_PARALLEL_MODE)
124 namespace potentially_parallel {
126 #if STXXL_PARALLEL_MODE_EXPLICIT
148 template <
typename RandomAccessIteratorPairIterator,
149 typename RandomAccessIterator3,
typename DiffType,
typename Comparator>
150 RandomAccessIterator3
151 multiway_merge(RandomAccessIteratorPairIterator seqs_begin,
152 RandomAccessIteratorPairIterator seqs_end,
153 RandomAccessIterator3 target,
157 #if defined(STXXL_PARALLEL_MODE) && ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40400)
158 return __gnu_parallel::multiway_merge(seqs_begin, seqs_end, target, length, comp);
159 #elif defined(STXXL_PARALLEL_MODE)
160 return __gnu_parallel::multiway_merge(seqs_begin, seqs_end, target, comp, length);
162 #error "no implementation found for multiway_merge()"
175 template <
typename RandomAccessIteratorPairIterator,
176 typename RandomAccessIterator3,
typename DiffType,
typename Comparator>
177 RandomAccessIterator3
178 multiway_merge_sentinel(RandomAccessIteratorPairIterator seqs_begin,
179 RandomAccessIteratorPairIterator seqs_end,
180 RandomAccessIterator3 target,
184 #if defined(STXXL_PARALLEL_MODE) && ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40400)
185 return __gnu_parallel::multiway_merge_sentinels(seqs_begin, seqs_end, target, length, comp);
186 #elif defined(STXXL_PARALLEL_MODE)
187 return __gnu_parallel::multiway_merge_sentinels(seqs_begin, seqs_end, target, comp, length);
189 #error "no implementation found for multiway_merge_sentinel()"
199 #endif // !STXXL_PARALLEL_HEADER
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.
void check_sort_settings()
void random_shuffle(ExtIterator first, ExtIterator last, RandomNumberGenerator &rand, unsigned_type M, AllocStrategy AS=STXXL_DEFAULT_ALLOC_STRATEGY())
External equivalent of std::random_shuffle.
#define STXXL_BEGIN_NAMESPACE
Provides a static class to store runtime tuning parameters.
#define STXXL_END_NAMESPACE