multiway_merge.h: Simple formatting and uglification fixes.
2009-11-05 Paolo Carlini <paolo.carlini@oracle.com> * include/parallel/multiway_merge.h: Simple formatting and uglification fixes. * include/parallel/losertree.h: Likewise. * include/parallel/base.h: Likewise. * include/parallel/par_loop.h: Likewise. * include/parallel/omp_loop_static.h: Likewise. * include/parallel/multiway_mergesort.h: Likewise. * include/parallel/partial_sum.h: Likewise. * include/parallel/omp_loop.h: Likewise. From-SVN: r153939
This commit is contained in:
parent
94086ef69c
commit
338311e5d7
|
@ -1,3 +1,15 @@
|
|||
2009-11-05 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* include/parallel/multiway_merge.h: Simple formatting and
|
||||
uglification fixes.
|
||||
* include/parallel/losertree.h: Likewise.
|
||||
* include/parallel/base.h: Likewise.
|
||||
* include/parallel/par_loop.h: Likewise.
|
||||
* include/parallel/omp_loop_static.h: Likewise.
|
||||
* include/parallel/multiway_mergesort.h: Likewise.
|
||||
* include/parallel/partial_sum.h: Likewise.
|
||||
* include/parallel/omp_loop.h: Likewise.
|
||||
|
||||
2009-11-04 Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
* testsuite/25_algorithms/fill/5.cc: Move...
|
||||
|
|
|
@ -163,9 +163,7 @@ template<typename _T1, typename _T2, typename _Compare>
|
|||
_EqualFromLess(_Compare& __comp) : _M_comp(__comp) { }
|
||||
|
||||
bool operator()(const _T1& __a, const _T2& __b)
|
||||
{
|
||||
return !_M_comp(__a, __b) && !_M_comp(__b, __a);
|
||||
}
|
||||
{ return !_M_comp(__a, __b) && !_M_comp(__b, __a); }
|
||||
};
|
||||
|
||||
|
||||
|
@ -199,8 +197,7 @@ template<typename _Operation, typename _FirstArgumentType,
|
|||
_FirstArgumentType _M_value;
|
||||
|
||||
public:
|
||||
__binder1st(const _Operation& __x,
|
||||
const _FirstArgumentType& __y)
|
||||
__binder1st(const _Operation& __x, const _FirstArgumentType& __y)
|
||||
: _M_op(__x), _M_value(__y) { }
|
||||
|
||||
_ResultType
|
||||
|
@ -228,8 +225,7 @@ template<typename _Operation, typename _FirstArgumentType,
|
|||
_SecondArgumentType _M_value;
|
||||
|
||||
public:
|
||||
binder2nd(const _Operation& __x,
|
||||
const _SecondArgumentType& __y)
|
||||
binder2nd(const _Operation& __x, const _SecondArgumentType& __y)
|
||||
: _M_op(__x), _M_value(__y) { }
|
||||
|
||||
_ResultType
|
||||
|
@ -343,8 +339,8 @@ template<typename _Tp, typename _DifferenceTp>
|
|||
_DifferenceType _M_pos;
|
||||
|
||||
public:
|
||||
_PseudoSequenceIterator(const _Tp& _M_val, _DifferenceType _M_pos)
|
||||
: _M_val(_M_val), _M_pos(_M_pos) { }
|
||||
_PseudoSequenceIterator(const _Tp& __val, _DifferenceType __pos)
|
||||
: _M_val(__val), _M_pos(__pos) { }
|
||||
|
||||
// Pre-increment operator.
|
||||
_PseudoSequenceIterator&
|
||||
|
@ -399,8 +395,8 @@ template<typename _Tp, typename _DifferenceTp>
|
|||
* @param _M_val Element of the sequence.
|
||||
* @param __count Number of (virtual) copies.
|
||||
*/
|
||||
_PseudoSequence(const _Tp& _M_val, _DifferenceType __count)
|
||||
: _M_val(_M_val), __count(__count) { }
|
||||
_PseudoSequence(const _Tp& __val, _DifferenceType __count)
|
||||
: _M_val(__val), _M_count(__count) { }
|
||||
|
||||
/** @brief Begin iterator. */
|
||||
iterator
|
||||
|
@ -410,11 +406,11 @@ template<typename _Tp, typename _DifferenceTp>
|
|||
/** @brief End iterator. */
|
||||
iterator
|
||||
end() const
|
||||
{ return iterator(_M_val, __count); }
|
||||
{ return iterator(_M_val, _M_count); }
|
||||
|
||||
private:
|
||||
const _Tp& _M_val;
|
||||
_DifferenceType __count;
|
||||
_DifferenceType _M_count;
|
||||
};
|
||||
|
||||
/** @brief Functor that does nothing */
|
||||
|
|
|
@ -163,7 +163,8 @@ template<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;
|
||||
using _Base::_M_k;
|
||||
|
@ -797,7 +798,7 @@ public:
|
|||
* run empty. This is a very fast variant.
|
||||
*/
|
||||
template<typename _Tp, typename _Compare>
|
||||
class LoserTreePointerUnguardedBase
|
||||
class _LoserTreePointerUnguardedBase
|
||||
{
|
||||
protected:
|
||||
struct _Loser
|
||||
|
@ -812,7 +813,7 @@ template<typename _Tp, typename _Compare>
|
|||
|
||||
public:
|
||||
|
||||
LoserTreePointerUnguardedBase(unsigned int __k, const _Tp& _sentinel,
|
||||
_LoserTreePointerUnguardedBase(unsigned int __k, const _Tp& _sentinel,
|
||||
_Compare __comp = std::less<_Tp>())
|
||||
: _M_comp(__comp)
|
||||
{
|
||||
|
@ -831,7 +832,7 @@ template<typename _Tp, typename _Compare>
|
|||
}
|
||||
}
|
||||
|
||||
~LoserTreePointerUnguardedBase()
|
||||
~_LoserTreePointerUnguardedBase()
|
||||
{ delete[] _M_losers; }
|
||||
|
||||
int
|
||||
|
@ -861,16 +862,16 @@ template<typename _Tp, typename _Compare>
|
|||
*/
|
||||
template<bool __stable/* default == true */, typename _Tp, typename _Compare>
|
||||
class _LoserTreePointerUnguarded
|
||||
: public LoserTreePointerUnguardedBase<_Tp, _Compare>
|
||||
: public _LoserTreePointerUnguardedBase<_Tp, _Compare>
|
||||
{
|
||||
typedef LoserTreePointerUnguardedBase<_Tp, _Compare> _Base;
|
||||
typedef _LoserTreePointerUnguardedBase<_Tp, _Compare> _Base;
|
||||
using _Base::_M_k;
|
||||
using _Base::_M_losers;
|
||||
|
||||
public:
|
||||
_LoserTreePointerUnguarded(unsigned int __k, const _Tp& _sentinel,
|
||||
_Compare __comp = std::less<_Tp>())
|
||||
: _Base::LoserTreePointerUnguardedBase(__k, _sentinel, __comp)
|
||||
: _Base::_LoserTreePointerUnguardedBase(__k, _sentinel, __comp)
|
||||
{ }
|
||||
|
||||
unsigned int
|
||||
|
@ -945,16 +946,16 @@ template<bool __stable/* default == true */, typename _Tp, typename _Compare>
|
|||
*/
|
||||
template<typename _Tp, typename _Compare>
|
||||
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::_M_k;
|
||||
using _Base::_M_losers;
|
||||
|
||||
public:
|
||||
_LoserTreePointerUnguarded(unsigned int __k, const _Tp& _sentinel,
|
||||
_Compare __comp = std::less<_Tp>())
|
||||
: _Base::LoserTreePointerUnguardedBase(__k, _sentinel, __comp)
|
||||
: _Base::_LoserTreePointerUnguardedBase(__k, _sentinel, __comp)
|
||||
{ }
|
||||
|
||||
unsigned int
|
||||
|
|
|
@ -54,24 +54,6 @@
|
|||
|
||||
namespace __gnu_parallel
|
||||
{
|
||||
|
||||
// Announce guarded and unguarded iterator.
|
||||
|
||||
template<typename _RAIter, typename _Compare>
|
||||
class _GuardedIterator;
|
||||
|
||||
// Making the arguments const references seems to dangerous,
|
||||
// the user-defined comparator might not be const.
|
||||
template<typename _RAIter, typename _Compare>
|
||||
inline bool
|
||||
operator<(_GuardedIterator<_RAIter, _Compare>& __bi1,
|
||||
_GuardedIterator<_RAIter, _Compare>& __bi2);
|
||||
|
||||
template<typename _RAIter, typename _Compare>
|
||||
inline bool
|
||||
operator<=(_GuardedIterator<_RAIter, _Compare>& __bi1,
|
||||
_GuardedIterator<_RAIter, _Compare>& __bi2);
|
||||
|
||||
/** @brief _Iterator wrapper supporting an implicit supremum at the end
|
||||
* of the sequence, dominating all comparisons.
|
||||
*
|
||||
|
@ -96,12 +78,11 @@ template<typename _RAIter, typename _Compare>
|
|||
public:
|
||||
/** @brief Constructor. Sets iterator to beginning of sequence.
|
||||
* @param __begin Begin iterator of sequence.
|
||||
* @param _M_end End iterator of sequence.
|
||||
* @param __end End iterator of sequence.
|
||||
* @param __comp Comparator provided for associated overloaded
|
||||
* compare operators. */
|
||||
_GuardedIterator(_RAIter __begin,
|
||||
_RAIter _M_end, _Compare& __comp)
|
||||
: _M_current(__begin), _M_end(_M_end), __comp(__comp)
|
||||
_GuardedIterator(_RAIter __begin, _RAIter __end, _Compare& __comp)
|
||||
: _M_current(__begin), _M_end(__end), __comp(__comp)
|
||||
{ }
|
||||
|
||||
/** @brief Pre-increment operator.
|
||||
|
@ -124,23 +105,11 @@ template<typename _RAIter, typename _Compare>
|
|||
operator _RAIter()
|
||||
{ return _M_current; }
|
||||
|
||||
friend bool
|
||||
operator< <_RAIter, _Compare>(
|
||||
_GuardedIterator<_RAIter, _Compare>& __bi1,
|
||||
_GuardedIterator<_RAIter, _Compare>& __bi2);
|
||||
|
||||
friend bool
|
||||
operator<= <_RAIter, _Compare>(
|
||||
_GuardedIterator<_RAIter, _Compare>& __bi1,
|
||||
_GuardedIterator<_RAIter, _Compare>& __bi2);
|
||||
};
|
||||
|
||||
/** @brief Compare two elements referenced by guarded iterators.
|
||||
* @param __bi1 First iterator.
|
||||
* @param __bi2 Second iterator.
|
||||
* @return @__c true if less. */
|
||||
template<typename _RAIter, typename _Compare>
|
||||
inline bool
|
||||
friend bool
|
||||
operator<(_GuardedIterator<_RAIter, _Compare>& __bi1,
|
||||
_GuardedIterator<_RAIter, _Compare>& __bi2)
|
||||
{
|
||||
|
@ -155,8 +124,7 @@ template<typename _RAIter, typename _Compare>
|
|||
* @param __bi1 First iterator.
|
||||
* @param __bi2 Second iterator.
|
||||
* @return @__c True if less equal. */
|
||||
template<typename _RAIter, typename _Compare>
|
||||
inline bool
|
||||
friend bool
|
||||
operator<=(_GuardedIterator<_RAIter, _Compare>& __bi1,
|
||||
_GuardedIterator<_RAIter, _Compare>& __bi2)
|
||||
{
|
||||
|
@ -166,19 +134,7 @@ template<typename _RAIter, typename _Compare>
|
|||
return false;
|
||||
return !(__bi1.__comp)(*__bi2, *__bi1); //normal compare
|
||||
}
|
||||
|
||||
template<typename _RAIter, typename _Compare>
|
||||
class _UnguardedIterator;
|
||||
|
||||
template<typename _RAIter, typename _Compare>
|
||||
inline bool
|
||||
operator<(_UnguardedIterator<_RAIter, _Compare>& __bi1,
|
||||
_UnguardedIterator<_RAIter, _Compare>& __bi2);
|
||||
|
||||
template<typename _RAIter, typename _Compare>
|
||||
inline bool
|
||||
operator<=(_UnguardedIterator<_RAIter, _Compare>& __bi1,
|
||||
_UnguardedIterator<_RAIter, _Compare>& __bi2);
|
||||
};
|
||||
|
||||
template<typename _RAIter, typename _Compare>
|
||||
class _UnguardedIterator
|
||||
|
@ -192,10 +148,10 @@ template<typename _RAIter, typename _Compare>
|
|||
public:
|
||||
/** @brief Constructor. Sets iterator to beginning of sequence.
|
||||
* @param __begin Begin iterator of sequence.
|
||||
* @param _M_end Unused, only for compatibility.
|
||||
* @param __end Unused, only for compatibility.
|
||||
* @param __comp Unused, only for compatibility. */
|
||||
_UnguardedIterator(_RAIter __begin,
|
||||
_RAIter _M_end, _Compare& __comp)
|
||||
_RAIter /* __end */, _Compare& __comp)
|
||||
: _M_current(__begin), __comp(__comp)
|
||||
{ }
|
||||
|
||||
|
@ -219,23 +175,11 @@ template<typename _RAIter, typename _Compare>
|
|||
operator _RAIter()
|
||||
{ return _M_current; }
|
||||
|
||||
friend bool
|
||||
operator< <_RAIter, _Compare>(
|
||||
_UnguardedIterator<_RAIter, _Compare>& __bi1,
|
||||
_UnguardedIterator<_RAIter, _Compare>& __bi2);
|
||||
|
||||
friend bool
|
||||
operator<= <_RAIter, _Compare>(
|
||||
_UnguardedIterator<_RAIter, _Compare>& __bi1,
|
||||
_UnguardedIterator<_RAIter, _Compare>& __bi2);
|
||||
};
|
||||
|
||||
/** @brief Compare two elements referenced by unguarded iterators.
|
||||
* @param __bi1 First iterator.
|
||||
* @param __bi2 Second iterator.
|
||||
* @return @__c true if less. */
|
||||
template<typename _RAIter, typename _Compare>
|
||||
inline bool
|
||||
friend bool
|
||||
operator<(_UnguardedIterator<_RAIter, _Compare>& __bi1,
|
||||
_UnguardedIterator<_RAIter, _Compare>& __bi2)
|
||||
{
|
||||
|
@ -247,14 +191,14 @@ template<typename _RAIter, typename _Compare>
|
|||
* @param __bi1 First iterator.
|
||||
* @param __bi2 Second iterator.
|
||||
* @return @__c True if less equal. */
|
||||
template<typename _RAIter, typename _Compare>
|
||||
inline bool
|
||||
friend bool
|
||||
operator<=(_UnguardedIterator<_RAIter, _Compare>& __bi1,
|
||||
_UnguardedIterator<_RAIter, _Compare>& __bi2)
|
||||
{
|
||||
// Normal compare.
|
||||
return !(__bi1.__comp)(*__bi2, *__bi1);
|
||||
}
|
||||
};
|
||||
|
||||
/** @brief Highly efficient 3-way merging procedure.
|
||||
*
|
||||
|
@ -287,8 +231,7 @@ template<template<typename RAI, typename C> class iterator,
|
|||
typename _DifferenceTp,
|
||||
typename _Compare>
|
||||
_RAIter3
|
||||
multiway_merge_3_variant(
|
||||
_RAIterIterator __seqs_begin,
|
||||
multiway_merge_3_variant(_RAIterIterator __seqs_begin,
|
||||
_RAIterIterator __seqs_end,
|
||||
_RAIter3 __target,
|
||||
_DifferenceTp __length, _Compare __comp)
|
||||
|
@ -612,8 +555,7 @@ template<typename _LT,
|
|||
typename _RAIter3,
|
||||
typename _DifferenceTp, typename _Compare>
|
||||
_RAIter3
|
||||
multiway_merge_loser_tree_unguarded(
|
||||
_RAIterIterator __seqs_begin,
|
||||
multiway_merge_loser_tree_unguarded(_RAIterIterator __seqs_begin,
|
||||
_RAIterIterator __seqs_end,
|
||||
_RAIter3 __target,
|
||||
const typename std::iterator_traits<typename std::iterator_traits<
|
||||
|
@ -702,8 +644,7 @@ template<typename UnguardedLoserTree,
|
|||
typename _DifferenceTp,
|
||||
typename _Compare>
|
||||
_RAIter3
|
||||
multiway_merge_loser_tree_sentinel(
|
||||
_RAIterIterator __seqs_begin,
|
||||
multiway_merge_loser_tree_sentinel(_RAIterIterator __seqs_begin,
|
||||
_RAIterIterator __seqs_end,
|
||||
_RAIter3 __target,
|
||||
const typename std::iterator_traits<typename std::iterator_traits<
|
||||
|
@ -796,7 +737,8 @@ template<bool __sentinels /*default == false*/,
|
|||
typename _Compare>
|
||||
struct __multiway_merge_3_variant_sentinel_switch
|
||||
{
|
||||
_RAIter3 operator()(_RAIterIterator __seqs_begin,
|
||||
_RAIter3
|
||||
operator()(_RAIterIterator __seqs_begin,
|
||||
_RAIterIterator __seqs_end,
|
||||
_RAIter3 __target,
|
||||
_DifferenceTp __length, _Compare __comp)
|
||||
|
@ -815,10 +757,12 @@ template<typename _RAIterIterator,
|
|||
typename _RAIter3,
|
||||
typename _DifferenceTp,
|
||||
typename _Compare>
|
||||
struct __multiway_merge_3_variant_sentinel_switch
|
||||
<true, _RAIterIterator, _RAIter3, _DifferenceTp, _Compare>
|
||||
struct __multiway_merge_3_variant_sentinel_switch<true, _RAIterIterator,
|
||||
_RAIter3, _DifferenceTp,
|
||||
_Compare>
|
||||
{
|
||||
_RAIter3 operator()(_RAIterIterator __seqs_begin,
|
||||
_RAIter3
|
||||
operator()(_RAIterIterator __seqs_begin,
|
||||
_RAIterIterator __seqs_end,
|
||||
_RAIter3 __target,
|
||||
_DifferenceTp __length, _Compare __comp)
|
||||
|
@ -840,7 +784,8 @@ template<bool __sentinels /*default == false*/,
|
|||
typename _Compare>
|
||||
struct __multiway_merge_4_variant_sentinel_switch
|
||||
{
|
||||
_RAIter3 operator()(_RAIterIterator __seqs_begin,
|
||||
_RAIter3
|
||||
operator()(_RAIterIterator __seqs_begin,
|
||||
_RAIterIterator __seqs_end,
|
||||
_RAIter3 __target,
|
||||
_DifferenceTp __length, _Compare __comp)
|
||||
|
@ -859,10 +804,12 @@ template<typename _RAIterIterator,
|
|||
typename _RAIter3,
|
||||
typename _DifferenceTp,
|
||||
typename _Compare>
|
||||
struct __multiway_merge_4_variant_sentinel_switch
|
||||
<true, _RAIterIterator, _RAIter3, _DifferenceTp, _Compare>
|
||||
struct __multiway_merge_4_variant_sentinel_switch<true, _RAIterIterator,
|
||||
_RAIter3, _DifferenceTp,
|
||||
_Compare>
|
||||
{
|
||||
_RAIter3 operator()(_RAIterIterator __seqs_begin,
|
||||
_RAIter3
|
||||
operator()(_RAIterIterator __seqs_begin,
|
||||
_RAIterIterator __seqs_end,
|
||||
_RAIter3 __target,
|
||||
_DifferenceTp __length, _Compare __comp)
|
||||
|
@ -883,8 +830,8 @@ template<bool __sentinels,
|
|||
typename _Compare>
|
||||
struct __multiway_merge_k_variant_sentinel_switch
|
||||
{
|
||||
_RAIter3 operator()
|
||||
(_RAIterIterator __seqs_begin,
|
||||
_RAIter3
|
||||
operator()(_RAIterIterator __seqs_begin,
|
||||
_RAIterIterator __seqs_end,
|
||||
_RAIter3 __target,
|
||||
const typename std::iterator_traits<typename std::iterator_traits<
|
||||
|
@ -903,8 +850,8 @@ template<bool __sentinels,
|
|||
_LoserTreeTraits<_ValueType>::_M_use_pointer,
|
||||
_LoserTreePointerUnguarded<__stable, _ValueType, _Compare>,
|
||||
_LoserTreeUnguarded<__stable, _ValueType, _Compare>
|
||||
>::__type>(
|
||||
__seqs_begin, __seqs_end, __target, __sentinel, __length, __comp);
|
||||
>::__type>
|
||||
(__seqs_begin, __seqs_end, __target, __sentinel, __length, __comp);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -916,11 +863,12 @@ template<bool __stable,
|
|||
typename _RAIter3,
|
||||
typename _DifferenceTp,
|
||||
typename _Compare>
|
||||
struct __multiway_merge_k_variant_sentinel_switch
|
||||
<false, __stable, _RAIterIterator, _RAIter3, _DifferenceTp, _Compare>
|
||||
struct __multiway_merge_k_variant_sentinel_switch<false, __stable,
|
||||
_RAIterIterator, _RAIter3,
|
||||
_DifferenceTp, _Compare>
|
||||
{
|
||||
_RAIter3 operator()
|
||||
(_RAIterIterator __seqs_begin,
|
||||
_RAIter3
|
||||
operator()(_RAIterIterator __seqs_begin,
|
||||
_RAIterIterator __seqs_end,
|
||||
_RAIter3 __target,
|
||||
const typename std::iterator_traits<typename std::iterator_traits<
|
||||
|
@ -963,8 +911,7 @@ template<bool __stable,
|
|||
typename _DifferenceTp,
|
||||
typename _Compare>
|
||||
_RAIter3
|
||||
__sequential_multiway_merge(
|
||||
_RAIterIterator __seqs_begin,
|
||||
__sequential_multiway_merge(_RAIterIterator __seqs_begin,
|
||||
_RAIterIterator __seqs_end,
|
||||
_RAIter3 __target,
|
||||
const typename std::iterator_traits<typename std::iterator_traits<
|
||||
|
@ -1061,8 +1008,8 @@ template<bool __stable,
|
|||
template<bool __stable, class _RAIter, class _StrictWeakOrdering>
|
||||
struct _SamplingSorter
|
||||
{
|
||||
void operator()(_RAIter __first, _RAIter __last,
|
||||
_StrictWeakOrdering __comp)
|
||||
void
|
||||
operator()(_RAIter __first, _RAIter __last, _StrictWeakOrdering __comp)
|
||||
{ __gnu_sequential::stable_sort(__first, __last, __comp); }
|
||||
};
|
||||
|
||||
|
@ -1074,8 +1021,8 @@ template<bool __stable, class _RAIter, class _StrictWeakOrdering>
|
|||
template<class _RAIter, class _StrictWeakOrdering>
|
||||
struct _SamplingSorter<false, _RAIter, _StrictWeakOrdering>
|
||||
{
|
||||
void operator()(_RAIter __first, _RAIter __last,
|
||||
_StrictWeakOrdering __comp)
|
||||
void
|
||||
operator()(_RAIter __first, _RAIter __last, _StrictWeakOrdering __comp)
|
||||
{ __gnu_sequential::sort(__first, __last, __comp); }
|
||||
};
|
||||
|
||||
|
@ -1087,10 +1034,11 @@ template<bool __stable,
|
|||
typename _Compare,
|
||||
typename _DifferenceType>
|
||||
void
|
||||
multiway_merge_sampling_splitting
|
||||
(_RAIterIterator __seqs_begin,
|
||||
multiway_merge_sampling_splitting(_RAIterIterator __seqs_begin,
|
||||
_RAIterIterator __seqs_end,
|
||||
_DifferenceType __length, _DifferenceType __total_length, _Compare __comp,
|
||||
_DifferenceType __length,
|
||||
_DifferenceType __total_length,
|
||||
_Compare __comp,
|
||||
std::vector<std::pair<_DifferenceType, _DifferenceType> > *__pieces)
|
||||
{
|
||||
typedef typename std::iterator_traits<_RAIterIterator>
|
||||
|
@ -1168,10 +1116,10 @@ template<bool __stable,
|
|||
typename _Compare,
|
||||
typename _DifferenceType>
|
||||
void
|
||||
multiway_merge_exact_splitting
|
||||
(_RAIterIterator __seqs_begin,
|
||||
multiway_merge_exact_splitting(_RAIterIterator __seqs_begin,
|
||||
_RAIterIterator __seqs_end,
|
||||
_DifferenceType __length, _DifferenceType __total_length,
|
||||
_DifferenceType __length,
|
||||
_DifferenceType __total_length,
|
||||
_Compare __comp,
|
||||
std::vector<std::pair<_DifferenceType, _DifferenceType> > *__pieces)
|
||||
{
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
|
||||
namespace __gnu_parallel
|
||||
{
|
||||
|
||||
/** @brief Subsequence description. */
|
||||
template<typename _DifferenceTp>
|
||||
struct _Piece
|
||||
|
@ -111,7 +110,8 @@ template<typename _RAIter, typename _DifferenceTp>
|
|||
|
||||
for (_DifferenceType __i = 0; __i < __num_samples; ++__i)
|
||||
::new(&(__sd->_M_samples[__iam * __num_samples + __i]))
|
||||
_ValueType(__sd->_M_source[__sd->_M_starts[__iam] + __es[__i + 1]]);
|
||||
_ValueType(__sd->_M_source[__sd->_M_starts[__iam]
|
||||
+ __es[__i + 1]]);
|
||||
|
||||
delete[] __es;
|
||||
}
|
||||
|
@ -120,27 +120,26 @@ template<typename _RAIter, typename _DifferenceTp>
|
|||
template<bool __exact, typename _RAIter,
|
||||
typename _Compare, typename _SortingPlacesIterator>
|
||||
struct _SplitConsistently
|
||||
{
|
||||
};
|
||||
{ };
|
||||
|
||||
/** @brief Split by exact splitting. */
|
||||
template<typename _RAIter, typename _Compare,
|
||||
typename _SortingPlacesIterator>
|
||||
struct _SplitConsistently
|
||||
<true, _RAIter, _Compare, _SortingPlacesIterator>
|
||||
struct _SplitConsistently<true, _RAIter,
|
||||
_Compare, _SortingPlacesIterator>
|
||||
{
|
||||
void operator()(
|
||||
const _ThreadIndex __iam,
|
||||
void
|
||||
operator()(const _ThreadIndex __iam,
|
||||
_PMWMSSortingData<_RAIter>* __sd,
|
||||
_Compare& __comp,
|
||||
const typename
|
||||
std::iterator_traits<_RAIter>::difference_type
|
||||
__num_samples)
|
||||
const
|
||||
__num_samples) const
|
||||
{
|
||||
# pragma omp barrier
|
||||
|
||||
std::vector<std::pair<_SortingPlacesIterator, _SortingPlacesIterator> >
|
||||
std::vector<std::pair<_SortingPlacesIterator,
|
||||
_SortingPlacesIterator> >
|
||||
seqs(__sd->_M_num_threads);
|
||||
for (_ThreadIndex __s = 0; __s < __sd->_M_num_threads; __s++)
|
||||
seqs[__s] = std::make_pair(__sd->_M_temporary[__s],
|
||||
|
@ -189,14 +188,13 @@ template<typename _RAIter, typename _Compare,
|
|||
struct _SplitConsistently<false, _RAIter, _Compare,
|
||||
_SortingPlacesIterator>
|
||||
{
|
||||
void operator()(
|
||||
const _ThreadIndex __iam,
|
||||
void
|
||||
operator()(const _ThreadIndex __iam,
|
||||
_PMWMSSortingData<_RAIter>* __sd,
|
||||
_Compare& __comp,
|
||||
const typename
|
||||
std::iterator_traits<_RAIter>::difference_type
|
||||
__num_samples)
|
||||
const
|
||||
__num_samples) const
|
||||
{
|
||||
typedef std::iterator_traits<_RAIter> _TraitsType;
|
||||
typedef typename _TraitsType::value_type _ValueType;
|
||||
|
@ -221,7 +219,8 @@ template<typename _RAIter, typename _Compare,
|
|||
__sd->_M_pieces[__iam][__s]._M_begin =
|
||||
std::lower_bound(__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]),
|
||||
__sd->_M_samples[__num_samples * __iam],
|
||||
__comp)
|
||||
- __sd->_M_temporary[__s];
|
||||
|
@ -234,31 +233,29 @@ template<typename _RAIter, typename _Compare,
|
|||
__sd->_M_pieces[__iam][__s]._M_end =
|
||||
std::lower_bound(__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]),
|
||||
__sd->_M_samples[__num_samples * (__iam + 1)],
|
||||
__comp)
|
||||
- __sd->_M_temporary[__s];
|
||||
else
|
||||
// Absolute end.
|
||||
__sd->_M_pieces[__iam][__s]._M_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]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<bool __stable, typename _RAIter, typename _Compare>
|
||||
struct __possibly_stable_sort
|
||||
{
|
||||
};
|
||||
{ };
|
||||
|
||||
template<typename _RAIter, typename _Compare>
|
||||
struct __possibly_stable_sort<true, _RAIter, _Compare>
|
||||
{
|
||||
void operator()(const _RAIter& __begin,
|
||||
const _RAIter& __end, _Compare& __comp) const
|
||||
{
|
||||
__gnu_sequential::stable_sort(__begin, __end, __comp);
|
||||
}
|
||||
{ __gnu_sequential::stable_sort(__begin, __end, __comp); }
|
||||
};
|
||||
|
||||
template<typename _RAIter, typename _Compare>
|
||||
|
@ -266,29 +263,25 @@ template<typename _RAIter, typename _Compare>
|
|||
{
|
||||
void operator()(const _RAIter __begin,
|
||||
const _RAIter __end, _Compare& __comp) const
|
||||
{
|
||||
__gnu_sequential::sort(__begin, __end, __comp);
|
||||
}
|
||||
{ __gnu_sequential::sort(__begin, __end, __comp); }
|
||||
};
|
||||
|
||||
template<bool __stable, typename Seq_RAIter,
|
||||
typename _RAIter, typename _Compare,
|
||||
typename DiffType>
|
||||
struct __possibly_stable_multiway_merge
|
||||
{
|
||||
};
|
||||
{ };
|
||||
|
||||
template<typename Seq_RAIter, typename _RAIter,
|
||||
typename _Compare, typename DiffType>
|
||||
struct __possibly_stable_multiway_merge
|
||||
<true, Seq_RAIter, _RAIter, _Compare,
|
||||
DiffType>
|
||||
typename _Compare, typename _DiffType>
|
||||
struct __possibly_stable_multiway_merge<true, Seq_RAIter,
|
||||
_RAIter, _Compare, _DiffType>
|
||||
{
|
||||
void operator()(const Seq_RAIter& __seqs_begin,
|
||||
const Seq_RAIter& __seqs_end,
|
||||
const _RAIter& __target,
|
||||
_Compare& __comp,
|
||||
DiffType __length_am) const
|
||||
_DiffType __length_am) const
|
||||
{
|
||||
stable_multiway_merge(__seqs_begin, __seqs_end, __target, __length_am,
|
||||
__comp, sequential_tag());
|
||||
|
@ -296,16 +289,15 @@ template<typename Seq_RAIter, typename _RAIter,
|
|||
};
|
||||
|
||||
template<typename Seq_RAIter, typename _RAIter,
|
||||
typename _Compare, typename DiffType>
|
||||
struct __possibly_stable_multiway_merge
|
||||
<false, Seq_RAIter, _RAIter, _Compare,
|
||||
DiffType>
|
||||
typename _Compare, typename _DiffType>
|
||||
struct __possibly_stable_multiway_merge<false, Seq_RAIter,
|
||||
_RAIter, _Compare, _DiffType>
|
||||
{
|
||||
void operator()(const Seq_RAIter& __seqs_begin,
|
||||
const Seq_RAIter& __seqs_end,
|
||||
const _RAIter& __target,
|
||||
_Compare& __comp,
|
||||
DiffType __length_am) const
|
||||
_DiffType __length_am) const
|
||||
{
|
||||
multiway_merge(__seqs_begin, __seqs_end, __target, __length_am, __comp,
|
||||
sequential_tag());
|
||||
|
@ -337,13 +329,13 @@ template<bool __stable, bool __exact, typename _RAIter,
|
|||
typedef _ValueType* _SortingPlacesIterator;
|
||||
|
||||
__sd->_M_temporary[__iam] =
|
||||
static_cast<_ValueType*>(
|
||||
::operator new(sizeof(_ValueType) * (__length_local + 1)));
|
||||
static_cast<_ValueType*>(::operator new(sizeof(_ValueType)
|
||||
* (__length_local + 1)));
|
||||
|
||||
// Copy there.
|
||||
std::uninitialized_copy(
|
||||
__sd->_M_source + __sd->_M_starts[__iam],
|
||||
__sd->_M_source + __sd->_M_starts[__iam] + __length_local,
|
||||
std::uninitialized_copy(__sd->_M_source + __sd->_M_starts[__iam],
|
||||
__sd->_M_source + __sd->_M_starts[__iam]
|
||||
+ __length_local,
|
||||
__sd->_M_temporary[__iam]);
|
||||
|
||||
__possibly_stable_sort<__stable, _SortingPlacesIterator, _Compare>()
|
||||
|
@ -366,8 +358,8 @@ template<bool __stable, bool __exact, typename _RAIter,
|
|||
_DifferenceType __offset = 0, __length_am = 0;
|
||||
for (_ThreadIndex __s = 0; __s < __sd->_M_num_threads; __s++)
|
||||
{
|
||||
__length_am += __sd->_M_pieces[__iam][__s]._M_end
|
||||
- __sd->_M_pieces[__iam][__s]._M_begin;
|
||||
__length_am += (__sd->_M_pieces[__iam][__s]._M_end
|
||||
- __sd->_M_pieces[__iam][__s]._M_begin);
|
||||
__offset += __sd->_M_pieces[__iam][__s]._M_begin;
|
||||
}
|
||||
|
||||
|
@ -379,8 +371,8 @@ template<bool __stable, bool __exact, typename _RAIter,
|
|||
for (int __s = 0; __s < __sd->_M_num_threads; ++__s)
|
||||
{
|
||||
seqs[__s] =
|
||||
std::make_pair(
|
||||
__sd->_M_temporary[__s] + __sd->_M_pieces[__iam][__s]._M_begin,
|
||||
std::make_pair
|
||||
(__sd->_M_temporary[__s] + __sd->_M_pieces[__iam][__s]._M_begin,
|
||||
__sd->_M_temporary[__s] + __sd->_M_pieces[__iam][__s]._M_end);
|
||||
}
|
||||
|
||||
|
@ -447,8 +439,8 @@ template<bool __stable, bool __exact, typename _RAIter,
|
|||
_DifferenceType __size =
|
||||
(_Settings::get().sort_mwms_oversampling * __num_threads - 1)
|
||||
* __num_threads;
|
||||
__sd._M_samples = static_cast<_ValueType*>(
|
||||
::operator new(__size * sizeof(_ValueType)));
|
||||
__sd._M_samples = static_cast<_ValueType*>
|
||||
(::operator new(__size * sizeof(_ValueType)));
|
||||
}
|
||||
else
|
||||
__sd._M_samples = NULL;
|
||||
|
@ -486,6 +478,7 @@ template<bool __stable, bool __exact, typename _RAIter,
|
|||
delete[] __sd._M_offsets;
|
||||
delete[] __sd._M_pieces;
|
||||
}
|
||||
|
||||
} //namespace __gnu_parallel
|
||||
|
||||
#endif /* _GLIBCXX_PARALLEL_MULTIWAY_MERGESORT_H */
|
||||
|
|
|
@ -64,13 +64,13 @@ template<typename _RAIter,
|
|||
typename _Red,
|
||||
typename _Result>
|
||||
_Op
|
||||
__for_each_template_random_access_omp_loop(
|
||||
_RAIter __begin, _RAIter __end, _Op __o, _Fu& __f, _Red __r,
|
||||
_Result __base, _Result& __output,
|
||||
__for_each_template_random_access_omp_loop(_RAIter __begin, _RAIter __end,
|
||||
_Op __o, _Fu& __f, _Red __r,
|
||||
_Result __base,
|
||||
_Result& __output,
|
||||
typename std::iterator_traits<_RAIter>::difference_type __bound)
|
||||
{
|
||||
typedef typename
|
||||
std::iterator_traits<_RAIter>::difference_type
|
||||
typedef typename std::iterator_traits<_RAIter>::difference_type
|
||||
_DifferenceType;
|
||||
|
||||
_DifferenceType __length = __end - __begin;
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
|
||||
namespace __gnu_parallel
|
||||
{
|
||||
|
||||
/** @brief Embarrassingly parallel algorithm for random access
|
||||
* iterators, using an OpenMP for loop with static scheduling.
|
||||
*
|
||||
|
@ -64,13 +63,14 @@ template<typename _RAIter,
|
|||
typename _Red,
|
||||
typename _Result>
|
||||
_Op
|
||||
__for_each_template_random_access_omp_loop_static(
|
||||
_RAIter __begin, _RAIter __end, _Op __o, _Fu& __f, _Red __r,
|
||||
_Result __base, _Result& __output,
|
||||
__for_each_template_random_access_omp_loop_static(_RAIter __begin,
|
||||
_RAIter __end, _Op __o,
|
||||
_Fu& __f, _Red __r,
|
||||
_Result __base,
|
||||
_Result& __output,
|
||||
typename std::iterator_traits<_RAIter>::difference_type __bound)
|
||||
{
|
||||
typedef typename
|
||||
std::iterator_traits<_RAIter>::difference_type
|
||||
typedef typename std::iterator_traits<_RAIter>::difference_type
|
||||
_DifferenceType;
|
||||
|
||||
_DifferenceType __length = __end - __begin;
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
|
||||
namespace __gnu_parallel
|
||||
{
|
||||
|
||||
/** @brief Embarrassingly parallel algorithm for random access
|
||||
* iterators, using hand-crafted parallelization by equal splitting
|
||||
* the work.
|
||||
|
@ -65,8 +64,8 @@ template<typename _RAIter,
|
|||
typename _Red,
|
||||
typename _Result>
|
||||
_Op
|
||||
__for_each_template_random_access_ed(
|
||||
_RAIter __begin, _RAIter __end, _Op __o, _Fu& __f, _Red __r,
|
||||
__for_each_template_random_access_ed(_RAIter __begin, _RAIter __end,
|
||||
_Op __o, _Fu& __f, _Red __r,
|
||||
_Result __base, _Result& __output,
|
||||
typename std::iterator_traits<_RAIter>::difference_type __bound)
|
||||
{
|
||||
|
@ -85,8 +84,8 @@ template<typename _RAIter,
|
|||
{
|
||||
__num_threads = omp_get_num_threads();
|
||||
__thread_results =
|
||||
static_cast<_Result*>(
|
||||
::operator new(__num_threads * sizeof(_Result)));
|
||||
static_cast<_Result*>(::operator new(__num_threads
|
||||
* sizeof(_Result)));
|
||||
__constructed = new bool[__num_threads];
|
||||
}
|
||||
|
||||
|
|
|
@ -55,8 +55,8 @@ template<typename _IIter,
|
|||
typename _OutputIterator,
|
||||
typename _BinaryOperation>
|
||||
_OutputIterator
|
||||
__parallel_partial_sum_basecase(
|
||||
_IIter __begin, _IIter __end, _OutputIterator __result,
|
||||
__parallel_partial_sum_basecase(_IIter __begin, _IIter __end,
|
||||
_OutputIterator __result,
|
||||
_BinaryOperation __bin_op,
|
||||
typename std::iterator_traits <_IIter>::value_type __value)
|
||||
{
|
||||
|
@ -87,8 +87,8 @@ template<typename _IIter,
|
|||
typename _OutputIterator,
|
||||
typename _BinaryOperation>
|
||||
_OutputIterator
|
||||
__parallel_partial_sum_linear(
|
||||
_IIter __begin, _IIter __end, _OutputIterator __result,
|
||||
__parallel_partial_sum_linear(_IIter __begin, _IIter __end,
|
||||
_OutputIterator __result,
|
||||
_BinaryOperation __bin_op,
|
||||
typename std::iterator_traits<_IIter>::difference_type __n)
|
||||
{
|
||||
|
@ -105,8 +105,9 @@ template<typename _IIter,
|
|||
if (__num_threads < 2)
|
||||
{
|
||||
*__result = *__begin;
|
||||
return __parallel_partial_sum_basecase(
|
||||
__begin + 1, __end, __result + 1, __bin_op, *__begin);
|
||||
return __parallel_partial_sum_basecase(__begin + 1, __end,
|
||||
__result + 1, __bin_op,
|
||||
*__begin);
|
||||
}
|
||||
|
||||
_DifferenceType* __borders;
|
||||
|
@ -172,8 +173,7 @@ template<typename _IIter,
|
|||
# pragma omp barrier
|
||||
|
||||
// Still same team.
|
||||
__parallel_partial_sum_basecase(
|
||||
__begin + __borders[__iam + 1],
|
||||
__parallel_partial_sum_basecase(__begin + __borders[__iam + 1],
|
||||
__begin + __borders[__iam + 2],
|
||||
__result + __borders[__iam + 1],
|
||||
__bin_op, __sums[__iam]);
|
||||
|
@ -210,8 +210,8 @@ template<typename _IIter,
|
|||
{
|
||||
case LINEAR:
|
||||
// Need an initial offset.
|
||||
return __parallel_partial_sum_linear(
|
||||
__begin, __end, __result, __bin_op, __n);
|
||||
return __parallel_partial_sum_linear(__begin, __end, __result,
|
||||
__bin_op, __n);
|
||||
default:
|
||||
// Partial_sum algorithm not implemented.
|
||||
_GLIBCXX_PARALLEL_ASSERT(0);
|
||||
|
|
Loading…
Reference in New Issue