summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/parallel
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/include/parallel')
-rw-r--r--libstdc++-v3/include/parallel/base.h16
-rw-r--r--libstdc++-v3/include/parallel/basic_iterator.h3
-rw-r--r--libstdc++-v3/include/parallel/find.h18
-rw-r--r--libstdc++-v3/include/parallel/multiseq_selection.h10
-rw-r--r--libstdc++-v3/include/parallel/multiway_merge.h4
-rw-r--r--libstdc++-v3/include/parallel/multiway_mergesort.h2
-rw-r--r--libstdc++-v3/include/parallel/partial_sum.h9
-rw-r--r--libstdc++-v3/include/parallel/partition.h2
-rw-r--r--libstdc++-v3/include/parallel/set_operations.h6
-rw-r--r--libstdc++-v3/include/parallel/settings.h6
10 files changed, 41 insertions, 35 deletions
diff --git a/libstdc++-v3/include/parallel/base.h b/libstdc++-v3/include/parallel/base.h
index 1a8c3cb60a8..3e3041d27df 100644
--- a/libstdc++-v3/include/parallel/base.h
+++ b/libstdc++-v3/include/parallel/base.h
@@ -140,13 +140,13 @@ namespace __gnu_parallel
/** @brief Equivalent to std::min. */
template<typename _Tp>
- const _Tp&
+ inline const _Tp&
min(const _Tp& __a, const _Tp& __b)
{ return (__a < __b) ? __a : __b; }
/** @brief Equivalent to std::max. */
template<typename _Tp>
- const _Tp&
+ inline const _Tp&
max(const _Tp& __a, const _Tp& __b)
{ return (__a > __b) ? __a : __b; }
@@ -267,8 +267,8 @@ namespace __gnu_parallel
/** @brief Similar to std::plus, but allows two different types. */
template<typename _Tp1, typename _Tp2, typename _Result
- = __typeof__(*static_cast<_Tp1*>(NULL)
- + *static_cast<_Tp2*>(NULL))>
+ = __typeof__(*static_cast<_Tp1*>(0)
+ + *static_cast<_Tp2*>(0))>
struct _Plus : public std::binary_function<_Tp1, _Tp2, _Result>
{
_Result
@@ -283,8 +283,8 @@ namespace __gnu_parallel
/** @brief Similar to std::multiplies, but allows two different types. */
template<typename _Tp1, typename _Tp2, typename _Result
- = __typeof__(*static_cast<_Tp1*>(NULL)
- * *static_cast<_Tp2*>(NULL))>
+ = __typeof__(*static_cast<_Tp1*>(0)
+ * *static_cast<_Tp2*>(0))>
struct _Multiplies : public std::binary_function<_Tp1, _Tp2, _Result>
{
_Result
@@ -300,7 +300,7 @@ namespace __gnu_parallel
/** @brief _Iterator associated with __gnu_parallel::_PseudoSequence.
* If features the usual random-access iterator functionality.
* @param _Tp Sequence _M_value type.
- * @param _DifferenceType Sequence difference type.
+ * @param _DifferenceTp Sequence difference type.
*/
template<typename _Tp, typename _DifferenceTp>
class _PseudoSequenceIterator
@@ -353,7 +353,7 @@ namespace __gnu_parallel
the same element.
* The copies are not stored explicitly, of course.
* @param _Tp Sequence _M_value type.
- * @param _DifferenceType Sequence difference type.
+ * @param _DifferenceTp Sequence difference type.
*/
template<typename _Tp, typename _DifferenceTp>
class _PseudoSequence
diff --git a/libstdc++-v3/include/parallel/basic_iterator.h b/libstdc++-v3/include/parallel/basic_iterator.h
index c5c067a0b0d..a624edc1a3b 100644
--- a/libstdc++-v3/include/parallel/basic_iterator.h
+++ b/libstdc++-v3/include/parallel/basic_iterator.h
@@ -1,6 +1,6 @@
// -*- C++ -*-
-// Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -34,7 +34,6 @@
#define _GLIBCXX_PARALLEL_BASIC_ITERATOR_H 1
#include <bits/c++config.h>
-#include <cstddef>
#include <bits/stl_iterator_base_types.h>
#include <bits/stl_iterator_base_funcs.h>
#include <bits/stl_iterator.h>
diff --git a/libstdc++-v3/include/parallel/find.h b/libstdc++-v3/include/parallel/find.h
index b4e581488ae..eb37d8aace1 100644
--- a/libstdc++-v3/include/parallel/find.h
+++ b/libstdc++-v3/include/parallel/find.h
@@ -168,9 +168,7 @@ namespace __gnu_parallel
* @param __selector _Functionality (e. g. std::find_if(), std::equal(),...)
* @return Place of finding in both sequences.
* @see __gnu_parallel::_Settings::find_sequential_search_size
- * @see __gnu_parallel::_Settings::find_initial_block_size
- * @see __gnu_parallel::_Settings::find_maximum_block_size
- * @see __gnu_parallel::_Settings::find_increasing_factor
+ * @see __gnu_parallel::_Settings::find_scale_factor
*
* There are two main differences between the growing blocks and
* the constant-size blocks variants.
@@ -218,6 +216,8 @@ namespace __gnu_parallel
omp_lock_t __result_lock;
omp_init_lock(&__result_lock);
+ const float __scale_factor = __s.find_scale_factor;
+
_ThreadIndex __num_threads = __get_max_threads();
# pragma omp parallel shared(__result) num_threads(__num_threads)
{
@@ -227,7 +227,8 @@ namespace __gnu_parallel
// Not within first __k elements -> start parallel.
_ThreadIndex __iam = omp_get_thread_num();
- _DifferenceType __block_size = __s.find_initial_block_size;
+ _DifferenceType __block_size =
+ std::max<_DifferenceType>(1, __scale_factor * __next_block_start);
_DifferenceType __start = __fetch_and_add<_DifferenceType>
(&__next_block_start, __block_size);
@@ -265,15 +266,14 @@ namespace __gnu_parallel
omp_unset_lock(&__result_lock);
}
- __block_size = std::min<_DifferenceType>
- (__block_size * __s.find_increasing_factor,
- __s.find_maximum_block_size);
+ _DifferenceType __block_size =
+ std::max<_DifferenceType>(1, __scale_factor * __next_block_start);
// Get new block, update pointer to next block.
__start = __fetch_and_add<_DifferenceType>(&__next_block_start,
__block_size);
- __stop = (__length < (__start + __block_size)
- ? __length : (__start + __block_size));
+ __stop =
+ std::min<_DifferenceType>(__length, __start + __block_size);
}
} //parallel
diff --git a/libstdc++-v3/include/parallel/multiseq_selection.h b/libstdc++-v3/include/parallel/multiseq_selection.h
index 1fab257ccdd..e77653aeefa 100644
--- a/libstdc++-v3/include/parallel/multiseq_selection.h
+++ b/libstdc++-v3/include/parallel/multiseq_selection.h
@@ -1,6 +1,6 @@
// -*- C++ -*-
-// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -230,7 +230,7 @@ namespace __gnu_parallel
__n /= 2;
_SeqNumber __lmax_seq = -1; // to avoid warning
- const _ValueType* __lmax = NULL; // impossible to avoid the warning?
+ const _ValueType* __lmax = 0; // impossible to avoid the warning?
for (_SeqNumber __i = 0; __i < __m; __i++)
{
if (__a[__i] > 0)
@@ -332,8 +332,8 @@ namespace __gnu_parallel
// Compare the keys on both edges of the border.
// Maximum of left edge, minimum of right edge.
- _ValueType* __maxleft = NULL;
- _ValueType* __minright = NULL;
+ _ValueType* __maxleft = 0;
+ _ValueType* __minright = 0;
for (_SeqNumber __i = 0; __i < __m; __i++)
{
if (__a[__i] > 0)
@@ -482,7 +482,7 @@ namespace __gnu_parallel
{
__n /= 2;
- const _Tp* __lmax = NULL;
+ const _Tp* __lmax = 0;
for (_SeqNumber __i = 0; __i < __m; ++__i)
{
if (__a[__i] > 0)
diff --git a/libstdc++-v3/include/parallel/multiway_merge.h b/libstdc++-v3/include/parallel/multiway_merge.h
index 445184ae5ec..1baf76beb9c 100644
--- a/libstdc++-v3/include/parallel/multiway_merge.h
+++ b/libstdc++-v3/include/parallel/multiway_merge.h
@@ -502,11 +502,11 @@ namespace __gnu_parallel
_LT __lt(__k, __comp);
// Default value for potentially non-default-constructible types.
- _ValueType* __arbitrary_element = NULL;
+ _ValueType* __arbitrary_element = 0;
for (_SeqNumber __t = 0; __t < __k; ++__t)
{
- if(__arbitrary_element == NULL
+ if(!__arbitrary_element
&& _GLIBCXX_PARALLEL_LENGTH(__seqs_begin[__t]) > 0)
__arbitrary_element = &(*__seqs_begin[__t].first);
}
diff --git a/libstdc++-v3/include/parallel/multiway_mergesort.h b/libstdc++-v3/include/parallel/multiway_mergesort.h
index 85894719dc0..8e2c53ec661 100644
--- a/libstdc++-v3/include/parallel/multiway_mergesort.h
+++ b/libstdc++-v3/include/parallel/multiway_mergesort.h
@@ -434,7 +434,7 @@ namespace __gnu_parallel
(::operator new(__size * sizeof(_ValueType)));
}
else
- __sd._M_samples = NULL;
+ __sd._M_samples = 0;
__sd._M_offsets = new _DifferenceType[__num_threads - 1];
__sd._M_pieces
diff --git a/libstdc++-v3/include/parallel/partial_sum.h b/libstdc++-v3/include/parallel/partial_sum.h
index 966d9db0572..d398c4585a2 100644
--- a/libstdc++-v3/include/parallel/partial_sum.h
+++ b/libstdc++-v3/include/parallel/partial_sum.h
@@ -127,10 +127,13 @@ namespace __gnu_parallel
equally_split(__n, __num_threads + 1, __borders);
else
{
+ _DifferenceType __first_part_length =
+ std::max<_DifferenceType>(1,
+ __n / (1.0f + __s.partial_sum_dilation * __num_threads));
_DifferenceType __chunk_length =
- ((double)__n
- / ((double)__num_threads + __s.partial_sum_dilation)),
- __borderstart = __n - __num_threads * __chunk_length;
+ (__n - __first_part_length) / __num_threads;
+ _DifferenceType __borderstart =
+ __n - __num_threads * __chunk_length;
__borders[0] = 0;
for (_ThreadIndex __i = 1; __i < (__num_threads + 1); ++__i)
{
diff --git a/libstdc++-v3/include/parallel/partition.h b/libstdc++-v3/include/parallel/partition.h
index 0d5a139968c..27b3871f41b 100644
--- a/libstdc++-v3/include/parallel/partition.h
+++ b/libstdc++-v3/include/parallel/partition.h
@@ -73,7 +73,7 @@ namespace __gnu_parallel
__leftnew, __rightnew;
// just 0 or 1, but int to allow atomic operations
- int* __reserved_left = NULL, * __reserved_right = NULL;
+ int* __reserved_left = 0, * __reserved_right = 0;
_DifferenceType __chunk_size = __s.partition_chunk_size;
diff --git a/libstdc++-v3/include/parallel/set_operations.h b/libstdc++-v3/include/parallel/set_operations.h
index 346fb97775d..f6b076f0655 100644
--- a/libstdc++-v3/include/parallel/set_operations.h
+++ b/libstdc++-v3/include/parallel/set_operations.h
@@ -1,6 +1,6 @@
// -*- C++ -*-
-// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -345,11 +345,11 @@ namespace __gnu_parallel
template<typename _IIter,
typename _OutputIterator,
- typename Operation>
+ typename _Operation>
_OutputIterator
__parallel_set_operation(_IIter __begin1, _IIter __end1,
_IIter __begin2, _IIter __end2,
- _OutputIterator __result, Operation __op)
+ _OutputIterator __result, _Operation __op)
{
_GLIBCXX_CALL((__end1 - __begin1) + (__end2 - __begin2))
diff --git a/libstdc++-v3/include/parallel/settings.h b/libstdc++-v3/include/parallel/settings.h
index 3b326ff8e47..5d00b026944 100644
--- a/libstdc++-v3/include/parallel/settings.h
+++ b/libstdc++-v3/include/parallel/settings.h
@@ -272,6 +272,9 @@ namespace __gnu_parallel
/// Minimal input size for search and search_n.
_SequenceIndex search_minimal_n;
+ /// Block size scale-down factor with respect to current position.
+ float find_scale_factor;
+
/// Get the global settings.
_GLIBCXX_CONST static const _Settings&
get() throw();
@@ -331,7 +334,8 @@ namespace __gnu_parallel
TLB_size(128),
cache_line_size(64),
qsb_steals(0),
- search_minimal_n(1000)
+ search_minimal_n(1000),
+ find_scale_factor(0.01f)
{ }
};
}