This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

DistributeDefinitions

DistributeDefinitions
distributes all definitions for the symbols to all parallel kernels.
DistributeDefinitions
distributes definitions for all symbols in the specified context.
  • DistributeDefinitions in effect applies ParallelEvaluate to all assignments for values and attributes with the symbols , including not only ownvalues but also downvalues, upvalues, and other types of values.
  • DistributeDefinitions applies itself recursively to any symbols appearing in the definitions of the symbols .
  • DistributeDefinitions in effect "registers" the definitions for the symbols so that they are automatically distributed to every new parallel kernel that may be launched.
  • DistributeDefinitions[expr] for an arbitrary expression expr distributes definitions for all symbols appearing in expr.
Functions used in subkernels need to be distributed first:
Higher-level parallel commands automatically distribute definitions needed:
Functions used in subkernels need to be distributed first:
In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
In[3]:=
Click for copyable input
Out[3]=
Higher-level parallel commands automatically distribute definitions needed:
In[4]:=
Click for copyable input
In[5]:=
Click for copyable input
Out[5]=
Values of variables:
Functions:
Upvalues:
Attributes:
Distribute definitions for all symbols in the current context:
Auxiliary definitions on which a distributed definition depends are also automatically distributed:
DistributeDefinitions overwrites any previous values and attributes present:
Remove a distributed definition by clearing the function and distributing it again:
DistributeDefinitions uses ParallelEvaluate to transport definitions to all kernels:
An explicit ParallelEvaluate does the same:
Distributed definitions are remembered for new kernels; the effect of ParallelEvaluate is not:
For higher-level parallel commands, functions defined interactively are automatically distributed:
Distribute definitions manually and disable automatic distribution:
Symbols that have values only on the subkernels are not distributed:
The values on the subkernels remain intact:
As soon as a symbol gets a local value, it will be distributed with the next parallel computation:
Use ParallelNeeds to set up a package on all parallel kernels:
Use DistributeDefinitions to set up your own definitions:
A function used that is not known on the parallel kernels may lead to sequential evaluation:
Define the function on all parallel kernels:
The function is now evaluated on the parallel kernels:
The use of DistributeDefinitions does not suppress automatic distribution of definitions:
Modify the definition:
The modified definition is automatically distributed:
Suppress the automatic distribution of definitions:
Symbols defined only on the subkernels are not distributed automatically:
Certain objects with an internal state may not work efficiently when distributed:
Recompute such objects on all subkernels for better performance:
Quickly visualize the Gaussian primes:
New in 7 | Last modified in 8