I have been trying to understand how @parallel
works for some time now, but I have not been able to reason why the below code works the way it works:
julia> nprocs()
4
julia> res = @parallel (+) for n in 1:3
n
end
6
julia> res = @parallel for n in 1:3
n
end
3-element Array{Future,1}:
Future(2,1,8,#NULL)
Future(3,1,9,#NULL)
Future(4,1,10,#NULL)
julia> fetch.(res)
3-element Array{Void,1}:
nothing
nothing
nothing
According to the documentation, @parallel
without the reduction operation returns an array of Future
s (that I can see). However, fetch
ing these Future
s results in nothing
. If these Future
s are nothing, what does (+)
aggregate in @parallel
? I’d expect to have either the last n
value, or simply the vectors of these n
s stored in the Future
, when I issue a fetch
.
I’d appreciate if you told me what I am missing.