Julia v1.7.0-beta2 is now available

The NEWS file is the one with the changes for the current release.

See here for an (non necessarily efficient) idea for reproducible random number independent on number of threads the code run with, version of Julia and specific RNG:

https://sylvaticus.github.io/BetaML.jl/stable/Utils.html#BetaML.Utils.generateParallelRngs-Tuple{Random.AbstractRNG,%20Integer}

TESTRNG = StableRNG(123)

# ==================================
# New test
println("** Testing generateParallelRngs()...")
x = rand(copy(TESTRNG),100)

function innerFunction(bootstrappedx; rng=Random.GLOBAL_RNG)
     sum(bootstrappedx .* rand(rng) ./ 0.5)
end
function outerFunction(x;rng = Random.GLOBAL_RNG)
    masterSeed = rand(rng,100:9999999999999) # important: with some RNG it is important to do this before the generateParallelRngs to guarantee independance from number of threads
    rngs       = generateParallelRngs(rng,Threads.nthreads()) # make new copy instances
    results    = Array{Float64,1}(undef,30)
    Threads.@threads for i in 1:30
        tsrng = rngs[Threads.threadid()]    # Thread safe random number generator: one RNG per thread
        Random.seed!(tsrng,masterSeed+i*10) # But the seeding depends on the i of the loop not the thread: we get same results indipendently of the number of threads
        toSample = rand(tsrng, 1:100,100)
        bootstrappedx = x[toSample]
        innerResult = innerFunction(bootstrappedx, rng=tsrng)
        results[i] = innerResult
    end
    overallResult = mean(results)
    return overallResult
end


# Different sequences..
@test outerFunction(x) != outerFunction(x)

# Different values, but same sequence
mainRng = copy(TESTRNG)
a = outerFunction(x, rng=mainRng)
b = outerFunction(x, rng=mainRng)

mainRng = copy(TESTRNG)
A = outerFunction(x, rng=mainRng)
B = outerFunction(x, rng=mainRng)

@test a != b && a == A && b == B


# Same value at each call
a = outerFunction(x,rng=copy(TESTRNG))
b = outerFunction(x,rng=copy(TESTRNG))
@test a == b

I thought that the 1.8.0-dev changes are in News file, and that what is new for 1.7.0 are on History. I think It’s as you say untill the beta-release. Then, everything in News have been moved to History. Now History points to 1.8.0-dev. Maybe I’m wrong. Sorry if that’s the case.

UPDATE: Sorry, I was pointing to master branch on which what’s on NEWS.md is now on HISTORY.md.

1 Like