Clear Filters
Clear Filters

How much codegen speed up the performance ? Please give numbers!!!

4 views (last 30 days)
Hello, Could you please validate my understanding. What does mcc ? mcc packages the matlab code in only file. So the execution is still based on the interpretation of the matlab language (no compilation). So there is no runtime speed improvement. Right ?
Assuming the vectorization is done, the algorithm is optimized...
To improve speed performance i must used codegen as described extensively on this site.
But quantitatively speaking, i would like to estimate the speeed will be increased. Are there some benchmark somewhere ?
Will the overall time execution will be divided by 2 or 10 or 50 ? I can see a lot of numbers on internet.
Could someone give me some indications ?
Very best regards Al

Answers (1)

Adam
Adam on 7 Feb 2017
Edited: Adam on 7 Feb 2017
Matlab compiler creating an executable may have some effects on speed (either faster or slower), but as far as my experience goes timings are comparable between a compiled app and code run in Matlab so you are correct on that, to the best of my knowledge.
To estimate speed-up of codegen in a generic manner is impossible though. It depends on many factors, most obviously the code that you are generating the C++ code for. Some code in Matlab is more optimised than others, especially builtin functions. Some of these have gone through many iterations of optimisation.
If you write your own Matlab code with a bunch of nested for loops this will likely be very slow in Matlab, but C++ works fine with for loops so using codegen to turn it into C++ code will likely give a huge speedup there. But it is all qualitative. For all I know some code may even be slower if you use codegen than run the Matlab version if the latter is highly optimised.
You would have to test it for yourself on the code you actually want to use it for.
  1 Comment
Walter Roberson
Walter Roberson on 7 Feb 2017
For example, generating code for linear algebra is almost certain to be slower than using MATLAB, as MATLAB calls upon the highly optimized MKL or BLAS or LINPAK that uses multiple threads and which pay careful attention to buffering and cache effects.

Sign in to comment.

Categories

Find more on C Shared Library Integration in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!