Computing on multiple notes with multiple cores
Mostrar comentarios más antiguos
Hello,
I have a code with the following structure:
for ... % Split between multiple nodes
parfor ... % Split betwenn mutliple cores
...
end
end
Is it possible to tell MATLAB, that it has to split the for-Loop between the nodes? Or does that MATLAB automatically if I use parfor 2 times? I.e.
parfor ... % Split between multiple nodes
parfor ... % Split betwenn mutliple cores
...
end
end
Respuesta aceptada
Más respuestas (1)
Harald
el 6 de Nov. de 2023
1 voto
Hi Paul,
you can only have one level of parallelization, thus no nested parfor statements within a single script / function.
If the parallel pool that runs the parfor has cores on multiple nodes, they will automatically be used. While there might be reasons to parallelize the inner loop, I typically first try to parallelize the outer loop.
Best wishes,
Harald
5 comentarios
Paul Muster
el 9 de Nov. de 2023
Harald
el 9 de Nov. de 2023
Hi Paul,
that's correct. With a reasonably long computation time, the additional overhead of parallelizing the inner loop should become negligible anyway.
I hope that the answer has overall addressed your question. If not, please let me know.
Best wishes,
Harald
Paul Muster
el 9 de Nov. de 2023
Editada: Paul Muster
el 9 de Nov. de 2023
Harald
el 9 de Nov. de 2023
Hi Paul,
in many cases, there may not be a problem of parallelizing the inner loop as you initially suggested.
Matt J has offered a nice alternative to thinking about which loop to parallelize.
My understanding is that your main question was if your code was going to use multiple cores on multiple nodes, and the answer to that was: If the parallel pool that runs the parfor has cores on multiple nodes, they will automatically be used.
Please let me know if I can be of further help.
Best wishes,
Harald
Paul Muster
el 9 de Nov. de 2023
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!