The command DistributeDefinitions[z] installs all current definitions for z on the local kernels. A simple example: we assign the value 1 to z in the mainkernel, distribute the definitions of z and inspect the values of z in the subkernels. All are 1.
z=1; DistributeDefinitions[z]; {z, ParallelEvaluate[z]} (* {1,{1,1,1,1}} *) The function DistributeDefinitions does not establish a synchronization between the local kernels and the main kernel. Therefore, when change z to 2 in the main kernel, in the subkernels the value of z is still 1:
z=2; {z, ParallelEvaluate[z]} (* {2,{1,1,1,1}} *) Anyway, that was the result in Mathematica 8 and Mathematica 9. But Mathematica 10.4 does at least some synchronization. There we obtain
z=1; DistributeDefinitions[z]; {z, ParallelEvaluate[z]} z=2; {z, ParallelEvaluate[z]} (* {1,{1,1,1,1}} *) (* {2,{2,2,2,2}} *) Does someone know what exactly has changed in DistributeDefinitions? The documentation does not help me, but I might have overlooked a release note.
Edit
After some further playing, I found the following buggish behaviour:
z=4; DistributeDefinitions[z] (* {z} *) {z, ParallelEvaluate[z]} (* {4,{4,4,4,4}} *) ParallelEvaluate[ValueQ[z]] (* {True, True, True, True} *) ParallelEvaluate[Clear[z]] (* {Null,Null,Null,Null} *) ParallelEvaluate[ValueQ[z]] (* {False,False,False,False} *) {z, ParallelEvaluate[z]} (* {4,{4,4,4,4}} *) {z, ParallelEvaluate[1+z^2]} (* {4,{17,17,17,17}} *) ParallelEvaluate[ValueQ[z]] (* {False,False,False,False} *) We can do numerical computations with variables that do not have a value!
DistributeDefinitionsdoes register distributed symbols, seeParallel`Developer`$DistributedDefinitions. Perhaps this is a good starting point for researching what happens. $\endgroup$ParallelEvaluateandDistributedContexts. $\endgroup$