]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
random_shuffle.h (__parallel_random_shuffle_drs): Take as many threads as possible, i.
authorJohannes Singler <singler@kit.edu>
Tue, 30 Mar 2010 14:50:56 +0000 (14:50 +0000)
committerJohannes Singler <singler@gcc.gnu.org>
Tue, 30 Mar 2010 14:50:56 +0000 (14:50 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/include/parallel/random_shuffle.h

index 06457d8bd728c48819992589ddba9d09bbb424b7..adf53ceac76c5fe2b71a6f75730c6013ca69a0b2 100644 (file)
@@ -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.
index 3082ea8dbc0306e0266f9a05af8718f24a8782a6..baad24d4f66451bcf9d4f9520577a04266a114c5 100644 (file)
@@ -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;