I'm trying to use Parallesubmit to run some calculations in parallel, but it looks like all the calculations are evaluated at one kernel. Consider this example:
LaunchKernels[]
(* {"KernelObject"[1, "local"], "KernelObject"[2, "local"],
"KernelObject"[3, "local"], "KernelObject"[4, "local"]} *)
f[a_, b_, {min_, max_}] := Pause[1]
ls = {0, 1};
DistributeDefinitions[f]
(* {f} *)
evl = Table[ParallelSubmit[{n}, {f[1, 0, ls], $KernelID}], {n, 1, 8}]
WaitAll[evl] // AbsoluteTiming
(* {8.0152, {{Null, 4}, {Null, 3}, {Null, 2}, {Null, 1}, {Null,
4}, {Null, 3}, {Null, 2}, {Null, 1}}} *)
We can see that $KernelID reported that the work are distributed among four kernels, but the timing shows they are evaluated at one kernel.
For comparison, ParallelTable works as expected
ParallelTable[{f[1, 0, ls], $KernelID}, {n, 1,
8}] // AbsoluteTiming
(* {2.00714, {{Null, 4}, {Null, 4}, {Null, 3}, {Null, 3}, {Null,
2}, {Null, 2}, {Null, 1}, {Null, 1}}} *)
It appears that the problem may relate to the distribution of definition for ls, but why is there the inconsistency between $KernelID and AbsoluteTiming?
If ParallelSubmit doesn't know the definition of ls, I expect it to just complain, like in this example
t = 1;
evl = Table[ParallelSubmit[{n}, {Pause[t], $KernelID}], {n, 1, 4}];
WaitAll[evl]
(kernel 4) Pause::numnm : Non-negative machine-sized number expected at position 1 in Pause[t]. (kernel 3) Pause::numnm : Non-negative machine-sized number expected at position 1 in Pause[t]. (kernel 2) Pause::numnm : Non-negative machine-sized number expected at position 1 in Pause[t]. (kernel 1) Pause::numnm : Non-negative machine-sized number expected at position 1 in Pause[t].
(* {{Null, 4}, {Null, 3}, {Null, 2}, {Null, 1}} *)
Shall we consider this behavor as a bug?