Personally I think it is totally worth it. I see my c# devs write so much code to deal with this situation.
I think I may have found a bug when running the same code on a single threaded instance in Julia and an instance with 4 cores.
I would think since each task has a local random number generator state, that it shouldn’t matter how many cores I’m using.
The numbers start off the same but diverge. Not sure if coincidence, but the ones that match are all on thread 1.
using Random
N = 10
Random.seed!(1234);
# Any because I was experimenting with gathering task local info not just doubles.
x = Array{Any}(undef, N)
Threads.@threads for i in 1:N
x[i] = rand()
end
One thread:
julia> x
10-element Vector{Any}:
0.8521319181373054
0.7689799548530378
0.6243499745554029
0.3293649906351931
0.9990226080289056
0.24044820241363107
0.0192236627448511
0.6335674481579363
0.7846641780713622
0.25749532080682724
Julia -t 4
julia> x
10-element Vector{Any}:
0.8521319181373054
0.7689799548530378
0.6243499745554029
0.4129780578067782
0.5739657632171419
0.9755932386001536
0.6278063483588922
0.9986465688348583
0.5105042328844386
0.7418532936197424