Smpd - Slower than Serial

4 views (last 30 days)
Yunus Emre
Yunus Emre on 7 May 2013
Hi everybody,
I am new to parallel computing. Therefore the solution to the problem might be easy.
I have a grid and I need to evaluate a function at each grid point. Therefore I wanted to assign some part of the grid to different workers in order to have speedup. However when I run the code in parallel I cannot see a difference in the computation time compared to serial computation. I also tested the case while changing the number of workers. In order to avoid overhead computations I run the code long enough. So what is my mistake?
My code is like this:
matlabpool ( 'open' , 4 )
Xpos = 10:0.1:25;
Ypos = 1:0.1:10;
n_x = length(Xpos);
n_y = length(Ypos);
spmd
i_x=codistributed(1:n_x);
i_y=codistributed(1:n_y);
end
tic;
for i_x = 1:n_x
for i_y = 1:n_y
output = myfunction(Xpos(i_x),Ypos(i_y));
end
end
Time=toc;
matlabpool('close')
  2 Comments
Jill Reese
Jill Reese on 8 May 2013
What operations are you performing on the Xpos and Ypos variables within myfunction?
Jason Ross
Jason Ross on 8 May 2013
Edited: Jason Ross on 8 May 2013
Which scheduler are you using? (I assume "local")
How many compute cores (not hyperthreaded cores) does your machine have? (I assume 4)
How much RAM does your machine have? Do you use it all up and go to swap?
What is "long enough"? Seconds? Minutes? Hours? Days?

Sign in to comment.

Answers (0)

Categories

Find more on Parallel for-Loops (parfor) in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!