OSDN Git Service

2010-03-30 Johannes Singler <singler@kit.edu>
authorsingler <singler@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 30 Mar 2010 14:50:56 +0000 (14:50 +0000)
committersingler <singler@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 30 Mar 2010 14:50:56 +0000 (14:50 +0000)
        * 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157826 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 06457d8..adf53ce 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 3082ea8..baad24d 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;