I’m working on some code where each remote worker needs to compute an array by accumulating values, and the arrays then need to be summed. Below is an absolute minimum working example to demonstrate the problem I’m encountering.
Obviously, the code below (lines 5 and 6) will not work because I did not use
@everywhere when defining
q. In my program though, “
q” is the result of many functions and other variables, so I’m hoping there is another way to copy
q to all workers without needing to use
@everywhere in front of every one of
Any guidance or suggestions would be much appreciated. Thanks!
using Distributed addprocs(2) q = reshape(rand(9), 3, 3) @everywhere nrow = eval(size(q, 1)) @everywhere ncol = eval(size(q, 2)) for i in workers() @spawnat i eval(:(a = fill(0, nrow, ncol))) end