And I figured out the answer to my own problem.

The suspect line in the `addprocs` behavior is here:
https://github.com/JuliaLang/julia/blob/v0.4.3/base/multi.jl#L1120
This function calls `blas_set_num_threads(1)` so I can undo this behavior
by just calling `Base.blas_set_num_threads(16)` after `addprocs`.

I am going to open an issue asking for this to become a keyword argument.

Thanks,
Michael



On Thu, Jun 2, 2016 at 2:44 PM, Michael Eastwood <
michael.w.eastw...@gmail.com> wrote:

> Hello julia-users,
>
> I've noticed that if I start a worker blas is all of the sudden restricted
> to only running on one thread. See for example the following log. Here I
> multiply a large matrix by itself, add a remote worker, and repeat the
> multiplication (on the master process). In the latter case blas only uses
> one thread despite the fact it was happily using 16 threads before adding
> the worker. (Note that this log only shows timings but I've verified the
> number of threads being used by watching top).
>
> Can this behavior be circumvented?
>
> $ julia
>                _
>    _       _ _(_)_     |  A fresh approach to technical computing
>   (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
>    _ _   _| |_  __ _   |  Type "?help" for help.
>   | | | | | | |/ _` |  |
>   | | |_| | | | (_| |  |  Version 0.4.3 (2016-01-12 21:37 UTC)
>  _/ |\__'_|_|_|\__'_|  |
> |__/                   |  x86_64-unknown-linux-gnu
>
> julia> function multiply(A)
>            A'*A
>        end
> multiply (generic function with 1 method)
>
> julia> A = randn(5000, 5000);
>
> julia> ENV["OMP_NUM_THREADS"]
> "16"
>
> julia> @time multiply(A); # 16 threads used as expected
>   1.302345 seconds (634.91 k allocations: 220.681 MB, 3.01% gc time)
>
> julia> addprocs([("astm10", 1)]) # add a process on a remote machine
> 1-element Array{Int64,1}:
>  2
>
> julia> ENV["OMP_NUM_THREADS"] # unchanged
> "16"
>
> julia> @time multiply(A); # only one thread used
>  10.126372 seconds (9 allocations: 190.735 MB, 0.02% gc time)
>
> julia> versioninfo()
> Julia Version 0.4.3
> Commit a2f713d* (2016-01-12 21:37 UTC)
> Platform Info:
>   System: Linux (x86_64-unknown-linux-gnu)
>   CPU: Intel(R) Xeon(R) CPU E5-2630 v3 @ 2.40GHz
>   WORD_SIZE: 64
>   BLAS: libopenblas (USE64BITINT NO_AFFINITY NEHALEM)
>   LAPACK: libopenblas64_
>   LIBM: libopenlibm
>   LLVM: libLLVM-3.3
>
>
> Thanks,
> Michael
>
>

Reply via email to