Can Compiler SDK C++ library support multithread?
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MathWorks Support Team
il 11 Apr 2025
Risposto: MathWorks Support Team
il 11 Apr 2025
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?
Risposta accettata
MathWorks Support Team
il 11 Apr 2025
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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Get Started with MATLAB Compiler SDK in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!