FFTW vs Matlab FFT

后端 未结 4 1829
旧时难觅i
旧时难觅i 2020-12-14 14:44

I posted this on matlab central but didn\'t get any responses so I figured I\'d repost here.

I recently wrote a simple routine in Matlab that uses an FFT in a for-l

4条回答
  •  北海茫月
    2020-12-14 15:34

    A few observations rather than a definite answer since I do not know any of the specifics of the MATLAB FFT implementation:

    • Based on the code you have, I can see two explanations for the speed difference:
      • the speed difference is explained by differences in levels of optimization of the FFT
      • the while loop in MATLAB is executed a significantly smaller number of times

    I will assume you already looked into the second issue and that the number of iterations are comparable. (If they aren't, this is most likely to some accuracy issues and worth further investigations.)

    Now, regarding FFT speed comparison:

    • Yes, the theory is that FFTW is faster than other high-level FFT implementations but it is only relevant as long as you compare apples to apples: here you are comparing implementations at a level further down, at the assembly level, where not only the selection of the algorithm but its actual optimization for a specific processor and by software developers with varying skills comes at play
    • I have optimized or reviewed optimized FFTs in assembly on many processors over the year (I was in the benchmarking industry) and great algorithms are only part of the story. There are considerations that are very specific to the architecture you are coding for (accounting for latencies, scheduling of instructions, optimization of register usage, arrangement of data in memory, accounting for branch taken/not taken latencies, etc.) and that make differences as important as the selection of the algorithm.
    • With N=500000, we are also talking about large memory buffers: yet another door for more optimizations that can quickly get pretty specific to the platform you run your code on: how well you manage to avoid cache misses won't be dictated by the algorithm so much as by how the data flow and what optimizations a software developer may have used to bring data in and out of memory efficiently.
    • Though I do not know the details of the MATLAB FFT implementation, I am pretty sure that an army of DSP engineers has been (and is still) honing on its optimization as it is key to so many designs. This could very well mean that MATLAB had the right combination of developers to produce a much faster FFT.

提交回复
热议问题