-
Notifications
You must be signed in to change notification settings - Fork 147
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
Default to high resolution random number generators #594
Comments
(see discussion also in #292) |
Hi-res vs low-res ranmar rng timing for isotropic photon source:
In low Z materials the slowdown is about 8% from keV energies up to 2 MeV. While in high Z materials the penalty is only 4%. ranlux vs low-res ranmar rng timing for isotropic photon source (Mortran):
@dworogers it would be interesting to check what happens for Linac simulations! |
I don't still have the hard numbers, but in my gold nanoparticle simulations when I first started using the high resolution option years ago, I found slowdowns ranging 10-14% |
Hmm, that's not negligible. I wonder if we make the low-res version the default, with a prominent notice to turn the hi-res option when "needed" (with a clearer definition), or default to hi-res with a prominent notice stating that one could gain ~10% with the low-res option, at your own risk! The latter is the safer. Will look at ranlux timing, and of course the real answer is |
@MartinMartinov thanks for sharing that info! I'm running a case for a Pb sphere and will update above. |
@ftessier if you are interested here is a bit of a soap opera I discover last night in the world of RNGs researchers: https://www.pcg-random.org/posts/on-vignas-pcg-critique.html Spoiler alert: They might be arguing about minutiae in our MC world! |
Wow, thanks for that perspective; perhaps |
I agree with highres default with instructions to switch to lowres when the time savings are needed. I think the general philosophy in EGSnrc is that the default settings are accurate in the vast majority of conditions. |
@ftessier see above the result ranlux vs ranmar in Mortran. It is actually getting worse! |
Darn! Skip all this and implement xoshiro256+ right away? 🤓 |
Posted in the thread again. Here are my replies regarding the pcg vs xoshiro debate: Interesting and entertaining feud between the xoshiro and pcg generator authors! From there I was led to a talk by pcg author Melissa O'Neill with an great historical perspective and a simple explanation of what pcg does. |
On pcg vs xoshiro: after additional reading, I side with the |
Only thing left as an implementation detail is how to sample doubles uniformly on [0,1). Do we just take the high bits from the xoshiro256+ 64-bit integer result and plug them into the mantissa of a double? Is that correct? Other suggestions welcome. |
Using the 53 most significant bits as the mantissa is sufficient for our purpose in EGSnrc, although strictly speaking it is not uniform: values in (0, 2e-53) are never picked. I think we can live with that!
This is from http://mumble.net/~campbell/tmp/random_real.c, which also proposes a neat solution to the the non-uniformity issue. |
@ftessier looking forward to your xoshiro256+ implementation! 🤓 |
Perhaps it's worth mentioning ranlux++ as another potential choice? Greatly improved performance over plain ranlux but still "suitable for use in the most demanding Monte Carlo calculations". There exists a portable C++ implementation that was recently added to ROOT: https://arxiv.org/abs/2106.02504 |
I have not looked at the |
There are situations were
ranmar
gives wrong results. It is a better approach to have someone switch to the low resolution ranmar rng intentionally, than having users obtaining wrong results unaware of this issue. Make ranlux (Mortran apps) or the high-resolution version (C++ apps) the default random number generator in EGSnrc.This is especially important as more simulations move to low energies and small scales.
The text was updated successfully, but these errors were encountered: