I want to transfer a variable to all parallel workers. However, if I do:
A=rand()
pmap(x->A+x,1:3)
Return error:
exception on 2: ERROR: A not defined
in anonymous at none:1
in anonymous at multi.jl:855
in run_work_thunk at multi.jl:621
in anonymous at task.jl:855
exception on 3: ERROR: A not defined
in anonymous at none:1
in anonymous at multi.jl:855
in run_work_thunk at multi.jl:621
in anonymous at task.jl:855
2-element Array{Any,1}:
UndefVarError(:A)
UndefVarError(:A)
The result of
@everywhere A=rand()
pmap(x->A+x,1:3)
is not what I want, since I hope A in all mashines are the same.
I know that pmap((x,y)->x+y,1:3,fill(A,3)) will be work, but I don't think
it is smart since A is expand in memery unnessarily. Is there any simple
way to just send a copy of A, or the reference of A, to all parallel
mashines?