Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: performance of parfor
Replies: 4   Last Post: Apr 8, 2013 3:28 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Edric Ellis

Posts: 691
Registered: 12/7/04
Re: performance of parfor
Posted: Apr 5, 2013 8:50 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"kinor " <kinor.removethiswithdot@gmx.de> writes:

> I used parfor a while ago and it worked quite well (2.5 time faster
> with 3 labs). Now I tried to use it on win 7 with 2012a and an
> example from
> http://blogs.mathworks.com/loren/2007/10/03/parfor-the-course/ with
> the following results:
>
> matlabpool local 3
>
> n = 600;
> tic
> ranks = zeros(1,n);
> parfor (ind = 1:n)
> ranks(ind) = rank(magic(ind)); % last index could be ind,not n-ind+1
> end
> toc
>
> tic
> ranks = zeros(1,n);
> for (ind = 1:n)
> ranks(ind) = rank(magic(ind)); % last index could be ind,not n-ind+1
> end
> toc
>
> Starting matlabpool using the 'local' profile ... connected to 3 labs.
> Elapsed time is 10.773548 seconds.
> Elapsed time is 13.993966 seconds.
>
> Which is surprisingly slow for 3 labs. I would be really grateful for
> any hint to get the 3 labs working.


The MATLAB function 'RANK' is instrinsically multithreaded. On a single
machine, it's always going to be more efficient to use intrinsic
multithreading than to use explicit parallelism using a MATLABPOOL and
PARFOR because of the overheads of distributing the body of the loop to
the workers. MATLABPOOL workers run in "single computational thread"
mode, so to make a fair comparison, you should start MATLAB using
"-singleCompThread".

Cheers,

Edric.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.