Skip to content

Commit 4a6cfdc

Browse files
committed
Make split() deterministic across architectures
1 parent 6c2cee3 commit 4a6cfdc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/rng.jl

+5-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ Base.rand(rng::TracedRNG, ::Type{T}) where {T} = Base.rand(rng.rng, T)
3535
3636
Split `key` into `n` new keys
3737
"""
38-
function split(key::Integer, n::Integer=1)
39-
T = typeof(key) # Make sure the type of `key` is consistent on W32 and W64 systems.
40-
return T[hash(key, i) for i in UInt(1):UInt(n)]
38+
function my_split(key::Integer, n::Integer=1)
39+
T = typeof(key)
40+
inner_rng = Random.MersenneTwister(key)
41+
retval = rand(inner_rng, T, n)
42+
return retval
4143
end
4244

4345
"""

0 commit comments

Comments
 (0)