Borrar filtros
Borrar filtros

how to Parallize independent jobs

3 visualizaciones (últimos 30 días)
Daniel Parisi
Daniel Parisi el 30 de Abr. de 2021
Comentada: Daniel Parisi el 4 de Mayo de 2021
I would like to send jobs i...j to workers i...j. In a way each worker acts as one independent matlab workspace. In other words, I would like to explictly indicate ot each worker to do one particular task and to contein the the variables in itself without sharing the variables values with other workers...
parfor is not usuful for that.
Can you give me and idea how to do it ? Thanks
  1 comentario
Jeff Miller
Jeff Miller el 30 de Abr. de 2021
I'm not sure why parfor is unsuitable. If you call a function within the parfor loop, that function will have its own separate workspace unshared with other workers--why isn't that sufficient?
I guess in the extreme case you could open multiple instances of MATLAB on your computer and run each task in a different instance...

Iniciar sesión para comentar.

Respuestas (1)

Edric Ellis
Edric Ellis el 4 de Mayo de 2021
It's not clear why you think parfor is not suitable for this case without showing us what you tried and why it doesn't work for you. Workers in a parallel pool are separate MATLAB processes, and as such there is no sharing of data between them - so when you run a parfor loop, each worker gets copies of the necessary data.
If you really want to run fully independent MATLAB processes for each of your tasks, you can use batch to do that. Something like this:
numOutputs = 2; % number of output arguments from the function "myFunction"
inputArgs = {17, 3}; % Required input arguments for "myFunction"
j = batch(@myFunction, numOutputs, inputArgs);
  1 comentario
Daniel Parisi
Daniel Parisi el 4 de Mayo de 2021
Thank you very much. This solved my problem.

Iniciar sesión para comentar.


Más información sobre MATLAB Parallel Server 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!

Translated by