Commit 338311e5 by Paolo Carlini Committed by Paolo Carlini

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
parent 94086ef6
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> 2009-11-04 Benjamin Kosnik <bkoz@redhat.com>
* testsuite/25_algorithms/fill/5.cc: Move... * testsuite/25_algorithms/fill/5.cc: Move...
......
...@@ -163,7 +163,8 @@ template<typename _Tp, typename _Compare> ...@@ -163,7 +163,8 @@ template<typename _Tp, typename _Compare>
*/ */
template<bool __stable/* default == true */, typename _Tp, template<bool __stable/* default == true */, typename _Tp,
typename _Compare> 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::_M_k; using _Base::_M_k;
...@@ -797,7 +798,7 @@ public: ...@@ -797,7 +798,7 @@ public:
* run empty. This is a very fast variant. * run empty. This is a very fast variant.
*/ */
template<typename _Tp, typename _Compare> template<typename _Tp, typename _Compare>
class LoserTreePointerUnguardedBase class _LoserTreePointerUnguardedBase
{ {
protected: protected:
struct _Loser struct _Loser
...@@ -812,7 +813,7 @@ template<typename _Tp, typename _Compare> ...@@ -812,7 +813,7 @@ template<typename _Tp, typename _Compare>
public: public:
LoserTreePointerUnguardedBase(unsigned int __k, const _Tp& _sentinel, _LoserTreePointerUnguardedBase(unsigned int __k, const _Tp& _sentinel,
_Compare __comp = std::less<_Tp>()) _Compare __comp = std::less<_Tp>())
: _M_comp(__comp) : _M_comp(__comp)
{ {
...@@ -831,7 +832,7 @@ template<typename _Tp, typename _Compare> ...@@ -831,7 +832,7 @@ template<typename _Tp, typename _Compare>
} }
} }
~LoserTreePointerUnguardedBase() ~_LoserTreePointerUnguardedBase()
{ delete[] _M_losers; } { delete[] _M_losers; }
int int
...@@ -861,16 +862,16 @@ template<typename _Tp, typename _Compare> ...@@ -861,16 +862,16 @@ template<typename _Tp, typename _Compare>
*/ */
template<bool __stable/* default == true */, typename _Tp, typename _Compare> template<bool __stable/* default == true */, typename _Tp, typename _Compare>
class _LoserTreePointerUnguarded 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_k;
using _Base::_M_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
...@@ -945,16 +946,16 @@ template<bool __stable/* default == true */, typename _Tp, typename _Compare> ...@@ -945,16 +946,16 @@ template<bool __stable/* default == true */, typename _Tp, typename _Compare>
*/ */
template<typename _Tp, typename _Compare> template<typename _Tp, typename _Compare>
class _LoserTreePointerUnguarded</* __stable == */false, _Tp, _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_k;
using _Base::_M_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
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
namespace __gnu_parallel namespace __gnu_parallel
{ {
/** @brief Embarrassingly parallel algorithm for random access /** @brief Embarrassingly parallel algorithm for random access
* iterators, using an OpenMP for loop. * iterators, using an OpenMP for loop.
* *
* @param __begin Begin iterator of element sequence. * @param __begin Begin iterator of element sequence.
...@@ -58,19 +58,19 @@ namespace __gnu_parallel ...@@ -58,19 +58,19 @@ namespace __gnu_parallel
* std::count_n()). * std::count_n()).
* @return User-supplied functor (that may contain a part of the result). * @return User-supplied functor (that may contain a part of the result).
*/ */
template<typename _RAIter, template<typename _RAIter,
typename _Op, typename _Op,
typename _Fu, typename _Fu,
typename _Red, typename _Red,
typename _Result> typename _Result>
_Op _Op
__for_each_template_random_access_omp_loop( __for_each_template_random_access_omp_loop(_RAIter __begin, _RAIter __end,
_RAIter __begin, _RAIter __end, _Op __o, _Fu& __f, _Red __r, _Op __o, _Fu& __f, _Red __r,
_Result __base, _Result& __output, _Result __base,
_Result& __output,
typename std::iterator_traits<_RAIter>::difference_type __bound) typename std::iterator_traits<_RAIter>::difference_type __bound)
{ {
typedef typename typedef typename std::iterator_traits<_RAIter>::difference_type
std::iterator_traits<_RAIter>::difference_type
_DifferenceType; _DifferenceType;
_DifferenceType __length = __end - __begin; _DifferenceType __length = __end - __begin;
......
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
namespace __gnu_parallel namespace __gnu_parallel
{ {
/** @brief Embarrassingly parallel algorithm for random access /** @brief Embarrassingly parallel algorithm for random access
* iterators, using an OpenMP for loop with static scheduling. * iterators, using an OpenMP for loop with static scheduling.
* *
...@@ -58,19 +57,20 @@ namespace __gnu_parallel ...@@ -58,19 +57,20 @@ namespace __gnu_parallel
* std::count_n()). * std::count_n()).
* @return User-supplied functor (that may contain a part of the result). * @return User-supplied functor (that may contain a part of the result).
*/ */
template<typename _RAIter, template<typename _RAIter,
typename _Op, typename _Op,
typename _Fu, typename _Fu,
typename _Red, typename _Red,
typename _Result> typename _Result>
_Op _Op
__for_each_template_random_access_omp_loop_static( __for_each_template_random_access_omp_loop_static(_RAIter __begin,
_RAIter __begin, _RAIter __end, _Op __o, _Fu& __f, _Red __r, _RAIter __end, _Op __o,
_Result __base, _Result& __output, _Fu& __f, _Red __r,
_Result __base,
_Result& __output,
typename std::iterator_traits<_RAIter>::difference_type __bound) typename std::iterator_traits<_RAIter>::difference_type __bound)
{ {
typedef typename typedef typename std::iterator_traits<_RAIter>::difference_type
std::iterator_traits<_RAIter>::difference_type
_DifferenceType; _DifferenceType;
_DifferenceType __length = __end - __begin; _DifferenceType __length = __end - __begin;
......
...@@ -40,8 +40,7 @@ ...@@ -40,8 +40,7 @@
namespace __gnu_parallel namespace __gnu_parallel
{ {
/** @brief Embarrassingly parallel algorithm for random access
/** @brief Embarrassingly parallel algorithm for random access
* iterators, using hand-crafted parallelization by equal splitting * iterators, using hand-crafted parallelization by equal splitting
* the work. * the work.
* *
...@@ -59,14 +58,14 @@ namespace __gnu_parallel ...@@ -59,14 +58,14 @@ namespace __gnu_parallel
* std::count_n()). * std::count_n()).
* @return User-supplied functor (that may contain a part of the result). * @return User-supplied functor (that may contain a part of the result).
*/ */
template<typename _RAIter, template<typename _RAIter,
typename _Op, typename _Op,
typename _Fu, typename _Fu,
typename _Red, typename _Red,
typename _Result> typename _Result>
_Op _Op
__for_each_template_random_access_ed( __for_each_template_random_access_ed(_RAIter __begin, _RAIter __end,
_RAIter __begin, _RAIter __end, _Op __o, _Fu& __f, _Red __r, _Op __o, _Fu& __f, _Red __r,
_Result __base, _Result& __output, _Result __base, _Result& __output,
typename std::iterator_traits<_RAIter>::difference_type __bound) typename std::iterator_traits<_RAIter>::difference_type __bound)
{ {
...@@ -85,8 +84,8 @@ template<typename _RAIter, ...@@ -85,8 +84,8 @@ template<typename _RAIter,
{ {
__num_threads = omp_get_num_threads(); __num_threads = omp_get_num_threads();
__thread_results = __thread_results =
static_cast<_Result*>( static_cast<_Result*>(::operator new(__num_threads
::operator new(__num_threads * sizeof(_Result))); * sizeof(_Result)));
__constructed = new bool[__num_threads]; __constructed = new bool[__num_threads];
} }
......
...@@ -43,7 +43,7 @@ namespace __gnu_parallel ...@@ -43,7 +43,7 @@ namespace __gnu_parallel
{ {
// Problem: there is no 0-element given. // Problem: there is no 0-element given.
/** @brief Base case prefix sum routine. /** @brief Base case prefix sum routine.
* @param __begin Begin iterator of input sequence. * @param __begin Begin iterator of input sequence.
* @param __end End iterator of input sequence. * @param __end End iterator of input sequence.
* @param __result Begin iterator of output sequence. * @param __result Begin iterator of output sequence.
...@@ -51,12 +51,12 @@ namespace __gnu_parallel ...@@ -51,12 +51,12 @@ namespace __gnu_parallel
* @param __value Start value. Must be passed since the neutral * @param __value Start value. Must be passed since the neutral
* element is unknown in general. * element is unknown in general.
* @return End iterator of output sequence. */ * @return End iterator of output sequence. */
template<typename _IIter, template<typename _IIter,
typename _OutputIterator, typename _OutputIterator,
typename _BinaryOperation> typename _BinaryOperation>
_OutputIterator _OutputIterator
__parallel_partial_sum_basecase( __parallel_partial_sum_basecase(_IIter __begin, _IIter __end,
_IIter __begin, _IIter __end, _OutputIterator __result, _OutputIterator __result,
_BinaryOperation __bin_op, _BinaryOperation __bin_op,
typename std::iterator_traits <_IIter>::value_type __value) typename std::iterator_traits <_IIter>::value_type __value)
{ {
...@@ -73,7 +73,7 @@ template<typename _IIter, ...@@ -73,7 +73,7 @@ template<typename _IIter,
return __result; return __result;
} }
/** @brief Parallel partial sum implementation, two-phase approach, /** @brief Parallel partial sum implementation, two-phase approach,
no recursion. no recursion.
* @param __begin Begin iterator of input sequence. * @param __begin Begin iterator of input sequence.
* @param __end End iterator of input sequence. * @param __end End iterator of input sequence.
...@@ -83,12 +83,12 @@ template<typename _IIter, ...@@ -83,12 +83,12 @@ template<typename _IIter,
* @param __num_threads Number of threads to use. * @param __num_threads Number of threads to use.
* @return End iterator of output sequence. * @return End iterator of output sequence.
*/ */
template<typename _IIter, template<typename _IIter,
typename _OutputIterator, typename _OutputIterator,
typename _BinaryOperation> typename _BinaryOperation>
_OutputIterator _OutputIterator
__parallel_partial_sum_linear( __parallel_partial_sum_linear(_IIter __begin, _IIter __end,
_IIter __begin, _IIter __end, _OutputIterator __result, _OutputIterator __result,
_BinaryOperation __bin_op, _BinaryOperation __bin_op,
typename std::iterator_traits<_IIter>::difference_type __n) typename std::iterator_traits<_IIter>::difference_type __n)
{ {
...@@ -105,8 +105,9 @@ template<typename _IIter, ...@@ -105,8 +105,9 @@ template<typename _IIter,
if (__num_threads < 2) if (__num_threads < 2)
{ {
*__result = *__begin; *__result = *__begin;
return __parallel_partial_sum_basecase( return __parallel_partial_sum_basecase(__begin + 1, __end,
__begin + 1, __end, __result + 1, __bin_op, *__begin); __result + 1, __bin_op,
*__begin);
} }
_DifferenceType* __borders; _DifferenceType* __borders;
...@@ -172,8 +173,7 @@ template<typename _IIter, ...@@ -172,8 +173,7 @@ template<typename _IIter,
# pragma omp barrier # pragma omp barrier
// Still same team. // Still same team.
__parallel_partial_sum_basecase( __parallel_partial_sum_basecase(__begin + __borders[__iam + 1],
__begin + __borders[__iam + 1],
__begin + __borders[__iam + 2], __begin + __borders[__iam + 2],
__result + __borders[__iam + 1], __result + __borders[__iam + 1],
__bin_op, __sums[__iam]); __bin_op, __sums[__iam]);
...@@ -185,13 +185,13 @@ template<typename _IIter, ...@@ -185,13 +185,13 @@ template<typename _IIter,
return __result + __n; return __result + __n;
} }
/** @brief Parallel partial sum front-__end. /** @brief Parallel partial sum front-__end.
* @param __begin Begin iterator of input sequence. * @param __begin Begin iterator of input sequence.
* @param __end End iterator of input sequence. * @param __end End iterator of input sequence.
* @param __result Begin iterator of output sequence. * @param __result Begin iterator of output sequence.
* @param __bin_op Associative binary function. * @param __bin_op Associative binary function.
* @return End iterator of output sequence. */ * @return End iterator of output sequence. */
template<typename _IIter, template<typename _IIter,
typename _OutputIterator, typename _OutputIterator,
typename _BinaryOperation> typename _BinaryOperation>
_OutputIterator _OutputIterator
...@@ -210,8 +210,8 @@ template<typename _IIter, ...@@ -210,8 +210,8 @@ template<typename _IIter,
{ {
case LINEAR: case LINEAR:
// Need an initial offset. // Need an initial offset.
return __parallel_partial_sum_linear( return __parallel_partial_sum_linear(__begin, __end, __result,
__begin, __end, __result, __bin_op, __n); __bin_op, __n);
default: default:
// Partial_sum algorithm not implemented. // Partial_sum algorithm not implemented.
_GLIBCXX_PARALLEL_ASSERT(0); _GLIBCXX_PARALLEL_ASSERT(0);
......
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