-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tasks: don't advance task RNG on task spawn
Previously we had this unfortunate behavior: julia> Random.seed!(123) TaskLocalRNG() julia> randn() -0.6457306721039767 julia> Random.seed!(123) TaskLocalRNG() julia> fetch(@async nothing) julia> randn() 0.4922456865251828 In other words: the mere act of spawning a child task affects the parent task's RNG (by advancing it four times). This PR preserves the desirable parts of the previous situation: when seeded, the parent and child RNG streams are reproducible. Moreover, it fixes the undesirable behavior: julia> Random.seed!(123) TaskLocalRNG() julia> randn() -0.6457306721039767 julia> Random.seed!(123) TaskLocalRNG() julia> fetch(@async nothing) julia> randn() -0.6457306721039767 In other words: the parent RNG is unaffected by spawning a child. The design is documented in detail in a comment preceding the jl_rng_split function.
- Loading branch information
1 parent
9169c19
commit b27cb44
Showing
10 changed files
with
259 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.