Commit 54384f7f by Johannes Singler Committed by Johannes Singler

base.h (_EqualFromLess): Correct uglification of member variables and method arguments.

2009-09-16  Johannes Singler  <singler@ira.uka.de>

        * include/parallel/base.h (_EqualFromLess):
        Correct uglification of member variables and method arguments.
        * include/parallel/balanced_quicksort.h (_QSBThreadLocal): Likewise.
        * include/parallel/find_selectors.h (__find_first_of_selector):
        Likewise.
        * include/parallel/iterator.h (_IteratorTriple): Likewise.
        * include/parallel/multiseq_selection.h
        (_Lexicographic, _LexicographicReverse): Likewise.
        * include/parallel/multiway_mergesort.h (_Piece, _PMWMSSortingData):
        Likewise.
        * include/parallel/random_number.h (_RandomNumber): Likewise.
        * include/parallel/random_shuffle.h (_DRandomShufflingGlobalData):
        Likewise.
        * include/parallel/set_operations.h (__symmetric_difference_func,
        __difference_func, __intersection_func, __union_func,
        parallel_set_union, parallel_set_intersection, parallel_set_difference,
        parallel_set_symmetric_difference): Likewise.
        * include/parallel/tags.h (parallel_tag): Likewise.
        * include/parallel/workstealing.h (_Job): Likewise.
        * include/parallel/multiway_merge.h
        (__multiway_merge_k_variant_sentinel_switch:operator())
        correct uglification of _*LoserTree*.
        * include/parallel/losertree.h (_*LoserTree*): Likewise; correct
        uglification of member variables and method arguments.
        * include/parallel/par_loop.h: Correct uglification of finish_iterator.
        * include/parallel/for_each_selectors.h: Likewise.
        * include/parallel/omp_loop.h: Likewise.
        * include/parallel/algo.h: Likewise; uglify c_rand_number.

From-SVN: r151754
parent e038c37b
2009-09-16 Johannes Singler <singler@ira.uka.de> 2009-09-16 Johannes Singler <singler@ira.uka.de>
* include/parallel/base.h (_EqualFromLess):
Correct uglification of member variables and method arguments.
* include/parallel/balanced_quicksort.h (_QSBThreadLocal): Likewise.
* include/parallel/find_selectors.h (__find_first_of_selector):
Likewise.
* include/parallel/iterator.h (_IteratorTriple): Likewise.
* include/parallel/multiseq_selection.h
(_Lexicographic, _LexicographicReverse): Likewise.
* include/parallel/multiway_mergesort.h (_Piece, _PMWMSSortingData):
Likewise.
* include/parallel/random_number.h (_RandomNumber): Likewise.
* include/parallel/random_shuffle.h (_DRandomShufflingGlobalData):
Likewise.
* include/parallel/set_operations.h (__symmetric_difference_func,
__difference_func, __intersection_func, __union_func,
parallel_set_union, parallel_set_intersection, parallel_set_difference,
parallel_set_symmetric_difference): Likewise.
* include/parallel/tags.h (parallel_tag): Likewise.
* include/parallel/workstealing.h (_Job): Likewise.
* include/parallel/multiway_merge.h
(__multiway_merge_k_variant_sentinel_switch:operator())
correct uglification of _*LoserTree*.
* include/parallel/losertree.h (_*LoserTree*): Likewise; correct
uglification of member variables and method arguments.
* include/parallel/par_loop.h: Correct uglification of finish_iterator.
* include/parallel/for_each_selectors.h: Likewise.
* include/parallel/omp_loop.h: Likewise.
* include/parallel/algo.h: Likewise; uglify c_rand_number.
2009-09-16 Johannes Singler <singler@ira.uka.de>
* include/parallel/base.h (_PseudoSequenceIterator, _PseudoSequence): * include/parallel/base.h (_PseudoSequenceIterator, _PseudoSequence):
Replace redundant _Self. Replace redundant _Self.
* include/parallel/iterator.h (_IteratorPair, _IteratorTriple): * include/parallel/iterator.h (_IteratorPair, _IteratorTriple):
......
...@@ -1229,7 +1229,7 @@ namespace __parallel ...@@ -1229,7 +1229,7 @@ namespace __parallel
unary_op, __functionality, unary_op, __functionality,
__gnu_parallel::_DummyReduct(), __gnu_parallel::_DummyReduct(),
__dummy, __dummy, -1, __parallelism_tag); __dummy, __dummy, -1, __parallelism_tag);
return __functionality.finish_iterator; return __functionality._M_finish_iterator;
} }
else else
return transform(__begin, __end, __result, unary_op, return transform(__begin, __end, __result, unary_op,
...@@ -1322,7 +1322,7 @@ namespace __parallel ...@@ -1322,7 +1322,7 @@ namespace __parallel
__gnu_parallel::_DummyReduct(), __gnu_parallel::_DummyReduct(),
__dummy, __dummy, -1, __dummy, __dummy, -1,
__parallelism_tag); __parallelism_tag);
return __functionality.finish_iterator; return __functionality._M_finish_iterator;
} }
else else
return transform(__begin1, __end1, __begin2, __result, __binary_op, return transform(__begin1, __end1, __begin2, __result, __binary_op,
...@@ -1629,7 +1629,7 @@ namespace __parallel ...@@ -1629,7 +1629,7 @@ namespace __parallel
/** @brief Functor wrapper for std::rand(). */ /** @brief Functor wrapper for std::rand(). */
template<typename _MustBeInt = int> template<typename _MustBeInt = int>
struct c_rand_number struct _CRandNumber
{ {
int int
operator()(int __limit) operator()(int __limit)
...@@ -1641,7 +1641,7 @@ namespace __parallel ...@@ -1641,7 +1641,7 @@ namespace __parallel
inline void inline void
random_shuffle(_RAIter __begin, _RAIter __end) random_shuffle(_RAIter __begin, _RAIter __end)
{ {
c_rand_number<> __r; _CRandNumber<> __r;
// Parallelization still possible. // Parallelization still possible.
__gnu_parallel::random_shuffle(__begin, __end, __r); __gnu_parallel::random_shuffle(__begin, __end, __r);
} }
......
...@@ -75,7 +75,7 @@ template<typename _RAIter> ...@@ -75,7 +75,7 @@ template<typename _RAIter>
_RestrictedBoundedConcurrentQueue<_Piece> _M_leftover_parts; _RestrictedBoundedConcurrentQueue<_Piece> _M_leftover_parts;
/** @brief Number of threads involved in this algorithm. */ /** @brief Number of threads involved in this algorithm. */
_ThreadIndex __num_threads; _ThreadIndex _M_num_threads;
/** @brief Pointer to a counter of elements left over to sort. */ /** @brief Pointer to a counter of elements left over to sort. */
volatile _DifferenceType* _M_elements_leftover; volatile _DifferenceType* _M_elements_leftover;
...@@ -250,7 +250,7 @@ template<typename _RAIter, typename _Compare> ...@@ -250,7 +250,7 @@ template<typename _RAIter, typename _Compare>
_Settings::get().sort_qsb_base_case_maximal_n; _Settings::get().sort_qsb_base_case_maximal_n;
if (__base_case_n < 2) if (__base_case_n < 2)
__base_case_n = 2; __base_case_n = 2;
_ThreadIndex __num_threads = __tl.__num_threads; _ThreadIndex __num_threads = __tl._M_num_threads;
// Every thread has its own random number generator. // Every thread has its own random number generator.
_RandomNumber __rng(__iam + 1); _RandomNumber __rng(__iam + 1);
...@@ -451,7 +451,7 @@ template<typename _RAIter, typename _Compare> ...@@ -451,7 +451,7 @@ template<typename _RAIter, typename _Compare>
for (int __i = 0; __i < __num_threads; ++__i) for (int __i = 0; __i < __num_threads; ++__i)
{ {
__tls[__i]->_M_elements_leftover = &_M_elements_leftover; __tls[__i]->_M_elements_leftover = &_M_elements_leftover;
__tls[__i]->__num_threads = __num_threads; __tls[__i]->_M_num_threads = __num_threads;
__tls[__i]->_M_global = std::make_pair(__begin, __end); __tls[__i]->_M_global = std::make_pair(__begin, __end);
// Just in case nothing is left to assign. // Just in case nothing is left to assign.
......
...@@ -159,14 +159,14 @@ template<typename _Compare, typename _T1, typename _T2> ...@@ -159,14 +159,14 @@ template<typename _Compare, typename _T1, typename _T2>
class _EqualFromLess : public std::binary_function<_T1, _T2, bool> class _EqualFromLess : public std::binary_function<_T1, _T2, bool>
{ {
private: private:
_Compare& __comp; _Compare& _M_comp;
public: public:
_EqualFromLess(_Compare& _comp) : __comp(_comp) { } _EqualFromLess(_Compare& __comp) : _M_comp(__comp) { }
bool operator()(const _T1& __a, const _T2& __b) bool operator()(const _T1& __a, const _T2& __b)
{ {
return !__comp(__a, __b) && !__comp(__b, __a); return !_M_comp(__a, __b) && !_M_comp(__b, __a);
} }
}; };
......
...@@ -151,11 +151,11 @@ namespace __gnu_parallel ...@@ -151,11 +151,11 @@ namespace __gnu_parallel
template<typename _ForwardIterator> template<typename _ForwardIterator>
struct __find_first_of_selector : public __generic_find_selector struct __find_first_of_selector : public __generic_find_selector
{ {
_ForwardIterator __begin; _ForwardIterator _M_begin;
_ForwardIterator __end; _ForwardIterator _M_end;
explicit __find_first_of_selector(_ForwardIterator __begin, _ForwardIterator __end) explicit __find_first_of_selector(_ForwardIterator __begin, _ForwardIterator __end)
: __begin(__begin), __end(__end) { } : _M_begin(__begin), _M_end(__end) { }
/** @brief Test on one __position. /** @brief Test on one __position.
* @param __i1 _Iterator on first sequence. * @param __i1 _Iterator on first sequence.
...@@ -166,8 +166,8 @@ namespace __gnu_parallel ...@@ -166,8 +166,8 @@ namespace __gnu_parallel
bool bool
operator()(_RAIter1 __i1, _RAIter2 __i2, _Pred __pred) operator()(_RAIter1 __i1, _RAIter2 __i2, _Pred __pred)
{ {
for (_ForwardIterator __pos_in_candidates = __begin; for (_ForwardIterator __pos_in_candidates = _M_begin;
__pos_in_candidates != __end; ++__pos_in_candidates) __pos_in_candidates != _M_end; ++__pos_in_candidates)
if (__pred(*__i1, *__pos_in_candidates)) if (__pred(*__i1, *__pos_in_candidates))
return true; return true;
return false; return false;
...@@ -184,7 +184,7 @@ namespace __gnu_parallel ...@@ -184,7 +184,7 @@ namespace __gnu_parallel
_M_sequential_algorithm(_RAIter1 __begin1, _M_sequential_algorithm(_RAIter1 __begin1,
_RAIter1 __end1, _RAIter1 __end1,
_RAIter2 __begin2, _Pred __pred) _RAIter2 __begin2, _Pred __pred)
{ return std::make_pair(find_first_of(__begin1, __end1, __begin, __end, __pred, { return std::make_pair(find_first_of(__begin1, __end1, _M_begin, _M_end, __pred,
sequential_tag()), __begin2); } sequential_tag()), __begin2); }
}; };
} }
......
...@@ -45,7 +45,7 @@ namespace __gnu_parallel ...@@ -45,7 +45,7 @@ namespace __gnu_parallel
/** @brief _Iterator on last element processed; needed for some /** @brief _Iterator on last element processed; needed for some
* algorithms (e. g. std::transform()). * algorithms (e. g. std::transform()).
*/ */
_It finish_iterator; _It _M_finish_iterator;
}; };
...@@ -124,7 +124,7 @@ namespace __gnu_parallel ...@@ -124,7 +124,7 @@ namespace __gnu_parallel
bool bool
operator()(_Op& __o, _It __i) operator()(_Op& __o, _It __i)
{ {
*__i.__third = __o(*__i.__first, *__i.__second); *__i._M_third = __o(*__i._M_first, *__i._M_second);
return true; return true;
} }
}; };
......
...@@ -125,70 +125,70 @@ namespace __gnu_parallel ...@@ -125,70 +125,70 @@ namespace __gnu_parallel
typedef _IteratorTriple* pointer; typedef _IteratorTriple* pointer;
typedef _IteratorTriple& reference; typedef _IteratorTriple& reference;
_Iterator1 __first; _Iterator1 _M_first;
_Iterator2 __second; _Iterator2 _M_second;
_Iterator3 __third; _Iterator3 _M_third;
_IteratorTriple() { } _IteratorTriple() { }
_IteratorTriple(const _Iterator1& _first, const _Iterator2& _second, _IteratorTriple(const _Iterator1& __first, const _Iterator2& __second,
const _Iterator3& _third) const _Iterator3& __third)
{ {
__first = _first; _M_first = __first;
__second = _second; _M_second = __second;
__third = _third; _M_third = __third;
} }
// Pre-increment operator. // Pre-increment operator.
_IteratorTriple& _IteratorTriple&
operator++() operator++()
{ {
++__first; ++_M_first;
++__second; ++_M_second;
++__third; ++_M_third;
return *this; return *this;
} }
// Post-increment operator. // Post-increment operator.
const _IteratorTriple const _IteratorTriple
operator++(int) operator++(int)
{ return _IteratorTriple(__first++, __second++, __third++); } { return _IteratorTriple(_M_first++, _M_second++, _M_third++); }
// Pre-decrement operator. // Pre-decrement operator.
_IteratorTriple& _IteratorTriple&
operator--() operator--()
{ {
--__first; --_M_first;
--__second; --_M_second;
--__third; --_M_third;
return *this; return *this;
} }
// Post-decrement operator. // Post-decrement operator.
const _IteratorTriple const _IteratorTriple
operator--(int) operator--(int)
{ return _IteratorTriple(__first--, __second--, __third--); } { return _IteratorTriple(_M_first--, _M_second--, _M_third--); }
// Type conversion. // Type conversion.
operator _Iterator3() const operator _Iterator3() const
{ return __third; } { return _M_third; }
_IteratorTriple& _IteratorTriple&
operator=(const _IteratorTriple& __other) operator=(const _IteratorTriple& __other)
{ {
__first = __other.__first; _M_first = __other._M_first;
__second = __other.__second; _M_second = __other._M_second;
__third = __other.__third; _M_third = __other._M_third;
return *this; return *this;
} }
_IteratorTriple _IteratorTriple
operator+(difference_type __delta) const operator+(difference_type __delta) const
{ return _IteratorTriple(__first + __delta, __second + __delta, __third + __delta); } { return _IteratorTriple(_M_first + __delta, _M_second + __delta, _M_third + __delta); }
difference_type difference_type
operator-(const _IteratorTriple& __other) const operator-(const _IteratorTriple& __other) const
{ return __first - __other.__first; } { return _M_first - __other._M_first; }
}; };
} }
......
...@@ -54,70 +54,70 @@ namespace __gnu_parallel ...@@ -54,70 +54,70 @@ namespace __gnu_parallel
* @param _Compare the comparator to use, defaults to std::less<_Tp> * @param _Compare the comparator to use, defaults to std::less<_Tp>
*/ */
template<typename _Tp, typename _Compare> template<typename _Tp, typename _Compare>
class LoserTreeBase class _LoserTreeBase
{ {
protected: protected:
/** @brief Internal representation of a LoserTree element. */ /** @brief Internal representation of a _LoserTree element. */
struct _Loser struct _Loser
{ {
/** @brief flag, true iff this is a "maximum" __sentinel. */ /** @brief flag, true iff this is a "maximum" __sentinel. */
bool _M_sup; bool _M_sup;
/** @brief __index of the _M_source __sequence. */ /** @brief __index of the _M_source __sequence. */
int _M_source; int _M_source;
/** @brief _M_key of the element in the LoserTree. */ /** @brief _M_key of the element in the _LoserTree. */
_Tp _M_key; _Tp _M_key;
}; };
unsigned int __ik, __k, __offset; unsigned int _M_ik, _M_k, _M_offset;
/** log_2{__k} */ /** log_2{_M_k} */
unsigned int _M_log_k; unsigned int _M_log_k;
/** @brief LoserTree __elements. */ /** @brief _LoserTree __elements. */
_Loser* __losers; _Loser* _M_losers;
/** @brief _Compare to use. */ /** @brief _Compare to use. */
_Compare __comp; _Compare _M_comp;
/** /**
* @brief State flag that determines whether the LoserTree is empty. * @brief State flag that determines whether the _LoserTree is empty.
* *
* Only used for building the LoserTree. * Only used for building the _LoserTree.
*/ */
bool __first_insert; bool _M_first_insert;
public: public:
/** /**
* @brief The constructor. * @brief The constructor.
* *
* @param _k The number of sequences to merge. * @param __k The number of sequences to merge.
* @param _comp The comparator to use. * @param __comp The comparator to use.
*/ */
LoserTreeBase(unsigned int _k, _Compare _comp) _LoserTreeBase(unsigned int __k, _Compare __comp)
: __comp(_comp) : _M_comp(__comp)
{ {
__ik = _k; _M_ik = __k;
// Compute log_2{__k} for the _Loser Tree // Compute log_2{_M_k} for the _Loser Tree
_M_log_k = __log2(__ik - 1) + 1; _M_log_k = __log2(_M_ik - 1) + 1;
// Next greater power of 2. // Next greater power of 2.
__k = 1 << _M_log_k; _M_k = 1 << _M_log_k;
__offset = __k; _M_offset = _M_k;
// Avoid default-constructing __losers[]._M_key // Avoid default-constructing _M_losers[]._M_key
__losers = static_cast<_Loser*>(::operator new(2 * __k * sizeof(_Loser))); _M_losers = static_cast<_Loser*>(::operator new(2 * _M_k * sizeof(_Loser)));
for (unsigned int __i = __ik - 1; __i < __k; ++__i) for (unsigned int __i = _M_ik - 1; __i < _M_k; ++__i)
__losers[__i + __k]._M_sup = true; _M_losers[__i + _M_k]._M_sup = true;
__first_insert = true; _M_first_insert = true;
} }
/** /**
* @brief The destructor. * @brief The destructor.
*/ */
~LoserTreeBase() ~_LoserTreeBase()
{ ::operator delete(__losers); } { ::operator delete(_M_losers); }
/** /**
* @brief Initializes the sequence "_M_source" with the element "_M_key". * @brief Initializes the sequence "_M_source" with the element "_M_key".
...@@ -130,31 +130,31 @@ public: ...@@ -130,31 +130,31 @@ public:
inline void inline void
__insert_start(const _Tp& _M_key, int _M_source, bool _M_sup) __insert_start(const _Tp& _M_key, int _M_source, bool _M_sup)
{ {
unsigned int __pos = __k + _M_source; unsigned int __pos = _M_k + _M_source;
if(__first_insert) if(_M_first_insert)
{ {
// Construct all keys, so we can easily deconstruct them. // Construct all keys, so we can easily deconstruct them.
for (unsigned int __i = 0; __i < (2 * __k); ++__i) for (unsigned int __i = 0; __i < (2 * _M_k); ++__i)
new(&(__losers[__i]._M_key)) _Tp(_M_key); new(&(_M_losers[__i]._M_key)) _Tp(_M_key);
__first_insert = false; _M_first_insert = false;
} }
else else
new(&(__losers[__pos]._M_key)) _Tp(_M_key); new(&(_M_losers[__pos]._M_key)) _Tp(_M_key);
__losers[__pos]._M_sup = _M_sup; _M_losers[__pos]._M_sup = _M_sup;
__losers[__pos]._M_source = _M_source; _M_losers[__pos]._M_source = _M_source;
} }
/** /**
* @return the index of the sequence with the smallest element. * @return the index of the sequence with the smallest element.
*/ */
int __get_min_source() int __get_min_source()
{ return __losers[0]._M_source; } { return _M_losers[0]._M_source; }
}; };
/** /**
* @brief Stable LoserTree variant. * @brief Stable _LoserTree variant.
* *
* Provides the stable implementations of insert_start, __init_winner, * Provides the stable implementations of insert_start, __init_winner,
* __init and __delete_min_insert. * __init and __delete_min_insert.
...@@ -162,22 +162,22 @@ public: ...@@ -162,22 +162,22 @@ public:
* Unstable variant is done using partial specialisation below. * Unstable variant is done using partial specialisation below.
*/ */
template<bool __stable/* default == true */, typename _Tp, typename _Compare> template<bool __stable/* default == true */, typename _Tp, typename _Compare>
class LoserTree : public LoserTreeBase<_Tp, _Compare> class _LoserTree : public _LoserTreeBase<_Tp, _Compare>
{ {
typedef LoserTreeBase<_Tp, _Compare> Base; typedef _LoserTreeBase<_Tp, _Compare> Base;
using Base::__k; using Base::_M_k;
using Base::__losers; using Base::_M_losers;
using Base::__first_insert; using Base::_M_first_insert;
public: public:
LoserTree(unsigned int _k, _Compare _comp) _LoserTree(unsigned int __k, _Compare __comp)
: Base::LoserTreeBase(_k, _comp) : Base::_LoserTreeBase(__k, __comp)
{} {}
unsigned int unsigned int
__init_winner(unsigned int __root) __init_winner(unsigned int __root)
{ {
if (__root >= __k) if (__root >= _M_k)
{ {
return __root; return __root;
} }
...@@ -185,25 +185,25 @@ public: ...@@ -185,25 +185,25 @@ public:
{ {
unsigned int __left = __init_winner (2 * __root); unsigned int __left = __init_winner (2 * __root);
unsigned int __right = __init_winner (2 * __root + 1); unsigned int __right = __init_winner (2 * __root + 1);
if (__losers[__right]._M_sup if (_M_losers[__right]._M_sup
|| (!__losers[__left]._M_sup || (!_M_losers[__left]._M_sup
&& !__comp(__losers[__right]._M_key, __losers[__left]._M_key))) && !_M_comp(_M_losers[__right]._M_key, _M_losers[__left]._M_key)))
{ {
// Left one is less or equal. // Left one is less or equal.
__losers[__root] = __losers[__right]; _M_losers[__root] = _M_losers[__right];
return __left; return __left;
} }
else else
{ {
// Right one is less. // Right one is less.
__losers[__root] = __losers[__left]; _M_losers[__root] = _M_losers[__left];
return __right; return __right;
} }
} }
} }
void __init() void __init()
{ __losers[0] = __losers[__init_winner(1)]; } { _M_losers[0] = _M_losers[__init_winner(1)]; }
/** /**
* @brief Delete the smallest element and insert a new element from * @brief Delete the smallest element and insert a new element from
...@@ -216,50 +216,50 @@ public: ...@@ -216,50 +216,50 @@ public:
{ {
#if _GLIBCXX_ASSERTIONS #if _GLIBCXX_ASSERTIONS
// no dummy sequence can ever be at the top! // no dummy sequence can ever be at the top!
_GLIBCXX_PARALLEL_ASSERT(__losers[0]._M_source != -1); _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif #endif
int _M_source = __losers[0]._M_source; int _M_source = _M_losers[0]._M_source;
for (unsigned int __pos = (__k + _M_source) / 2; __pos > 0; __pos /= 2) for (unsigned int __pos = (_M_k + _M_source) / 2; __pos > 0; __pos /= 2)
{ {
// The smaller one gets promoted, ties are broken by _M_source. // The smaller one gets promoted, ties are broken by _M_source.
if ((_M_sup && (!__losers[__pos]._M_sup || __losers[__pos]._M_source < _M_source)) if ((_M_sup && (!_M_losers[__pos]._M_sup || _M_losers[__pos]._M_source < _M_source))
|| (!_M_sup && !__losers[__pos]._M_sup || (!_M_sup && !_M_losers[__pos]._M_sup
&& ((__comp(__losers[__pos]._M_key, _M_key)) && ((_M_comp(_M_losers[__pos]._M_key, _M_key))
|| (!__comp(_M_key, __losers[__pos]._M_key) || (!_M_comp(_M_key, _M_losers[__pos]._M_key)
&& __losers[__pos]._M_source < _M_source)))) && _M_losers[__pos]._M_source < _M_source))))
{ {
// The other one is smaller. // The other one is smaller.
std::swap(__losers[__pos]._M_sup, _M_sup); std::swap(_M_losers[__pos]._M_sup, _M_sup);
std::swap(__losers[__pos]._M_source, _M_source); std::swap(_M_losers[__pos]._M_source, _M_source);
std::swap(__losers[__pos]._M_key, _M_key); std::swap(_M_losers[__pos]._M_key, _M_key);
} }
} }
__losers[0]._M_sup = _M_sup; _M_losers[0]._M_sup = _M_sup;
__losers[0]._M_source = _M_source; _M_losers[0]._M_source = _M_source;
__losers[0]._M_key = _M_key; _M_losers[0]._M_key = _M_key;
} }
}; };
/** /**
* @brief Unstable LoserTree variant. * @brief Unstable _LoserTree variant.
* *
* Stability (non-stable here) is selected with partial specialization. * Stability (non-stable here) is selected with partial specialization.
*/ */
template<typename _Tp, typename _Compare> template<typename _Tp, typename _Compare>
class LoserTree</* __stable == */false, _Tp, _Compare> : class _LoserTree</* __stable == */false, _Tp, _Compare> :
public LoserTreeBase<_Tp, _Compare> public _LoserTreeBase<_Tp, _Compare>
{ {
typedef LoserTreeBase<_Tp, _Compare> Base; typedef _LoserTreeBase<_Tp, _Compare> Base;
using Base::_M_log_k; using Base::_M_log_k;
using Base::__k; using Base::_M_k;
using Base::__losers; using Base::_M_losers;
using Base::__first_insert; using Base::_M_first_insert;
public: public:
LoserTree(unsigned int _k, _Compare _comp) _LoserTree(unsigned int __k, _Compare __comp)
: Base::LoserTreeBase(_k, _comp) : Base::_LoserTreeBase(__k, __comp)
{} {}
/** /**
...@@ -272,7 +272,7 @@ public: ...@@ -272,7 +272,7 @@ public:
unsigned int unsigned int
__init_winner (unsigned int __root) __init_winner (unsigned int __root)
{ {
if (__root >= __k) if (__root >= _M_k)
{ {
return __root; return __root;
} }
...@@ -280,18 +280,18 @@ public: ...@@ -280,18 +280,18 @@ public:
{ {
unsigned int __left = __init_winner (2 * __root); unsigned int __left = __init_winner (2 * __root);
unsigned int __right = __init_winner (2 * __root + 1); unsigned int __right = __init_winner (2 * __root + 1);
if (__losers[__right]._M_sup || if (_M_losers[__right]._M_sup ||
(!__losers[__left]._M_sup (!_M_losers[__left]._M_sup
&& !__comp(__losers[__right]._M_key, __losers[__left]._M_key))) && !_M_comp(_M_losers[__right]._M_key, _M_losers[__left]._M_key)))
{ {
// Left one is less or equal. // Left one is less or equal.
__losers[__root] = __losers[__right]; _M_losers[__root] = _M_losers[__right];
return __left; return __left;
} }
else else
{ {
// Right one is less. // Right one is less.
__losers[__root] = __losers[__left]; _M_losers[__root] = _M_losers[__left];
return __right; return __right;
} }
} }
...@@ -299,7 +299,7 @@ public: ...@@ -299,7 +299,7 @@ public:
inline void inline void
__init() __init()
{ __losers[0] = __losers[__init_winner(1)]; } { _M_losers[0] = _M_losers[__init_winner(1)]; }
/** /**
* Delete the _M_key smallest element and insert the element _M_key instead. * Delete the _M_key smallest element and insert the element _M_key instead.
...@@ -313,25 +313,25 @@ public: ...@@ -313,25 +313,25 @@ public:
{ {
#if _GLIBCXX_ASSERTIONS #if _GLIBCXX_ASSERTIONS
// no dummy sequence can ever be at the top! // no dummy sequence can ever be at the top!
_GLIBCXX_PARALLEL_ASSERT(__losers[0]._M_source != -1); _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif #endif
int _M_source = __losers[0]._M_source; int _M_source = _M_losers[0]._M_source;
for (unsigned int __pos = (__k + _M_source) / 2; __pos > 0; __pos /= 2) for (unsigned int __pos = (_M_k + _M_source) / 2; __pos > 0; __pos /= 2)
{ {
// The smaller one gets promoted. // The smaller one gets promoted.
if (_M_sup || (!__losers[__pos]._M_sup && __comp(__losers[__pos]._M_key, _M_key))) if (_M_sup || (!_M_losers[__pos]._M_sup && _M_comp(_M_losers[__pos]._M_key, _M_key)))
{ {
// The other one is smaller. // The other one is smaller.
std::swap(__losers[__pos]._M_sup, _M_sup); std::swap(_M_losers[__pos]._M_sup, _M_sup);
std::swap(__losers[__pos]._M_source, _M_source); std::swap(_M_losers[__pos]._M_source, _M_source);
std::swap(__losers[__pos]._M_key, _M_key); std::swap(_M_losers[__pos]._M_key, _M_key);
} }
} }
__losers[0]._M_sup = _M_sup; _M_losers[0]._M_sup = _M_sup;
__losers[0]._M_source = _M_source; _M_losers[0]._M_source = _M_source;
__losers[0]._M_key = _M_key; _M_losers[0]._M_key = _M_key;
} }
}; };
...@@ -343,7 +343,7 @@ template<typename _Tp, typename _Compare> ...@@ -343,7 +343,7 @@ template<typename _Tp, typename _Compare>
class _LoserTreePointerBase class _LoserTreePointerBase
{ {
protected: protected:
/** @brief Internal representation of LoserTree __elements. */ /** @brief Internal representation of _LoserTree __elements. */
struct _Loser struct _Loser
{ {
bool _M_sup; bool _M_sup;
...@@ -351,42 +351,42 @@ protected: ...@@ -351,42 +351,42 @@ protected:
const _Tp* _M_keyp; const _Tp* _M_keyp;
}; };
unsigned int __ik, __k, __offset; unsigned int _M_ik, _M_k, _M_offset;
_Loser* __losers; _Loser* _M_losers;
_Compare __comp; _Compare _M_comp;
public: public:
_LoserTreePointerBase(unsigned int _k, _Compare _comp = std::less<_Tp>()) _LoserTreePointerBase(unsigned int __k, _Compare __comp = std::less<_Tp>())
: __comp(_comp) : _M_comp(__comp)
{ {
__ik = _k; _M_ik = __k;
// Next greater power of 2. // Next greater power of 2.
__k = 1 << (__log2(__ik - 1) + 1); _M_k = 1 << (__log2(_M_ik - 1) + 1);
__offset = __k; _M_offset = _M_k;
__losers = new _Loser[__k * 2]; _M_losers = new _Loser[_M_k * 2];
for (unsigned int __i = __ik - 1; __i < __k; __i++) for (unsigned int __i = _M_ik - 1; __i < _M_k; __i++)
__losers[__i + __k]._M_sup = true; _M_losers[__i + _M_k]._M_sup = true;
} }
~_LoserTreePointerBase() ~_LoserTreePointerBase()
{ ::operator delete[](__losers); } { ::operator delete[](_M_losers); }
int __get_min_source() int __get_min_source()
{ return __losers[0]._M_source; } { return _M_losers[0]._M_source; }
void __insert_start(const _Tp& _M_key, int _M_source, bool _M_sup) void __insert_start(const _Tp& _M_key, int _M_source, bool _M_sup)
{ {
unsigned int __pos = __k + _M_source; unsigned int __pos = _M_k + _M_source;
__losers[__pos]._M_sup = _M_sup; _M_losers[__pos]._M_sup = _M_sup;
__losers[__pos]._M_source = _M_source; _M_losers[__pos]._M_source = _M_source;
__losers[__pos]._M_keyp = &_M_key; _M_losers[__pos]._M_keyp = &_M_key;
} }
}; };
/** /**
* @brief Stable LoserTree implementation. * @brief Stable _LoserTree implementation.
* *
* The unstable variant is implemented using partial instantiation below. * The unstable variant is implemented using partial instantiation below.
*/ */
...@@ -394,18 +394,18 @@ template<bool __stable/* default == true */, typename _Tp, typename _Compare> ...@@ -394,18 +394,18 @@ template<bool __stable/* default == true */, typename _Tp, typename _Compare>
class _LoserTreePointer : public _LoserTreePointerBase<_Tp, _Compare> class _LoserTreePointer : public _LoserTreePointerBase<_Tp, _Compare>
{ {
typedef _LoserTreePointerBase<_Tp, _Compare> Base; typedef _LoserTreePointerBase<_Tp, _Compare> Base;
using Base::__k; using Base::_M_k;
using Base::__losers; using Base::_M_losers;
public: public:
_LoserTreePointer(unsigned int _k, _Compare _comp = std::less<_Tp>()) _LoserTreePointer(unsigned int __k, _Compare __comp = std::less<_Tp>())
: Base::_LoserTreePointerBase(_k, _comp) : Base::_LoserTreePointerBase(__k, __comp)
{} {}
unsigned int unsigned int
__init_winner(unsigned int __root) __init_winner(unsigned int __root)
{ {
if (__root >= __k) if (__root >= _M_k)
{ {
return __root; return __root;
} }
...@@ -413,59 +413,59 @@ public: ...@@ -413,59 +413,59 @@ public:
{ {
unsigned int __left = __init_winner (2 * __root); unsigned int __left = __init_winner (2 * __root);
unsigned int __right = __init_winner (2 * __root + 1); unsigned int __right = __init_winner (2 * __root + 1);
if (__losers[__right]._M_sup if (_M_losers[__right]._M_sup
|| (!__losers[__left]._M_sup && !__comp(*__losers[__right]._M_keyp, || (!_M_losers[__left]._M_sup && !_M_comp(*_M_losers[__right]._M_keyp,
*__losers[__left]._M_keyp))) *_M_losers[__left]._M_keyp)))
{ {
// Left one is less or equal. // Left one is less or equal.
__losers[__root] = __losers[__right]; _M_losers[__root] = _M_losers[__right];
return __left; return __left;
} }
else else
{ {
// Right one is less. // Right one is less.
__losers[__root] = __losers[__left]; _M_losers[__root] = _M_losers[__left];
return __right; return __right;
} }
} }
} }
void __init() void __init()
{ __losers[0] = __losers[__init_winner(1)]; } { _M_losers[0] = _M_losers[__init_winner(1)]; }
void __delete_min_insert(const _Tp& _M_key, bool _M_sup) void __delete_min_insert(const _Tp& _M_key, bool _M_sup)
{ {
#if _GLIBCXX_ASSERTIONS #if _GLIBCXX_ASSERTIONS
// no dummy sequence can ever be at the top! // no dummy sequence can ever be at the top!
_GLIBCXX_PARALLEL_ASSERT(__losers[0]._M_source != -1); _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif #endif
const _Tp* _M_keyp = &_M_key; const _Tp* _M_keyp = &_M_key;
int _M_source = __losers[0]._M_source; int _M_source = _M_losers[0]._M_source;
for (unsigned int __pos = (__k + _M_source) / 2; __pos > 0; __pos /= 2) for (unsigned int __pos = (_M_k + _M_source) / 2; __pos > 0; __pos /= 2)
{ {
// The smaller one gets promoted, ties are broken by _M_source. // The smaller one gets promoted, ties are broken by _M_source.
if ((_M_sup && (!__losers[__pos]._M_sup || __losers[__pos]._M_source < _M_source)) || if ((_M_sup && (!_M_losers[__pos]._M_sup || _M_losers[__pos]._M_source < _M_source)) ||
(!_M_sup && !__losers[__pos]._M_sup && (!_M_sup && !_M_losers[__pos]._M_sup &&
((__comp(*__losers[__pos]._M_keyp, *_M_keyp)) || ((_M_comp(*_M_losers[__pos]._M_keyp, *_M_keyp)) ||
(!__comp(*_M_keyp, *__losers[__pos]._M_keyp) (!_M_comp(*_M_keyp, *_M_losers[__pos]._M_keyp)
&& __losers[__pos]._M_source < _M_source)))) && _M_losers[__pos]._M_source < _M_source))))
{ {
// The other one is smaller. // The other one is smaller.
std::swap(__losers[__pos]._M_sup, _M_sup); std::swap(_M_losers[__pos]._M_sup, _M_sup);
std::swap(__losers[__pos]._M_source, _M_source); std::swap(_M_losers[__pos]._M_source, _M_source);
std::swap(__losers[__pos]._M_keyp, _M_keyp); std::swap(_M_losers[__pos]._M_keyp, _M_keyp);
} }
} }
__losers[0]._M_sup = _M_sup; _M_losers[0]._M_sup = _M_sup;
__losers[0]._M_source = _M_source; _M_losers[0]._M_source = _M_source;
__losers[0]._M_keyp = _M_keyp; _M_losers[0]._M_keyp = _M_keyp;
} }
}; };
/** /**
* @brief Unstable LoserTree implementation. * @brief Unstable _LoserTree implementation.
* *
* The stable variant is above. * The stable variant is above.
*/ */
...@@ -474,18 +474,18 @@ class _LoserTreePointer</* __stable == */false, _Tp, _Compare> : ...@@ -474,18 +474,18 @@ class _LoserTreePointer</* __stable == */false, _Tp, _Compare> :
public _LoserTreePointerBase<_Tp, _Compare> public _LoserTreePointerBase<_Tp, _Compare>
{ {
typedef _LoserTreePointerBase<_Tp, _Compare> Base; typedef _LoserTreePointerBase<_Tp, _Compare> Base;
using Base::__k; using Base::_M_k;
using Base::__losers; using Base::_M_losers;
public: public:
_LoserTreePointer(unsigned int _k, _Compare _comp = std::less<_Tp>()) _LoserTreePointer(unsigned int __k, _Compare __comp = std::less<_Tp>())
: Base::_LoserTreePointerBase(_k, _comp) : Base::_LoserTreePointerBase(__k, __comp)
{} {}
unsigned int unsigned int
__init_winner(unsigned int __root) __init_winner(unsigned int __root)
{ {
if (__root >= __k) if (__root >= _M_k)
{ {
return __root; return __root;
} }
...@@ -493,54 +493,54 @@ public: ...@@ -493,54 +493,54 @@ public:
{ {
unsigned int __left = __init_winner (2 * __root); unsigned int __left = __init_winner (2 * __root);
unsigned int __right = __init_winner (2 * __root + 1); unsigned int __right = __init_winner (2 * __root + 1);
if (__losers[__right]._M_sup if (_M_losers[__right]._M_sup
|| (!__losers[__left]._M_sup || (!_M_losers[__left]._M_sup
&& !__comp(*__losers[__right]._M_keyp, *__losers[__left]._M_keyp))) && !_M_comp(*_M_losers[__right]._M_keyp, *_M_losers[__left]._M_keyp)))
{ {
// Left one is less or equal. // Left one is less or equal.
__losers[__root] = __losers[__right]; _M_losers[__root] = _M_losers[__right];
return __left; return __left;
} }
else else
{ {
// Right one is less. // Right one is less.
__losers[__root] = __losers[__left]; _M_losers[__root] = _M_losers[__left];
return __right; return __right;
} }
} }
} }
void __init() void __init()
{ __losers[0] = __losers[__init_winner(1)]; } { _M_losers[0] = _M_losers[__init_winner(1)]; }
void __delete_min_insert(const _Tp& _M_key, bool _M_sup) void __delete_min_insert(const _Tp& _M_key, bool _M_sup)
{ {
#if _GLIBCXX_ASSERTIONS #if _GLIBCXX_ASSERTIONS
// no dummy sequence can ever be at the top! // no dummy sequence can ever be at the top!
_GLIBCXX_PARALLEL_ASSERT(__losers[0]._M_source != -1); _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif #endif
const _Tp* _M_keyp = &_M_key; const _Tp* _M_keyp = &_M_key;
int _M_source = __losers[0]._M_source; int _M_source = _M_losers[0]._M_source;
for (unsigned int __pos = (__k + _M_source) / 2; __pos > 0; __pos /= 2) for (unsigned int __pos = (_M_k + _M_source) / 2; __pos > 0; __pos /= 2)
{ {
// The smaller one gets promoted. // The smaller one gets promoted.
if (_M_sup || (!__losers[__pos]._M_sup && __comp(*__losers[__pos]._M_keyp, *_M_keyp))) if (_M_sup || (!_M_losers[__pos]._M_sup && _M_comp(*_M_losers[__pos]._M_keyp, *_M_keyp)))
{ {
// The other one is smaller. // The other one is smaller.
std::swap(__losers[__pos]._M_sup, _M_sup); std::swap(_M_losers[__pos]._M_sup, _M_sup);
std::swap(__losers[__pos]._M_source, _M_source); std::swap(_M_losers[__pos]._M_source, _M_source);
std::swap(__losers[__pos]._M_keyp, _M_keyp); std::swap(_M_losers[__pos]._M_keyp, _M_keyp);
} }
} }
__losers[0]._M_sup = _M_sup; _M_losers[0]._M_sup = _M_sup;
__losers[0]._M_source = _M_source; _M_losers[0]._M_source = _M_source;
__losers[0]._M_keyp = _M_keyp; _M_losers[0]._M_keyp = _M_keyp;
} }
}; };
/** @brief Base class for unguarded LoserTree implementation. /** @brief Base class for unguarded _LoserTree implementation.
* *
* The whole element is copied into the tree structure. * The whole element is copied into the tree structure.
* *
...@@ -560,56 +560,56 @@ protected: ...@@ -560,56 +560,56 @@ protected:
_Tp _M_key; _Tp _M_key;
}; };
unsigned int __ik, __k, __offset; unsigned int _M_ik, _M_k, _M_offset;
_Loser* __losers; _Loser* _M_losers;
_Compare __comp; _Compare _M_comp;
public: public:
inline inline
_LoserTreeUnguardedBase(unsigned int _k, const _Tp _sentinel, _LoserTreeUnguardedBase(unsigned int __k, const _Tp _sentinel,
_Compare _comp = std::less<_Tp>()) _Compare __comp = std::less<_Tp>())
: __comp(_comp) : _M_comp(__comp)
{ {
__ik = _k; _M_ik = __k;
// Next greater power of 2. // Next greater power of 2.
__k = 1 << (__log2(__ik - 1) + 1); _M_k = 1 << (__log2(_M_ik - 1) + 1);
__offset = __k; _M_offset = _M_k;
// Avoid default-constructing __losers[]._M_key // Avoid default-constructing _M_losers[]._M_key
__losers = static_cast<_Loser*>(::operator new(2 * __k * sizeof(_Loser))); _M_losers = static_cast<_Loser*>(::operator new(2 * _M_k * sizeof(_Loser)));
for (unsigned int __i = __k + __ik - 1; __i < (2 * __k); ++__i) for (unsigned int __i = _M_k + _M_ik - 1; __i < (2 * _M_k); ++__i)
{ {
__losers[__i]._M_key = _sentinel; _M_losers[__i]._M_key = _sentinel;
__losers[__i]._M_source = -1; _M_losers[__i]._M_source = -1;
} }
} }
inline ~_LoserTreeUnguardedBase() inline ~_LoserTreeUnguardedBase()
{ ::operator delete(__losers); } { ::operator delete(_M_losers); }
inline int inline int
__get_min_source() __get_min_source()
{ {
#if _GLIBCXX_ASSERTIONS #if _GLIBCXX_ASSERTIONS
// no dummy sequence can ever be at the top! // no dummy sequence can ever be at the top!
_GLIBCXX_PARALLEL_ASSERT(__losers[0]._M_source != -1); _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif #endif
return __losers[0]._M_source; return _M_losers[0]._M_source;
} }
inline void inline void
__insert_start(const _Tp& _M_key, int _M_source, bool) __insert_start(const _Tp& _M_key, int _M_source, bool)
{ {
unsigned int __pos = __k + _M_source; unsigned int __pos = _M_k + _M_source;
new(&(__losers[__pos]._M_key)) _Tp(_M_key); new(&(_M_losers[__pos]._M_key)) _Tp(_M_key);
__losers[__pos]._M_source = _M_source; _M_losers[__pos]._M_source = _M_source;
} }
}; };
/** /**
* @brief Stable implementation of unguarded LoserTree. * @brief Stable implementation of unguarded _LoserTree.
* *
* Unstable variant is selected below with partial specialization. * Unstable variant is selected below with partial specialization.
*/ */
...@@ -617,19 +617,19 @@ template<bool __stable/* default == true */, typename _Tp, typename _Compare> ...@@ -617,19 +617,19 @@ template<bool __stable/* default == true */, typename _Tp, typename _Compare>
class _LoserTreeUnguarded : public _LoserTreeUnguardedBase<_Tp, _Compare> class _LoserTreeUnguarded : public _LoserTreeUnguardedBase<_Tp, _Compare>
{ {
typedef _LoserTreeUnguardedBase<_Tp, _Compare> Base; typedef _LoserTreeUnguardedBase<_Tp, _Compare> Base;
using Base::__k; using Base::_M_k;
using Base::__losers; using Base::_M_losers;
public: public:
_LoserTreeUnguarded(unsigned int _k, const _Tp _sentinel, _LoserTreeUnguarded(unsigned int __k, const _Tp _sentinel,
_Compare _comp = std::less<_Tp>()) _Compare __comp = std::less<_Tp>())
: Base::_LoserTreeUnguardedBase(_k, _sentinel, _comp) : Base::_LoserTreeUnguardedBase(__k, _sentinel, __comp)
{} {}
unsigned int unsigned int
__init_winner(unsigned int __root) __init_winner(unsigned int __root)
{ {
if (__root >= __k) if (__root >= _M_k)
{ {
return __root; return __root;
} }
...@@ -637,16 +637,16 @@ public: ...@@ -637,16 +637,16 @@ public:
{ {
unsigned int __left = __init_winner (2 * __root); unsigned int __left = __init_winner (2 * __root);
unsigned int __right = __init_winner (2 * __root + 1); unsigned int __right = __init_winner (2 * __root + 1);
if (!__comp(__losers[__right]._M_key, __losers[__left]._M_key)) if (!_M_comp(_M_losers[__right]._M_key, _M_losers[__left]._M_key))
{ {
// Left one is less or equal. // Left one is less or equal.
__losers[__root] = __losers[__right]; _M_losers[__root] = _M_losers[__right];
return __left; return __left;
} }
else else
{ {
// Right one is less. // Right one is less.
__losers[__root] = __losers[__left]; _M_losers[__root] = _M_losers[__left];
return __right; return __right;
} }
} }
...@@ -655,11 +655,11 @@ public: ...@@ -655,11 +655,11 @@ public:
inline void inline void
__init() __init()
{ {
__losers[0] = __losers[__init_winner(1)]; _M_losers[0] = _M_losers[__init_winner(1)];
#if _GLIBCXX_ASSERTIONS #if _GLIBCXX_ASSERTIONS
// no dummy sequence can ever be at the top at the beginning (0 sequences!) // no dummy sequence can ever be at the top at the beginning (0 sequences!)
_GLIBCXX_PARALLEL_ASSERT(__losers[0]._M_source != -1); _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif #endif
} }
...@@ -669,29 +669,29 @@ public: ...@@ -669,29 +669,29 @@ public:
{ {
#if _GLIBCXX_ASSERTIONS #if _GLIBCXX_ASSERTIONS
// no dummy sequence can ever be at the top! // no dummy sequence can ever be at the top!
_GLIBCXX_PARALLEL_ASSERT(__losers[0]._M_source != -1); _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif #endif
int _M_source = __losers[0]._M_source; int _M_source = _M_losers[0]._M_source;
for (unsigned int __pos = (__k + _M_source) / 2; __pos > 0; __pos /= 2) for (unsigned int __pos = (_M_k + _M_source) / 2; __pos > 0; __pos /= 2)
{ {
// The smaller one gets promoted, ties are broken by _M_source. // The smaller one gets promoted, ties are broken by _M_source.
if (__comp(__losers[__pos]._M_key, _M_key) if (_M_comp(_M_losers[__pos]._M_key, _M_key)
|| (!__comp(_M_key, __losers[__pos]._M_key) && __losers[__pos]._M_source < _M_source)) || (!_M_comp(_M_key, _M_losers[__pos]._M_key) && _M_losers[__pos]._M_source < _M_source))
{ {
// The other one is smaller. // The other one is smaller.
std::swap(__losers[__pos]._M_source, _M_source); std::swap(_M_losers[__pos]._M_source, _M_source);
std::swap(__losers[__pos]._M_key, _M_key); std::swap(_M_losers[__pos]._M_key, _M_key);
} }
} }
__losers[0]._M_source = _M_source; _M_losers[0]._M_source = _M_source;
__losers[0]._M_key = _M_key; _M_losers[0]._M_key = _M_key;
} }
}; };
/** /**
* @brief Non-Stable implementation of unguarded LoserTree. * @brief Non-Stable implementation of unguarded _LoserTree.
* *
* Stable implementation is above. * Stable implementation is above.
*/ */
...@@ -700,19 +700,19 @@ class _LoserTreeUnguarded</* __stable == */false, _Tp, _Compare> : ...@@ -700,19 +700,19 @@ class _LoserTreeUnguarded</* __stable == */false, _Tp, _Compare> :
public _LoserTreeUnguardedBase<_Tp, _Compare> public _LoserTreeUnguardedBase<_Tp, _Compare>
{ {
typedef _LoserTreeUnguardedBase<_Tp, _Compare> Base; typedef _LoserTreeUnguardedBase<_Tp, _Compare> Base;
using Base::__k; using Base::_M_k;
using Base::__losers; using Base::_M_losers;
public: public:
_LoserTreeUnguarded(unsigned int _k, const _Tp _sentinel, _LoserTreeUnguarded(unsigned int __k, const _Tp _sentinel,
_Compare _comp = std::less<_Tp>()) _Compare __comp = std::less<_Tp>())
: Base::_LoserTreeUnguardedBase(_k, _sentinel, _comp) : Base::_LoserTreeUnguardedBase(__k, _sentinel, __comp)
{} {}
unsigned int unsigned int
__init_winner (unsigned int __root) __init_winner (unsigned int __root)
{ {
if (__root >= __k) if (__root >= _M_k)
{ {
return __root; return __root;
} }
...@@ -723,20 +723,20 @@ public: ...@@ -723,20 +723,20 @@ public:
#if _GLIBCXX_ASSERTIONS #if _GLIBCXX_ASSERTIONS
// If __left one is sentinel then __right one must be, too. // If __left one is sentinel then __right one must be, too.
if (__losers[__left]._M_source == -1) if (_M_losers[__left]._M_source == -1)
_GLIBCXX_PARALLEL_ASSERT(__losers[__right]._M_source == -1); _GLIBCXX_PARALLEL_ASSERT(_M_losers[__right]._M_source == -1);
#endif #endif
if (!__comp(__losers[__right]._M_key, __losers[__left]._M_key)) if (!_M_comp(_M_losers[__right]._M_key, _M_losers[__left]._M_key))
{ {
// Left one is less or equal. // Left one is less or equal.
__losers[__root] = __losers[__right]; _M_losers[__root] = _M_losers[__right];
return __left; return __left;
} }
else else
{ {
// Right one is less. // Right one is less.
__losers[__root] = __losers[__left]; _M_losers[__root] = _M_losers[__left];
return __right; return __right;
} }
} }
...@@ -745,11 +745,11 @@ public: ...@@ -745,11 +745,11 @@ public:
inline void inline void
__init() __init()
{ {
__losers[0] = __losers[__init_winner(1)]; _M_losers[0] = _M_losers[__init_winner(1)];
#if _GLIBCXX_ASSERTIONS #if _GLIBCXX_ASSERTIONS
// no dummy sequence can ever be at the top at the beginning (0 sequences!) // no dummy sequence can ever be at the top at the beginning (0 sequences!)
_GLIBCXX_PARALLEL_ASSERT(__losers[0]._M_source != -1); _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif #endif
} }
...@@ -759,23 +759,23 @@ public: ...@@ -759,23 +759,23 @@ public:
{ {
#if _GLIBCXX_ASSERTIONS #if _GLIBCXX_ASSERTIONS
// no dummy sequence can ever be at the top! // no dummy sequence can ever be at the top!
_GLIBCXX_PARALLEL_ASSERT(__losers[0]._M_source != -1); _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif #endif
int _M_source = __losers[0]._M_source; int _M_source = _M_losers[0]._M_source;
for (unsigned int __pos = (__k + _M_source) / 2; __pos > 0; __pos /= 2) for (unsigned int __pos = (_M_k + _M_source) / 2; __pos > 0; __pos /= 2)
{ {
// The smaller one gets promoted. // The smaller one gets promoted.
if (__comp(__losers[__pos]._M_key, _M_key)) if (_M_comp(_M_losers[__pos]._M_key, _M_key))
{ {
// The other one is smaller. // The other one is smaller.
std::swap(__losers[__pos]._M_source, _M_source); std::swap(_M_losers[__pos]._M_source, _M_source);
std::swap(__losers[__pos]._M_key, _M_key); std::swap(_M_losers[__pos]._M_key, _M_key);
} }
} }
__losers[0]._M_source = _M_source; _M_losers[0]._M_source = _M_source;
__losers[0]._M_key = _M_key; _M_losers[0]._M_key = _M_key;
} }
}; };
...@@ -795,57 +795,57 @@ protected: ...@@ -795,57 +795,57 @@ protected:
const _Tp* _M_keyp; const _Tp* _M_keyp;
}; };
unsigned int __ik, __k, __offset; unsigned int _M_ik, _M_k, _M_offset;
_Loser* __losers; _Loser* _M_losers;
_Compare __comp; _Compare _M_comp;
public: public:
inline inline
LoserTreePointerUnguardedBase(unsigned int _k, const _Tp& _sentinel, LoserTreePointerUnguardedBase(unsigned int __k, const _Tp& _sentinel,
_Compare _comp = std::less<_Tp>()) _Compare __comp = std::less<_Tp>())
: __comp(_comp) : _M_comp(__comp)
{ {
__ik = _k; _M_ik = __k;
// Next greater power of 2. // Next greater power of 2.
__k = 1 << (__log2(__ik - 1) + 1); _M_k = 1 << (__log2(_M_ik - 1) + 1);
__offset = __k; _M_offset = _M_k;
// Avoid default-constructing __losers[]._M_key // Avoid default-constructing _M_losers[]._M_key
__losers = new _Loser[2 * __k]; _M_losers = new _Loser[2 * _M_k];
for (unsigned int __i = __k + __ik - 1; __i < (2 * __k); ++__i) for (unsigned int __i = _M_k + _M_ik - 1; __i < (2 * _M_k); ++__i)
{ {
__losers[__i]._M_keyp = &_sentinel; _M_losers[__i]._M_keyp = &_sentinel;
__losers[__i]._M_source = -1; _M_losers[__i]._M_source = -1;
} }
} }
inline ~LoserTreePointerUnguardedBase() inline ~LoserTreePointerUnguardedBase()
{ delete[] __losers; } { delete[] _M_losers; }
inline int inline int
__get_min_source() __get_min_source()
{ {
#if _GLIBCXX_ASSERTIONS #if _GLIBCXX_ASSERTIONS
// no dummy sequence can ever be at the top! // no dummy sequence can ever be at the top!
_GLIBCXX_PARALLEL_ASSERT(__losers[0]._M_source != -1); _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif #endif
return __losers[0]._M_source; return _M_losers[0]._M_source;
} }
inline void inline void
__insert_start(const _Tp& _M_key, int _M_source, bool) __insert_start(const _Tp& _M_key, int _M_source, bool)
{ {
unsigned int __pos = __k + _M_source; unsigned int __pos = _M_k + _M_source;
__losers[__pos]._M_keyp = &_M_key; _M_losers[__pos]._M_keyp = &_M_key;
__losers[__pos]._M_source = _M_source; _M_losers[__pos]._M_source = _M_source;
} }
}; };
/** /**
* @brief Stable unguarded LoserTree variant storing pointers. * @brief Stable unguarded _LoserTree variant storing pointers.
* *
* Unstable variant is implemented below using partial specialization. * Unstable variant is implemented below using partial specialization.
*/ */
...@@ -854,19 +854,19 @@ class LoserTreePointerUnguarded : ...@@ -854,19 +854,19 @@ class LoserTreePointerUnguarded :
public LoserTreePointerUnguardedBase<_Tp, _Compare> public LoserTreePointerUnguardedBase<_Tp, _Compare>
{ {
typedef LoserTreePointerUnguardedBase<_Tp, _Compare> Base; typedef LoserTreePointerUnguardedBase<_Tp, _Compare> Base;
using Base::__k; using Base::_M_k;
using Base::__losers; using Base::_M_losers;
public: public:
LoserTreePointerUnguarded(unsigned int _k, const _Tp& _sentinel, LoserTreePointerUnguarded(unsigned int __k, const _Tp& _sentinel,
_Compare _comp = std::less<_Tp>()) _Compare __comp = std::less<_Tp>())
: Base::LoserTreePointerUnguardedBase(_k, _sentinel, _comp) : Base::LoserTreePointerUnguardedBase(__k, _sentinel, __comp)
{} {}
unsigned int unsigned int
__init_winner(unsigned int __root) __init_winner(unsigned int __root)
{ {
if (__root >= __k) if (__root >= _M_k)
{ {
return __root; return __root;
} }
...@@ -874,16 +874,16 @@ public: ...@@ -874,16 +874,16 @@ public:
{ {
unsigned int __left = __init_winner (2 * __root); unsigned int __left = __init_winner (2 * __root);
unsigned int __right = __init_winner (2 * __root + 1); unsigned int __right = __init_winner (2 * __root + 1);
if (!__comp(*__losers[__right]._M_keyp, *__losers[__left]._M_keyp)) if (!_M_comp(*_M_losers[__right]._M_keyp, *_M_losers[__left]._M_keyp))
{ {
// Left one is less or equal. // Left one is less or equal.
__losers[__root] = __losers[__right]; _M_losers[__root] = _M_losers[__right];
return __left; return __left;
} }
else else
{ {
// Right one is less. // Right one is less.
__losers[__root] = __losers[__left]; _M_losers[__root] = _M_losers[__left];
return __right; return __right;
} }
} }
...@@ -892,11 +892,11 @@ public: ...@@ -892,11 +892,11 @@ public:
inline void inline void
__init() __init()
{ {
__losers[0] = __losers[__init_winner(1)]; _M_losers[0] = _M_losers[__init_winner(1)];
#if _GLIBCXX_ASSERTIONS #if _GLIBCXX_ASSERTIONS
// no dummy sequence can ever be at the top at the beginning (0 sequences!) // no dummy sequence can ever be at the top at the beginning (0 sequences!)
_GLIBCXX_PARALLEL_ASSERT(__losers[0]._M_source != -1); _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif #endif
} }
...@@ -905,30 +905,30 @@ public: ...@@ -905,30 +905,30 @@ public:
{ {
#if _GLIBCXX_ASSERTIONS #if _GLIBCXX_ASSERTIONS
// no dummy sequence can ever be at the top! // no dummy sequence can ever be at the top!
_GLIBCXX_PARALLEL_ASSERT(__losers[0]._M_source != -1); _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif #endif
const _Tp* _M_keyp = &_M_key; const _Tp* _M_keyp = &_M_key;
int _M_source = __losers[0]._M_source; int _M_source = _M_losers[0]._M_source;
for (unsigned int __pos = (__k + _M_source) / 2; __pos > 0; __pos /= 2) for (unsigned int __pos = (_M_k + _M_source) / 2; __pos > 0; __pos /= 2)
{ {
// The smaller one gets promoted, ties are broken by _M_source. // The smaller one gets promoted, ties are broken by _M_source.
if (__comp(*__losers[__pos]._M_keyp, *_M_keyp) if (_M_comp(*_M_losers[__pos]._M_keyp, *_M_keyp)
|| (!__comp(*_M_keyp, *__losers[__pos]._M_keyp) && __losers[__pos]._M_source < _M_source)) || (!_M_comp(*_M_keyp, *_M_losers[__pos]._M_keyp) && _M_losers[__pos]._M_source < _M_source))
{ {
// The other one is smaller. // The other one is smaller.
std::swap(__losers[__pos]._M_source, _M_source); std::swap(_M_losers[__pos]._M_source, _M_source);
std::swap(__losers[__pos]._M_keyp, _M_keyp); std::swap(_M_losers[__pos]._M_keyp, _M_keyp);
} }
} }
__losers[0]._M_source = _M_source; _M_losers[0]._M_source = _M_source;
__losers[0]._M_keyp = _M_keyp; _M_losers[0]._M_keyp = _M_keyp;
} }
}; };
/** /**
* @brief Unstable unguarded LoserTree variant storing pointers. * @brief Unstable unguarded _LoserTree variant storing pointers.
* *
* Stable variant is above. * Stable variant is above.
*/ */
...@@ -937,19 +937,19 @@ class LoserTreePointerUnguarded</* __stable == */false, _Tp, _Compare> : ...@@ -937,19 +937,19 @@ class LoserTreePointerUnguarded</* __stable == */false, _Tp, _Compare> :
public LoserTreePointerUnguardedBase<_Tp, _Compare> public LoserTreePointerUnguardedBase<_Tp, _Compare>
{ {
typedef LoserTreePointerUnguardedBase<_Tp, _Compare> Base; typedef LoserTreePointerUnguardedBase<_Tp, _Compare> Base;
using Base::__k; using Base::_M_k;
using Base::__losers; using Base::_M_losers;
public: public:
LoserTreePointerUnguarded(unsigned int _k, const _Tp& _sentinel, LoserTreePointerUnguarded(unsigned int __k, const _Tp& _sentinel,
_Compare _comp = std::less<_Tp>()) _Compare __comp = std::less<_Tp>())
: Base::LoserTreePointerUnguardedBase(_k, _sentinel, _comp) : Base::LoserTreePointerUnguardedBase(__k, _sentinel, __comp)
{} {}
unsigned int unsigned int
__init_winner(unsigned int __root) __init_winner(unsigned int __root)
{ {
if (__root >= __k) if (__root >= _M_k)
{ {
return __root; return __root;
} }
...@@ -960,20 +960,20 @@ public: ...@@ -960,20 +960,20 @@ public:
#if _GLIBCXX_ASSERTIONS #if _GLIBCXX_ASSERTIONS
// If __left one is sentinel then __right one must be, too. // If __left one is sentinel then __right one must be, too.
if (__losers[__left]._M_source == -1) if (_M_losers[__left]._M_source == -1)
_GLIBCXX_PARALLEL_ASSERT(__losers[__right]._M_source == -1); _GLIBCXX_PARALLEL_ASSERT(_M_losers[__right]._M_source == -1);
#endif #endif
if (!__comp(*__losers[__right]._M_keyp, *__losers[__left]._M_keyp)) if (!_M_comp(*_M_losers[__right]._M_keyp, *_M_losers[__left]._M_keyp))
{ {
// Left one is less or equal. // Left one is less or equal.
__losers[__root] = __losers[__right]; _M_losers[__root] = _M_losers[__right];
return __left; return __left;
} }
else else
{ {
// Right one is less. // Right one is less.
__losers[__root] = __losers[__left]; _M_losers[__root] = _M_losers[__left];
return __right; return __right;
} }
} }
...@@ -982,11 +982,11 @@ public: ...@@ -982,11 +982,11 @@ public:
inline void inline void
__init() __init()
{ {
__losers[0] = __losers[__init_winner(1)]; _M_losers[0] = _M_losers[__init_winner(1)];
#if _GLIBCXX_ASSERTIONS #if _GLIBCXX_ASSERTIONS
// no dummy sequence can ever be at the top at the beginning (0 sequences!) // no dummy sequence can ever be at the top at the beginning (0 sequences!)
_GLIBCXX_PARALLEL_ASSERT(__losers[0]._M_source != -1); _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif #endif
} }
...@@ -995,24 +995,24 @@ public: ...@@ -995,24 +995,24 @@ public:
{ {
#if _GLIBCXX_ASSERTIONS #if _GLIBCXX_ASSERTIONS
// no dummy sequence can ever be at the top! // no dummy sequence can ever be at the top!
_GLIBCXX_PARALLEL_ASSERT(__losers[0]._M_source != -1); _GLIBCXX_PARALLEL_ASSERT(_M_losers[0]._M_source != -1);
#endif #endif
const _Tp* _M_keyp = &_M_key; const _Tp* _M_keyp = &_M_key;
int _M_source = __losers[0]._M_source; int _M_source = _M_losers[0]._M_source;
for (unsigned int __pos = (__k + _M_source) / 2; __pos > 0; __pos /= 2) for (unsigned int __pos = (_M_k + _M_source) / 2; __pos > 0; __pos /= 2)
{ {
// The smaller one gets promoted. // The smaller one gets promoted.
if (__comp(*(__losers[__pos]._M_keyp), *_M_keyp)) if (_M_comp(*(_M_losers[__pos]._M_keyp), *_M_keyp))
{ {
// The other one is smaller. // The other one is smaller.
std::swap(__losers[__pos]._M_source, _M_source); std::swap(_M_losers[__pos]._M_source, _M_source);
std::swap(__losers[__pos]._M_keyp, _M_keyp); std::swap(_M_losers[__pos]._M_keyp, _M_keyp);
} }
} }
__losers[0]._M_source = _M_source; _M_losers[0]._M_source = _M_source;
__losers[0]._M_keyp = _M_keyp; _M_losers[0]._M_keyp = _M_keyp;
} }
}; };
......
...@@ -56,19 +56,19 @@ namespace __gnu_parallel ...@@ -56,19 +56,19 @@ namespace __gnu_parallel
: public std::binary_function<std::pair<_T1, _T2>, std::pair<_T1, _T2>, bool> : public std::binary_function<std::pair<_T1, _T2>, std::pair<_T1, _T2>, bool>
{ {
private: private:
_Compare& __comp; _Compare& _M_comp;
public: public:
_Lexicographic(_Compare& _comp) : __comp(_comp) { } _Lexicographic(_Compare& __comp) : _M_comp(__comp) { }
bool bool
operator()(const std::pair<_T1, _T2>& __p1, operator()(const std::pair<_T1, _T2>& __p1,
const std::pair<_T1, _T2>& __p2) const const std::pair<_T1, _T2>& __p2) const
{ {
if (__comp(__p1.first, __p2.first)) if (_M_comp(__p1.first, __p2.first))
return true; return true;
if (__comp(__p2.first, __p1.first)) if (_M_comp(__p2.first, __p1.first))
return false; return false;
// Firsts are equal. // Firsts are equal.
...@@ -81,19 +81,19 @@ namespace __gnu_parallel ...@@ -81,19 +81,19 @@ namespace __gnu_parallel
class _LexicographicReverse : public std::binary_function<_T1, _T2, bool> class _LexicographicReverse : public std::binary_function<_T1, _T2, bool>
{ {
private: private:
_Compare& __comp; _Compare& _M_comp;
public: public:
_LexicographicReverse(_Compare& _comp) : __comp(_comp) { } _LexicographicReverse(_Compare& __comp) : _M_comp(__comp) { }
bool bool
operator()(const std::pair<_T1, _T2>& __p1, operator()(const std::pair<_T1, _T2>& __p1,
const std::pair<_T1, _T2>& __p2) const const std::pair<_T1, _T2>& __p2) const
{ {
if (__comp(__p2.first, __p1.first)) if (_M_comp(__p2.first, __p1.first))
return true; return true;
if (__comp(__p1.first, __p2.first)) if (_M_comp(__p1.first, __p2.first))
return false; return false;
// Firsts are equal. // Firsts are equal.
......
...@@ -950,7 +950,7 @@ struct __multiway_merge_k_variant_sentinel_switch ...@@ -950,7 +950,7 @@ struct __multiway_merge_k_variant_sentinel_switch
typename __gnu_cxx::__conditional_type< typename __gnu_cxx::__conditional_type<
_LoserTreeTraits<_ValueType>::_M_use_pointer _LoserTreeTraits<_ValueType>::_M_use_pointer
, _LoserTreePointer<__stable, _ValueType, _Compare> , _LoserTreePointer<__stable, _ValueType, _Compare>
, LoserTree<__stable, _ValueType, _Compare> , _LoserTree<__stable, _ValueType, _Compare>
>::__type >(__seqs_begin, __seqs_end, __target, __length, __comp); >::__type >(__seqs_begin, __seqs_end, __target, __length, __comp);
} }
}; };
......
...@@ -49,10 +49,10 @@ template<typename _DifferenceTp> ...@@ -49,10 +49,10 @@ template<typename _DifferenceTp>
typedef _DifferenceTp _DifferenceType; typedef _DifferenceTp _DifferenceType;
/** @brief Begin of subsequence. */ /** @brief Begin of subsequence. */
_DifferenceType __begin; _DifferenceType _M_begin;
/** @brief End of subsequence. */ /** @brief End of subsequence. */
_DifferenceType __end; _DifferenceType _M_end;
}; };
/** @brief Data accessed by all threads. /** @brief Data accessed by all threads.
...@@ -66,7 +66,7 @@ template<typename _RAIter> ...@@ -66,7 +66,7 @@ template<typename _RAIter>
typedef typename _TraitsType::difference_type _DifferenceType; typedef typename _TraitsType::difference_type _DifferenceType;
/** @brief Number of threads involved. */ /** @brief Number of threads involved. */
_ThreadIndex __num_threads; _ThreadIndex _M_num_threads;
/** @brief Input __begin. */ /** @brief Input __begin. */
_RAIter _M_source; _RAIter _M_source;
...@@ -141,40 +141,40 @@ template<typename _RAIter, typename _Compare, ...@@ -141,40 +141,40 @@ template<typename _RAIter, typename _Compare,
# pragma omp barrier # pragma omp barrier
std::vector<std::pair<_SortingPlacesIterator, _SortingPlacesIterator> > std::vector<std::pair<_SortingPlacesIterator, _SortingPlacesIterator> >
seqs(__sd->__num_threads); seqs(__sd->_M_num_threads);
for (_ThreadIndex __s = 0; __s < __sd->__num_threads; __s++) for (_ThreadIndex __s = 0; __s < __sd->_M_num_threads; __s++)
seqs[__s] = std::make_pair(__sd->_M_temporary[__s], seqs[__s] = std::make_pair(__sd->_M_temporary[__s],
__sd->_M_temporary[__s] __sd->_M_temporary[__s]
+ (__sd->_M_starts[__s + 1] - __sd->_M_starts[__s])); + (__sd->_M_starts[__s + 1] - __sd->_M_starts[__s]));
std::vector<_SortingPlacesIterator> _M_offsets(__sd->__num_threads); std::vector<_SortingPlacesIterator> _M_offsets(__sd->_M_num_threads);
// if not last thread // if not last thread
if (__iam < __sd->__num_threads - 1) if (__iam < __sd->_M_num_threads - 1)
multiseq_partition(seqs.begin(), seqs.end(), multiseq_partition(seqs.begin(), seqs.end(),
__sd->_M_starts[__iam + 1], _M_offsets.begin(), __comp); __sd->_M_starts[__iam + 1], _M_offsets.begin(), __comp);
for (int __seq = 0; __seq < __sd->__num_threads; __seq++) for (int __seq = 0; __seq < __sd->_M_num_threads; __seq++)
{ {
// for each sequence // for each sequence
if (__iam < (__sd->__num_threads - 1)) if (__iam < (__sd->_M_num_threads - 1))
__sd->_M_pieces[__iam][__seq].__end = _M_offsets[__seq] - seqs[__seq].first; __sd->_M_pieces[__iam][__seq]._M_end = _M_offsets[__seq] - seqs[__seq].first;
else else
// very end of this sequence // very end of this sequence
__sd->_M_pieces[__iam][__seq].__end = __sd->_M_pieces[__iam][__seq]._M_end =
__sd->_M_starts[__seq + 1] - __sd->_M_starts[__seq]; __sd->_M_starts[__seq + 1] - __sd->_M_starts[__seq];
} }
# pragma omp barrier # pragma omp barrier
for (_ThreadIndex __seq = 0; __seq < __sd->__num_threads; __seq++) for (_ThreadIndex __seq = 0; __seq < __sd->_M_num_threads; __seq++)
{ {
// For each sequence. // For each sequence.
if (__iam > 0) if (__iam > 0)
__sd->_M_pieces[__iam][__seq].__begin = __sd->_M_pieces[__iam - 1][__seq].__end; __sd->_M_pieces[__iam][__seq]._M_begin = __sd->_M_pieces[__iam - 1][__seq]._M_end;
else else
// Absolute beginning. // Absolute beginning.
__sd->_M_pieces[__iam][__seq].__begin = 0; __sd->_M_pieces[__iam][__seq]._M_begin = 0;
} }
} }
}; };
...@@ -204,16 +204,16 @@ template<typename _RAIter, typename _Compare, ...@@ -204,16 +204,16 @@ template<typename _RAIter, typename _Compare,
# pragma omp single # pragma omp single
__gnu_sequential::sort(__sd->_M_samples, __gnu_sequential::sort(__sd->_M_samples,
__sd->_M_samples + (__num_samples * __sd->__num_threads), __sd->_M_samples + (__num_samples * __sd->_M_num_threads),
__comp); __comp);
# pragma omp barrier # pragma omp barrier
for (_ThreadIndex __s = 0; __s < __sd->__num_threads; ++__s) for (_ThreadIndex __s = 0; __s < __sd->_M_num_threads; ++__s)
{ {
// For each sequence. // For each sequence.
if (__num_samples * __iam > 0) if (__num_samples * __iam > 0)
__sd->_M_pieces[__iam][__s].__begin = __sd->_M_pieces[__iam][__s]._M_begin =
std::lower_bound(__sd->_M_temporary[__s], std::lower_bound(__sd->_M_temporary[__s],
__sd->_M_temporary[__s] __sd->_M_temporary[__s]
+ (__sd->_M_starts[__s + 1] - __sd->_M_starts[__s]), + (__sd->_M_starts[__s + 1] - __sd->_M_starts[__s]),
...@@ -222,10 +222,10 @@ template<typename _RAIter, typename _Compare, ...@@ -222,10 +222,10 @@ template<typename _RAIter, typename _Compare,
- __sd->_M_temporary[__s]; - __sd->_M_temporary[__s];
else else
// Absolute beginning. // Absolute beginning.
__sd->_M_pieces[__iam][__s].__begin = 0; __sd->_M_pieces[__iam][__s]._M_begin = 0;
if ((__num_samples * (__iam + 1)) < (__num_samples * __sd->__num_threads)) if ((__num_samples * (__iam + 1)) < (__num_samples * __sd->_M_num_threads))
__sd->_M_pieces[__iam][__s].__end = __sd->_M_pieces[__iam][__s]._M_end =
std::lower_bound(__sd->_M_temporary[__s], std::lower_bound(__sd->_M_temporary[__s],
__sd->_M_temporary[__s] __sd->_M_temporary[__s]
+ (__sd->_M_starts[__s + 1] - __sd->_M_starts[__s]), + (__sd->_M_starts[__s + 1] - __sd->_M_starts[__s]),
...@@ -234,7 +234,7 @@ template<typename _RAIter, typename _Compare, ...@@ -234,7 +234,7 @@ template<typename _RAIter, typename _Compare,
- __sd->_M_temporary[__s]; - __sd->_M_temporary[__s];
else else
// Absolute __end. // Absolute __end.
__sd->_M_pieces[__iam][__s].__end = __sd->_M_starts[__s + 1] - __sd->_M_starts[__s]; __sd->_M_pieces[__iam][__s]._M_end = __sd->_M_starts[__s + 1] - __sd->_M_starts[__s];
} }
} }
}; };
...@@ -346,29 +346,29 @@ template<bool __stable, bool __exact, typename _RAIter, ...@@ -346,29 +346,29 @@ template<bool __stable, bool __exact, typename _RAIter,
// No barrier here: Synchronization is done by the splitting routine. // No barrier here: Synchronization is done by the splitting routine.
_DifferenceType __num_samples = _DifferenceType __num_samples =
_Settings::get().sort_mwms_oversampling * __sd->__num_threads - 1; _Settings::get().sort_mwms_oversampling * __sd->_M_num_threads - 1;
_SplitConsistently _SplitConsistently
<__exact, _RAIter, _Compare, _SortingPlacesIterator>() <__exact, _RAIter, _Compare, _SortingPlacesIterator>()
(__iam, __sd, __comp, __num_samples); (__iam, __sd, __comp, __num_samples);
// Offset from __target __begin, __length after merging. // Offset from __target __begin, __length after merging.
_DifferenceType __offset = 0, __length_am = 0; _DifferenceType __offset = 0, __length_am = 0;
for (_ThreadIndex __s = 0; __s < __sd->__num_threads; __s++) for (_ThreadIndex __s = 0; __s < __sd->_M_num_threads; __s++)
{ {
__length_am += __sd->_M_pieces[__iam][__s].__end - __sd->_M_pieces[__iam][__s].__begin; __length_am += __sd->_M_pieces[__iam][__s]._M_end - __sd->_M_pieces[__iam][__s]._M_begin;
__offset += __sd->_M_pieces[__iam][__s].__begin; __offset += __sd->_M_pieces[__iam][__s]._M_begin;
} }
typedef std::vector< typedef std::vector<
std::pair<_SortingPlacesIterator, _SortingPlacesIterator> > std::pair<_SortingPlacesIterator, _SortingPlacesIterator> >
seq_vector_type; seq_vector_type;
seq_vector_type seqs(__sd->__num_threads); seq_vector_type seqs(__sd->_M_num_threads);
for (int __s = 0; __s < __sd->__num_threads; ++__s) for (int __s = 0; __s < __sd->_M_num_threads; ++__s)
{ {
seqs[__s] = seqs[__s] =
std::make_pair(__sd->_M_temporary[__s] + __sd->_M_pieces[__iam][__s].__begin, std::make_pair(__sd->_M_temporary[__s] + __sd->_M_pieces[__iam][__s]._M_begin,
__sd->_M_temporary[__s] + __sd->_M_pieces[__iam][__s].__end); __sd->_M_temporary[__s] + __sd->_M_pieces[__iam][__s]._M_end);
} }
__possibly_stable_multiway_merge< __possibly_stable_multiway_merge<
...@@ -424,7 +424,7 @@ template<bool __stable, bool __exact, typename _RAIter, ...@@ -424,7 +424,7 @@ template<bool __stable, bool __exact, typename _RAIter,
# pragma omp single # pragma omp single
{ {
__sd.__num_threads = __num_threads; __sd._M_num_threads = __num_threads;
__sd._M_source = __begin; __sd._M_source = __begin;
__sd._M_temporary = new _ValueType*[__num_threads]; __sd._M_temporary = new _ValueType*[__num_threads];
......
...@@ -108,7 +108,7 @@ template<typename _RAIter, ...@@ -108,7 +108,7 @@ template<typename _RAIter,
// Points to last element processed (needed as return value for // Points to last element processed (needed as return value for
// some algorithms like transform). // some algorithms like transform).
__f.finish_iterator = __begin + __length; __f._M_finish_iterator = __begin + __length;
return __o; return __o;
} }
......
...@@ -122,7 +122,7 @@ template<typename _RAIter, ...@@ -122,7 +122,7 @@ template<typename _RAIter,
// Points to last element processed (needed as return value for // Points to last element processed (needed as return value for
// some algorithms like transform). // some algorithms like transform).
__f.finish_iterator = __begin + __length; __f._M_finish_iterator = __begin + __length;
delete[] __thread_results; delete[] __thread_results;
delete[] __constructed; delete[] __constructed;
......
...@@ -43,9 +43,9 @@ namespace __gnu_parallel ...@@ -43,9 +43,9 @@ namespace __gnu_parallel
private: private:
std::tr1::mt19937 _M_mt; std::tr1::mt19937 _M_mt;
uint64 _M_supremum; uint64 _M_supremum;
uint64 _RAND_SUP; uint64 _M_rand_sup;
double _M_supremum_reciprocal; double _M_supremum_reciprocal;
double _RAND_SUP_REC; double _M_rand_sup_reciprocal;
// Assumed to be twice as long as the usual random number. // Assumed to be twice as long as the usual random number.
uint64 __cache; uint64 __cache;
...@@ -72,9 +72,9 @@ namespace __gnu_parallel ...@@ -72,9 +72,9 @@ namespace __gnu_parallel
/** @brief Default constructor. Seed with 0. */ /** @brief Default constructor. Seed with 0. */
_RandomNumber() _RandomNumber()
: _M_mt(0), _M_supremum(0x100000000ULL), : _M_mt(0), _M_supremum(0x100000000ULL),
_RAND_SUP(1ULL << (sizeof(uint32) * 8)), _M_rand_sup(1ULL << (sizeof(uint32) * 8)),
_M_supremum_reciprocal(double(_M_supremum) / double(_RAND_SUP)), _M_supremum_reciprocal(double(_M_supremum) / double(_M_rand_sup)),
_RAND_SUP_REC(1.0 / double(_RAND_SUP)), _M_rand_sup_reciprocal(1.0 / double(_M_rand_sup)),
__cache(0), __bits_left(0) { } __cache(0), __bits_left(0) { }
/** @brief Constructor. /** @brief Constructor.
...@@ -83,9 +83,9 @@ namespace __gnu_parallel ...@@ -83,9 +83,9 @@ namespace __gnu_parallel
* interval @__c [0,_M_supremum). */ * interval @__c [0,_M_supremum). */
_RandomNumber(uint32 __seed, uint64 _M_supremum = 0x100000000ULL) _RandomNumber(uint32 __seed, uint64 _M_supremum = 0x100000000ULL)
: _M_mt(__seed), _M_supremum(_M_supremum), : _M_mt(__seed), _M_supremum(_M_supremum),
_RAND_SUP(1ULL << (sizeof(uint32) * 8)), _M_rand_sup(1ULL << (sizeof(uint32) * 8)),
_M_supremum_reciprocal(double(_M_supremum) / double(_RAND_SUP)), _M_supremum_reciprocal(double(_M_supremum) / double(_M_rand_sup)),
_RAND_SUP_REC(1.0 / double(_RAND_SUP)), _M_rand_sup_reciprocal(1.0 / double(_M_rand_sup)),
__cache(0), __bits_left(0) { } __cache(0), __bits_left(0) { }
/** @brief Generate unsigned random 32-bit integer. */ /** @brief Generate unsigned random 32-bit integer. */
...@@ -99,17 +99,17 @@ namespace __gnu_parallel ...@@ -99,17 +99,17 @@ namespace __gnu_parallel
operator()(uint64 local_supremum) operator()(uint64 local_supremum)
{ {
return __scale_down(_M_mt(), local_supremum, return __scale_down(_M_mt(), local_supremum,
double(local_supremum * _RAND_SUP_REC)); double(local_supremum * _M_rand_sup_reciprocal));
} }
/** @brief Generate a number of random bits, run-time parameter. /** @brief Generate a number of random bits, run-time parameter.
* @param bits Number of bits to generate. */ * @param bits Number of bits to generate. */
unsigned long unsigned long
__genrand_bits(int bits) __genrand_bits(int __bits)
{ {
unsigned long __res = __cache & ((1 << bits) - 1); unsigned long __res = __cache & ((1 << __bits) - 1);
__cache = __cache >> bits; __cache = __cache >> __bits;
__bits_left -= bits; __bits_left -= __bits;
if (__bits_left < 32) if (__bits_left < 32)
{ {
__cache |= ((uint64(_M_mt())) << __bits_left); __cache |= ((uint64(_M_mt())) << __bits_left);
......
...@@ -63,7 +63,7 @@ template<typename _RAIter> ...@@ -63,7 +63,7 @@ template<typename _RAIter>
/** @brief Two-dimensional array to hold the thread-bin distribution. /** @brief Two-dimensional array to hold the thread-bin distribution.
* *
* Dimensions (__num_threads + 1) __x (_M_num_bins + 1). */ * Dimensions (_M_num_threads + 1) __x (_M_num_bins + 1). */
_DifferenceType** _M_dist; _DifferenceType** _M_dist;
/** @brief Start indexes of the threads' __chunks. */ /** @brief Start indexes of the threads' __chunks. */
...@@ -91,7 +91,7 @@ template<typename _RAIter, typename RandomNumberGenerator> ...@@ -91,7 +91,7 @@ template<typename _RAIter, typename RandomNumberGenerator>
struct _DRSSorterPU struct _DRSSorterPU
{ {
/** @brief Number of threads participating in total. */ /** @brief Number of threads participating in total. */
int __num_threads; int _M_num_threads;
/** @brief Begin __index for bins taken care of by this thread. */ /** @brief Begin __index for bins taken care of by this thread. */
_BinIndex _M_bins_begin; _BinIndex _M_bins_begin;
...@@ -135,7 +135,7 @@ template<typename _RAIter, typename RandomNumberGenerator> ...@@ -135,7 +135,7 @@ template<typename _RAIter, typename RandomNumberGenerator>
_BinIndex* __oracles = new _BinIndex[__length]; _BinIndex* __oracles = new _BinIndex[__length];
_DifferenceType* _M_dist = new _DifferenceType[_M_sd->_M_num_bins + 1]; _DifferenceType* _M_dist = new _DifferenceType[_M_sd->_M_num_bins + 1];
_BinIndex* _M_bin_proc = new _BinIndex[_M_sd->_M_num_bins]; _BinIndex* _M_bin_proc = new _BinIndex[_M_sd->_M_num_bins];
_ValueType** _M_temporaries = new _ValueType*[d->__num_threads]; _ValueType** _M_temporaries = new _ValueType*[d->_M_num_threads];
// Compute oracles and count appearances. // Compute oracles and count appearances.
for (_BinIndex __b = 0; __b < _M_sd->_M_num_bins + 1; ++__b) for (_BinIndex __b = 0; __b < _M_sd->_M_num_bins + 1; ++__b)
...@@ -161,11 +161,11 @@ template<typename _RAIter, typename RandomNumberGenerator> ...@@ -161,11 +161,11 @@ template<typename _RAIter, typename RandomNumberGenerator>
# pragma omp single # pragma omp single
{ {
// Sum up bins, _M_sd->_M_dist[__s + 1][d->__num_threads] now contains the // Sum up bins, _M_sd->_M_dist[__s + 1][d->_M_num_threads] now contains the
// total number of items in bin __s // total number of items in bin __s
for (_BinIndex __s = 0; __s < _M_sd->_M_num_bins; ++__s) for (_BinIndex __s = 0; __s < _M_sd->_M_num_bins; ++__s)
__gnu_sequential::partial_sum(_M_sd->_M_dist[__s + 1], __gnu_sequential::partial_sum(_M_sd->_M_dist[__s + 1],
_M_sd->_M_dist[__s + 1] + d->__num_threads + 1, _M_sd->_M_dist[__s + 1] + d->_M_num_threads + 1,
_M_sd->_M_dist[__s + 1]); _M_sd->_M_dist[__s + 1]);
} }
...@@ -173,15 +173,15 @@ template<typename _RAIter, typename RandomNumberGenerator> ...@@ -173,15 +173,15 @@ template<typename _RAIter, typename RandomNumberGenerator>
_SequenceIndex __offset = 0, __global_offset = 0; _SequenceIndex __offset = 0, __global_offset = 0;
for (_BinIndex __s = 0; __s < d->_M_bins_begin; ++__s) for (_BinIndex __s = 0; __s < d->_M_bins_begin; ++__s)
__global_offset += _M_sd->_M_dist[__s + 1][d->__num_threads]; __global_offset += _M_sd->_M_dist[__s + 1][d->_M_num_threads];
# pragma omp barrier # pragma omp barrier
for (_BinIndex __s = d->_M_bins_begin; __s < d->__bins_end; ++__s) for (_BinIndex __s = d->_M_bins_begin; __s < d->__bins_end; ++__s)
{ {
for (int __t = 0; __t < d->__num_threads + 1; ++__t) for (int __t = 0; __t < d->_M_num_threads + 1; ++__t)
_M_sd->_M_dist[__s + 1][__t] += __offset; _M_sd->_M_dist[__s + 1][__t] += __offset;
__offset = _M_sd->_M_dist[__s + 1][d->__num_threads]; __offset = _M_sd->_M_dist[__s + 1][d->_M_num_threads];
} }
_M_sd->_M_temporaries[__iam] = static_cast<_ValueType*>( _M_sd->_M_temporaries[__iam] = static_cast<_ValueType*>(
...@@ -194,7 +194,7 @@ template<typename _RAIter, typename RandomNumberGenerator> ...@@ -194,7 +194,7 @@ template<typename _RAIter, typename RandomNumberGenerator>
_M_dist[__b] = _M_sd->_M_dist[__b][__iam]; _M_dist[__b] = _M_sd->_M_dist[__b][__iam];
for (_BinIndex __b = 0; __b < _M_sd->_M_num_bins; ++__b) for (_BinIndex __b = 0; __b < _M_sd->_M_num_bins; ++__b)
_M_bin_proc[__b] = _M_sd->_M_bin_proc[__b]; _M_bin_proc[__b] = _M_sd->_M_bin_proc[__b];
for (_ThreadIndex __t = 0; __t < d->__num_threads; ++__t) for (_ThreadIndex __t = 0; __t < d->_M_num_threads; ++__t)
_M_temporaries[__t] = _M_sd->_M_temporaries[__t]; _M_temporaries[__t] = _M_sd->_M_temporaries[__t];
_RAIter _M_source = _M_sd->_M_source; _RAIter _M_source = _M_sd->_M_source;
...@@ -206,7 +206,7 @@ template<typename _RAIter, typename RandomNumberGenerator> ...@@ -206,7 +206,7 @@ template<typename _RAIter, typename RandomNumberGenerator>
_BinIndex target_bin = __oracles[__i]; _BinIndex target_bin = __oracles[__i];
_ThreadIndex target_p = _M_bin_proc[target_bin]; _ThreadIndex target_p = _M_bin_proc[target_bin];
// Last column [d->__num_threads] stays unchanged. // Last column [d->_M_num_threads] stays unchanged.
::new(&(_M_temporaries[target_p][_M_dist[target_bin + 1]++])) ::new(&(_M_temporaries[target_p][_M_dist[target_bin + 1]++]))
_ValueType(*(_M_source + __i + __start)); _ValueType(*(_M_source + __i + __start));
} }
...@@ -223,12 +223,12 @@ template<typename _RAIter, typename RandomNumberGenerator> ...@@ -223,12 +223,12 @@ template<typename _RAIter, typename RandomNumberGenerator>
{ {
_ValueType* __begin = _ValueType* __begin =
_M_sd->_M_temporaries[__iam] + _M_sd->_M_temporaries[__iam] +
((__b == d->_M_bins_begin) ? 0 : _M_sd->_M_dist[__b][d->__num_threads]), ((__b == d->_M_bins_begin) ? 0 : _M_sd->_M_dist[__b][d->_M_num_threads]),
* __end = * __end =
_M_sd->_M_temporaries[__iam] + _M_sd->_M_dist[__b + 1][d->__num_threads]; _M_sd->_M_temporaries[__iam] + _M_sd->_M_dist[__b + 1][d->_M_num_threads];
__sequential_random_shuffle(__begin, __end, __rng); __sequential_random_shuffle(__begin, __end, __rng);
std::copy(__begin, __end, _M_sd->_M_source + __global_offset + std::copy(__begin, __end, _M_sd->_M_source + __global_offset +
((__b == d->_M_bins_begin) ? 0 : _M_sd->_M_dist[__b][d->__num_threads])); ((__b == d->_M_bins_begin) ? 0 : _M_sd->_M_dist[__b][d->_M_num_threads]));
} }
::operator delete(_M_sd->_M_temporaries[__iam]); ::operator delete(_M_sd->_M_temporaries[__iam]);
...@@ -364,7 +364,7 @@ template<typename _RAIter, typename RandomNumberGenerator> ...@@ -364,7 +364,7 @@ template<typename _RAIter, typename RandomNumberGenerator>
__pus[__i].__bins_end = bin_cursor; __pus[__i].__bins_end = bin_cursor;
for (; __j < bin_cursor; ++__j) for (; __j < bin_cursor; ++__j)
_M_sd._M_bin_proc[__j] = __i; _M_sd._M_bin_proc[__j] = __i;
__pus[__i].__num_threads = __num_threads; __pus[__i]._M_num_threads = __num_threads;
__pus[__i]._M_seed = __rng(std::numeric_limits<uint32>::max()); __pus[__i]._M_seed = __rng(std::numeric_limits<uint32>::max());
__pus[__i]._M_sd = &_M_sd; __pus[__i]._M_sd = &_M_sd;
} }
......
...@@ -71,9 +71,9 @@ template<typename _IIter, ...@@ -71,9 +71,9 @@ template<typename _IIter,
typedef typename _TraitsType::difference_type _DifferenceType; typedef typename _TraitsType::difference_type _DifferenceType;
typedef typename std::pair<_IIter, _IIter> _IteratorPair; typedef typename std::pair<_IIter, _IIter> _IteratorPair;
symmetric_difference_func(_Compare __c) : __comp(__c) {} symmetric_difference_func(_Compare __comp) : _M_comp(__comp) {}
_Compare __comp; _Compare _M_comp;
_OutputIterator _OutputIterator
_M_invoke(_IIter __a, _IIter __b, _M_invoke(_IIter __a, _IIter __b,
...@@ -82,13 +82,13 @@ template<typename _IIter, ...@@ -82,13 +82,13 @@ template<typename _IIter,
{ {
while (__a != __b && __c != d) while (__a != __b && __c != d)
{ {
if (__comp(*__a, *__c)) if (_M_comp(*__a, *__c))
{ {
*__r = *__a; *__r = *__a;
++__a; ++__a;
++__r; ++__r;
} }
else if (__comp(*__c, *__a)) else if (_M_comp(*__c, *__a))
{ {
*__r = *__c; *__r = *__c;
++__c; ++__c;
...@@ -111,12 +111,12 @@ template<typename _IIter, ...@@ -111,12 +111,12 @@ template<typename _IIter,
while (__a != __b && __c != d) while (__a != __b && __c != d)
{ {
if (__comp(*__a, *__c)) if (_M_comp(*__a, *__c))
{ {
++__a; ++__a;
++__counter; ++__counter;
} }
else if (__comp(*__c, *__a)) else if (_M_comp(*__c, *__a))
{ {
++__c; ++__c;
++__counter; ++__counter;
...@@ -150,9 +150,9 @@ template<typename _IIter, ...@@ -150,9 +150,9 @@ template<typename _IIter,
typedef typename _TraitsType::difference_type _DifferenceType; typedef typename _TraitsType::difference_type _DifferenceType;
typedef typename std::pair<_IIter, _IIter> _IteratorPair; typedef typename std::pair<_IIter, _IIter> _IteratorPair;
__difference_func(_Compare __c) : __comp(__c) {} __difference_func(_Compare __comp) : _M_comp(__comp) {}
_Compare __comp; _Compare _M_comp;
_OutputIterator _OutputIterator
_M_invoke(_IIter __a, _IIter __b, _IIter __c, _IIter d, _M_invoke(_IIter __a, _IIter __b, _IIter __c, _IIter d,
...@@ -160,13 +160,13 @@ template<typename _IIter, ...@@ -160,13 +160,13 @@ template<typename _IIter,
{ {
while (__a != __b && __c != d) while (__a != __b && __c != d)
{ {
if (__comp(*__a, *__c)) if (_M_comp(*__a, *__c))
{ {
*__r = *__a; *__r = *__a;
++__a; ++__a;
++__r; ++__r;
} }
else if (__comp(*__c, *__a)) else if (_M_comp(*__c, *__a))
{ ++__c; } { ++__c; }
else else
{ {
...@@ -185,12 +185,12 @@ template<typename _IIter, ...@@ -185,12 +185,12 @@ template<typename _IIter,
while (__a != __b && __c != d) while (__a != __b && __c != d)
{ {
if (__comp(*__a, *__c)) if (_M_comp(*__a, *__c))
{ {
++__a; ++__a;
++__counter; ++__counter;
} }
else if (__comp(*__c, *__a)) else if (_M_comp(*__c, *__a))
{ ++__c; } { ++__c; }
else else
{ ++__a; ++__c; } { ++__a; ++__c; }
...@@ -218,9 +218,9 @@ template<typename _IIter, ...@@ -218,9 +218,9 @@ template<typename _IIter,
typedef typename _TraitsType::difference_type _DifferenceType; typedef typename _TraitsType::difference_type _DifferenceType;
typedef typename std::pair<_IIter, _IIter> _IteratorPair; typedef typename std::pair<_IIter, _IIter> _IteratorPair;
__intersection_func(_Compare __c) : __comp(__c) {} __intersection_func(_Compare __comp) : _M_comp(__comp) {}
_Compare __comp; _Compare _M_comp;
_OutputIterator _OutputIterator
_M_invoke(_IIter __a, _IIter __b, _IIter __c, _IIter d, _M_invoke(_IIter __a, _IIter __b, _IIter __c, _IIter d,
...@@ -228,9 +228,9 @@ template<typename _IIter, ...@@ -228,9 +228,9 @@ template<typename _IIter,
{ {
while (__a != __b && __c != d) while (__a != __b && __c != d)
{ {
if (__comp(*__a, *__c)) if (_M_comp(*__a, *__c))
{ ++__a; } { ++__a; }
else if (__comp(*__c, *__a)) else if (_M_comp(*__c, *__a))
{ ++__c; } { ++__c; }
else else
{ {
...@@ -252,9 +252,9 @@ template<typename _IIter, ...@@ -252,9 +252,9 @@ template<typename _IIter,
while (__a != __b && __c != d) while (__a != __b && __c != d)
{ {
if (__comp(*__a, *__c)) if (_M_comp(*__a, *__c))
{ ++__a; } { ++__a; }
else if (__comp(*__c, *__a)) else if (_M_comp(*__c, *__a))
{ ++__c; } { ++__c; }
else else
{ {
...@@ -282,9 +282,9 @@ template<class _IIter, class _OutputIterator, class _Compare> ...@@ -282,9 +282,9 @@ template<class _IIter, class _OutputIterator, class _Compare>
typedef typename std::iterator_traits<_IIter>::difference_type typedef typename std::iterator_traits<_IIter>::difference_type
_DifferenceType; _DifferenceType;
__union_func(_Compare __c) : __comp(__c) {} __union_func(_Compare __comp) : _M_comp(__comp) {}
_Compare __comp; _Compare _M_comp;
_OutputIterator _OutputIterator
_M_invoke(_IIter __a, const _IIter __b, _IIter __c, _M_invoke(_IIter __a, const _IIter __b, _IIter __c,
...@@ -292,12 +292,12 @@ template<class _IIter, class _OutputIterator, class _Compare> ...@@ -292,12 +292,12 @@ template<class _IIter, class _OutputIterator, class _Compare>
{ {
while (__a != __b && __c != d) while (__a != __b && __c != d)
{ {
if (__comp(*__a, *__c)) if (_M_comp(*__a, *__c))
{ {
*__r = *__a; *__r = *__a;
++__a; ++__a;
} }
else if (__comp(*__c, *__a)) else if (_M_comp(*__c, *__a))
{ {
*__r = *__c; *__r = *__c;
++__c; ++__c;
...@@ -321,9 +321,9 @@ template<class _IIter, class _OutputIterator, class _Compare> ...@@ -321,9 +321,9 @@ template<class _IIter, class _OutputIterator, class _Compare>
while (__a != __b && __c != d) while (__a != __b && __c != d)
{ {
if (__comp(*__a, *__c)) if (_M_comp(*__a, *__c))
{ ++__a; } { ++__a; }
else if (__comp(*__c, *__a)) else if (_M_comp(*__c, *__a))
{ ++__c; } { ++__c; }
else else
{ {
...@@ -400,14 +400,14 @@ template<typename _IIter, ...@@ -400,14 +400,14 @@ template<typename _IIter,
_IIter __offset[2]; _IIter __offset[2];
const _DifferenceType __rank = __borders[__iam + 1]; const _DifferenceType __rank = __borders[__iam + 1];
multiseq_partition(__sequence, __sequence + 2, __rank, __offset, __op.__comp); multiseq_partition(__sequence, __sequence + 2, __rank, __offset, __op._M_comp);
// allowed to read? // allowed to read?
// together // together
// *(__offset[ 0 ] - 1) == *__offset[ 1 ] // *(__offset[ 0 ] - 1) == *__offset[ 1 ]
if (__offset[ 0 ] != __begin1 && __offset[ 1 ] != __end2 if (__offset[ 0 ] != __begin1 && __offset[ 1 ] != __end2
&& !__op.__comp(*(__offset[ 0 ] - 1), *__offset[ 1 ]) && !__op._M_comp(*(__offset[ 0 ] - 1), *__offset[ 1 ])
&& !__op.__comp(*__offset[ 1 ], *(__offset[ 0 ] - 1))) && !__op._M_comp(*__offset[ 1 ], *(__offset[ 0 ] - 1)))
{ {
// Avoid split between globally equal elements: move one to // Avoid split between globally equal elements: move one to
// front in first sequence. // front in first sequence.
...@@ -476,10 +476,10 @@ template<typename _IIter, ...@@ -476,10 +476,10 @@ template<typename _IIter,
inline _OutputIterator inline _OutputIterator
__parallel_set_union(_IIter __begin1, _IIter __end1, __parallel_set_union(_IIter __begin1, _IIter __end1,
_IIter __begin2, _IIter __end2, _IIter __begin2, _IIter __end2,
_OutputIterator __result, _Compare __comp) _OutputIterator __result, _Compare _M_comp)
{ {
return __parallel_set_operation(__begin1, __end1, __begin2, __end2, __result, return __parallel_set_operation(__begin1, __end1, __begin2, __end2, __result,
__union_func< _IIter, _OutputIterator, _Compare>(__comp)); __union_func< _IIter, _OutputIterator, _Compare>(_M_comp));
} }
template<typename _IIter, template<typename _IIter,
...@@ -488,10 +488,10 @@ template<typename _IIter, ...@@ -488,10 +488,10 @@ template<typename _IIter,
inline _OutputIterator inline _OutputIterator
__parallel_set_intersection(_IIter __begin1, _IIter __end1, __parallel_set_intersection(_IIter __begin1, _IIter __end1,
_IIter __begin2, _IIter __end2, _IIter __begin2, _IIter __end2,
_OutputIterator __result, _Compare __comp) _OutputIterator __result, _Compare _M_comp)
{ {
return __parallel_set_operation(__begin1, __end1, __begin2, __end2, __result, return __parallel_set_operation(__begin1, __end1, __begin2, __end2, __result,
__intersection_func<_IIter, _OutputIterator, _Compare>(__comp)); __intersection_func<_IIter, _OutputIterator, _Compare>(_M_comp));
} }
template<typename _IIter, template<typename _IIter,
...@@ -500,10 +500,10 @@ template<typename _IIter, ...@@ -500,10 +500,10 @@ template<typename _IIter,
inline _OutputIterator inline _OutputIterator
__parallel_set_difference(_IIter __begin1, _IIter __end1, __parallel_set_difference(_IIter __begin1, _IIter __end1,
_IIter __begin2, _IIter __end2, _IIter __begin2, _IIter __end2,
_OutputIterator __result, _Compare __comp) _OutputIterator __result, _Compare _M_comp)
{ {
return __parallel_set_operation(__begin1, __end1, __begin2, __end2, __result, return __parallel_set_operation(__begin1, __end1, __begin2, __end2, __result,
__difference_func<_IIter, _OutputIterator, _Compare>(__comp)); __difference_func<_IIter, _OutputIterator, _Compare>(_M_comp));
} }
template<typename _IIter, template<typename _IIter,
...@@ -512,11 +512,11 @@ template<typename _IIter, ...@@ -512,11 +512,11 @@ template<typename _IIter,
inline _OutputIterator inline _OutputIterator
__parallel_set_symmetric_difference(_IIter __begin1, _IIter __end1, __parallel_set_symmetric_difference(_IIter __begin1, _IIter __end1,
_IIter __begin2, _IIter __end2, _IIter __begin2, _IIter __end2,
_OutputIterator __result, _Compare __comp) _OutputIterator __result, _Compare _M_comp)
{ {
return __parallel_set_operation(__begin1, __end1, __begin2, __end2, __result, return __parallel_set_operation(__begin1, __end1, __begin2, __end2, __result,
symmetric_difference_func<_IIter, _OutputIterator, _Compare> symmetric_difference_func<_IIter, _OutputIterator, _Compare>
(__comp)); (_M_comp));
} }
} }
......
...@@ -46,37 +46,37 @@ namespace __gnu_parallel ...@@ -46,37 +46,37 @@ namespace __gnu_parallel
struct parallel_tag struct parallel_tag
{ {
private: private:
_ThreadIndex __num_threads; _ThreadIndex _M_num_threads;
public: public:
/** @brief Default constructor. Use default number of threads. */ /** @brief Default constructor. Use default number of threads. */
parallel_tag() parallel_tag()
{ {
this->__num_threads = 0; this->_M_num_threads = 0;
} }
/** @brief Default constructor. Recommend number of threads to use. /** @brief Default constructor. Recommend number of threads to use.
* @param __num_threads Desired number of threads. */ * @param __num_threads Desired number of threads. */
parallel_tag(_ThreadIndex __num_threads) parallel_tag(_ThreadIndex __num_threads)
{ {
this->__num_threads = __num_threads; this->_M_num_threads = __num_threads;
} }
/** @brief Find __out desired number of threads. /** @brief Find __out desired number of threads.
* @return Desired number of threads. */ * @return Desired number of threads. */
inline _ThreadIndex __get_num_threads() inline _ThreadIndex __get_num_threads()
{ {
if(__num_threads == 0) if(_M_num_threads == 0)
return omp_get_max_threads(); return omp_get_max_threads();
else else
return __num_threads; return _M_num_threads;
} }
/** @brief Set the desired number of threads. /** @brief Set the desired number of threads.
* @param __num_threads Desired number of threads. */ * @param __num_threads Desired number of threads. */
inline void set_num_threads(_ThreadIndex __num_threads) inline void set_num_threads(_ThreadIndex __num_threads)
{ {
this->__num_threads = __num_threads; this->_M_num_threads = __num_threads;
} }
}; };
......
...@@ -59,17 +59,17 @@ template<typename _DifferenceTp> ...@@ -59,17 +59,17 @@ template<typename _DifferenceTp>
* *
* Changed by owning and stealing thread. By stealing thread, * Changed by owning and stealing thread. By stealing thread,
* always incremented. */ * always incremented. */
_GLIBCXX_JOB_VOLATILE _DifferenceType __first; _GLIBCXX_JOB_VOLATILE _DifferenceType _M_first;
/** @brief Last element. /** @brief Last element.
* *
* Changed by owning thread only. */ * Changed by owning thread only. */
_GLIBCXX_JOB_VOLATILE _DifferenceType __last; _GLIBCXX_JOB_VOLATILE _DifferenceType _M_last;
/** @brief Number of elements, i.e. @__c __last-__first+1. /** @brief Number of elements, i.e. @__c _M_last-_M_first+1.
* *
* Changed by owning thread only. */ * Changed by owning thread only. */
_GLIBCXX_JOB_VOLATILE _DifferenceType __load; _GLIBCXX_JOB_VOLATILE _DifferenceType _M_load;
}; };
/** @brief Work stealing algorithm for random access iterators. /** @brief Work stealing algorithm for random access iterators.
...@@ -177,21 +177,21 @@ template<typename _RAIter, ...@@ -177,21 +177,21 @@ template<typename _RAIter,
__iam_working = true; __iam_working = true;
// How many jobs per thread? last thread gets the rest. // How many jobs per thread? last thread gets the rest.
__my_job.__first = __my_job._M_first =
static_cast<_DifferenceType>(__iam * (__length / __num_threads)); static_cast<_DifferenceType>(__iam * (__length / __num_threads));
__my_job.__last = (__iam == (__num_threads - 1)) ? __my_job._M_last = (__iam == (__num_threads - 1)) ?
(__length - 1) : ((__iam + 1) * (__length / __num_threads) - 1); (__length - 1) : ((__iam + 1) * (__length / __num_threads) - 1);
__my_job.__load = __my_job.__last - __my_job.__first + 1; __my_job._M_load = __my_job._M_last - __my_job._M_first + 1;
// Init __result with __first __value (to have a base value for reduction). // Init __result with _M_first __value (to have a base value for reduction).
if (__my_job.__first <= __my_job.__last) if (__my_job._M_first <= __my_job._M_last)
{ {
// Cannot use volatile variable directly. // Cannot use volatile variable directly.
_DifferenceType __my_first = __my_job.__first; _DifferenceType __my_first = __my_job._M_first;
__result = __f(__op, __begin + __my_first); __result = __f(__op, __begin + __my_first);
++__my_job.__first; ++__my_job._M_first;
--__my_job.__load; --__my_job._M_load;
} }
_RAIter __current; _RAIter __current;
...@@ -206,18 +206,18 @@ template<typename _RAIter, ...@@ -206,18 +206,18 @@ template<typename _RAIter,
# pragma omp flush(__busy) # pragma omp flush(__busy)
// Thread has own work to do // Thread has own work to do
while (__my_job.__first <= __my_job.__last) while (__my_job._M_first <= __my_job._M_last)
{ {
// fetch-and-add call // fetch-and-add call
// Reserve __current __job block (size __chunk_size) in my queue. // Reserve __current __job block (size __chunk_size) in my queue.
_DifferenceType current_job = _DifferenceType current_job =
__fetch_and_add<_DifferenceType>(&(__my_job.__first), __chunk_size); __fetch_and_add<_DifferenceType>(&(__my_job._M_first), __chunk_size);
// Update __load, to make the three values consistent, // Update _M_load, to make the three values consistent,
// __first might have been changed in the meantime // _M_first might have been changed in the meantime
__my_job.__load = __my_job.__last - __my_job.__first + 1; __my_job._M_load = __my_job._M_last - __my_job._M_first + 1;
for (_DifferenceType job_counter = 0; for (_DifferenceType job_counter = 0;
job_counter < __chunk_size && current_job <= __my_job.__last; job_counter < __chunk_size && current_job <= __my_job._M_last;
++job_counter) ++job_counter)
{ {
// Yes: process it! // Yes: process it!
...@@ -248,9 +248,9 @@ template<typename _RAIter, ...@@ -248,9 +248,9 @@ template<typename _RAIter,
__yield(); __yield();
# pragma omp flush(__busy) # pragma omp flush(__busy)
__victim = rand_gen(); __victim = rand_gen();
__supposed_first = __job[__victim * __stride].__first; __supposed_first = __job[__victim * __stride]._M_first;
__supposed_last = __job[__victim * __stride].__last; __supposed_last = __job[__victim * __stride]._M_last;
__supposed_load = __job[__victim * __stride].__load; __supposed_load = __job[__victim * __stride]._M_load;
} }
while (__busy > 0 while (__busy > 0
&& ((__supposed_load <= 0) && ((__supposed_load <= 0)
...@@ -268,13 +268,13 @@ template<typename _RAIter, ...@@ -268,13 +268,13 @@ template<typename _RAIter,
// Push __victim's __start forward. // Push __victim's __start forward.
_DifferenceType __stolen_first = _DifferenceType __stolen_first =
__fetch_and_add<_DifferenceType>( __fetch_and_add<_DifferenceType>(
&(__job[__victim * __stride].__first), __steal); &(__job[__victim * __stride]._M_first), __steal);
_DifferenceType stolen_try = _DifferenceType stolen_try =
__stolen_first + __steal - _DifferenceType(1); __stolen_first + __steal - _DifferenceType(1);
__my_job.__first = __stolen_first; __my_job._M_first = __stolen_first;
__my_job.__last = __gnu_parallel::min(stolen_try, __supposed_last); __my_job._M_last = __gnu_parallel::min(stolen_try, __supposed_last);
__my_job.__load = __my_job.__last - __my_job.__first + 1; __my_job._M_load = __my_job._M_last - __my_job._M_first + 1;
// Has potential work again. // Has potential work again.
# pragma omp atomic # pragma omp atomic
...@@ -295,7 +295,7 @@ template<typename _RAIter, ...@@ -295,7 +295,7 @@ template<typename _RAIter,
// Points to last element processed (needed as return value for // Points to last element processed (needed as return value for
// some algorithms like transform) // some algorithms like transform)
__f.finish_iterator = __begin + __length; __f._M_finish_iterator = __begin + __length;
omp_destroy_lock(&__output_lock); omp_destroy_lock(&__output_lock);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment