/usr/include/stxxl/bits/parallel.h is in libstxxl-dev 1.3.1-5ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | /***************************************************************************
* include/stxxl/bits/parallel.h
*
* Part of the STXXL. See http://stxxl.sourceforge.net
*
* Copyright (C) 2008-2010 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
* Copyright (C) 2011 Johannes Singler <singler@kit.edu>
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
**************************************************************************/
#ifndef STXXL_PARALLEL_HEADER
#define STXXL_PARALLEL_HEADER
#undef STXXL_PARALLEL
#undef STXXL_PARALLEL_MODE
#if defined(_GLIBCXX_PARALLEL) || defined (STXXL_PARALLEL_MODE_EXPLICIT)
#define STXXL_PARALLEL_MODE
#endif
#if defined(PARALLEL_MODE) && defined (__MCSTL__)
#error (_GLIBCXX_PARALLEL or STXXL_PARALLEL_MODE_EXPLICIT) and __MCSTL__ are defined
#endif
#if defined(STXXL_PARALLEL_MODE) || defined (__MCSTL__)
#define STXXL_PARALLEL 1
#else
#define STXXL_PARALLEL 0
#endif
#include <cassert>
#ifdef STXXL_PARALLEL_MODE
#include <omp.h>
#endif
#ifdef __MCSTL__
#include <mcstl.h>
#include <bits/mcstl_multiway_merge.h>
#include <stxxl/bits/compat/type_traits.h>
#endif
#if STXXL_PARALLEL
#include <algorithm>
#endif
#include <stxxl/bits/namespace.h>
#include <stxxl/bits/common/settings.h>
#if defined(_GLIBCXX_PARALLEL)
//use _STXXL_FORCE_SEQUENTIAL to tag calls which are not worthwhile parallelizing
#define _STXXL_FORCE_SEQUENTIAL , __gnu_parallel::sequential_tag()
#elif defined(__MCSTL__)
#define _STXXL_FORCE_SEQUENTIAL , mcstl::sequential_tag()
#else
#define _STXXL_FORCE_SEQUENTIAL
#endif
#if 0
// sorting triggers is done sequentially
#define _STXXL_SORT_TRIGGER_FORCE_SEQUENTIAL _STXXL_FORCE_SEQUENTIAL
#else
// sorting triggers may be parallelized
#define _STXXL_SORT_TRIGGER_FORCE_SEQUENTIAL
#endif
#if !STXXL_PARALLEL
#undef STXXL_PARALLEL_MULTIWAY_MERGE
#define STXXL_PARALLEL_MULTIWAY_MERGE 0
#endif
#if defined(STXXL_PARALLEL_MODE) && ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) < 40400)
#undef STXXL_PARALLEL_MULTIWAY_MERGE
#define STXXL_PARALLEL_MULTIWAY_MERGE 0
#endif
#if !defined(STXXL_PARALLEL_MULTIWAY_MERGE)
#define STXXL_PARALLEL_MULTIWAY_MERGE 1
#endif
#if !defined(STXXL_NOT_CONSIDER_SORT_MEMORY_OVERHEAD)
#define STXXL_NOT_CONSIDER_SORT_MEMORY_OVERHEAD 0
#endif
#ifdef STXXL_PARALLEL_MODE_EXPLICIT
#include <parallel/algorithm>
#else
#include <algorithm>
#endif
__STXXL_BEGIN_NAMESPACE
inline unsigned sort_memory_usage_factor()
{
#if STXXL_PARALLEL && !STXXL_NOT_CONSIDER_SORT_MEMORY_OVERHEAD && defined(STXXL_PARALLEL_MODE)
return (__gnu_parallel::_Settings::get().sort_algorithm == __gnu_parallel::MWMS && omp_get_max_threads() > 1) ? 2 : 1; //memory overhead for multiway mergesort
#elif STXXL_PARALLEL && !STXXL_NOT_CONSIDER_SORT_MEMORY_OVERHEAD && defined(__MCSTL__)
return (mcstl::SETTINGS::sort_algorithm == mcstl::SETTINGS::MWMS && mcstl::SETTINGS::num_threads > 1) ? 2 : 1; //memory overhead for multiway mergesort
#else
return 1; //no overhead
#endif
}
inline bool do_parallel_merge()
{
#if STXXL_PARALLEL_MULTIWAY_MERGE && defined(STXXL_PARALLEL_MODE)
return !stxxl::SETTINGS::native_merge && omp_get_max_threads() >= 1;
#elif STXXL_PARALLEL_MULTIWAY_MERGE && defined(__MCSTL__)
return !stxxl::SETTINGS::native_merge && mcstl::SETTINGS::num_threads >= 1;
#else
return false;
#endif
}
namespace potentially_parallel
{
#ifdef STXXL_PARALLEL_MODE_EXPLICIT
using __gnu_parallel::sort;
using __gnu_parallel::random_shuffle;
#else
using std::sort;
using std::random_shuffle;
#endif
}
namespace parallel
{
#if STXXL_PARALLEL
/** @brief Multi-way merging dispatcher.
* @param seqs_begin Begin iterator of iterator pair input sequence.
* @param seqs_end End iterator of iterator pair input sequence.
* @param target Begin iterator out output sequence.
* @param comp Comparator.
* @param length Maximum length to merge.
* @return End iterator of output sequence. */
template <typename RandomAccessIteratorPairIterator,
typename RandomAccessIterator3, typename DiffType, typename Comparator>
RandomAccessIterator3
multiway_merge(RandomAccessIteratorPairIterator seqs_begin,
RandomAccessIteratorPairIterator seqs_end,
RandomAccessIterator3 target,
Comparator comp,
DiffType length)
{
#if defined(STXXL_PARALLEL_MODE) && ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40400)
return __gnu_parallel::multiway_merge(seqs_begin, seqs_end, target, length, comp);
#elif defined(STXXL_PARALLEL_MODE)
return __gnu_parallel::multiway_merge(seqs_begin, seqs_end, target, comp, length);
#elif defined(__MCSTL__)
typedef typename compat::make_signed<DiffType>::type difference_type;
return mcstl::multiway_merge(seqs_begin, seqs_end, target, comp, difference_type(length), false);
#else
#error "no implementation found for multiway_merge()"
#endif
}
/** @brief Multi-way merging front-end.
* @param seqs_begin Begin iterator of iterator pair input sequence.
* @param seqs_end End iterator of iterator pair input sequence.
* @param target Begin iterator out output sequence.
* @param comp Comparator.
* @param length Maximum length to merge.
* @return End iterator of output sequence.
* @pre For each @c i, @c seqs_begin[i].second must be the end marker of the sequence, but also reference the one more sentinel element. */
template <typename RandomAccessIteratorPairIterator,
typename RandomAccessIterator3, typename DiffType, typename Comparator>
RandomAccessIterator3
multiway_merge_sentinel(RandomAccessIteratorPairIterator seqs_begin,
RandomAccessIteratorPairIterator seqs_end,
RandomAccessIterator3 target,
Comparator comp,
DiffType length)
{
#if defined(STXXL_PARALLEL_MODE) && ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40400)
return __gnu_parallel::multiway_merge_sentinels(seqs_begin, seqs_end, target, length, comp);
#elif defined(STXXL_PARALLEL_MODE)
return __gnu_parallel::multiway_merge_sentinels(seqs_begin, seqs_end, target, comp, length);
#elif defined(__MCSTL__)
typedef typename compat::make_signed<DiffType>::type difference_type;
return mcstl::multiway_merge_sentinel(seqs_begin, seqs_end, target, comp, difference_type(length), false);
#else
#error "no implementation found for multiway_merge_sentinel()"
#endif
}
#endif
}
__STXXL_END_NAMESPACE
#endif // !STXXL_PARALLEL_HEADER
// vim: et:ts=4:sw=4
|