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 Futures (that I can see). However, fetching these Futures results in nothing. If these Futures are nothing, what does (+) aggregate in @parallel? I’d expect to have either the last n value, or simply the vectors of these ns stored in the Future, when I issue a fetch.
I’d appreciate if you told me what I am missing.