matlab coder mex faster than exe?

9 次查看(过去 30 天)
I am getting the Mex code to run 10x faster than Exe, both generated by Matlab coder. The function that consumes the most compute is lpc (which combines fft & levinson algos). Does this make sense? Is there some configuration difference between Mex and Exe that would account for this? How can I configure Mex generation to get back the 10x? Thanks!

回答(1 个)

Ryan Livingston
Ryan Livingston 2018-4-27
编辑:Ryan Livingston 2018-4-27
It definitely makes sense that MEX could be faster. When generating MEX code, Coder has access to the high-performance libraries used by MATLAB. In standalone code that isn't always the case. In this case, it may be that fft is slower. You'd need to measure to be sure. Extracting the FFTs being performed, generating MEX and EXE, and comparing the performance will show you this. You could also use a C profiler to profile the generated EXE to determine the bottleneck.
If FFT computation is dominating the execution time in EXE, Coder MEX and MATLAB use an optimized FFT library. You can link in the optimized FFTW with the standalone code for EXE,LIB,DLL starting in R2017b:
Provided that the FFTs are the bottleneck, using that should reclaim a fair bit of the performance.
The Coder doc also provides a number of optimization techniques:
Are you enabling C compiler optimizations when compiling your EXE? When compiling the EXE using Coder, set the config setting BuildConfiguration to 'Faster Runs'

类别

Help CenterFile Exchange 中查找有关 MATLAB Coder 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by