Can Compiler SDK C++ library support multithread?
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 11 de Abr. de 2025
Respondida: MathWorks Support Team
el 11 de Abr. de 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?
Respuesta aceptada
MathWorks Support Team
el 11 de Abr. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Get Started with MATLAB Compiler SDK en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!