Parallel Program using SPMD command in Parallel Computing Toolbox in MATLAB!!!

1 view (last 30 days)
Hello,
I just want to know that if we are reading an image normally by using imread command than it takes lesser time than executing same imread command in individual lab(which is written below)..plz help me..I am very much confused about parallel computing toolbox in MATLAB.
Sequential--
tic
I = imread('cameraman.tif');
I = I + 5;
J = imread('cameraman.tif');
J = J * 5;
K = imread('cameraman.tif');
K = K + 15;
L = imread('cameraman.tif');
L = L + 115;
toc
Parallel Program--
matlabpool open local 4
spmd(4)
if labindex == 1
tic
I = imread('cameraman.tif');
toc
I = I + 5;
elseif labindex == 2
tic
I = imread('cameraman.tif');
I = I + 5;
toc
elseif labindex == 3
tic
I = imread('cameraman.tif');
I = I + 15;
toc
else
tic
I = imread('cameraman.tif');
I = I + 115;
toc
end
end
For the First Sequential program overall Elapsed time is 0.070329 seconds.
And for the parallel one
Lab 1:
Elapsed time is 0.228841 seconds.
Lab 2:
Elapsed time is 0.228596 seconds.
Lab 3:
Elapsed time is 0.227497 seconds.
Lab 4:
Elapsed time is 0.306381 seconds.

Answers (1)

Walter Roberson
Walter Roberson on 20 Feb 2013
Keep in mind that you are asking the file system to work harder, having to read the file four separate times. I do not know how such things are handled in MS Windows; in Linux and OS-X the first read would probably end up caching the data in memory (for reasonable sized files), but still copies of the data would need to be transferred to each process.

Categories

Find more on Parallel Computing 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!