From: Johannes Singler Date: Tue, 30 Mar 2010 14:50:56 +0000 (+0000) Subject: random_shuffle.h (__parallel_random_shuffle_drs): Take as many threads as possible, i. X-Git-Tag: releases/gcc-4.5.0~160 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=26e020539c3d5bc0831d0443e38a9f0ed37620a7;p=thirdparty%2Fgcc.git random_shuffle.h (__parallel_random_shuffle_drs): Take as many threads as possible, i. 2010-03-30 Johannes Singler * 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 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 06457d8bd728..adf53ceac76c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2010-03-30 Johannes Singler + + * 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 * 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 3082ea8dbc03..baad24d4f664 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::max())); + __sequential_random_shuffle(__begin, __end, __derived_rng); + return; + } _DRandomShufflingGlobalData<_RAIter> __sd(__begin); _DRSSorterPU<_RAIter, _RandomNumber >* __pus;