MatLab maxes out exactly one of my cores.

3 views (last 30 days)
Lennart
Lennart on 26 Sep 2013
Commented: Lennart on 27 Sep 2013
I am doing a lot of lsqcurvefits (order of 10^9 datapoints about 20 per fit so thats 10^8 fits) and all data is loaded in memory. Matlab maxes out exactly one of my cores on every system I try this on (dual core at work, quadcore at home). Even if I use parfor in my loops. Everywhere on this forum people tell eachother that there must be some other bottleneck, but I just dont buy it. Especially after trying it out at home with really fast RAM. Why does MatLab exactly max out one core if CPU is not the bottleneck?
My code goes something like this:
%size(data)==[15000 20];
times = [1:20];
startvals = [1,1];
pre_al = zeros(15000, 1);
amps = pre_al;
exps = pre_al;
expdecayfun = @([amplitude, exponent], time) amplitude*exp(-time/exponent)
parfor i=1:15000
x = lsqcurvefit(expdecayfun, startvals, times, data(i,:));
amps(i) = x(1);
exps(i) = x(2);
end
  4 Comments
Lennart
Lennart on 26 Sep 2013
I was very hopefull that that would be it, however at work this did not help. Ill try it at home too, where I can make sure there are no other bottlenecks. Still the one core thats used is maxed at the office, so I do think thats the bottleneck.
Lennart
Lennart on 27 Sep 2013
Edited: Lennart on 27 Sep 2013
Yes this did it at home!One core took 440 seconds, four cores took 150 seconds. I think my memory is the bottleneck at work then. Thanks! Still getting used to the strange habits of Matlab... sorry if this question was too basic.

Sign in to comment.

Accepted Answer

Jan
Jan on 26 Sep 2013
Without seeing any line of the code, guessing the reason cannot be reliable. Perhaps you start Matlab with a flag to run on one core only? Or your PARFOR loops run one instance only? Could you provide more details?
  2 Comments
Lennart
Lennart on 26 Sep 2013
I created an example and added it to my question
Lennart
Lennart on 27 Sep 2013
This question is answered in the comments so I accepted this one to not leave it open.

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!