Commit 6f95a65a by Benjamin Kosnik Committed by Benjamin Kosnik

re PR libstdc++/33487 (parallel v3: more functions not in right namespace)

2007-10-06  Benjamin Kosnik  <bkoz@redhat.com>

	PR libstdc++/33487
	* include/parallel/algorithmfwd.h (for_each, generate, generate_n,
	transform, replace, replace_if, max_element, min_element, count,
	count_if): Consistently construct overloads.
	* include/parallel/numericfwd.h (accumulate, adjacent_difference,
	inner_product): Same.
	* include/parallel/algobase.h: Same.
	* include/parallel/algo.h: Same.
	* include/parallel/numeric: Same.

	* include/bits/algorithmfwd.h: Correct find_end placement.

	* docs/html/parallel_mode.html: Document some of the interface
	conventions.

	* include/parallel/search.h (calc_borders): Only use operator ==.
	
	* include/parallel/algorithmfwd.h: Move __gnu_sequential bits to...
	* include/parallel/tags.h: ...here, and use a using directive.

	* include/parallel/random_shuffle.h: Include stl_numeric. Qualify
	uses of partial_num with __gnu_sequential.

	* include/parallel/tree.h: Formatting.

From-SVN: r129054
parent a0689cdf
2007-10-06 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/33487
* include/parallel/algorithmfwd.h (for_each, generate, generate_n,
transform, replace, replace_if, max_element, min_element, count,
count_if): Consistently construct overloads.
* include/parallel/numericfwd.h (accumulate, adjacent_difference,
inner_product): Same.
* include/parallel/algobase.h: Same.
* include/parallel/algo.h: Same.
* include/parallel/numeric: Same.
* include/bits/algorithmfwd.h: Correct find_end placement.
* docs/html/parallel_mode.html: Document some of the interface
conventions.
* include/parallel/search.h (calc_borders): Only use operator ==.
* include/parallel/algorithmfwd.h: Move __gnu_sequential bits to...
* include/parallel/tags.h: ...here, and use a using directive.
* include/parallel/random_shuffle.h: Include stl_numeric. Qualify
uses of partial_num with __gnu_sequential.
* include/parallel/tree.h: Formatting.
2007-10-05 Benjamin Kosnik <bkoz@redhat.com>
Fixes for --disable-libstdcxx-pch.
......
......@@ -388,26 +388,109 @@ computing.</p>
<p> Something about compile-time settings and configuration, ie using
<code>__gnu_parallel::Settings</code>. XXX Up in the air.</p>
<h4 class="left">Interface basics and relevant namespaces</h4>
<h4 class="left">Interface basics and general design</h4>
<p>All parallel algorithms are intended to have signatures that are
equivalent to the ISO C++ algorithms replaced. For instance, the
<code>std::adjacent_find</code> function is declared as:
<pre>
namespace std
{
template&lt;typename _FIter&gt;
_FIter
adjacent_find(_FIter, _FIter);
}
</pre>
Which means that there should be something equivalent for the parallel
version. Indeed, this is the case:
<pre>
namespace std
{
namespace __parallel
{
template&lt;typename _FIter&gt;
_FIter
adjacent_find(_FIter, _FIter);
...
}
}
</pre>
<p>But.... why the elipses?
</p>
<p> Two namespaces contain the parallel mode:
<code>std::__parallel</code> and <code>__gnu_parallel</code>.
<p> The elipses in the example above represent additional overloads
required for the parallel version of the function. These additional
overloads are used to dispatch calls from the ISO C++ function
signature to the appropriate parallel function (or sequential
function, if no parallel functions are deemed worthy), based on either
compile-time or run-time conditions.
</p>
<p> Compile-time conditions are referred to as "embarrassingly
parallel," and are denoted with the appropriate dispatch object, ie
one of <code>__gnu_parallel::sequential_tag</code>,
<code>__gnu_parallel::parallel_tag</code>,
<code>__gnu_parallel::balanced_tag</code>,
<code>__gnu_parallel::unbalanced_tag</code>,
<code>__gnu_parallel::omp_loop_tag</code>, or
<code>__gnu_parallel::omp_loop_static_tag</code>.
</p>
<p> Run-time conditions depend on the hardware being used, the number
of threads available, etc., and are denoted by the use of the enum
<code>__gnu_parallel::parallelism</code>. Values of this enum include
<code>__gnu_parallel::sequential</code>,
<code>__gnu_parallel::parallel_unbalanced</code>,
<code>__gnu_parallel::parallel_balanced</code>,
<code>__gnu_parallel::parallel_omp_loop</code>,
<code>__gnu_parallel::parallel_omp_loop_static</code>, or
<code>__gnu_parallel::parallel_taskqueue</code>.
</p>
<p> Putting all this together, the general view of overloads for the
parallel algorithms look like this:
<p>
<ul>
<li>ISO C++ signature</li>
<li>ISO C++ signature + sequential_tag argument</li>
<li>ISO C++ signature + parallelism argument</li>
</ul>
<p> Please note that the implementation may use additional functions
(designated with the <code>_switch</code> suffix) to dispatch from the
ISO C++ signature to the correct parallel version. Also, some of the
algorithms do not have support for run-time conditions, so the last
overload is therefore missing.
</p>
<h4 class="left">Relevant namespaces</h4>
<p> One namespace contain versions of code that are explicitly sequential:
<code>__gnu_serial</code>.
</p>
<p> Parallel implementations of the sequential standard components are
defined in <code>namespace std::__parallel</code>. For instance,
<code>std::transform</code> from &lt;algorithm&gt; has a parallel
counterpart in <code>std::__parallel::transform</code> from
<p> Two namespaces contain the parallel mode:
<code>std::__parallel</code> and <code>__gnu_parallel</code>.
</p>
<p> Parallel implementations of standard components, including
template helpers to select parallelism, are defined in <code>namespace
std::__parallel</code>. For instance, <code>std::transform</code> from
&lt;algorithm&gt; has a parallel counterpart in
<code>std::__parallel::transform</code> from
&lt;parallel/algorithm&gt;. In addition, these parallel
implementatations are injected into <code>namespace
__gnu_parallel</code> with using declarations.
__gnu_parallel</code> with using declarations.
</p>
<p> Support and infrastructure is in <code>namespace __gnu_parallel</code>.
<p> Support and general infrastructure is in <code>namespace
__gnu_parallel</code>.
</p>
<p> More information, and an organized index of types and functions
......
......@@ -148,7 +148,15 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
fill_n(_OIter, _Size, const _Tp&);
// find
// find_end
template<typename _FIter1, typename _FIter2>
_FIter1
find_end(_FIter1, _FIter1, _FIter2, _FIter2);
template<typename _FIter1, typename _FIter2, typename _BinaryPredicate>
_FIter1
find_end(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate);
// find_first_of
// find_if
// for_each
......@@ -391,14 +399,6 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_P)
template<typename _FIter1, typename _FIter2>
_FIter1
find_end(_FIter1, _FIter1, _FIter2, _FIter2);
template<typename _FIter1, typename _FIter2, typename _BinaryPredicate>
_FIter1
find_end(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate);
template<typename _FIter1, typename _FIter2>
_FIter1
find_first_of(_FIter1, _FIter1, _FIter2, _FIter2);
template<typename _FIter1, typename _FIter2, typename _BinaryPredicate>
......
......@@ -59,15 +59,15 @@ namespace __parallel
// Sequential fallback
template<typename InputIterator1, typename InputIterator2>
inline bool
equal(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2, __gnu_parallel::sequential_tag)
{
return _GLIBCXX_STD_P::equal<InputIterator1, InputIterator2>(begin1, end1, begin2);
}
equal(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_P::equal(begin1, end1, begin2); }
// Sequential fallback
template<typename InputIterator1, typename InputIterator2, typename Predicate>
inline bool
equal(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2, Predicate pred, __gnu_parallel::sequential_tag)
equal(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2,
Predicate pred, __gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_P::equal(begin1, end1, begin2, pred); }
// Public interface
......@@ -79,7 +79,8 @@ namespace __parallel
// Public interface
template<typename InputIterator1, typename InputIterator2, typename Predicate>
inline bool
equal(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2, Predicate pred)
equal(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2,
Predicate pred)
{ return mismatch(begin1, end1, begin2, pred).first == end1; }
// NB: lexicographical_compare equires mismatch.
......@@ -87,33 +88,36 @@ namespace __parallel
// Sequential fallback
template<typename InputIterator1, typename InputIterator2>
inline pair<InputIterator1, InputIterator2>
mismatch(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2, __gnu_parallel::sequential_tag)
{
return _GLIBCXX_STD_P::mismatch<InputIterator1, InputIterator2>(begin1, end1, begin2);
}
mismatch(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2,
__gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_P::mismatch(begin1, end1, begin2); }
// Sequential fallback
template<typename InputIterator1, typename InputIterator2, typename Predicate>
inline pair<InputIterator1, InputIterator2>
mismatch(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2, Predicate pred, __gnu_parallel::sequential_tag)
mismatch(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2,
Predicate pred, __gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_P::mismatch(begin1, end1, begin2, pred); }
// Sequential fallback for input iterator case
template<typename InputIterator1, typename InputIterator2, typename Predicate, typename IteratorTag1, typename IteratorTag2>
inline pair<InputIterator1, InputIterator2>
mismatch_switch(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2, Predicate pred, IteratorTag1, IteratorTag2)
mismatch_switch(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, Predicate pred, IteratorTag1,
IteratorTag2)
{ return _GLIBCXX_STD_P::mismatch(begin1, end1, begin2, pred); }
// Parallel mismatch for random access iterators
template<typename RandomAccessIterator1, typename RandomAccessIterator2, typename Predicate>
pair<RandomAccessIterator1, RandomAccessIterator2>
mismatch_switch(RandomAccessIterator1 begin1, RandomAccessIterator1 end1, RandomAccessIterator2 begin2, Predicate pred, random_access_iterator_tag, random_access_iterator_tag)
mismatch_switch(RandomAccessIterator1 begin1, RandomAccessIterator1 end1,
RandomAccessIterator2 begin2, Predicate pred,
random_access_iterator_tag, random_access_iterator_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(true))
{
RandomAccessIterator1 res_first =
__gnu_parallel::find_template(begin1, end1, begin2, pred, __gnu_parallel::mismatch_selector()).first;
return make_pair(res_first, begin2 + (res_first - begin1));
RandomAccessIterator1 res = __gnu_parallel::find_template(begin1, end1, begin2, pred, __gnu_parallel::mismatch_selector()).first;
return make_pair(res , begin2 + (res - begin1));
}
else
return _GLIBCXX_STD_P::mismatch(begin1, end1, begin2, pred);
......@@ -131,7 +135,10 @@ namespace __parallel
typedef typename iterator1_traits::iterator_category iterator1_category;
typedef typename iterator2_traits::iterator_category iterator2_category;
return mismatch_switch(begin1, end1, begin2, __gnu_parallel::equal_to<value1_type, value2_type>(), iterator1_category(), iterator2_category());
typedef __gnu_parallel::equal_to<value1_type, value2_type> equal_to_type;
return mismatch_switch(begin1, end1, begin2, equal_to_type(),
iterator1_category(), iterator2_category());
}
// Public interface
......@@ -145,38 +152,52 @@ namespace __parallel
typedef typename iterator1_traits::iterator_category iterator1_category;
typedef typename iterator2_traits::iterator_category iterator2_category;
return mismatch_switch(begin1, end1, begin2, pred, iterator1_category(), iterator2_category());
return mismatch_switch(begin1, end1, begin2, pred, iterator1_category(),
iterator2_category());
}
// Sequential fallback
template<typename InputIterator1, typename InputIterator2>
inline bool
lexicographical_compare(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2, InputIterator2 end2, __gnu_parallel::sequential_tag)
lexicographical_compare(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2,
__gnu_parallel::sequential_tag)
{
return _GLIBCXX_STD_P::lexicographical_compare<InputIterator1, InputIterator2>(begin1, end1, begin2, end2);
return _GLIBCXX_STD_P::lexicographical_compare(begin1, end1, begin2, end2);
}
// Sequential fallback
template<typename InputIterator1, typename InputIterator2, typename Predicate>
inline bool
lexicographical_compare(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2, InputIterator2 end2, Predicate pred, __gnu_parallel::sequential_tag)
lexicographical_compare(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2,
Predicate pred, __gnu_parallel::sequential_tag)
{
return _GLIBCXX_STD_P::lexicographical_compare(begin1, end1, begin2, end2, pred);
return _GLIBCXX_STD_P::lexicographical_compare(begin1, end1,
begin2, end2, pred);
}
// Sequential fallback for input iterator case
template<typename InputIterator1, typename InputIterator2, typename Predicate, typename IteratorTag1, typename IteratorTag2>
inline bool
lexicographical_compare_switch(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2, InputIterator2 end2, Predicate pred, IteratorTag1, IteratorTag2)
lexicographical_compare_switch(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2,
Predicate pred, IteratorTag1, IteratorTag2)
{
return _GLIBCXX_STD_P::lexicographical_compare(begin1, end1, begin2, end2, pred);
return _GLIBCXX_STD_P::lexicographical_compare(begin1, end1,
begin2, end2, pred);
}
// Parallel lexicographical_compare for random access iterators
// Limitation: Both valuetypes must be the same
template<typename RandomAccessIterator1, typename RandomAccessIterator2, typename Predicate>
bool
lexicographical_compare_switch(RandomAccessIterator1 begin1, RandomAccessIterator1 end1, RandomAccessIterator2 begin2, RandomAccessIterator2 end2, Predicate pred, random_access_iterator_tag, random_access_iterator_tag)
lexicographical_compare_switch(RandomAccessIterator1 begin1,
RandomAccessIterator1 end1,
RandomAccessIterator2 begin2,
RandomAccessIterator2 end2, Predicate pred,
random_access_iterator_tag,
random_access_iterator_tag)
{
if (_GLIBCXX_PARALLEL_CONDITION(true))
{
......@@ -192,7 +213,10 @@ namespace __parallel
if ((end1 - begin1) < (end2 - begin2))
{
typedef pair<RandomAccessIterator1, RandomAccessIterator2> pair_type;
pair_type mm = mismatch_switch(begin1, end1, begin2, equal_type(pred), random_access_iterator_tag(), random_access_iterator_tag());
pair_type mm = mismatch_switch(begin1, end1, begin2,
equal_type(pred),
random_access_iterator_tag(),
random_access_iterator_tag());
// Less because shorter.
const bool lbs = mm.first == end1;
......@@ -205,7 +229,10 @@ namespace __parallel
else
{
typedef pair<RandomAccessIterator2, RandomAccessIterator1> pair_type;
pair_type mm = mismatch_switch(begin2, end2, begin1, equal_type(pred), random_access_iterator_tag(), random_access_iterator_tag());
pair_type mm = mismatch_switch(begin2, end2, begin1,
equal_type(pred),
random_access_iterator_tag(),
random_access_iterator_tag());
// Less because shorter.
const bool lbs = mm.first != end2;
......@@ -234,7 +261,9 @@ namespace __parallel
typedef typename traits2_type::iterator_category iterator2_category;
typedef __gnu_parallel::less<value1_type, value2_type> less_type;
return lexicographical_compare_switch(begin1, end1, begin2, end2, less_type(), iterator1_category(), iterator2_category());
return lexicographical_compare_switch(begin1, end1, begin2, end2,
less_type(), iterator1_category(),
iterator2_category());
}
// Public interface
......@@ -248,7 +277,9 @@ namespace __parallel
typedef iterator_traits<InputIterator2> traits2_type;
typedef typename traits2_type::iterator_category iterator2_category;
return lexicographical_compare_switch(begin1, end1, begin2, end2, pred, iterator1_category(), iterator2_category());
return lexicographical_compare_switch(begin1, end1, begin2, end2, pred,
iterator1_category(),
iterator2_category());
}
} // end namespace
} // end namespace
......
......@@ -46,32 +46,50 @@ namespace __parallel
{
template<typename _IIter, typename T>
inline T
accumulate(_IIter, _IIter, T, __gnu_parallel::sequential_tag);
accumulate(_IIter, _IIter, T);
template<typename _IIter, typename T, typename _BinaryOper>
template<typename _IIter, typename T>
inline T
accumulate(_IIter, _IIter, T, _BinaryOper, __gnu_parallel::sequential_tag);
accumulate(_IIter, _IIter, T, __gnu_parallel::sequential_tag);
template<typename _IIter, typename T>
inline T
accumulate(_IIter, _IIter, T, __gnu_parallel::parallelism parallelism_tag = __gnu_parallel::parallel_unbalanced);
accumulate(_IIter, _IIter, T, __gnu_parallel::parallelism parallelism_tag);
template<typename _IIter, typename T, typename _Tag>
inline T
accumulate_switch(_IIter, _IIter, T, _Tag);
template<typename _IIter, typename T, typename _BinaryOper>
inline T
accumulate(_IIter, _IIter, T, _BinaryOper, __gnu_parallel::parallelism parallelism_tag = __gnu_parallel::parallel_unbalanced);
accumulate(_IIter, _IIter, T, _BinaryOper);
template<typename _IIter, typename T, typename _Tag>
template<typename _IIter, typename T, typename _BinaryOper>
inline T
accumulate_switch(_IIter, _IIter, T, _Tag, __gnu_parallel::parallelism parallelism_tag);
accumulate(_IIter, _IIter, T, _BinaryOper, __gnu_parallel::sequential_tag);
template<typename _IIter, typename T, typename _BinaryOper>
inline T
accumulate(_IIter, _IIter, T, _BinaryOper,
__gnu_parallel::parallelism parallelism_tag);
template<typename _IIter, typename T, typename _BinaryOper, typename _Tag>
T
accumulate_switch(_IIter, _IIter, T, _BinaryOper, _Tag, __gnu_parallel::parallelism parallelism_tag);
accumulate_switch(_IIter, _IIter, T, _BinaryOper, _Tag);
template<typename _RAIter, typename T, typename _BinaryOper>
T
accumulate_switch(_RAIter, _RAIter, T, _BinaryOper, random_access_iterator_tag, __gnu_parallel::parallelism parallelism_tag);
accumulate_switch(_RAIter, _RAIter, T, _BinaryOper,
random_access_iterator_tag, __gnu_parallel::parallelism);
template<typename _IIter, typename _OIter>
inline _OIter
adjacent_difference(_IIter, _IIter, _OIter);
template<typename _IIter, typename _OIter, typename _BinaryOper>
inline _OIter
adjacent_difference(_IIter, _IIter, _OIter, _BinaryOper);
template<typename _IIter, typename _OIter>
inline _OIter
......@@ -79,48 +97,68 @@ namespace __parallel
template<typename _IIter, typename _OIter, typename _BinaryOper>
inline _OIter
adjacent_difference(_IIter, _IIter, _OIter, _BinaryOper, __gnu_parallel::sequential_tag);
adjacent_difference(_IIter, _IIter, _OIter, _BinaryOper,
__gnu_parallel::sequential_tag);
template<typename _IIter, typename _OIter>
inline _OIter
adjacent_difference(_IIter, _IIter, _OIter, __gnu_parallel::parallelism parallelism_tag = __gnu_parallel::parallel_balanced);
adjacent_difference(_IIter, _IIter, _OIter, __gnu_parallel::parallelism);
template<typename _IIter, typename _OIter, typename _BinaryOper>
inline _OIter
adjacent_difference(_IIter, _IIter, _OIter, _BinaryOper, __gnu_parallel::parallelism parallelism_tag = __gnu_parallel::parallel_balanced);
adjacent_difference(_IIter, _IIter, _OIter, _BinaryOper,
__gnu_parallel::parallelism);
template<typename _IIter, typename _OIter, typename _BinaryOper, typename _Tag1, typename _Tag2>
inline _OIter
adjacent_difference_switch(_IIter, _IIter, _OIter, _BinaryOper, _Tag1, _Tag2, __gnu_parallel::parallelism);
adjacent_difference_switch(_IIter, _IIter, _OIter, _BinaryOper, _Tag1, _Tag2);
template<typename _IIter, typename _OIter, typename _BinaryOper>
_OIter
adjacent_difference_switch(_IIter, _IIter, _OIter, _BinaryOper, random_access_iterator_tag, random_access_iterator_tag, __gnu_parallel::parallelism parallelism_tag);
adjacent_difference_switch(_IIter, _IIter, _OIter, _BinaryOper,
random_access_iterator_tag,
random_access_iterator_tag,
__gnu_parallel::parallelism);
template<typename _IIter1, typename _IIter2, typename T, typename BinaryFunction1, typename BinaryFunction2>
template<typename _IIter1, typename _IIter2, typename T>
inline T
inner_product(_IIter1, _IIter1, _IIter2, T, BinaryFunction1, BinaryFunction2, __gnu_parallel::sequential_tag);
inner_product(_IIter1, _IIter1, _IIter2, T);
template<typename _IIter1, typename _IIter2, typename T>
inline T
inner_product(_IIter1, _IIter1, _IIter2, T, __gnu_parallel::sequential_tag);
template<typename _IIter1, typename _IIter2, typename T>
inline T
inner_product(_IIter1, _IIter1, _IIter2, T, __gnu_parallel::parallelism);
template<typename _IIter1, typename _IIter2, typename T, typename BinaryFunction1, typename BinaryFunction2>
inline T
inner_product(_IIter1, _IIter1, _IIter2, T, BinaryFunction1, BinaryFunction2, __gnu_parallel::parallelism parallelism_tag = __gnu_parallel::parallel_unbalanced);
inner_product(_IIter1, _IIter1, _IIter2, T, BinaryFunction1, BinaryFunction2);
template<typename _IIter1, typename _IIter2, typename T>
template<typename _IIter1, typename _IIter2, typename T, typename BinaryFunction1, typename BinaryFunction2>
inline T
inner_product(_IIter1, _IIter1, _IIter2, T, BinaryFunction1, BinaryFunction2,
__gnu_parallel::sequential_tag);
template<typename _IIter1, typename _IIter2, typename T, typename BinaryFunction1, typename BinaryFunction2>
inline T
inner_product(_IIter1, _IIter1, _IIter2, T, __gnu_parallel::parallelism parallelism_tag = __gnu_parallel::parallel_unbalanced);
inner_product(_IIter1, _IIter1, _IIter2, T, BinaryFunction1, BinaryFunction2,
__gnu_parallel::parallelism);
template<typename _RAIter1, typename _RAIter2, typename T, typename BinaryFunction1, typename BinaryFunction2>
T
inner_product_switch(_RAIter1, _RAIter1, _RAIter2, T, BinaryFunction1, BinaryFunction2, random_access_iterator_tag, random_access_iterator_tag, __gnu_parallel::parallelism parallelism_tag);
inner_product_switch(_RAIter1, _RAIter1, _RAIter2, T, BinaryFunction1,
BinaryFunction2, random_access_iterator_tag,
random_access_iterator_tag,
__gnu_parallel::parallelism);
template<typename _IIter1, typename _IIter2, typename T, typename BinaryFunction1, typename BinaryFunction2, typename _Tag1, typename _Tag2>
inline T
inner_product_switch(_IIter1, _IIter1, _IIter2, T, BinaryFunction1, BinaryFunction2, _Tag1, _Tag2, __gnu_parallel::parallelism parallelism_tag);
inner_product_switch(_IIter1, _IIter1, _IIter2, T, BinaryFunction1,
BinaryFunction2, _Tag1, _Tag2);
template<typename _IIter, typename _OIter>
......
......@@ -39,12 +39,8 @@
#define _GLIBCXX_PARALLEL_RANDOM_SHUFFLE_H 1
#include <limits>
#include <parallel/basic_iterator.h>
#include <bits/stl_algo.h>
#include <bits/stl_numeric.h>
#include <parallel/parallel.h>
#include <parallel/base.h>
#include <parallel/random_number.h>
#include <parallel/timing.h>
......@@ -125,15 +121,16 @@ namespace __gnu_parallel
* @param rng Random number generator to use.
*/
template<typename RandomNumberGenerator>
inline int random_number_pow2(int logp, RandomNumberGenerator& rng)
{
return rng.genrand_bits(logp);
}
inline int
random_number_pow2(int logp, RandomNumberGenerator& rng)
{ return rng.genrand_bits(logp); }
/** @brief Random shuffle code executed by each thread.
* @param pus Array of thread-local data records. */
template<typename RandomAccessIterator, typename RandomNumberGenerator>
inline void parallel_random_shuffle_drs_pu(DRSSorterPU<RandomAccessIterator, RandomNumberGenerator>* pus)
inline void
parallel_random_shuffle_drs_pu(DRSSorterPU<RandomAccessIterator,
RandomNumberGenerator>* pus)
{
typedef std::iterator_traits<RandomAccessIterator> traits_type;
typedef typename traits_type::value_type value_type;
......@@ -184,7 +181,9 @@ namespace __gnu_parallel
// Sum up bins, sd->dist[s + 1][d->num_threads] now contains the
// total number of items in bin s
for (bin_index s = 0; s < sd->num_bins; s++)
partial_sum(sd->dist[s + 1], sd->dist[s + 1] + d->num_threads + 1, sd->dist[s + 1]);
__gnu_sequential::partial_sum(sd->dist[s + 1],
sd->dist[s + 1] + d->num_threads + 1,
sd->dist[s + 1]);
}
#pragma omp barrier
......@@ -263,7 +262,8 @@ namespace __gnu_parallel
/** @brief Round up to the next greater power of 2.
* @param x Integer to round up */
template<typename T>
T round_up_to_pow2(T x)
T
round_up_to_pow2(T x)
{
if (x <= 1)
return 1;
......@@ -396,7 +396,9 @@ namespace __gnu_parallel
*/
template<typename RandomAccessIterator, typename RandomNumberGenerator>
inline void
sequential_random_shuffle(RandomAccessIterator begin, RandomAccessIterator end, RandomNumberGenerator& rng)
sequential_random_shuffle(RandomAccessIterator begin,
RandomAccessIterator end,
RandomNumberGenerator& rng)
{
typedef std::iterator_traits<RandomAccessIterator> traits_type;
typedef typename traits_type::value_type value_type;
......@@ -468,7 +470,7 @@ namespace __gnu_parallel
t.tic();
// Sum up bins.
partial_sum(dist0, dist0 + num_bins + 1, dist0);
__gnu_sequential::partial_sum(dist0, dist0 + num_bins + 1, dist0);
for (int b = 0; b < num_bins + 1; b++)
dist1[b] = dist0[b];
......@@ -503,7 +505,8 @@ namespace __gnu_parallel
*/
template<typename RandomAccessIterator, typename RandomNumberGenerator>
inline void
parallel_random_shuffle(RandomAccessIterator begin, RandomAccessIterator end, RandomNumberGenerator rng = random_number())
parallel_random_shuffle(RandomAccessIterator begin, RandomAccessIterator end,
RandomNumberGenerator rng = random_number())
{
typedef std::iterator_traits<RandomAccessIterator> traits_type;
typedef typename traits_type::difference_type difference_type;
......
......@@ -55,7 +55,8 @@ namespace __gnu_parallel
*/
template<typename RandomAccessIterator, typename _DifferenceTp>
void
calc_borders(RandomAccessIterator elements, _DifferenceTp length, _DifferenceTp* off)
calc_borders(RandomAccessIterator elements, _DifferenceTp length,
_DifferenceTp* off)
{
typedef _DifferenceTp difference_type;
......@@ -65,7 +66,7 @@ namespace __gnu_parallel
difference_type k = 0;
for (difference_type j = 2; j <= length; j++)
{
while ((k >= 0) && (elements[k] != elements[j-1]))
while ((k >= 0) && !(elements[k] == elements[j-1]))
k = off[k];
off[j] = ++k;
}
......
......@@ -49,7 +49,14 @@ namespace std
* @namespace __gnu_sequential
* @brief GNU sequential classes for public use.
*/
namespace __gnu_sequential { }
namespace __gnu_sequential
{
#ifdef _GLIBCXX_PARALLEL
using namespace std::__norm;
#else
using namespace std;
#endif
}
/**
* @namespace __gnu_parallel
......
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