How does parallel computing toolbox works in nested loop?

5 visualizaciones (últimos 30 días)
mono
mono el 6 de Mayo de 2023
Comentada: Raymond Norris el 10 de Mayo de 2023
Say pseudo code as following:
parfor ii = 1:2
firtgp(X_, y, 'UseParallel', true);
end
Now assume 8 workers available, how are these 8 workers assigned to the task above?

Respuesta aceptada

Raymond Norris
Raymond Norris el 6 de Mayo de 2023
MATLAB will run the inner parfor loop as a for-loop. Therefore, in your example, where you have a parallel pool of 8 workers, 2 will be used for the ii loop and the other 6 will stay idle. The parfor loop embedded within firtgp will run as a for-loop.
  2 comentarios
mono
mono el 6 de Mayo de 2023
Thanks. Is there a simple way I can make the fitrgp go parallel using other 6 workers?
Raymond Norris
Raymond Norris el 10 de Mayo de 2023
No. You have to either choose the parallel for-loop on the outside (ii = 1:2) or the inside (firtgp).

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Parallel for-Loops (parfor) en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by