# Scaled FFT implementation seems to only use one thread despite setting no. of threads to 8

**URL:** https://discourse.julialang.org/t/scaled-fft-implementation-seems-to-only-use-one-thread-despite-setting-no-of-threads-to-8/89396
**Category:** New to Julia
**Tags:** fftw, multithreading
**Created:** [October 27, 2022, 7:32pm UTC](https://discourse.julialang.org/t/scaled-fft-implementation-seems-to-only-use-one-thread-despite-setting-no-of-threads-to-8/89396 "2022-10-27T19:32:23Z")
**Posts on this page:** 1
**Showing post:** 2

<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: [October 27, 2022, 7:35pm UTC](https://discourse.julialang.org/t/scaled-fft-implementation-seems-to-only-use-one-thread-despite-setting-no-of-threads-to-8/89396/2 "2022-10-27T19:35:50Z")

</div>

> [@Thaegy](#):
>
> Am I missing an obvious trick that is causing wild inefficiencies in Julia?

If you care about efficiency, you should use `plan_fft` to precompute a plan and re-use it, rather than calling `fft` repeatedly. (And ideally pass `flags=FFTW.MEASURE` or `flags=FFTW.PATIENT`.) This is _the_ key to using FFTW effectively, as described in the [FFTW FAQ](https://www.fftw.org/faq/section3.html#slow).

(Matlab precomputes plans for a set of common sizes IIRC.)

There is also no need to use `nextpow(2, …)`. FFTW is fast as long the sizes are composites of small factors 2,3,5,7. In particular, you can use `nextprod([2,3,5], n)` or `nextprod([2,3,5,7], n)` as discussed in another thread: [How to set the length of fft](https://discourse.julialang.org/t/how-to-set-the-length-of-fft/38885) … but it is better to set your length to be such a number to begin with rather than padding (which changes the transform, not to mention incurring copies).

---

_[View the full topic](https://discourse.julialang.org/t/scaled-fft-implementation-seems-to-only-use-one-thread-despite-setting-no-of-threads-to-8/89396)._
