Borrar filtros
Borrar filtros

MEX Generation with Coder: Link FFTW?

8 visualizaciones (últimos 30 días)
Raj el 11 de Feb. de 2014
Editada: Ryan Livingston el 11 de Abr. de 2018
I have an algorithm that heavily uses FFTs, and I am using Coder to generate a MEX function. However, I see that for C/C++ targets, FFT lengths must be a power of 2:
My algorithm needs to perform FFTs that have length CLOSE to a power of two; my algorithm naturally generates a vector with length 2^(N-1), but then because my calculations require a type-I inverse DCT, I end up passing a vector of length (2^N-2) into the FFT algorithm. Because (2^N-2) is not a power of two, I get an error about FFT lengths when using Coder in this way. The Signal Processing toolbox function "idct" doesn't do the trick either, because that's a type-II transform.
I can get around this by declaring coder.extrinsic("fft"), but then I'm not really getting the full speed benefit of C/C++ because data is being sent back into MATLAB, which presumably calls FFTW anyway to do the calculation, then passes the result back.
My question is: can I get Coder to generate C/C++ that calls FFTW directly, and link the generated MEX against the FFTW library? It seems that Coder supports this kind of thing with BLAS already, where it generates calls to BLAS and links in the library (I think). Any one out there have thoughts or experience they can share about this?

Respuesta aceptada

Ryan Livingston
Ryan Livingston el 13 de Feb. de 2014
Editada: Ryan Livingston el 11 de Abr. de 2018
Edit April 11, 2018 As of MATLAB R2017b MATLAB Coder supports generating FFTW calls from the base MATLAB functions fft,fft2,fftn and their inverses: Generated MEX files use the FFTW library shipped with MATLAB. Generated standalone code uses the FFTW library that a user downloads and specifies.
Prior to R2017b, the base MATLAB Coder version of FFT does not support generating calls to FFTW. One option is to use the dsp.FFT system object if you have the DSP System Toolbox:
Otherwise, you could use an extrinsic as you mentioned or call external C code using coder.ceval. These external calls could be used to call FFTW directly or call a C wrapper which implements calling FFTW.

Más respuestas (0)


Más información sobre DSP Algorithm Acceleration en Help Center y File Exchange.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by