Different random shuffles generated when compiled with gdc than with dmd

Ivan Kazmenko via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jun 1 05:11:20 PDT 2014


On Saturday, 31 May 2014 at 21:22:48 UTC, Joseph Rushton Wakeling 
via Digitalmars-d-learn wrote:
> On 31/05/14 22:37, Joseph Rushton Wakeling via 
> Digitalmars-d-learn wrote:
>> On 30/05/14 22:45, monarch_dodra via Digitalmars-d-learn wrote:
>>> Didn't you make changes to how and when the global PRNG is 
>>> popped and accessed
>>> in randomShuffle? I figured it *could* be an explanation.
>>
>> I think it's more likely that the culprit is either your set 
>> of patches to the
>> Mersenne Twister, or the patches made to uniform() (which is 
>> called by
>> partialShuffle).  I'll look more deeply into this.
>
> It's due to the the updated uniform() provided in this pull 
> request:
> https://github.com/D-Programming-Language/phobos/commit/fc48d56284f19bf171780554b63b4ae83808b894

I second the thought that reproducibility across different 
versions is an important feature of any random generation 
library.  Sadly, I didn't use a language yet which supported such 
a flavor of reproducibility for a significant period of time in 
its default random library, so I have to use my own randomness 
routines when it matters.  I've reported my concern [1] at the 
moment of breakage, but apparently it didn't convince people.  
Perhaps I should make a more significant effort next time (like a 
pull request) for the things that matter to me.  Well, now I know 
it does matter for others, at least.

In short, if uniform() has to be tweaked, the sooner it happens, 
the better.

Alternatively, the library design could allow different uniform() 
implementations to be plugged in, and provide legacy 
implementations along with the current (default) one.  In that 
case, all one has to do to reproduce the old behavior is to plug 
the appropriate one in.

[1] 
http://forum.dlang.org/thread/vgmdoyyqhcqurpmobyuy@forum.dlang.org#post-gjuprkxzmcbdixtbucea:40forum.dlang.org


More information about the Digitalmars-d-learn mailing list