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

reentrant TA::rand() #394

Conversation

evaleev
Copy link
Member

@evaleev evaleev commented Mar 9, 2023

introduces TA::{rand,drand,srand}

  • TA::{rand,drand} are reentrant versions of rand and drand48 that uses Boost.Random's mt19937 and uniform distribution classes (the latter is needed to produce platform-portable results, see https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2059r0.pdf ) ... TA::srand controls the seeds of the thread-specific random engines
  • detail::MakeRandom now uses TA::rand instead of std::rand (the latter is not guaranteed to be reentrant.
  • this PR also introduces control of the executor for DistArray::{init_elements,init_tiles,fill_random} so that it is possible to use DistArray::fill_random to get reproducibly-random tensors even if using >1 thread/rank.

- TA::{rand,drand} are reentrant versions of rand and drand48 that uses Boost.Random's mt19937 and uniform distribution classes (the latter is needed to produce platform-portable results, see https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2059r0.pdf ) ... TA::srand controls the seeds of the thread-specific random engines
- MakeRandom now uses TA::rand instead of std::rand ... the latter is not reentrant so technically any use of DistArray::fill_random was UB ... single-threaded version of DistArray::fill_random to get random tensors witrh contents independent of schedule will be introduced in a separate commit
…les,fill_random}

default is to use MADWorld's taskq, but useful with non-reentrant ops or, even when op is reentrant, e.g. to ensure that same random tensor is generated by DistArray::fill_random (since initial state of every thread-specific random engine is the same tiles generated by different threads will initially have the same content ... )
@evaleev evaleev merged commit 9c2a18d into evaleev/fix/rank-1-index-vs-ordinal-accessors Mar 9, 2023
@evaleev evaleev deleted the evaleev/feature/reentrant-rand branch March 9, 2023 22:21
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 this pull request may close these issues.

None yet

1 participant