# \`@parallel\` macro

**URL:** <https://discourse.julialang.org/t/parallel-macro/4059>\
**Category:** General Usage\
**Tags:** parallel\
**Created:** [June 2, 2017, 3:23pm UTC](https://discourse.julialang.org/t/parallel-macro/4059 "2017-06-02T15:23:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon61610682](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@anon61610682](https://discourse.julialang.org/u/anon61610682)\
**Post date:** [June 2, 2017, 3:23pm UTC](https://discourse.julialang.org/t/parallel-macro/4059/1 "2017-06-02T15:23:43Z")

</div>

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
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](https://docs.julialang.org/en/stable/manual/parallel-computing/#parallel-map-and-loops), `@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.

---

<div class="post-metadata">

**Author:** ![bicycle1885](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bicycle1885/32/107_2.png) [@bicycle1885](https://discourse.julialang.org/u/bicycle1885)\
**Post date:** [June 4, 2017, 6:14am UTC](https://discourse.julialang.org/t/parallel-macro/4059/2 "2017-06-04T06:14:33Z")

</div>

My understanding is that for loop returns nothing and hence `@parallel for` returns nothing as well if no reducer is given. If you’d like to do parallel computation using multiple processors, using `pmap` may be handier and more deterministic.

---

<div class="post-metadata">

**Author:** ![anon61610682](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@anon61610682](https://discourse.julialang.org/u/anon61610682)\
**Post date:** [June 5, 2017, 7:28am UTC](https://discourse.julialang.org/t/parallel-macro/4059/3 "2017-06-05T07:28:16Z")

</div>

Thanks for the answer, @bicycle1885. Apparently, you are right; only when there is a reduction, the result of the last expression becomes the return value. Returning `Future` values just adds to my confusion.
