Commit 15e2a6c0 by Johannes Singler Committed by Johannes Singler

re PR libstdc++/40852 ([parallel-mode] parallel sort run time increases ~10 fold…

re PR libstdc++/40852 ([parallel-mode] parallel sort run time increases ~10 fold when vector size gets over ~4*10^9)

2009-10-28  Johannes Singler  <singler@kit.edu>

        PR libstdc++/40852
        * include/parallel/multiseq_selection.h
        (multiseq_partition, multiseq_selection):  Avoid intermediate
        values exceeding the integer type range for very large inputs.

From-SVN: r153648
parent 533d4b99
2009-10-28 Johannes Singler <singler@kit.edu>
PR libstdc++/40852
* include/parallel/multiseq_selection.h
(multiseq_partition, multiseq_selection): Avoid intermediate
values exceeding the integer type range for very large inputs.
2009-10-26 Paolo Carlini <paolo.carlini@oracle.com> 2009-10-26 Paolo Carlini <paolo.carlini@oracle.com>
* include/std/chrono (duration<>::duration(const duration<>&)): Fix * include/std/chrono (duration<>::duration(const duration<>&)): Fix
......
...@@ -187,9 +187,6 @@ namespace __gnu_parallel ...@@ -187,9 +187,6 @@ namespace __gnu_parallel
// equality iff __nmax = 2^__k - 1. // equality iff __nmax = 2^__k - 1.
__l = (1ULL << __r) - 1; __l = (1ULL << __r) - 1;
// From now on, including padding.
__N = __l * __m;
for (int __i = 0; __i < __m; __i++) for (int __i = 0; __i < __m; __i++)
{ {
__a[__i] = 0; __a[__i] = 0;
...@@ -215,7 +212,7 @@ namespace __gnu_parallel ...@@ -215,7 +212,7 @@ namespace __gnu_parallel
__sample.push_back( __sample.push_back(
std::make_pair(__S(__i)[0] /*__dummy element*/, __i)); std::make_pair(__S(__i)[0] /*__dummy element*/, __i));
_DifferenceType __localrank = __rank * __m / __N ; _DifferenceType __localrank = __rank / __l;
int __j; int __j;
for (__j = 0; for (__j = 0;
...@@ -265,15 +262,11 @@ namespace __gnu_parallel ...@@ -265,15 +262,11 @@ namespace __gnu_parallel
__b[__i] -= __n + 1; __b[__i] -= __n + 1;
} }
_DifferenceType __leftsize = 0, __total = 0; _DifferenceType __leftsize = 0;
for (int __i = 0; __i < __m; __i++) for (int __i = 0; __i < __m; __i++)
{
__leftsize += __a[__i] / (__n + 1); __leftsize += __a[__i] / (__n + 1);
__total += __l / (__n + 1);
} _DifferenceType __skew = __rank / (__n + 1) - __leftsize;
_DifferenceType __skew = static_cast<_DifferenceType>
(static_cast<uint64_t>(__total) * __rank / __N - __leftsize);
if (__skew > 0) if (__skew > 0)
{ {
...@@ -442,9 +435,6 @@ namespace __gnu_parallel ...@@ -442,9 +435,6 @@ namespace __gnu_parallel
// equality iff __nmax = 2^__k - 1 // equality iff __nmax = 2^__k - 1
__l = pow2(__r) - 1; __l = pow2(__r) - 1;
// From now on, including padding.
__N = __l * __m;
for (int __i = 0; __i < __m; ++__i) for (int __i = 0; __i < __m; ++__i)
{ {
__a[__i] = 0; __a[__i] = 0;
...@@ -472,7 +462,7 @@ namespace __gnu_parallel ...@@ -472,7 +462,7 @@ namespace __gnu_parallel
__sample.push_back( __sample.push_back(
std::make_pair(__S(__i)[0] /*__dummy element*/, __i)); std::make_pair(__S(__i)[0] /*__dummy element*/, __i));
_DifferenceType __localrank = __rank * __m / __N ; _DifferenceType __localrank = __rank / __l;
int __j; int __j;
for (__j = 0; for (__j = 0;
...@@ -513,15 +503,11 @@ namespace __gnu_parallel ...@@ -513,15 +503,11 @@ namespace __gnu_parallel
__b[__i] -= __n + 1; __b[__i] -= __n + 1;
} }
_DifferenceType __leftsize = 0, __total = 0; _DifferenceType __leftsize = 0;
for (int __i = 0; __i < __m; ++__i) for (int __i = 0; __i < __m; ++__i)
{
__leftsize += __a[__i] / (__n + 1); __leftsize += __a[__i] / (__n + 1);
__total += __l / (__n + 1);
}
_DifferenceType __skew = ((unsigned long long)__total * __rank / __N _DifferenceType __skew = __rank / (__n + 1) - __leftsize;
- __leftsize);
if (__skew > 0) if (__skew > 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