[Bench!][Mir] +54%..+185% performance boost for Mersenne Twister.
Ilya Yaroshenko via Digitalmars-d
digitalmars-d at puremagic.com
Sat Nov 26 08:31:40 PST 2016
Hey,
32-bit Mt19937 random number Generator is default in Phobos.
It is default in Mir too, except that 64-bit targets use 64-bit
Mt19937 instead.
The last Mir Random beta improves performance for Mt19937.
The goal was to:
1. Improve RNG generation performance by making code more
friendly for CPU pipelining. Tempering (finalization) operations
was mixed with internal payload update operations.
2. Reduce number of required comparison operations using
unification with add/sub operations. The order of payload
iteration was reversed (the engine generates the same numbers as
before).
3. Reduce memory access twice both for generation (required for
1) and initialization. This will make the algorithm more
cache-friendly for real world applications. Ditto (1)
Bench results:
----
mir.random 32-bit Mt19937:
6.80851 Gb/s
mir.random 64-bit Mt19937:
12.5984 Gb/s
std.random 32-bit Mt19937:
4.41989 Gb/s
std.random 64-bit Mt19937:
wrong initialization and tempering (finalization)
----
54%: 1.54 = 6.80851 / 4.41989
185%: 2.85 = 12.5984 / 4.41989
The benchmark can be found here:
https://github.com/libmir/mir-random/blob/master/bench/Mt19937_bench.d
Ads:
We are looking for new contributors and partners! Star and
contribute!
https://github.com/libmir :
- mir - Generic numeric library
- dcv - D Computer Vision library
- mir-glas - Linear Algebra Subprograms (written in D)
- mir-random - random numbers generators, includes non-uniform
distributions.
- mir-cpuid - CPU identification
Future:
- mir-runtime - lightweight always inlined `nothrow @nogc` Dlang
Runtime
- mir-neural - neural network library [WIP]
- mir-fft - Fast and multidimensional FFT
- mir-svm - support vector machines
Cheers,
Ilya & Mir Team
More information about the Digitalmars-d
mailing list