Distributing Arrays with parfor

Hi, I would like to know if it's possible to use Distributing Arrays with parfor loops.
Thanks in advance!
Here the code:
for n=1:1:fbdAct
indice=find(bdAnt(:,columnaID)==bdAct(n,columnaID));
if(~isempty(indice))
if((bdAnt(indice,columnaInc)>0) && (bdAct(n,columnaInc)==0))
if(~isempty(acelerados))
indiceAcel=find(acelerados(:,colAcID)==bdAct(n,columnaID));
if(isempty(indiceAcel))
newAcelerado=[bdAct(n,columnaID) tEspera];
acelerados=vertcat(acelerados,newAcelerado);
end
else
acelerados=[bdAct(n,columnaID) tEspera];
end
bDAcelerados=acelerados;
end
end
end

1 comentario

Jan
Jan el 2 de Ag. de 2011
Please explain any details. Currently the best answer is: "It depends".

Iniciar sesión para comentar.

Respuestas (1)

Edric Ellis
Edric Ellis el 2 de Ag. de 2011

1 voto

Distributed arrays are designed to be used with SPMD blocks, not PARFOR loops. In general, it is a mistake to use a distributed array within the body of a PARFOR loop. What are you trying to do?

3 comentarios

Javier
Javier el 2 de Ag. de 2011
Hi! First of all thanks for replying.
My aim is to parallelize a for loop. I have been traying it with parfor statement, but the issue is that in the for loop I have a matrix(this matrix is defined out the parfor loop) in which it might be added a row or not depend on a coditions, and with parfor loop I'm not able to do it due to the fact I always get a nondeterministic or temporary error , so having found out the distributed array I was wondering if I could use it.
Regards,Javier.
Konrad Malkowski
Konrad Malkowski el 3 de Ag. de 2011
Javier,
Could you post a copy of your sequential code (for loop)? This would help in determining if there is a way to parallelize that loop using parfor.
Javier
Javier el 3 de Ag. de 2011
It is,bdAnt and bdAct are both matrix of nx8, and acelerados is nx2
for n=1:1:fbdAct
indice=find(bdAnt(:,columnaID)==bdAct(n,columnaID));
if(~isempty(indice))
if((bdAnt(indice,columnaInc)>0) && (bdAct(n,columnaInc)==0))
if(~isempty(acelerados))
indiceAcel=find(acelerados(:,colAcID)==bdAct(n,columnaID));
if(isempty(indiceAcel))
newAcelerado=[bdAct(n,columnaID) tEspera];
acelerados=vertcat(acelerados,newAcelerado);
end
else
acelerados=[bdAct(n,columnaID) tEspera];
end
bDAcelerados=acelerados;
end
end
end
thanks

Iniciar sesión para comentar.

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Preguntada:

el 2 de Ag. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by