distributes all definitions for the symbols si to all parallel kernels.
distributes definitions for all symbols in the specified context.
Details and Options
- DistributeDefinitions in effect applies ParallelEvaluate to all assignments for values and attributes with the symbols si, 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 si.
- DistributeDefinitions has attribute HoldAll.
- DistributeDefinitions in effect "registers" the definitions for the symbols si 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.
Examplesopen allclose all
Basic Examples (2)
Generalizations & Extensions (1)
Properties & Relations (6)
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:
Possible Issues (4)
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:
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:
Alternatively, reevaluate the data on all subkernels:
Definitions of symbols with the ReadProtected attribute cannot be distributed:
Wolfram Research (2008), DistributeDefinitions, Wolfram Language function, https://reference.wolfram.com/language/ref/DistributeDefinitions.html (updated 2010).
Wolfram Language. 2008. "DistributeDefinitions." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2010. https://reference.wolfram.com/language/ref/DistributeDefinitions.html.
Wolfram Language. (2008). DistributeDefinitions. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DistributeDefinitions.html