# FFTW Performance

**URL:** <https://discourse.julialang.org/t/fftw-performance/77175>\
**Category:** General Usage\
**Tags:** fftw, performance\
**Created:** [February 28, 2022, 10:39am UTC](https://discourse.julialang.org/t/fftw-performance/77175 "2022-02-28T10:39:17Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![jonas-kr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jonas-kr/32/1810_2.png) [@jonas-kr](https://discourse.julialang.org/u/jonas-kr)\
**Post date:** [March 18, 2022, 8:52am UTC](https://discourse.julialang.org/t/fftw-performance/77175/21 "2022-03-18T08:52:16Z")

</div>

At least in MATLAB the MKL FFTW also makes use of the ESTIMATE planner by default. Hence, I would be surprised it the MKL version in julia would enforce the use of MEASURE. Especially, since creating a plan with MEASURE should take a lot longer than it does by default.

---

<div class="post-metadata">

**Author:** ![gbellomia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gbellomia/32/19443_2.png) [@gbellomia](https://discourse.julialang.org/u/gbellomia)\
**Post date:** [March 18, 2022, 9:09am UTC](https://discourse.julialang.org/t/fftw-performance/77175/22 "2022-03-18T09:09:46Z")

</div>

Oh you’re right, just checked it… Ok, then I totally miss why MKL version behaves so much better with defaults. I guess it goes as intel magic…

---

<div class="post-metadata">

**Author:** ![AshtonSBradley](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ashtonsbradley/32/11140_2.png) [@AshtonSBradley](https://discourse.julialang.org/u/AshtonSBradley)\
**Post date:** [September 15, 2022, 10:34am UTC](https://discourse.julialang.org/t/fftw-performance/77175/23 "2022-09-15T10:34:43Z")

</div>

The comparison above is with Matlab `fft`, but Julia transforms all dimensions by default, which should be compared with Matlab’s `fftn`.

On an m1, if I compare with something column major

```julia
x = randn(1001,128,128) + 1j*randn(1001,128,128)
f = @() fftn(x)
timeit(f)

```

takes 64ms in Matlab 2022a, while

```julia
using LinearAlgebra, FFTW, BenchmarkTools
x=randn(ComplexF64,1001,128,128);
FFTW.set_num_threads(8)
p = plan_fft(x,flags=FFTW.MEASURE)
y=deepcopy(x);
@btime mul!($y,$p,$x);

```

in Julia 1.8.0 takes

21.374 ms (136 allocations: 9.53 KiB)

---

<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:** [September 15, 2022, 12:31pm UTC](https://discourse.julialang.org/t/fftw-performance/77175/24 "2022-09-15T12:31:57Z")

</div>

> [@gbellomia](#):
>
> the default planning in FFTW should be “measure”, so why in the julia wrapper it seems to be “estimate”?

The issue is that `MEASURE` plans require a large start-up latency, so they are only useful if you know you are going to be performing many FFTs of the same sizes. Interactive users wouldn’t appreciate this.

I don’t know where Matlab uses MKL and where it uses FFTW, but I suspect that for FFTW it pre-packages “wisdom” (precomputed plans) for a set of common sizes (powers of 2 and powers of 10, probably) and otherwise uses ESTIMATE plans.

---

<div class="post-metadata">

**Author:** ![gbellomia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gbellomia/32/19443_2.png) [@gbellomia](https://discourse.julialang.org/u/gbellomia)\
**Post date:** [September 15, 2022, 1:16pm UTC](https://discourse.julialang.org/t/fftw-performance/77175/25 "2022-09-15T13:16:57Z")

</div>

> [@stevengj](#):
>
> I don’t know where Matlab uses MKL and where it uses FFTW, but I suspect that for FFTW it pre-packages “wisdom” (precomputed plans) for a set of common sizes (powers of 2 and powers of 10, probably) and otherwise uses ESTIMATE plans.

Yes, that’s exactly [what they do](https://it.mathworks.com/help/matlab/ref/fftw.html) , but for the powers of two only.

 ![IMG_20220915_150733](https://global.discourse-cdn.com/julialang/original/3X/6/6/66a4df7630766095585b3d5f727c374941a92730.jpeg)

> [@stevengj](#):
>
> Interactive users wouldn’t appreciate this.

Sure, I had misunderstood what Matlab does. Prepackaged wisdom seems to be a nice solution for enhanced user experience. (Still 1001 is a very bad length for FFTs, hence out of scope for any reasonable wisdom prepackaging, so this should not apply to the previously discussed test cases).

---

<div class="post-metadata">

**Author:** ![photor](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/photor/32/14343_2.png) [@photor](https://discourse.julialang.org/u/photor)\
**Post date:** [November 2, 2022, 1:05pm UTC](https://discourse.julialang.org/t/fftw-performance/77175/26 "2022-11-02T13:05:36Z")

</div>

The MKL backend doesn’t support 1 dim planning? When I use

```julia
p = plan_fft(x,1)

```

, it says

```julia
FFTW could not create plan

```

But the FFTW backend works perfectly.

[Previous page](https://discourse.julialang.org/t/fftw-performance/77175.md?page=1)
