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
ParallelTable
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?