I have the following code where ParallelSubmit
called on OverBar
does not return the same result as non-parallel code even though I used DistributeDefinitions
. Without the OverBar
it works fine. The code
A = Sum[lambda[order] (r - rp)^order, {order, 0, 2}];
OverBar[x_ + y_] := OverBar[x] + OverBar[y];
OverBar[x_ y_] := OverBar[x] OverBar[y];
OverBar[x_ /; NumericQ[x]] := Conjugate[x]
OverBar[x_[xa__]] := OverBar[x][xa]
OverBar[x_ /; MemberQ[RealSymbols, x]] := x
DefaultRealSymbols = {Power, r, rp};
RealSymbols = DefaultRealSymbols;
DistributeDefinitions[A, OverBar];
Coefficient[A, r - rp, 2]
WaitAll[ParallelSubmit[Coefficient[A, r - rp, 2]]]
Coefficient[OverBar[A], r - rp, 2]
WaitAll[ParallelSubmit[Coefficient[OverBar[A], r - rp, 2]]]
returns
lambda[2]
lambda[2]
\!\(\*OverscriptBox[\(lambda\), \(_\)]\)[2]
0
where the 0 should be \!\(\*OverscriptBox[\(lambda\), \(_\)]\)[2]
.
What am I doing wrong?
ParallelEvaluate
works as expected? $\endgroup$ – mmeent Jun 13 '18 at 18:09OverBar
replaced withoverbar
, it works. The same applies when I useParallelEvaluate
instead ofWaitAll
. So it looks like a bug to me. At least, it is unexpected behaviour, as you said. $\endgroup$ – Fred Simons Jun 13 '18 at 18:55