using MPI
function main()
MPI.Init()
comm = MPI.COMM_WORLD
id = MPI.Comm_rank(comm)
# compile and initialize
inv(rand(100,100));
A = rand(3500,3500)
@time inv(A);
println("$id of $(MPI.Comm_size(comm))")
MPI.Finalize()
end
main()
In this code each process should create and invert a random matrix, independently of other processes. However, the timings are not independent on the number of mpiruns
~/julia/parallel$ mpirun -n 1 julia inv_parallel.jl
0.960765 seconds (7 allocations: 95.196 MiB, 4.07% gc time)
0 of 1
~/julia/parallel$ mpirun -n 2 julia inv_parallel.jl
2.218972 seconds (7 allocations: 95.196 MiB, 2.19% gc time)
0 of 2
2.389026 seconds (7 allocations: 95.196 MiB, 1.92% gc time)
1 of 2
~/julia/parallel$ mpirun -n 4 julia inv_parallel.jl
6.949281 seconds (7 allocations: 95.196 MiB, 0.74% gc time)
3 of 4
7.425516 seconds (7 allocations: 95.196 MiB, 0.89% gc time)
1 of 4
7.520218 seconds (7 allocations: 95.196 MiB, 1.00% gc time)
2 of 4
7.576838 seconds (7 allocations: 95.196 MiB, 0.73% gc time)
0 of 4
Instead they scale with the number of processes?! Can somebody explain me this behaviour?