faster random number engine

Paolo Carlini paolo.carlini@oracle.com
Wed Aug 29 15:43:00 GMT 2012


On 8/29/12 4:19 PM, Ulrich Drepper wrote:
> The<random>  header so far contains the random number engines
> documented in the header.  None of these are well suited for modern
> CPUs.  There is a variant of the Mersenne twister engines which is
> explicitly designed to perform well on CPUs with SIMD instructions.
> The result is an engine with equal properties to the original Mersenne
> twisters but several times faster.
Great.
> The attached patch implements this new engine.  It's in the __gnu_cxx
> namespace.  I added definitions for all the variants defined by the
> authors.  The test suite checks the returned values based on results
> obtained from the original code.  The SIMD optimization is so far done
> for x86.  In all other cases a generic implementation is used.  The
> generic implementation works correctly for little endian machines.
> For big endian machines someone will come up with fixes.  Until then
> the new default.cc test is expected to fail.
>
> I hope this is an uncontroversial change.
The substance isn't of course. But normally we don't have __gnu_cxx 
things in the same std header. Can't we have a new ext/random and put it 
in there? If we can separate the new code to it, I think people would 
not even object to the target dependency, etc. In ext/ we are quite free 
to do extension / experimental work.

Paolo.



More information about the Libstdc++ mailing list