diff options
author | Johannes Singler <singler@kit.edu> | 2009-11-19 16:43:20 +0000 |
---|---|---|
committer | Johannes Singler <singler@gcc.gnu.org> | 2009-11-19 16:43:20 +0000 |
commit | d95ba652abbbfda10f29ca8b80c2126825a65eeb (patch) | |
tree | 00becbbe063e4775c84ee513458dc9b6c1c6f1e5 | |
parent | b66a1bac4615611113eafcd633406e761b1f544c (diff) | |
download | gcc-d95ba652abbbfda10f29ca8b80c2126825a65eeb.tar.gz |
partition.h (__parallel_partition): Correctly initialize chunk size.
2009-11-19 Johannes Singler <singler@kit.edu>
* include/parallel/partition.h (__parallel_partition): Correctly
initialize chunk size.
(__parallel_nth_element): Respect nth_element_minimal_n. Use
sequential nth_element as base case, instead of sequential sort.
From-SVN: r154333
-rw-r--r-- | libstdc++-v3/ChangeLog | 7 | ||||
-rw-r--r-- | libstdc++-v3/include/parallel/partition.h | 11 |
2 files changed, 13 insertions, 5 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 76caa592846..db8246e199d 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2009-11-19 Johannes Singler <singler@kit.edu> + + * include/parallel/partition.h (__parallel_partition): Correctly + initialize chunk size. + (__parallel_nth_element): Respect nth_element_minimal_n. Use + sequential nth_element as base case, instead of sequential sort. + 2009-11-17 Benjamin Kosnik <bkoz@redhat.com> * include/profile/impl/profiler.h: Remove namespace markup. diff --git a/libstdc++-v3/include/parallel/partition.h b/libstdc++-v3/include/parallel/partition.h index cfc2fd3737e..52993c86c95 100644 --- a/libstdc++-v3/include/parallel/partition.h +++ b/libstdc++-v3/include/parallel/partition.h @@ -73,7 +73,7 @@ namespace __gnu_parallel bool* __reserved_left = NULL, * __reserved_right = NULL; - _DifferenceType __chunk_size; + _DifferenceType __chunk_size = __s.partition_chunk_size; omp_lock_t __result_lock; omp_init_lock(&__result_lock); @@ -345,15 +345,16 @@ namespace __gnu_parallel _RAIter __split; _RandomNumber __rng; - _DifferenceType __minimum_length = - std::max<_DifferenceType>(2, _Settings::get().partition_minimal_n); + const _Settings& __s = _Settings::get(); + _DifferenceType __minimum_length = std::max<_DifferenceType>(2, + std::max(__s.nth_element_minimal_n, __s.partition_minimal_n)); // Break if input range to small. while (static_cast<_SequenceIndex>(__end - __begin) >= __minimum_length) { _DifferenceType __n = __end - __begin; - _RAIter __pivot_pos = __begin + __rng(__n); + _RAIter __pivot_pos = __begin + __rng(__n); // Swap __pivot_pos value to end. if (__pivot_pos != (__end - 1)) @@ -412,7 +413,7 @@ namespace __gnu_parallel } // Only at most _Settings::partition_minimal_n __elements __left. - __gnu_sequential::sort(__begin, __end, __comp); + __gnu_sequential::nth_element(__begin, __nth, __end, __comp); } /** @brief Parallel implementation of std::partial_sort(). |