# Innefficient paralellization? Need some help optimizing a simple dot product

**URL:** <https://discourse.julialang.org/t/innefficient-paralellization-need-some-help-optimizing-a-simple-dot-product/9723>\
**Category:** Performance\
**Tags:** question, parallel\
**Created:** [March 14, 2018, 10:34pm UTC](https://discourse.julialang.org/t/innefficient-paralellization-need-some-help-optimizing-a-simple-dot-product/9723 "2018-03-14T22:34:20Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)\
**Post date:** [March 15, 2018, 4:17pm UTC](https://discourse.julialang.org/t/innefficient-paralellization-need-some-help-optimizing-a-simple-dot-product/9723/15 "2018-03-15T16:17:10Z")

</div>

Yeah, with `@threads` there seems to always be some reason to have to manually split up the workload over the threads.

- In this case it’s because you want each of the threads to reduce to their own local variable before summing the results of the threads together. Similarly in [Parallel is very slow - #17 by Elrod](https://discourse.julialang.org/t/parallel-is-very-slow/9443/17).
- Another case: [Parallelizing for loop in the computation of a gradient - #18 by saschatimme](https://discourse.julialang.org/t/parallelizing-for-loop-in-the-computation-of-a-gradient/9154/18) (perhaps not as frequently encountered as the first, but still)

Maybe `@threads` in its current form is just not the right abstraction? At the very least, a `mapreduce`-style version of `@threads` similar to `@parallel` would be pretty useful I think.

---

_[View the full topic](https://discourse.julialang.org/t/innefficient-paralellization-need-some-help-optimizing-a-simple-dot-product/9723)._
