One thing Bradley Setzler suggested on this forum a few weeks back was to put A = rand() in a separate file, require() that file, and then proceed. I use that setup frequently.
On Monday, September 15, 2014 4:52:33 AM UTC-5, xiong...@gmail.com wrote: > > 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? >