Re: ParallelTable slows down computation
- To: mathgroup at smc.vnet.net
- Subject: [mg105697] Re: [mg105692] ParallelTable slows down computation
- From: Eric Wort <ewort at wolfram.com>
- Date: Wed, 16 Dec 2009 06:16:09 -0500 (EST)
- References: <200912151233.HAA15506@smc.vnet.net>
Hi K,
Some processors support adjusting their clock speed on the fly, and in
Linux if a process has a low priority the machine will stay running at a
lower clock speed if there are only low priority threads competing for
cpu time.
By default, Mathematica launches subkernels with a lower than standard
priority, which can often cause this issue. If you look in the Parallel
tab of the Preferences dialog, there is an option entitled "Run kernels
at a lower process priority". Make sure that this is not checked if you
want the subkernels to run as quickly as possible.
I obtained the following results running your example on my system with
the option unchecked:
In[1]:= 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}];]
Out[2]= {37.142150, Null}
In[3]:= LaunchKernels[2]
Out[3]= {KernelObject[1, "local"], KernelObject[2, "local"]}
In[4]:= 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"];]
Out[5]= {23.712933, Null}
Sincerely,
Eric Wort
K wrote:
> 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.
>
>
- References:
- ParallelTable slows down computation
- From: K <kgspga@googlemail.com>
- ParallelTable slows down computation