Can Compiler SDK C++ library support multithread?

조회 수: 8 (최근 30일)
MathWorks Support Team
MathWorks Support Team 2025년 4월 11일
답변: MathWorks Support Team 2025년 4월 11일

I use MATLAB Compiler SDK to compile a MATLAB function, and this function will be called in an app with concurrent users. Can this be supported?

채택된 답변

MathWorks Support Team
MathWorks Support Team 2025년 4월 11일
When using the C++ MATLAB Data API, you can either start the run-time in in-process mode or out-of-process mode:
When running in in-process mode, there is only a single interpreter thread and thus all calls to your library will be serialized. In this case, there will be no concurrency benefit.
When running in out-of-process-mode, there will be a separate mvm server for each library object created. Thus, if you call 'initMATLABLibrary' from each thread, each thread would have its own interpreter, and hence the threads will able to run MATLAB code concurrently. However, since the MATLAB Runtime is out-of-process, there is a trade-off in that your program must communicate data in-between processes. Overall, whether there is a performance boost in this case is dependent on how much data your application must transfer between the run-time process relative to how much work is done in the library code.
Also, the out-of-process feature has not been heavily used and therefore is not as stable as in-process.
The out-of-process mode is not supported with mwArray API. Namely it doesn't support multithread.

추가 답변 (0개)

카테고리

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

태그

아직 태그를 입력하지 않았습니다.

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by