Can Compiler SDK C++ library support multithread?
9 次查看(过去 30 天)
显示 更早的评论
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
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with MATLAB Compiler SDK 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!