I don't know if this is a feature or a bug. Functions used inside a pmap
call can only see SharedArrays when the pmap call is preceded by @async. To
replicate, be sure to start julia with more than one process (e.g., `julia
-p 2`):
julia> foo = convert(SharedArray, [1,2,3,4]);
julia> @async pmap(i->println(foo), 1:2)
Task (waiting) @0x000000010cd8f730
julia> From worker 2: [1,2,3,4]
From worker 3: [1,2,3,4]
julia> pmap(i->println(foo), 1:2)
2-element Array{Any,1}:
RemoteException(2,CapturedException(UndefVarError(:foo),Any[(:anonymous,:
none,1,symbol(""),-1,1),(:anonymous,symbol("multi.jl"),907,symbol(""),-1,1
),(:run_work_thunk,symbol("multi.jl"),645,symbol(""),-1,1),(:anonymous,
symbol("multi.jl"),907,symbol("task.jl"),63,1)]))
RemoteException(3,CapturedException(UndefVarError(:foo),Any[(:anonymous,:
none,1,symbol(""),-1,1),(:anonymous,symbol("multi.jl"),907,symbol(""),-1,1
),(:run_work_thunk,symbol("multi.jl"),645,symbol(""),-1,1),(:anonymous,
symbol("multi.jl"),907,symbol("task.jl"),63,1)]))
julia> versioninfo()
Julia Version 0.4.2
Commit bb73f34 (2015-12-06 21:47 UTC)
Platform Info:
System: Darwin (x86_64-apple-darwin15.0.0)
CPU: Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.3
I can also replicate this on Julia v0.3.9.