Skip to main content
2 of 3
added 2 characters in body
Rojo
  • 42.8k
  • 7
  • 98
  • 190

This non-answer won't fit in a comment.

The following makes me suspect that the problem has something to do with how the parallel kernels are representing data internally:

LaunchKernels[];

datatest = Table[rule[x, x], {2}];
data = Table[Rule[x, x], {2}];

Trace[datatest]
(* ==> {datatest,{rule[x,x],rule[x,x]}}*)
Trace[data]
(* ==> {data,{x->x,x->x}}*)

DistributeDefinitions[datatest, data];

ParallelEvaluate[foo = datatest /. rule -> Rule];

ParallelEvaluate[Trace[datatest]]
(* ==>{{datatest,{rule[x,x],rule[x,x]}},{datatest,{rule[x,x],rule[x,x]}},
  {datatest,{rule[x,x],rule[x,x]}},{datatest,{rule[x,x],rule[x,x]}},
  {datatest,{rule[x,x],rule[x,x]}},{datatest,{rule[x,x],rule[x,x]}},
  {datatest,{rule[x,x],rule[x,x]}},{datatest,{rule[x,x],rule[x,x]}}} *)

ParallelEvaluate[Trace[data]]
(* ==> {{data,{x->x,x->x},{x->x,x->x},{x->x,x->x},{x->x,x->x}},
  {data,{x->x,x->x},{x->x,x->x},{x->x,x->x},{x->x,x->x}},
  {data,{x->x,x->x},{x->x,x->x},{x->x,x->x},{x->x,x->x}},
  {data,{x->x,x->x},{x->x,x->x},{x->x,x->x},{x->x,x->x}},
  {data,{x->x,x->x},{x->x,x->x},{x->x,x->x},{x->x,x->x}},
  {data,{x->x,x->x},{x->x,x->x},{x->x,x->x},{x->x,x->x}},
  {data,{x->x,x->x},{x->x,x->x},{x->x,x->x},{x->x,x->x}},
  {data,{x->x,x->x},{x->x,x->x},{x->x,x->x},{x->x,x->x}}} *)

ParallelEvaluate[Trace[foo]]
(* {{foo,{x->x,x->x}},{foo,{x->x,x->x}},{foo,{x->x,x->x}},
  {foo,{x->x,x->x}},{foo,{x->x,x->x}},{foo,{x->x,x->x}},
  {foo,{x->x,x->x}},{foo,{x->x,x->x}}} *)

In the parallel kernels, data and foo are Equal, satisfy SameQ, and have, as near as I can tell, the equivalent Language`ExtendedFullDefinition (how to backtick?), but one can see from the traces that the evaluation paths are different.

Tobias Hagge
  • 1.4k
  • 9
  • 17