Running several Julia engines

Not sure I am using correct terms/language to describe the problem, but I will try.

I want to run several Julia processes on one PC (Monte Carlo simulations). When I do it in Matlab, I simply start several Labs, and the loss in the speed of computation in moving from running one lab to 8 labs is about 30% (approximately, naked eye, based on some tick toks but not two markov chains are identical in speed)
When I do the same with Julia, the loss in speed from moving 1 to 8 engines is more substantial, I would say 60% or more, wiping out nearly the whole gain in moving from Matlab to Julia.
I am not using any fancy external dependencies, very simple code, using Julia 1.2 + several packages like Random, DelimitedFiles etc.

So the question is: may be there are some setting (in Atom?), language features (?) etc which will reduce this loss?

If relevant, it is AMD 3950x.

PS. yes, there is a similar thread, Slow down when running several parallel julia processes which use BLAS (MWE is provided) but I understand very little there, not sure I have the same reason, as I know nothing of BLAS.gemv! mentioned there.

I think this might be use of some Linear Algebra routines. If so, you need to lower OpenBlas threads. Each process separately runs OpenBlas routines if you use any BLAS or LinearAlgebra method and each of them wants to use all cores of the CPU via OpenBlas threads. Then, they are competing for computational resources, in a sense, causing context switching in operating system more. That slows down overall computations. Try BLAS.set_num_threads(n) before the MC simulations code where n = (# of CPU cores) / (# of Julia processes) = 16/8 = 2 (for AMD 3950x).

1 Like

Thank you, I am investigating this. Will report eventually what I discover: how using this setting affects the speed.