Compiled application is very slow

조회 수: 68 (최근 30일)
Peter Valent
Peter Valent 2022년 6월 6일
댓글: KAE 2024년 3월 7일
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
Peter
Peter 2022년 6월 6일
I have used Matlab Coder to generate mex files for the critical functions. Matlab Compiler was then used to generate a standalone application that is installed on an arbitrary PC.
The code uses a lot of memory and so occasional memory-disk issues are possible.
The problem is that on the same PC the compiled code is much slower than the code run directly in Matlab. I dont see any externalities that could be responsible for this.
dpb
dpb 2022년 6월 6일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Peter
Peter 2022년 6월 8일
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.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2022년 6월 6일
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.
  댓글 수: 8
Peter
Peter 2022년 6월 8일
You were right. There is no slowdown. It was probably only related to the first run of the code.
KAE
KAE 2024년 3월 7일
What do you mean, 'first run of the code'? I have a simple standalone application. It takes less than 1 s to run in Matlab, and 11 s to run from Windows. I found this thread looking for info. If I run it muliple times from Windows, it still takes 11 s.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB Compiler에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by