MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

ParallelTable slows down computation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105692] ParallelTable slows down computation
  • From: K <kgspga at googlemail.com>
  • Date: Tue, 15 Dec 2009 07:33:06 -0500 (EST)

Hi,

I was trying to evaluate definite integrals of different product
combinations of trigonometric functions like so:

ClearSystemCache[];
AbsoluteTiming[
   Table[Integrate[
     Sin[ph]*1/(2 Pi)*Sin[nn*ph]*Cos[mm*ph], {ph, Pi/2, Pi}], {nn, 0,
     15}, {mm, 0, 15}];]

I included ClearSystemCache[] to get comparable results for successive
runs. Output of the actual matrix result is suppressed. On my dual
core AMD, I got this result from Mathematica 7.0.1 (Linux x86 64-bit)
for the above command:

{65.240614, Null}

Now I thought that this computation could be almost perfectly
parallelized by having, e.g., nn = 0,...,7 evaluated by one kernel and
nn=8, ..., 15 by the other and typed:

ParallelEvaluate[ClearSystemCache[]];
AbsoluteTiming[
  ParallelTable[
    Integrate[
     Sin[ph]*1/(2 Pi)*Sin[nn*ph]*Cos[mm*ph], {ph, Pi/2, Pi}], {nn, 0,
     15}, {mm, 0, 15}, Method -> "CoarsestGrained"];]

The result, however, was disappointing:

{76.993888, Null}

By the way, Kernel[] returns:

{KernelObject[1,local],KernelObject[2,local]}

This seems to me that the parallel command should in fact have been
evaluated by two kernels. With Method-> "CoarsestGrained", I hoped to
obtain the data splitting I mentioned above. If I do the splitting and
combining myself, it gets even a bit worse:

ParallelEvaluate[ClearSystemCache[]];
AbsoluteTiming[
   job1=ParallelSubmit[Table[Integrate[Sin[ph]*1/(2 Pi)*Sin[nn*ph]*Cos
[mm*ph],{ph, Pi/2,Pi}],{nn,0,7},{mm,0,15}]];
   job2=ParallelSubmit[Table[Integrate[Sin[ph]*1/(2 Pi)*Sin[nn*ph]*Cos
[mm*ph],{ph, Pi/2,Pi}],{nn,8,15},{mm,0,15}]];
   {res1,res2}=WaitAll[{job1,job2}];
   Flatten[{{res1},{res2}},2];]

Result is here:

{78.669442,Null}

I can't believe that the splitting and combining overhead on a single
machine (no network involved here) can eat up all the gain from
distributing the actual workload to two kernels. Does anyone have an
idea what is going wrong here?
Thanks,
K.


  • Prev by Date: Re: Toolbar
  • Next by Date: Re: Finding simplest Fourier series between two given
  • Previous by thread: Re: Need to speed up a matrix calculation
  • Next by thread: Re: ParallelTable slows down computation