# Looking for advice on threading

**URL:** <https://discourse.julialang.org/t/looking-for-advice-on-threading/33301>\
**Category:** General Usage\
**Created:** [January 13, 2020, 1:51pm UTC](https://discourse.julialang.org/t/looking-for-advice-on-threading/33301 "2020-01-13T13:51:56Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Jakub\_Wronowski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jakub_wronowski/32/204030_2.png) [@Jakub\_Wronowski](https://discourse.julialang.org/u/Jakub_Wronowski)\
**Post date:** [January 13, 2020, 2:33pm UTC](https://discourse.julialang.org/t/looking-for-advice-on-threading/33301/2 "2020-01-13T14:33:00Z")

</div>

Search for “map reduce” design pattern.

> [@Parallel reductions](https://discourse.julialang.org/t/parallel-reductions/30180):
>
> “Parallel mapreduce” is a really common need, and it’s surprisingly hard to find a Julia implementation. Say we have julia\> x = randn(10000000); julia\> f = log∘sqrt∘abs #56 (generic function with 1 method) The goal is to build a fast, parallel work-alike to julia\> @btime sum($f.($x)) 150.037 ms (2 allocations: 76.29 MiB) -3.1741049251367934e6 julia\> @btime mapreduce($f,$+,$x) 135.280 ms (0 allocations: 0 bytes) -3.1741049251367934e6 When I asked this on Julia Slack #multithreading, @a…

> [@Map and mapreduce with Threads](https://discourse.julialang.org/t/map-and-mapreduce-with-threads/31861):
>
> I would like to experiment with parallelizing an embarrassingly parallel computation on an iterable using [the new multithreading in 1.3](https://julialang.org/blog/2019/07/multithreading). I need map and mapreduce. I would prefer to leave return type determination to Julia, so I would prefer not to preallocate. Do I just need to @spawn and then fetch, as in using Base.Threads: @spawn, fetch, threadid, nthreads @show nthreads() function ploop(f, itr) map(fetch, map(i -\> @spawn(f(i)), itr)) end function pmapreduce(f, op, itr) mapreduc…

Anyway 6x on desktop seems to be very good for me.

---

_[View the full topic](https://discourse.julialang.org/t/looking-for-advice-on-threading/33301)._
