Group Abstract Group Abstract

Message Boards Message Boards

ParallelTable vs ParallelSubmit

Posted 11 years ago

I want to solve two ODEs in parallel which almost need the same time to solve. So I expected the parallel program to have approximately 50% of the running time of the serial one. This is true when I use ParallelSubmit but when I use ParallelTable the speedup is much lower.

Method          Walltime
Serial          3m10.647
ParallelSubmit  1m42.175s
ParallelTable   2m48.830s

Here are the codes I use:
ParallelSubmit

f := (
        d := 0.0000001;
        {time,tbl} = AbsoluteTiming[Table[{step, Timing[NDSolve[{x'[t] == x[t]^2 - x[t]^3, x[0] == d}, x, {t, 0, 2/d}, MaxStepSize->step, MaxSteps->10000000]]}, {step,5,5,-0.4}]];
)

g := (
        d := 0.0000001;
        {time,tbl} = AbsoluteTiming[Table[{step, Timing[NDSolve[{x'[t] == x[t]^2 - x[t]^3, x[0] == d}, x, {t, 0, 2/d}, MaxStepSize->step, MaxSteps->10000000]]}, {step,4.6,4.6,-0.4}]];
)

LaunchKernels[2];
DistributeDefinitions[f, g];
e = {ParallelSubmit[f], ParallelSubmit[g]};
WaitAll[e];

ParallelTable

d := 0.0000001;

LaunchKernels[2];
{time,tbl} = AbsoluteTiming[ParallelTable[{step, Timing[NDSolve[{x'[t] == x[t]^2 - x[t]^3, x[0] == d}, x, {t, 0, 2/d}, MaxStepSize->step, MaxSteps->10000000]]}, {step,5,4.6,-0.4}]];
CloseKernels[];

These diagrams show the CPU usage of both Methods:
ParallelSubmit
enter image description here
ParallelTable
enter image description here

ParallelSubmit looks as expected but ParallelTable looks like it uses different cores at different times. Especially at the end the picture is quite chaotic.

Is there a better way to use ParallelTable? Maybe an option I am missing?

POSTED BY: Matthias Neuer
4 Replies

I think per ParallelTable's doc page it should distribute the definition automatically because DistributedContexts -> Automatic is preset. Omitting d should not affect the performance.

POSTED BY: Shenghui Yang

In your ParallelTable version, you didn't distribute the value of "d". When I do that (and get rid of extraneous stuff in your code), the timing results for the 2 cases are nearly identical.

POSTED BY: Chad Knutson
Posted 11 years ago
POSTED BY: Matthias Neuer
POSTED BY: Chad Knutson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard