ParallelDo

ParallelDo[expr,{imax}]

evaluates expr in parallel imax times.

ParallelDo[expr,{i,imax}]

evaluates expr in parallel with the variable i successively taking on the values 1 through imax (in steps of 1).

ParallelDo[expr,{i,imin,imax}]

starts with i=imin.

ParallelDo[expr,{i,imin,imax,di}]

uses steps di.

ParallelDo[expr,{i,{i1,i2,}}]

uses the successive values i1, i2, .

ParallelDo[expr,{i,imin,imax},{j,jmin,jmax},]

evaluates expr looping in parallel over different values of j, etc. for each i.

Details and Options

Examples

open allclose all

Basic Examples  (3)

ParallelDo works like Do, but in parallel:

No results are returned by ParallelDo:

Use a shared variable to communicate results found to the master kernel:

Options  (7)

Method  (2)

Calculations with vastly differing runtimes should be parallelized as finely as possible:

A large number of simple calculations should be distributed into as few batches as possible:

DistributedContexts  (5)

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

Do not distribute any definitions of functions:

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

Distribute only definitions in the given contexts:

Restore the value of the DistributedContexts option to its default:

Applications  (1)

Generate a number of animation frames and save them to individual files:

Import every 5^(th) file and display it:

Properties & Relations  (1)

ParallelDo performs the same iterations as ParallelTable, but does not return the values:

Possible Issues  (2)

A function used that is not known on the parallel kernels has no effect:

Define the function on all parallel kernels:

The function is now evaluated on the parallel kernels:

Definitions of functions in the current context are distributed automatically:

Side effects are local to each parallel kernel:

Use a shared variable to support global side effects:

Wolfram Research (2008), ParallelDo, Wolfram Language function, https://reference.wolfram.com/language/ref/ParallelDo.html (updated 2010).

Text

Wolfram Research (2008), ParallelDo, Wolfram Language function, https://reference.wolfram.com/language/ref/ParallelDo.html (updated 2010).

BibTeX

@misc{reference.wolfram_2021_paralleldo, author="Wolfram Research", title="{ParallelDo}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/ParallelDo.html}", note=[Accessed: 27-September-2021 ]}

BibLaTeX

@online{reference.wolfram_2021_paralleldo, organization={Wolfram Research}, title={ParallelDo}, year={2010}, url={https://reference.wolfram.com/language/ref/ParallelDo.html}, note=[Accessed: 27-September-2021 ]}

CMS

Wolfram Language. 2008. "ParallelDo." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2010. https://reference.wolfram.com/language/ref/ParallelDo.html.

APA

Wolfram Language. (2008). ParallelDo. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ParallelDo.html