aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Singler <singler@kit.edu>2010-03-30 14:50:56 +0000
committerJohannes Singler <singler@gcc.gnu.org>2010-03-30 14:50:56 +0000
commit26e020539c3d5bc0831d0443e38a9f0ed37620a7 (patch)
treea4438b4b1a29693fbd4bfedff53479ce7bd8cc2b
parenta3e7e012bf455a184a521162aa9ec8856a1e3622 (diff)
downloadgcc-26e020539c3d5bc0831d0443e38a9f0ed37620a7.zip
gcc-26e020539c3d5bc0831d0443e38a9f0ed37620a7.tar.gz
gcc-26e020539c3d5bc0831d0443e38a9f0ed37620a7.tar.bz2
random_shuffle.h (__parallel_random_shuffle_drs): Take as many threads as possible, i.
2010-03-30 Johannes Singler <singler@kit.edu> * include/parallel/random_shuffle.h (__parallel_random_shuffle_drs) : Take as many threads as possible, i. e. favor parallelism over cache efficiency. Use own PRNG also for the 1 thread case. From-SVN: r157826
-rw-r--r--libstdc++-v3/ChangeLog7
-rw-r--r--libstdc++-v3/include/parallel/random_shuffle.h10
2 files changed, 15 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 06457d8..adf53ce 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,10 @@
+2010-03-30 Johannes Singler <singler@kit.edu>
+
+ * include/parallel/random_shuffle.h
+ (__parallel_random_shuffle_drs) : Take as many threads as
+ possible, i. e. favor parallelism over cache efficiency.
+ Use own PRNG also for the 1 thread case.
+
2010-03-30 Paolo Carlini <paolo.carlini@oracle.com>
* include/debug/unordered_map: Clean-up includes and guards.
diff --git a/libstdc++-v3/include/parallel/random_shuffle.h b/libstdc++-v3/include/parallel/random_shuffle.h
index 3082ea8..baad24d 100644
--- a/libstdc++-v3/include/parallel/random_shuffle.h
+++ b/libstdc++-v3/include/parallel/random_shuffle.h
@@ -322,10 +322,16 @@ namespace __gnu_parallel
}
#endif
- __num_threads = std::min<_BinIndex>(__num_threads, __num_bins);
+ __num_bins = __round_up_to_pow2(
+ std::max<_BinIndex>(__num_threads, __num_bins));
if (__num_threads <= 1)
- return __sequential_random_shuffle(__begin, __end, __rng);
+ {
+ _RandomNumber __derived_rng(
+ __rng(std::numeric_limits<uint32_t>::max()));
+ __sequential_random_shuffle(__begin, __end, __derived_rng);
+ return;
+ }
_DRandomShufflingGlobalData<_RAIter> __sd(__begin);
_DRSSorterPU<_RAIter, _RandomNumber >* __pus;