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

Thread Subject:
parfor- when does it outweigh conventional for?

Subject: parfor- when does it outweigh conventional for?

From: Jveer

Date: 1 Feb, 2009 01:35:02

Message: 1 of 3

i've noticed that initialising and closing 'parfor' using 'matlabpool' takes so long that it's not worth it in many cases in many cases. for e.g it takes 24s to 'matlabpool local 2' and 'matlabpool close'.

so its only beneficial to replace 'for' loops that takes more 100s. using parfor brought the processing time down to 86s

i cant seem to find set some general to determine when program will switch to 'parfor' instead of the conventional 'for'

anyone knows?

Subject: parfor- when does it outweigh conventional for?

From: Narfi

Date: 2 Feb, 2009 20:52:01

Message: 2 of 3

Is there a reason for why you would open and close matlabpool once for each parfor statement rather than, say, once for each MATLAB session? These are two separate commands so that you can execute multiple parfor statements using a single matlabpool. For that reason, I would not include the matlabpool startup time in any timing measurements.

Unfortunately, it is extremely hard to determine when parfor will perform better than for because the answer will depend on your particular problem, the amount of communication vs. computation required to solve the particular problem as well as the computer hardware that you have.

Best,

Narfi
"Jveer " <jveer@jveer.com> wrote in message <gm2u86$7qb$1@fred.mathworks.com>...
> i've noticed that initialising and closing 'parfor' using 'matlabpool' takes so long that it's not worth it in many cases in many cases. for e.g it takes 24s to 'matlabpool local 2' and 'matlabpool close'.
>
> so its only beneficial to replace 'for' loops that takes more 100s. using parfor brought the processing time down to 86s
>
> i cant seem to find set some general to determine when program will switch to 'parfor' instead of the conventional 'for'
>
> anyone knows?

Subject: parfor- when does it outweigh conventional for?

From: Jveer

Date: 2 Feb, 2009 21:14:02

Message: 3 of 3

thanks for the reply. true matlabpool open and close are used only once.

i guess the main determining factor remains communication between the labs.

i've got the 2.4 ghz mac intel dual core 2. when i use 'local 2', the processing speeds up, 'local 3' remains the same and 'local 4' sometimes decreases speed

whats the relationship between 'clustersize' and cores on the processor?

apparently i can run 4 labs but running 2 labs seems to be more efficient all the time? why? coz of 2 cores?

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us