Revise random number generation and initialization
After v.3.6.0, discuss with wider group + update random initialization to a scheme that guarantees different random numbers on each thread.
One option is Counter-Based RNGs https://en.wikipedia.org/wiki/Counter-based_random_number_generator_(CBRNG)
Random123 is available here: http://www.thesalmons.org/john/random123/releases/latest/docs/index.html
Thanks. Do you have a preferred scheme?
My current thoughts on this topic are:
- We pick a new scheme. Use fast skip ahead for threads + mpi tasks. This is the default. Take care to avoid the obvious mistakes in the current initialization. (Note that the observed problem with the current scheme is how parallelization is handled in initialization. My reading indicates that the current generator is not terrible.)
- Keep the current scheme as an option to avoid having to redo all the deterministic tests (only, the short & long must be fine by definition). e.g. New generator="legacy" option in the XML.
- Consider a debug/testing option to enable parallel deterministic tests e.g. all the random numbers follow the same sequence across threads and tasks.
- All the above is input switchable, no #defines
Comments welcome.
I'll weigh into this in one of the issues. RandomGenerator_t is not thread safe so particular thread needs to have sole access to a particular RandomGenerator just making copies isn't good enough. In the new drivers the Crowd has a "properly initialized" rng that it gives to the hamiltonians that need RNG. Ideally that would come as a function parameter (i.e. some sort of resource) but right now we update the hamiltonian object state in the initialLogEvaluation and at each step so this is correct for the step context it is in.
I think we have gone through whether this can be made to match the old method and the answer is no.
Food for thought on selecting RNG's:
https://www.pcg-random.org/statistical-tests.html#testu01-s-crush-and-bigcrush-batteries
I've been looking at that as well. They provide an API for c++ that follows the