ParallelEvaluate
✖
ParallelEvaluate
evaluates the expression expr on all available parallel kernels and returns the list of results obtained.
Details and Options

- ParallelEvaluate has attribute HoldFirst.
- Kernels can be specified either using KernelObject, as returned by Kernels[], or using their integer IDs, as returned by $KernelID. All can also be used.
- The following properties can also be used to select a subset of all running kernels:
-
All all kernels "CloudKernels" all cloud kernels "LinkKernels" all link kernels "LocalKernels" all kernels running locally "LWGKernels" all LightweightGrid kernels "OneKernelPerMachine" one kernel for each different machine "RemoteKernels" all kernels on remote machines "SshKernels" all SSH kernels "WSTPServerKernels" all WSTPServer kernels - The DistributedContexts option for ParallelEvaluate specifies which symbols appearing in expr have their definitions automatically distributed to all available kernels before the computation.
- The default value is DistributedContexts:>$DistributedContexts with $DistributedContexts:=$Context, which distributes definitions of all symbols in the current context, but does not distribute definitions of symbols from packages.
Examples
open allclose allBasic Examples (1)Summary of the most common use cases
Scope (9)Survey of the scope of standard use cases
Use ParallelEvaluate to perform initializations on all parallel kernels:

https://wolfram.com/xid/0g7ggpmjous-c3tuei

Make definitions of local functions on all parallel kernels:

https://wolfram.com/xid/0g7ggpmjous-dnw7g


https://wolfram.com/xid/0g7ggpmjous-fxbs6d

Obtain local properties of all parallel kernels:

https://wolfram.com/xid/0g7ggpmjous-8ii1v

Obtain a local property from a single kernel:

https://wolfram.com/xid/0g7ggpmjous-f1dqek

Access data from sources local to the parallel kernels:

https://wolfram.com/xid/0g7ggpmjous-nqiui

Save results computed on the parallel kernels locally in unique files:

https://wolfram.com/xid/0g7ggpmjous-fk6ty8

Verify that the files have been written:

https://wolfram.com/xid/0g7ggpmjous-n14iei

Prevent local reevaluation of results returned from subkernels:

https://wolfram.com/xid/0g7ggpmjous-pj1uve

https://wolfram.com/xid/0g7ggpmjous-digj1s


https://wolfram.com/xid/0g7ggpmjous-dbszdj

Run an evaluation on only one kernel per machine:

https://wolfram.com/xid/0g7ggpmjous-gy5m0z

Run an evaluation only on all local kernels:

https://wolfram.com/xid/0g7ggpmjous-52trw2

Run an evaluation only on all LightweightGrid kernels:

https://wolfram.com/xid/0g7ggpmjous-eowvua

Generalizations & Extensions (2)Generalized and extended use cases
Specify the kernels to query by a kernel object or a kernel ID:

https://wolfram.com/xid/0g7ggpmjous-sdk3y


https://wolfram.com/xid/0g7ggpmjous-c4yhw3


https://wolfram.com/xid/0g7ggpmjous-3snez


https://wolfram.com/xid/0g7ggpmjous-c86zvf

All can be used to specify all available kernels:

https://wolfram.com/xid/0g7ggpmjous-h1w6t0


https://wolfram.com/xid/0g7ggpmjous-er9w11

All is equivalent to Kernels[]:

https://wolfram.com/xid/0g7ggpmjous-knpye3

Options (5)Common values & functionality for each option
DistributedContexts (5)
By default, definitions in the current context are distributed automatically:

https://wolfram.com/xid/0g7ggpmjous-g9gh34

https://wolfram.com/xid/0g7ggpmjous-clbr3t

Do not distribute any definitions of functions:

https://wolfram.com/xid/0g7ggpmjous-6xao0

https://wolfram.com/xid/0g7ggpmjous-kx0x4h

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

https://wolfram.com/xid/0g7ggpmjous-hu6d1y

https://wolfram.com/xid/0g7ggpmjous-s80e6

Distribute only definitions in the given contexts:

https://wolfram.com/xid/0g7ggpmjous-yht7o

https://wolfram.com/xid/0g7ggpmjous-n7ym7a

Restore the value of the DistributedContexts option to its default:

https://wolfram.com/xid/0g7ggpmjous-qkhgjy

Applications (4)Sample problems that can be solved with this function
Tabulate properties of all parallel kernels:

https://wolfram.com/xid/0g7ggpmjous-jjrfks

Parallelize a Monte Carlo simulation by running the same code on all parallel kernels:

https://wolfram.com/xid/0g7ggpmjous-by54bl

Combine the individual averages for a more accurate overall result:

https://wolfram.com/xid/0g7ggpmjous-c4cs0q

Store large intermediate results locally on each parallel kernel:

https://wolfram.com/xid/0g7ggpmjous-njkl1d

Work with data stored locally:

https://wolfram.com/xid/0g7ggpmjous-likvlw

Check whether all of these polynomials are irreducible:

https://wolfram.com/xid/0g7ggpmjous-gdfn96

https://wolfram.com/xid/0g7ggpmjous-mg8ls7

Shared variables used for synchronization:

https://wolfram.com/xid/0g7ggpmjous-czwvi2
Run one search loop on each kernel until the computation is aborted:

https://wolfram.com/xid/0g7ggpmjous-dsntjf
Properties & Relations (5)Properties of the function, and connections to other functions
ParallelEvaluate performs the same evaluation on each subkernel:

https://wolfram.com/xid/0g7ggpmjous-3kiglo

Parallelize distributes parts of an evaluation to each subkernel:

https://wolfram.com/xid/0g7ggpmjous-es2xyb

Deterministic calculations give the same result on each parallel kernel:

https://wolfram.com/xid/0g7ggpmjous-eb193p

Calculations involving randomness give independent results on each parallel kernel:

https://wolfram.com/xid/0g7ggpmjous-ivxah

Force the same result by setting SeedRandom:

https://wolfram.com/xid/0g7ggpmjous-edsr3f

https://wolfram.com/xid/0g7ggpmjous-bsdjad

Each parallel kernel has a distinct ID, which can be used to make expressions unique:

https://wolfram.com/xid/0g7ggpmjous-hcmxy1

DistributeDefinitions uses ParallelEvaluate to transport definitions to all kernels:

https://wolfram.com/xid/0g7ggpmjous-ihim4b

https://wolfram.com/xid/0g7ggpmjous-fem2ri
An explicit ParallelEvaluate does the same:

https://wolfram.com/xid/0g7ggpmjous-dsbeg3

https://wolfram.com/xid/0g7ggpmjous-i058rf

Distributed definitions are remembered for new kernels:

https://wolfram.com/xid/0g7ggpmjous-isia9p
The effects of ParallelEvaluate are not remembered:

https://wolfram.com/xid/0g7ggpmjous-lpps4x

ParallelNeeds uses ParallelEvaluate to run Needs on all parallel kernels:

https://wolfram.com/xid/0g7ggpmjous-gde7je

https://wolfram.com/xid/0g7ggpmjous-cddqo
Additionally all uses are remembered, so that new kernels also load needed packages:

https://wolfram.com/xid/0g7ggpmjous-dqm48f

https://wolfram.com/xid/0g7ggpmjous-ehklot

ParallelEvaluate automatically distributes definitions of functions used:

https://wolfram.com/xid/0g7ggpmjous-ysr612

https://wolfram.com/xid/0g7ggpmjous-dzfz6p

Possible Issues (2)Common pitfalls and unexpected behavior
Side effects cannot be used between different parallel kernels:

https://wolfram.com/xid/0g7ggpmjous-lxfly9

Use a shared variable to support side effects:

https://wolfram.com/xid/0g7ggpmjous-cf7cc7

https://wolfram.com/xid/0g7ggpmjous-sdt1k


https://wolfram.com/xid/0g7ggpmjous-d5nkmd

Suppress the automatic distribution of definitions when making definitions with ParallelEvaluate:

https://wolfram.com/xid/0g7ggpmjous-oo6pk7

https://wolfram.com/xid/0g7ggpmjous-yzwwts


https://wolfram.com/xid/0g7ggpmjous-qngf10

Neat Examples (2)Surprising or curious use cases
Find such that
is prime, until the computation is manually aborted:

https://wolfram.com/xid/0g7ggpmjous-gje3ls

https://wolfram.com/xid/0g7ggpmjous-ddeli7

Given multiple running kernels on many different machines:

https://wolfram.com/xid/0g7ggpmjous-bgh92b

Load a resource function into the cache on each machine only once:

https://wolfram.com/xid/0g7ggpmjous-0t9jlv

Use the resource function in all kernels:

https://wolfram.com/xid/0g7ggpmjous-ycqbdg

Wolfram Research (2008), ParallelEvaluate, Wolfram Language function, https://reference.wolfram.com/language/ref/ParallelEvaluate.html (updated 2020).
Text
Wolfram Research (2008), ParallelEvaluate, Wolfram Language function, https://reference.wolfram.com/language/ref/ParallelEvaluate.html (updated 2020).
Wolfram Research (2008), ParallelEvaluate, Wolfram Language function, https://reference.wolfram.com/language/ref/ParallelEvaluate.html (updated 2020).
CMS
Wolfram Language. 2008. "ParallelEvaluate." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/ParallelEvaluate.html.
Wolfram Language. 2008. "ParallelEvaluate." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/ParallelEvaluate.html.
APA
Wolfram Language. (2008). ParallelEvaluate. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ParallelEvaluate.html
Wolfram Language. (2008). ParallelEvaluate. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ParallelEvaluate.html
BibTeX
@misc{reference.wolfram_2025_parallelevaluate, author="Wolfram Research", title="{ParallelEvaluate}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/ParallelEvaluate.html}", note=[Accessed: 26-March-2025
]}
BibLaTeX
@online{reference.wolfram_2025_parallelevaluate, organization={Wolfram Research}, title={ParallelEvaluate}, year={2020}, url={https://reference.wolfram.com/language/ref/ParallelEvaluate.html}, note=[Accessed: 26-March-2025
]}