- program shared memory (operating system specific; Mac and Linux use POSIX standard shared memory, Windows does its own shared memory)
- matFile() to access a shared file (I am not really confident this will work reliably)
- memmapfile() https://www.mathworks.com/help/matlab/ref/memmapfile.html
- use dataqueues to send between client and workers, with the client acting as the switchyard to distribute any changes to all workers
Sharing C mex variables Between Client and parallel Workers
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
How can I use a structure variable defined in C mex file and assigned in Client before entering spmd workers, inside this parallel workers with the same values?
When a global structure variable values changes insided C mex function in matlab client then the same C mex function is executed from the spmd parallel workers; the values of the global structure variable is returned to zeros inside the parallel worker (I'm using mexMakeMemoryPersistent function).
How can I share the structure variable between Client and parallel Workers?
0 comentarios
Respuestas (1)
Walter Roberson
el 19 de Abr. de 2021
mexMakeMemoryPersistent is the equivalent of persistent and is not the equivalent of global .
If you need changes in one worker (or on the client) to affect all of the workers, then you need to do one of:
2 comentarios
Walter Roberson
el 20 de Abr. de 2021
I have a complex C structure variable which contains many variables and pointers
Classical workers are in different processes; pointers shared would be useless, unless the pointers were to shared memory that was mapped into a fixed address location inside the process.
There is a File Exchange contribution for Shared Memory for Mac and Linux (not Windows). Reports are that it worked until MATLAB changed the headers for variables when it changed representation of complex a couple of releases ago, so it might potentially be repairable for current versions.
Ver también
Categorías
Más información sobre Startup and Shutdown 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!