Is there an easy way, to make the example below work?
using Distributed
addprocs(3)
@sync @distributed (+) for x in collect(1:10), y in collect(1:10)
sum(rand(x,y))
end
Is there an easy way, to make the example below work?
using Distributed
addprocs(3)
@sync @distributed (+) for x in collect(1:10), y in collect(1:10)
sum(rand(x,y))
end
What do you expect from the reducer (+) ?
Doing sum(rand(…)) for all combinations of x and y could be:
@sync @distributed for t in [ (x,y) for x in collect(1:10),y in collect(1:10)]
sum(rand(t[1],t[2]))
end
Thank you. this works.
Well, this was only a toy example. But I often have a reducer (maybe vcat or similar)
But beware, the comprehension [ (x,y) for x in collect(1:10),y in collect(1:10)]
is not distributed, or in other words the code is like:
arrayOfTuples = [ (x,y) for x in collect(1:10),y in collect(1:10)];
@sync @distributed for t in arrayOfTuples
sum(rand(t[1],t[2]))
end
that is perfectly fine. in my case ‘the workload’ in in place of sum(rand(…))