# Multithreading broadcasted array ops

**URL:** <https://discourse.julialang.org/t/multithreading-broadcasted-array-ops/126842>\
**Category:** General Usage\
**Created:** [March 12, 2025, 4:08am UTC](https://discourse.julialang.org/t/multithreading-broadcasted-array-ops/126842 "2025-03-12T04:08:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pxshen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pxshen/32/38776_2.png) [@pxshen](https://discourse.julialang.org/u/pxshen)\
**Post date:** [March 12, 2025, 4:08am UTC](https://discourse.julialang.org/t/multithreading-broadcasted-array-ops/126842/1 "2025-03-12T04:08:06Z")

</div>

What’s best practice for multithreading broadcasted array ops?  
I know of various multithreaded map functions but wish for a simple macro like `@threads A.+B` doesn’t seem to work?  
Even better why can’t compiler automatically multithread broadcasted calls if Julia is started w/ multithreads?

---

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [March 12, 2025, 4:37am UTC](https://discourse.julialang.org/t/multithreading-broadcasted-array-ops/126842/2 "2025-03-12T04:37:34Z")

</div>

I like to use Tullio.jl or OhMyThreads.jl for simple multithreading tasks.

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [March 12, 2025, 6:36am UTC](https://discourse.julialang.org/t/multithreading-broadcasted-array-ops/126842/3 "2025-03-12T06:36:49Z")

</div>

`@tturbo`

---

<div class="post-metadata">

**Author:** ![pxshen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pxshen/32/38776_2.png) [@pxshen](https://discourse.julialang.org/u/pxshen)\
**Post date:** [March 13, 2025, 2:51am UTC](https://discourse.julialang.org/t/multithreading-broadcasted-array-ops/126842/4 "2025-03-13T02:51:15Z")

</div>

docs says @tturbo has yet to support broadcasting?

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [March 13, 2025, 3:05am UTC](https://discourse.julialang.org/t/multithreading-broadcasted-array-ops/126842/5 "2025-03-13T03:05:38Z")

</div>

> [@pxshen](#):
>
> I know of various multithreaded map functions but wish for a simple macro like `@threads A.+B` doesn’t seem to work?

> <https://github.com/JuliaLang/julia/issues/19777>
>
> It would be nice to be able to put \`@threads\` in front of a dot call, e.g. \`@thr…eads X .= f.(Y)\`, and have it call a multi-threaded version of \`broadcast\` (which would assume \`f\` is thread-safe).

> [@Multithreaded broadcast?](https://discourse.julialang.org/t/multithreaded-broadcast/26786):
>
> So, with the new improvements to threading, I’m wondering how that can be exposed easily to users. One of the most common parallelizable pattern is broadcasting (discussed in [https://github.com/JuliaLang/julia/issues/19777](https://github.com/JuliaLang/julia/issues/19777)). The conservative approach is to make @threads work for these, so we can do @threads a.= b.+ c. This is fine, but adding annotations gets annoying really fast (“so, what combination of @threads @simd @inbounds @. do I need this time?”), especially in matlab/numpy vector code …

> [@What is the “standard” way to use multi-threading with dot-calls (vectorized/broadcast)?](https://discourse.julialang.org/t/what-is-the-standard-way-to-use-multi-threading-with-dot-calls-vectorized-broadcast/113473):
>
> All the discussions I’ve found on this topic are years old: [“Multithreaded broadcast?” thread](https://discourse.julialang.org/t/multithreaded-broadcast/26786)[use multiple threads in vectorized operations · Issue #1802 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/1802)[multi-threaded (@threads) dotcall/broadcast? · Issue #19777 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/19777)[`@threads f(...)` syntax to tell callee to use threaded version? · Issue #40329 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/40329) What is currently the most straight-forward way to get multi-threading with operations like these: a = rand(4000, 4000) b…

> **[GitHub - Jutho/Strided.jl: A Julia package for strided array views and...](https://github.com/Jutho/Strided.jl)**
>
> A Julia package for strided array views and efficient manipulations thereof
