From: Justin Bailey on
"Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <i32i9p$n51$1(a)fred.mathworks.com>...
> ...
> I guess that means MATLAB does a pretty good job of parallelizing things, even without the Parallel Computing Toolbox...

=============

Not exactly... The following lines of code must be included, else the parfor loops don't distribute and it maxes out at around 50%...

matlabpool open 2
options = optimset('UseParallel','always',...)

And... Without the Parallel Computing Toolbox, Matlab won't recognize the matlabpool command.
From: Matt J on
"Justin Bailey" <jbail3y+mathworks(a)gmail.com> wrote in message <i34bjh$ke7$1(a)fred.mathworks.com>...
> > I guess that means MATLAB does a pretty good job of parallelizing things, even without the Parallel Computing Toolbox...
>
> =============
>
> Not exactly... The following lines of code must be included, else the parfor loops don't distribute and it maxes out at around 50%...
>
> matlabpool open 2
> options = optimset('UseParallel','always',...)
=======

Well, I don't quite understand why you're seeing only a 20% reduction in computation time, if that's the case. It seems a lot more modest then what was seen with the dual core experiment here:

http://blogs.mathworks.com/loren/2007/10/03/parfor-the-course/
From: Justin Bailey on
"Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <i351kh$s9e$1(a)fred.mathworks.com>...
> ...
> Well, I don't quite understand why you're seeing only a 20% reduction in computation time, if that's the case. It seems a lot more modest then what was seen with the dual core experiment here:
>
> http://blogs.mathworks.com/loren/2007/10/03/parfor-the-course/

=============

My sample set was too small... WRT computation time, the processes leading up to the fit were proportionally significant to the fit itself. Note... Only my fitting procedure is taking advantage of the parfor loops, etc. After running a full set, where the fitting procedure computation time is orders of magnitude greater, I'm seeing something closer to a 60% reduction in total computation time! So cool...

Sorry, that's a confusing way to explain... In other words, using the Parallel Computing Toolbox with parfor loops everywhere, the total computation time would reduce by at least 60%... probably a little more, actually...
From: Steven_Lord on


"Justin Bailey" <jbail3y+mathworks(a)gmail.com> wrote in message
news:i31obq$80o$1(a)fred.mathworks.com...
> I'm running Matlab R2009b on an HP Pavilion (a6230n) desktop, W7 32-bit,
> AMD Athlon Dual Core Processor 5600+ (2.80 GHZ), and 3.00 GB of RAM.
> My code executes a least squares curve fitting routing, using the
> lsqcurvefit function, on an equation w/ 18 free parameters. It fits
> upwards of 16000 data points and takes around 24 hours to converge. To
> investigate performance, I started paying attention to the Task Manager
> and was surprised to see that only one core was being utilized, maxing the
> total CPU usage at 50%. So... I installed the Parallel Computing Toolbox
> 4.2 and added the following lines of code...
>
> matlabpool open 2
> options = optimset('UseParallel','always',...)

The reference page for LSQCURVEFIT doesn't indicate that it makes use of the
UseParallel option, so it doesn't.

http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/lsqcurvefit.html

> Now, while running my code, it does jump above 50% initially, up to 100%
> even, but once the command reaches the lsqcurvefit function (takes a
> couple of minutes) it settles back down. Curiously, the 50% is now
> distributed between both cores...
>
> Oh, and for reference, the RAM stays around 1 GB in both cases. Finally,
> and most importantly, my code takes the same amount of time to execute...
>
> My question... Does Matlab support parallel computing on multicore
> processors when using lsqcurvefit? If it does, any ideas why I'm maxing
> at 50%? Should I upgrade to R2010a and version 4.3?

It appears only FMINCON, FGOALATTAIN, and FMINIMAX support this option:

http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/briutqn-1.html

http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/f19175.html

Try running the code in the Profiler using a smaller data set, that only
takes an hour or two to converge, and see if the evaluation of your
"objective" function is what's taking the most time. If computing F(x,
xdata) takes a long time, then perhaps you could parallelize that function's
computation.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

From: Steven_Lord on


"Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message
news:i31pm9$nu$1(a)fred.mathworks.com...
> "Justin Bailey" <jbail3y+mathworks(a)gmail.com> wrote in message
> <i31obq$80o$1(a)fred.mathworks.com>...
>
>> So... I installed the Parallel Computing Toolbox 4.2 and added the
>> following lines of code...
>>
>> matlabpool open 2
>> options = optimset('UseParallel','always',...)
> [snip]
>> My question... Does Matlab support parallel computing on multicore
>> processors when using lsqcurvefit? If it does, any ideas why I'm maxing
>> at 50%? Should I upgrade to R2010a and version 4.3?
> =============
>
> I'm fairly new to the Parallel Computing Toolbox, but I don't see why
> running matlabpool alone is expected to give you any speed-up. You're
> meant to be running additional toolbox commands, e.g., parfor, telling how
> you want chunks of code to be split across different workers.
> I think it's also doubtful that native MATLAB routines like lsqcurvefit
> itself would be written to invoke Parallel Computing Toolbox features.

Why _wouldn't_ they?

http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/briutqn-1.html

> However, the speed of lsqcurvefit depends greatly on how long it takes to
> evaluate your fitting function F(x,xdata), which is clearly pretty
> intensive if you're running 24 hour jobs. You should probably be using
> parfor etc... to accelerate its evaluation and also the evaluation of its
> Jacobian, if applicable.

Agreed.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com