({{, (RefLink[DistributedContexts, paclet:ref/DistributedContexts]) 
is an option for various parallel computing functions that specifies which definitions for symbols appearing in an expression should be distributed to all parallel kernels.}})

OpenersNotesSection(Spacer1)Details

Possible settings include:

Definitions of symbols appearing in an expression set for parallel evaluation that match the given contexts are distributed automatically before the parallel evaluation, effectively using (RefLink[DistributeDefinitions, paclet:ref/DistributeDefinitions]).

Definitions for symbols on which other distributed definitions depend are also distributed, as long as they belong to one of the given contexts.

The initial value for most parallel computing functions is DistributedContexts:>(RefLink[$DistributedContexts, paclet:ref/$DistributedContexts]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (7)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

By default, definitions in the current context are distributed automatically in a parallel computation:

remote[x_]:={$KernelID,x^3}

Parallelize[Table[remote[i],{i,4}]]

Do not distribute definitions of functions defined:

local[x_]:={$KernelID,x^2}

Parallelize[Table[local[i],{i,4}],DistributedContexts->None]

Distribute definitions for all symbols in all contexts appearing in a parallel computation:

a`f[x_]:={$KernelID,x}
b`f[x_]:={$KernelID,-x}

Parallelize[{a`f[1],b`f[1]},DistributedContexts->Automatic]

Distribute only definitions in the given contexts:

a`g[x_]:={$KernelID,x}
b`g[x_]:={$KernelID,-x}

Parallelize[{a`g[1],b`g[1]},DistributedContexts->{"a`"}]

OpenersExampleSection1(Spacer1)Scope  (1)

Find all parallel functions that use the (RefLink[DistributedContexts, paclet:ref/DistributedContexts]) option:

Select[Names["System`Parallel*"],MemberQ[First/@Options[Symbol[#]],DistributedContexts]&]

OpenersExampleSection3(Spacer1)Applications  (1)

Turn off automatic distribution of definitions in all commands such as (RefLink[ParallelMap, paclet:ref/ParallelMap]):

$DistributedContexts=None;

Restore the default value:

$DistributedContexts:=$Context;

OpenersExampleSection4(Spacer1)Properties & Relations  (1)

The default setting of (RefLink[DistributedContexts, paclet:ref/DistributedContexts]) in most parallel commands:

Options[ParallelMap]

The default value of (RefLink[$DistributedContexts, paclet:ref/$DistributedContexts]) is (RefLink[$Context, paclet:ref/$Context]):

{$DistributedContexts,$Context}

(RefLink[Parallelize, paclet:ref/Parallelize]) uses a different default setting:

Options[Parallelize]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[DistributeDefinitions, paclet:ref/DistributeDefinitions])  ▪  (RefLink[$DistributedContexts, paclet:ref/$DistributedContexts])  ▪  (RefLink[Parallelize, paclet:ref/Parallelize])  ▪  (RefLink[ParallelMap, paclet:ref/ParallelMap])  ▪  (RefLink[SaveDefinitions, paclet:ref/SaveDefinitions])}})}})