Thread Subject: Parallel Computing seems to prolong the processing

Subject: Parallel Computing seems to prolong the processing

From: Florian Bahlke

Date: 4 Aug, 2009 09:23:03

Message: 1 of 4

Hi @ all!
I have a problem implementing Parallel Computing into a relatively complex program I use at university for a scientific project in information technology.
The Problem is that, no matter if I run the program on a Dual Core or Quad Core computer, the version with Parallel Computing (with a parfor-loop or spmd) always needs a longer time to process than the one without it.

The section where I use Parallel Computing is the following:

        memLength = [3 5 3 5];
        quant_bits = [4 4 6 6];
        histo_quant_bits = 6;
        seqLength = 1;
        A = [1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16];
...
        matlabpool 2;
        spmd(2)
        tic
        ii = labindex;
        A(1:3,ii) = mlse2(i_channels_shift_out, bitstream_fec, memLength(ii), quant_bits(ii), histo_quant_bits, seqLength);
        ii= labindex+2;
        A(1:3,ii) = mlse2(i_channels_shift_out, bitstream_fec, memLength(ii), quant_bits(ii), histo_quant_bits, seqLength);
        toc
        end
        Results_lab1 = A{1};
        Results_lab2 = A{2};
        matlabpool close;



Processing time is about 20 sec, with a normal for-loop about 9 sec (Dual Core).
I also can see in my Status Monitor that with PP both cores are used at 100% the entire 20 seconds and without only one core is used 100%.
So the assigning of the jobs to the processor cores seems to work.

Thanks for help!

Subject: Parallel Computing seems to prolong the processing

From: Juliette Salexa

Date: 8 Aug, 2009 20:27:01

Message: 2 of 4

For small jobs (like your 20 second one), using parallel computing will take longer because matlab has to submit the jobs to the scheduler and the scheduler has to do extra things in the background (Im not too sure about the details). When the jobs are completed on the individual labs, the labs need to send the information back to one central place where all the information is combined.

So there is some overhead in using matlabpool

in fact, just the commands:
matlabpool open 2
matlabpool close

together will probably take about 40 seconds to execute, so if your job only takes 20 seconds WITHOUT parallelizing, then it's obvious why the parallelizing takes longer.

But, if your program is large and very parallelizable, and takes over a minute, you'll notice a difference between using the pool and not using the pool.

Subject: Parallel Computing seems to prolong the processing

From: Florian Bahlke

Date: 9 Aug, 2009 22:01:02

Message: 3 of 4

"Juliette Salexa" <juliette.physicist@gmail.com> wrote in message <h5kn2l$qbu$1@fred.mathworks.com>...
> For small jobs (like your 20 second one), using parallel computing will take longer because matlab has to submit the jobs to the scheduler and the scheduler has to do extra things in the background (Im not too sure about the details). When the jobs are completed on the individual labs, the labs need to send the information back to one central place where all the information is combined.
>
> So there is some overhead in using matlabpool
>
> in fact, just the commands:
> matlabpool open 2
> matlabpool close
>
> together will probably take about 40 seconds to execute, so if your job only takes 20 seconds WITHOUT parallelizing, then it's obvious why the parallelizing takes longer.
>
> But, if your program is large and very parallelizable, and takes over a minute, you'll notice a difference between using the pool and not using the pool.

Hi!
Thank you for your answer. As you can see in the piece of code I posted, the tic and toc counter marks are placed so that the time of opening and closing the matlabpool should be excluded from the metered processing time.

Subject: Parallel Computing seems to prolong the processing

From: Juliette Salexa

Date: 9 Aug, 2009 23:05:20

Message: 4 of 4

I'm no expert. (In fact I started a few threads about parallel computing in matlab on this forum that not many people seem to be answering.. either not many people use the PCT, or people know but don't bother to share their knowledge!).

I've noticed similar things. For example, PARFOR runs slower than FOR even when I don't open any matlabpools (I'd assume they'd work at the same rate). This is still a mystery to me.

But based on the (very limited) knowledge I have about parallel computing, opening and closing the pools is not the only overhead associated with parallel computing. My understanding is that when the second 'lab' writes to your matrix 'A' , there's some communication between your two processors that takes some time. If it's only an 11 second difference, I wouldn't be surprised.

But as I said, I'm no expert.. I'm not sure if that's the reason. I'd suggest trying it with a computation that takes at least 2 minutes, and then you should see the parallel version being faster than the serial.

good luck

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
parallel computing Florian Bahlke 4 Aug, 2009 05:24:02
spmd Florian Bahlke 4 Aug, 2009 05:24:02
parfor Florian Bahlke 4 Aug, 2009 05:24:02
rssFeed for this Thread

Contact us at files@mathworks.com