Skip to content
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

Correct random generators for MPI #737

Merged
merged 2 commits into from
Mar 22, 2024
Merged

Correct random generators for MPI #737

merged 2 commits into from
Mar 22, 2024

Conversation

lfarv
Copy link
Contributor

@lfarv lfarv commented Feb 9, 2024

Following a user's report on the use of random generators with MPI, this PR corrects 2 points:

  1. The reset_rng(rank=0, seed=n) function, used for seeding the generators, behaved oddly and was not clearly documented. Up to now, the function needed to provide explicitly the MPI process rank to initialise correctly the process-specific generator (the so-called "thread" generator). Forgetting this resulted in all threads using the same random stream. Now by default, reset_rng now uses the actual rank, so that the rank argument can be omitted. The documentation is improved.
  2. The Gaussian generator used static variables to store values between successive calls. This could introduce correlations between the "common" and "thread" random streams. Static variables are now eliminated.

@lfarv lfarv added Matlab For Matlab/Octave AT code Python For python AT code bug fix labels Feb 9, 2024
@lfarv lfarv merged commit 6c07fe9 into master Mar 22, 2024
37 checks passed
@lfarv lfarv deleted the random_MPI branch March 22, 2024 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix Matlab For Matlab/Octave AT code Python For python AT code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants