I am new to parallel computing and I had a question regarding memory allocation. Is it possible to update an array in place while doing parallel computing? I tried using SharedArrays and DistributedArrays without success.
As an example,
# initializes the array to be updated in place
T = SharedArray{Float64,2}(10, 10, pids = workers());
for (i, ind) in enumerate(CartesianIndices(T))
T[ind] = i
end # works as intended
# reset all entries to zero
T .= 0.0;
@async @distributed for (i, ind) in enumerate(CartesianIndices(T))
T[ind] = i
end # T is only filled with zeros
You should wait() on that @async block to ensure it runs, and doesn’t throw any errors (which you won’t find out about until you wait() on it, anyway).