New Lagged Fib. PRNG gen and random2.d

monarch_dodra monarchdodra at gmail.com
Tue Aug 27 11:41:02 PDT 2013


On Monday, 26 August 2013 at 09:47:50 UTC, monarch_dodra wrote:
> FYI, I tweaked my algo a bit, as the benches revealed an issue. 
> Please wait for a new commit before testing my code.

I tweaked the algo a bit. It now runs faster when the amount of 
bits is the same as the size_t. I also renewed my benches, and 
did a linux dmd and gdc run.

The good news is the windows ulong|64 bit version is faster than 
before. The *great* news is that on linux, integral generation is 
*fast*. It's the fastest PRNG of all, faster than XOS and LC. 
*AND* it's generating 64 bit ulongs (!). In terms of performance, 
One could say it *creams* the competition :D

The BAD news though, is that it would appear the floating point 
generation on linux is *bad*. As in, so bad, it's faster to just 
generate integrals and divide. Arguably, I think the "native" 
double generation might be of slightly higher quality, but I 
don't think it is worth the cost.

Here are the new benches!!!

//=============================================
DMD32 2.063.2 on W764

Integrals
Time for LinearCongruentialEngine!(uint, 16807, 0, 214...):  8168
Time for MersenneTwisterEngine!(uint, 32, 624, 397, 31...): 14185
Time for LaggedFibonacciEngine!(uint, 32u, 607, 273)      :  7079
Time for LaggedFibonacciEngine!(ulong, 48u, 607, 273)     : 11869
Time for LaggedFibonacciEngine!(ulong, 64u, 607, 273)     :  9677

Floating
Time for LinearCongruentialEngine!(uint, 16807, 0, 214...): 12151
Time for MersenneTwisterEngine!(uint, 32, 624, 397, 31...): 19497
Time for XorshiftEngine!(uint, 32, 13, 17, 5)             : 10476
Time for LaggedFibonacciEngine!(uint, 32u, 607, 273)      : 11117
Time for LaggedFibonacciEngine!(ulong, 48u, 607, 273)     : 17415
Time for LaggedFibonacciEngine!(ulong, 64u, 607, 273)     : 15209
Time for LaggedFibonacciEngine!(double, 32u, 607, 273)    : 14882
Time for LaggedFibonacciEngine!(double, 48u, 607, 273)    : 14874
Time for LaggedFibonacciEngine!(real, 64u, 607, 273)      : 19138

//=============================================
Kubuntu 13.04-64 DMD64 HEAD

Integrals
Time for LinearCongruentialEngine!(uint, 16807, 0, 2147...):  6942
Time for MersenneTwisterEngine!(uint, 32, 624, 397, 31,...): 13352
Time for XorshiftEngine!(uint, 32, 13, 17, 15)             :  6267
Time for LaggedFibonacciEngine!(uint, 32LU, 607, 273)      :  4888
Time for LaggedFibonacciEngine!(ulong, 48LU, 607, 273)     : 10401
Time for LaggedFibonacciEngine!(ulong, 64LU, 607, 273)     :  6401

Floating
Time for LinearCongruentialEngine!(uint, 16807, 0, 2147...):  8200
Time for MersenneTwisterEngine!(uint, 32, 624, 397, 31, ..): 15357
Time for XorshiftEngine!(uint, 32, 13, 17, 15)             :  7851
Time for LaggedFibonacciEngine!(uint, 32LU, 607, 273)      :  5399
Time for LaggedFibonacciEngine!(ulong, 48LU, 607, 273)     : 11030
Time for LaggedFibonacciEngine!(ulong, 64LU, 607, 273)     :  6927
Time for LaggedFibonacciEngine!(double, 32LU, 607, 273)    : 20508
Time for LaggedFibonacciEngine!(double, 48LU, 607, 273)    : 20832
Time for LaggedFibonacciEngine!(real, 64LU, 607, 273)      : 34674


//=============================================
Kubuntu 13.04-64 gdc unknown version

Integrals
Time for LinearCongruentialEngine!(uint,16807,0,2147483...):  8397
Time for MersenneTwisterEngine!(uint,32,624,397,31,-172...): 13976
Time for XorshiftEngine!(uint,32,13,17,5)                  :  6135
Time for LaggedFibonacciEngine!(uint,32,607,273)           :  5165
Time for LaggedFibonacciEngine!(ulong,48,607,273)          :  8582
Time for LaggedFibonacciEngine!(ulong,64,607,273)          :  5250

Floating
Time for LinearCongruentialEngine!(uint,16807,0,2147483...):  8499
Time for MersenneTwisterEngine!(uint,32,624,397,31,-172...): 14523
Time for XorshiftEngine!(uint,32,13,17,5)                  :  6194
Time for LaggedFibonacciEngine!(uint,32,607,273)           :  5523
Time for LaggedFibonacciEngine!(ulong,48,607,273)          :  9239
Time for LaggedFibonacciEngine!(ulong,64,607,273)          :  5498
Time for LaggedFibonacciEngine!(double,32,607,273)         : 16733
Time for LaggedFibonacciEngine!(double,48,607,273)         : 16704
Time for LaggedFibonacciEngine!(real,64,607,273)           : 29949


More information about the Digitalmars-d mailing list