I've used spmd
to calculate two piece of code simultaneously. The computer which I'm using have a processor with 8 cores.which means the communication overhead is something like zero!
I compare the running time of this spmd
block and same code outside of spmd
with tic & toc
.
When I run the code, The parallel version of my code take more time than the sequential form.
Any idea why is that so?
Here is a sample code of what I'm talking about :
tic;
spmd
if labindex == 1
gamma = (alpha*beta);
end
if labindex == 2
for t = 1:T,
for i1=1:n
for j1=1:n
kesi(i1,j1,t) = (alpha(i1,t) + phi(j1,t));
end;
end;
end;
end
end
t_spmd = toc;
tic;
gamma2= (alpha * beta);
for t = 1:T,
for i1=1:n
for j1=1:n
kesi2(i1,j1,t) = (alpha(i1,t) + phi(j1,t));
end;
end;
end;
t_seq = toc;
disp('t spmd : ');disp(t_spmd);
disp('t seq : ');disp(t_seq);