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

Implement Multi-threaded compatible PRNG #585

Closed
kayceesrk opened this issue Jun 16, 2021 · 2 comments
Closed

Implement Multi-threaded compatible PRNG #585

kayceesrk opened this issue Jun 16, 2021 · 2 comments
Labels
post 5.00 Items to be worked on after OCaml 5.0 release

Comments

@kayceesrk
Copy link
Contributor

With #582, we have domain-local PRNGs following closely along the lines of stock OCaml. In particular, the behaviour remains the same for sequential OCaml programs. But the situation for parallel programs is not ideal. Without explicit initialisation, all the domains will draw the same initial sequence.

@xavierleroy suggested the use of splittable PRNGs which could one day replace OCaml's Random module. Multicore OCaml should prototype PRINGO as a replacement for the current Random module (after MVP).

@kayceesrk kayceesrk added the post 5.00 Items to be worked on after OCaml 5.0 release label Jun 25, 2021
@xavierleroy
Copy link
Contributor

For the record: it is also possible to use a PRNG that supports "jumping" but not arbitrary splitting. If you see a PRNG as a very long sequence of states s(i), producing one random number moves to the next state in the sequence, and jumping efficiently moves 2^64 or 2^128 states forward in the sequence. From a given seed, jumping N times produces N independent PRNGs that can be used by N different domains.

@kayceesrk
Copy link
Contributor Author

Fixed by ocaml/ocaml#10742.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
post 5.00 Items to be worked on after OCaml 5.0 release
Projects
None yet
Development

No branches or pull requests

2 participants