I am having problem implementing parfor
Información
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Mostrar comentarios más antiguos
I am using parfor to speed up my computation. But instead of getting speed up, it takes significantly longer. I don't know what I am doing wrong and I am new to matlab. Here's the code I have. I implemented the same with GPU and it takes like 20 secs but with two cores of my laptop it take 400s something seconds. And the surprising thing is that, I get answer in 60 secs with single core without parfor.
tic
for j2=1:screenpoints
for i2=1:screenpoints/vertscreen
temp=zeros(specimenpoints,specimenpoints);
for j=1:specimenpoints
parfor i=1:specimenpoints
kernelB=vortexpattern(i,j)*kernel1(i,j)* ...
exp(I*2.0*pi*(((i-specimenpoints/2.0-0.5)* ...
specimensize/specimenpoints- ...
(i2-screenpoints/2.0/vertscreen-0.5)* ...
screensize/screenpoints )^2.0+ ...
((j-specimenpoints/2.0-0.5)*...
specimensize/specimenpoints-...
(j2-screenpoints/2.0-0.5)*...
screensize/screenpoints)^2.0+...
(D-d)^2.0)^(1.0/2.0)/lambda);
temp(i,j)=kernelB;
end
end
kernel2(i2,j2)=sum(sum(temp));
end
end
timefork2=toc
Respuestas (1)
Edric Ellis
el 18 de Jun. de 2013
0 votos
Generally, it's best to have the PARFOR loop at the highest level possible because there's an overhead to running each PARFOR loop. In your case, it seems as though you could make the outermost loop be a PARFOR, and revert the innermost loop to a FOR.
1 comentario
Matador
el 19 de Jun. de 2013
La pregunta está cerrada.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!