parfor and nested loop

3 visualizaciones (últimos 30 días)
huda nawaf
huda nawaf el 23 de En. de 2014
Comentada: huda nawaf el 24 de En. de 2014
can I use parfor with nested loop?
for ex.
parfor i=1:5
for j=1:2
should I use par with each for or with one.
please, I need somebody can solve my problem.
Thanks in advance

Respuestas (2)

Mischa Kim
Mischa Kim el 23 de En. de 2014
Hello huda, there are no nested parfor loops. Parallelization with parfor only works on the outermost loop.
  1 comentario
huda nawaf
huda nawaf el 24 de En. de 2014
ok, do u mean it is not problem if i use parfor for outermost loop and the inside loop stay as it.
I just wonder because when I used parfor for only outermost loop, I did not find any improvement in terms of running time.
Please, I badly need that.

Iniciar sesión para comentar.

Matt J
Matt J el 23 de En. de 2014
Editada: Matt J el 23 de En. de 2014
To combine the loops into a single parfor loop,
parfor k=1:10
  3 comentarios
huda nawaf
huda nawaf el 24 de En. de 2014
yes, but I read if I have large array it is best to use spmd.
this function will distribute the array among workers.
but I have problem. Also I used pmode .
I did not find the efficiency of these functions. I hope to find simple example show me the difference between parallel and serial processing.

Iniciar sesión para comentar.


Más información sobre Parallel for-Loops (parfor) 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