# Data structures for threaded computing

**URL:** <https://discourse.julialang.org/t/data-structures-for-threaded-computing/30131>\
**Category:** Performance\
**Created:** [October 21, 2019, 12:07pm UTC](https://discourse.julialang.org/t/data-structures-for-threaded-computing/30131 "2019-10-21T12:07:47Z")\
**Posts on this page:** 1\
**Showing post:** 20

<div class="post-metadata">

**Author:** ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)\
**Post date:** [October 22, 2019, 9:20pm UTC](https://discourse.julialang.org/t/data-structures-for-threaded-computing/30131/20 "2019-10-22T21:20:08Z")

</div>

If you have a parallel `mapreduce(f, op, x)` (e.g., `reduce(op, Map(f), x)` from Transducers.jl), a neat way to minimize allocation and call `mul!` would be to use LazyArrays. Something like this (untested):

```julia
using LazyArrays: @~
using Transducers: Map

z = reduce(Map(x -> @~ x'x), x; init=nothing) do a, b
    a === nothing ? copy(b) : a .+= b
end

```

See also: [Parallel reductions](https://discourse.julialang.org/t/parallel-reductions/30180)

---

_[View the full topic](https://discourse.julialang.org/t/data-structures-for-threaded-computing/30131)._
