impy-project / chromo

Hadronic Interaction Model interface in PYthon
Other
31 stars 7 forks source link

fix EposLHC rng reproduction #201

Closed pre-commit-ci[bot] closed 6 months ago

pre-commit-ci[bot] commented 6 months ago

updates:

jncots commented 6 months ago

Following the comment https://github.com/impy-project/chromo/issues/176#issuecomment-2085858178 functions ranfgt and ranfst have been implemented. ranfgt reads structure of numpy's pcg64 random generator that represents state of pcg64 and saves as array of ints in common block. rangst read the common block and writes the values of arrays to the pcg64 structures thus restoring state.

Reading and writing to the structures of numpy's pcg64 is implemented by c functions in range.c file. Because there are many dereferencing of pointers and maybe because the code references numpy's library, the code is about 15-20 % slower compared to dummy functions.

The problem with reproducibility had irregular character, i.e. appeared from time to time and it was difficult to predict when it occurs. Still, sometimes it occurred. With current fix the problem has never showed up, which allows to hope that the source of the problem was indeed in ranfgt and ranfst