Compiled application is very slow

46 views (last 30 days)
Peter Valent
Peter Valent on 6 Jun 2022
Commented: Peter on 8 Jun 2022
I have a code that I need to compile into a stndalone application as I need to run it on multiple computers. The problem is that the compiled code runs twice as long as the code run directly from Matlab. I have read several questions but most of them mention the reason is the time needed to open/run the mcr.
RUNTIME:
  1. matlab - 1 hour
  2. compiled - 2 hours
The code is rather complex and contains: mex, parfor, objects, reading/writing to matfiles.
What causes the code to run so slowly?
  4 Comments
dpb
dpb on 6 Jun 2022
I wonder if compiled code use static instead of dynamic memory allocation and so is max'ed out whereas the native version only uses/allocates memory as needed?
Need somebody w/ more knowledge of internals and has used the code generation toolset much more than I.

Sign in to comment.

Accepted Answer

Peter
Peter on 8 Jun 2022
I WAS WRONG - THERE IS NO SLOWDOWN!!!
After I repeatedly run the code it seems that the run times of the compiled code are comparable to the code run directly from MATLAB. Probably the problem was related only to the first run of the code. Anyway, thank you for the discussion as I was not aware of some of the characteristics of the Coder and Compiler.

More Answers (1)

Walter Roberson
Walter Roberson on 6 Jun 2022
The code generated by MATLAB Coder does not use the high-performance MKL or LAPACK or BLAS libraries, because Coder is often used for situations where those libraries are not available. You should expect performance only about what you would get running single-core.
  7 Comments
Peter
Peter on 8 Jun 2022
You were right. There is no slowdown. It was probably only related to the first run of the code.

Sign in to comment.

Categories

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

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!