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

Usability enhancements for external package authors #64

Closed
rstub opened this issue Sep 20, 2023 · 3 comments · Fixed by #79
Closed

Usability enhancements for external package authors #64

rstub opened this issue Sep 20, 2023 · 3 comments · Fixed by #79

Comments

@rstub
Copy link
Member

rstub commented Sep 20, 2023

With PR #58 on its way it makes sense to think about how external users, in particular package authors, could make use of this:

  • Users MUST NOT delete the RNG. In order to make this less likely one could offer a wrapper class as the official interface, c.f. feat: global RNG access #58 (comment). This wrapper should implement dqrng::random_64bit_generator which can be used together with C++ distribution functions since it supports UniformRandomBitGenerator. Note that in order to support the sampling methods this requires moving bit64() and bit32() from random_64bit_wrapper to random_64bit_generator as well as a change in the signature of these methods, i.e. the expected RNG should not come as dqrng::rng64_t.
  • Users SHOULD NOT store a reference to the RNG permanently, because it can be invalidated by calls to dqRNGkind. This can be handled by documenting best practices.
  • Some support for parallel usage patterns similar to https://daqana.github.io/dqrng/articles/parallel.html#xoroshiro-jump-ahead-with-openmp:
    • Instead of creating a new global RNG in serial code, one retrieves the global RNG from the package.
    • In parallel code, clone the RNG and switch stream, probably via something like dqrng::random_64bit_generator::clone(uint64_t stream). RNG specific implementations can be handled similarly to current stream specific template specializations. Note: I am not sure if one can implement this for the Threefry engine, as there is no way to increment the counter.
@rstub
Copy link
Member Author

rstub commented Sep 21, 2023

Part of this is already covered in #58. What is still needed:

  • Signature change for sampling methods to accept external RNG.
  • Support for parallel computation, e.g. via clone(stream) method
  • Maybe extend documentation?

@hsloot
Copy link
Contributor

hsloot commented Sep 22, 2023

Note that it was not necessary #58 to move bit64 and bit32 (but you could still do it if it makes sense to you).

@rstub
Copy link
Member Author

rstub commented Apr 9, 2024

It might also make sense to implement some of the random_generator interface suggested in https://www.pcg-random.org/posts/ease-of-use-without-loss-of-power.html.

@rstub rstub closed this as completed in #79 Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants