-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the global RNG a Julia global variable instead of a libdSFMT variable #8399
Conversation
MersenneTwister's constructor making an instance with an Uint32 seed were removed in commit 4fb4622. But a subsequent call to srand(r::MersenneTwister, seed) would only accept an Uint32 as a seed, and would always make r.seed an Uint32; this was not consistent.
The srand methods working on a MersenneTwister instance did not catch up with those working on the global RNG. They are now made similar thanks to the make_seed function, which implements the different logics. Also, the manual is more precise on the types of valid seeds.
And similarly for rand!, randbool. Fixes JuliaLang#8360.
So, does #8380 need to be merged before this one? Let's keep the global version for now. It is likely that someone will find a performance issue once we merge and we may have to revert later. If no regressions are found, we can excise it in a few weeks. |
BTW, you can add commits to a PR after creating it too, if you need to add commits. |
Yes this depends on #8360. Really the goal here is to start testing a Julia global RNG but by no means it is ready to be merged. |
6c7c7e3
to
1a4c02f
Compare
It would be good to have just the global RNG part of this PR (where the global state is in Julia rather than in libdSFMT) merged, in light of other dSFMT work. |
This is now implemented by #8832. |
This is a follow-up of https://groups.google.com/forum/#!topic/julia-dev/0MUE8MoyO0k, where it is found that with simplistic benchmarks a global RNG controlled by Julia is no slower (and maybe slightly faster) than the one controlled by the dSFMT library (which is currently used by
rand()
with norng
argument).So this PR is to test more widely this assertion and find other possible problems.
Julia managing itself its global RNG may have advantages in a multi-threaded world (one "global" RNG per thread?). Are there any drawbacks? Note that an interface to the global RNG from libdSFMT can be kept (it just wouldn't be the default) if one really wants access to it.
This PR is built on #8380 (unmerged), and in fact adds only one small commit: I did the bare minimum so that everything builds and the tests pass. I certainly have missed things, please report problems.