MATLAB Answers

Sanjay Saxena

How to make fast computation through parfor in Parallel Computing Toolbox!!!

Asked by Sanjay Saxena
on 18 Feb 2013


I am very new about parallel computing toolbox. I just wanted to know that how can i increase speed of our program by using Parfor in MATLAB R2009a. My CPU is Intel Core 2 Duo T 6400 2.00 Ghz. I just write following two programs one is sequential and another is parallel but found that sequential program is taking lesser time than the parallel one.

Sequential Program--

a = fun1();
b = fun2();

Parallel Program--

funList = {fun1(),fun2()};
matlabpool open local 2
parfor i=1:length(funList)
for i = 1:2
matlabpool close

fun1() and fun2() are two simple function to find sum of 1st 100000 numbers and sum of square of that numbers..

Plzz help me!!!



No products are associated with this question.

1 Answer

Answer by Walter Roberson
on 18 Feb 2013
 Accepted answer

Your line

funList = {fun1(),fun2()};

calls fun1 and fun2 and stores the result in the cell array funList, and you do that before you start timing. After that in your code, you are extracting the data, not calling the routines. After that, you display the contents of the cell array and continue timing while you do that; you do not have any display at all in your sequential version, and display of values is time consuming.

  1 Comment

Hello Walter thanks for giving the answer of this question..I have posted two more questions...Please give me the suggestion for these questions...I am very much please help me...

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!