I was trying to learn distributed array. And I can distribute the arrays using distribute
, however I can’t work out how to get the localparts of arrays.
As a MWE here what I am trying to do
addprocs()
@everywhere using DistributedArrays
a = rand(1:5, 1_000_000)
b= rand(1_000_000)
@time da= distribute(a)
@time db= distribute(a)
sum(da) #these work fine
sum(db)
# I want to something like
@everywhere res = localpart(da) .* localpart(db)
But it says da
and db
are not defined on the workers, which makes sense, so how can define da
and db
in the workers?
My actual use cases uses much more complicated algorithms, but I would lilke to work with two or more distributed vectors.
Also just realised, wouldn’t it cause an issue where the vectors are distributed differently on different workers? I need finer control over how I distribute the vectors too then.