Products
  • Wolfram|One

    The definitive Wolfram Language and notebook experience

  • Mathematica

    The original technical computing environment

  • System Modeler

    Multidomain modeling and simulation of complex systems

  • Compute ServicesUse with Mathematica and Wolfram|One
  • AI AccessUse with Mathematica and Wolfram|One
  • Finance Platform
  • Wolfram|Alpha Notebook Edition
  • Application Server
  • Enterprise Private Cloud
  • Wolfram Engine
  • Wolfram Player
  • Wolfram Cloud App
  • Wolfram Player App

More mobile apps

Wolfram|Alpha

  • Wolfram|Alpha Website
  • Wolfram|Alpha APIs

AI Products

  • Wolfram AI Ecosystem
  • Wolfram Foundation Tool
  • Wolfram Cloud MCP
  • Wolfram Local MCP
  • Agent One API
  • CAG Component APIs

Core Technologies of Wolfram Products

  • Wolfram Language
  • Computable Data
  • Wolfram Notebooks
  • Linguistic Understanding

Additional Deployment Options

  • Wolfram Cloud
  • Wolfram Web Engine
  • wolframscript
  • WSTPServer
  • Group & Organizational Licensing
  • All Products
Consulting & Solutions

We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

Wolfram Consulting

Data Science, Finance & Business

  • Artificial Intelligence
  • Data Science
  • Healthcare
  • Real Estate

Engineering

  • Civil Engineering
  • Automotive Engineering
  • Sustainable Energy

Science & Technology

  • AgTech
  • Biosciences
  • Environmental Science
  • Food Science
  • Quantum Computation
  • Social and Behavioral Sciences

More Wolfram Solutions

Technology for Education

  • Research Universities
  • Colleges & Teaching Universities
  • High Schools
  • Resources for Students

Education Initiatives

  • Next-Gen EdTech
  • Computer-Based Math

More Solutions for Education

  • Contact Us
Learning & Support

Get Started

  • Wolfram Language Introduction
  • Fast Intro for Programmers
  • Fast Intro for Math Students
  • Wolfram Language Documentation

More Learning

  • Highlighted Core Areas
  • Demonstrations
  • YouTube
  • Daily Study Groups
  • Wolfram Schools and Programs
  • Books

Grow Your Skills

  • Wolfram U

    Courses in computing, science, life and more

  • Community

    Learn, solve problems and share ideas.

  • Blog

    News, views and insights from Wolfram

  • Resources for

    Software Developers

Tech Support

  • Contact Us
  • Support FAQs
  • Support FAQs
  • Contact Us
Company
  • About Wolfram
  • Career Center
  • All Sites & Resources
  • Connect & Follow
  • Contact Us

Work with Us

  • Student Ambassador Initiative
  • Wolfram for Startups
  • Student Opportunities
  • Jobs Using Wolfram Language

Educational Programs for Adults

  • Summer School
  • Winter School

Educational Programs for Youth

  • Middle School Camp
  • High School Research Program
  • Computational Adventures

Read

  • Stephen Wolfram's Writings
  • Wolfram Blog
  • Wolfram Tech | Books
  • Wolfram Media
  • Complex Systems

Educational Resources

  • Wolfram MathWorld
  • Wolfram in STEM
  • Wolfram Challenges
  • Wolfram Problem Generator

Wolfram Initiatives

  • Wolfram Science
  • Wolfram Foundation
  • History of Mathematics Project

Events

  • Stephen Wolfram Livestreams
  • Online & In-Person Events
  • Contact Us
  • Connect & Follow
For AIs
  • Your Account
  • User Portal
  • Wolfram Cloud
  • Products
    • Wolfram|One
    • Mathematica
    • System Modeler
    • Compute ServicesUse with Mathematica and Wolfram|One
    • AI AccessUse with Mathematica and Wolfram|One
    • Finance Platform
    • Wolfram|Alpha Notebook Edition
    • Application Server
    • Enterprise Private Cloud
    • Wolfram Engine
    • Wolfram Player
    • Wolfram Cloud App
    • Wolfram Player App

    More mobile apps

    • Wolfram|Alpha
      • Wolfram|Alpha Website
      • Wolfram|Alpha APIs
    • AI Products
      • Wolfram AI Ecosystem
      • Wolfram Foundation Tool
      • Wolfram Cloud MCP
      • Wolfram Local MCP
      • Agent One API
      • CAG Component APIs
    • Core Technologies
      • Wolfram Language
      • Computable Data
      • Wolfram Notebooks
      • Linguistic Understanding
    • Additional Deployment Options
      • Wolfram Cloud
      • Wolfram Web Engine
      • wolframscript
      • WSTPServer
    • Group & Organizational Licensing
    • All Products
  • Consulting & Solutions
    • Wolfram Consulting

    Data Science, Finance & Business

    • Artificial Intelligence
    • Data Science
    • Healthcare
    • Real Estate

    Engineering

    • Civil Engineering
    • Automotive Engineering
    • Sustainable Energy

    Science & Technology

    • AgTech
    • Biosciences
    • Environmental Science
    • Food Science
    • Quantum Computation
    • Social and Behavioral Sciences

    More Wolfram Solutions

    Technology for Education

    • Research Universities
    • Colleges & Teaching Universities
    • High Schools
    • Resources for Students

    Education Initiatives

    • Next-Gen EdTech
    • Computer-Based Math

    More Solutions for Education

    • Contact Us
  • Learning & Support

    Get Started

    • Wolfram Language Introduction
    • Fast Intro for Programmers
    • Fast Intro for Math Students
    • Wolfram Language Documentation

    Grow Your Skills

    • Wolfram U

      Courses in computing, science, life and more

    • Community

      Learn, solve problems and share ideas.

    • Blog

      News, views and insights from Wolfram

    • Resources for

      Software Developers
    • Tech Support
      • Contact Us
      • Support FAQs
    • More Learning
      • Highlighted Core Areas
      • Demonstrations
      • YouTube
      • Daily Study Groups
      • Wolfram Schools and Programs
      • Books
    • Support FAQs
    • Contact Us
  • Company
    • About Wolfram
    • Career Center
    • All Sites & Resources
    • Connect & Follow
    • Contact Us

    Work with Us

    • Student Ambassador Initiative
    • Wolfram for Startups
    • Student Opportunities
    • Jobs Using Wolfram Language

    Educational Programs for Adults

    • Summer School
    • Winter School

    Educational Programs for Youth

    • Middle School Camp
    • High School Research Program
    • Computational Adventures

    Read

    • Stephen Wolfram's Writings
    • Wolfram Blog
    • Wolfram Tech | Books
    • Wolfram Media
    • Complex Systems
    • Educational Resources
      • Wolfram MathWorld
      • Wolfram in STEM
      • Wolfram Challenges
      • Wolfram Problem Generator
    • Wolfram Initiatives
      • Wolfram Science
      • Wolfram Foundation
      • History of Mathematics Project
    • Events
      • Stephen Wolfram Livestreams
      • Online & In-Person Events
    • Contact Us
    • Connect & Follow
  • For AIs
  • Wolfram Cloud
  • Your Account
  • User Portal
Wolfram Language & System Documentation Center
Parallelize
  • See Also
    • ParallelEvaluate
    • ParallelTry
    • ParallelMap
    • LaunchKernels
    • DistributeDefinitions
  • Related Guides
    • Parallel Computing
    • Data Parallelism
    • Tuning & Debugging
    • Managing Remote and Parallel Kernels
  • Workflows
    • Run a Computation in Parallel
    • See Also
      • ParallelEvaluate
      • ParallelTry
      • ParallelMap
      • LaunchKernels
      • DistributeDefinitions
    • Related Guides
      • Parallel Computing
      • Data Parallelism
      • Tuning & Debugging
      • Managing Remote and Parallel Kernels
    • Workflows
      • Run a Computation in Parallel

Parallelize[expr]

evaluates expr using automatic parallelization.

Details and Options
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Listable Functions  
Structure-Preserving Functions  
Reductions  
Show More Show More
Inner and Outer Products  
Iterators  
Associative Functions  
Functions for Associations  
Generalizations & Extensions  
Options  
DistributedContexts  
Method  
ProgressReporting  
Applications  
Properties & Relations  
Possible Issues  
Neat Examples  
See Also
Related Guides
Related Workflows
History
Cite this Page
BUILT-IN SYMBOL
  • See Also
    • ParallelEvaluate
    • ParallelTry
    • ParallelMap
    • LaunchKernels
    • DistributeDefinitions
  • Related Guides
    • Parallel Computing
    • Data Parallelism
    • Tuning & Debugging
    • Managing Remote and Parallel Kernels
  • Workflows
    • Run a Computation in Parallel
    • See Also
      • ParallelEvaluate
      • ParallelTry
      • ParallelMap
      • LaunchKernels
      • DistributeDefinitions
    • Related Guides
      • Parallel Computing
      • Data Parallelism
      • Tuning & Debugging
      • Managing Remote and Parallel Kernels
    • Workflows
      • Run a Computation in Parallel

Parallelize

Parallelize[expr]

evaluates expr using automatic parallelization.

Details and Options

  • Parallelize[expr] automatically distributes different parts of the evaluation of expr among different available kernels and processors.
  • Parallelize[expr] normally gives the same result as evaluating expr, except for side effects during the computation.
  • Parallelize has attribute HoldFirst, so that expressions are not evaluated before parallelization.
  • Parallelize Options
  • The following options can be given:
  • Method Automaticgranularity of parallelization
    DistributedContexts $DistributedContextscontexts used to distribute symbols to parallel computations
    ProgressReporting $ProgressReportingwhether to report the progress of the computation
  • The Method option specifies the parallelization method to use. Possible settings include:
  • "CoarsestGrained"break the computation into as many pieces as there are available kernels
    "FinestGrained"break the computation into the smallest possible subunits
    "EvaluationsPerKernel"->ebreak the computation into at most e pieces per kernel
    "ItemsPerEvaluation"->mbreak the computation into evaluations of at most m subunits each
    Automaticcompromise between overhead and load balancing
  • Method->"CoarsestGrained" is suitable for computations involving many subunits, all of which take the same amount of time. It minimizes overhead but does not provide any load balancing.
  • Method->"FinestGrained" is suitable for computations involving few subunits whose evaluations take different amounts of time. It leads to higher overhead but maximizes load balancing.
  • The DistributedContexts option 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.
  • The ProgressReporting option specifies whether to report the progress of the parallel computation.
  • The default value is ProgressReporting:>$ProgressReporting.
  • Parallelize Scope
  • Parallelize[f[…]] parallelizes these functions that operate on a list element by element: Apply, AssociationMap, Cases, Count, FreeQ, KeyMap, KeySelect, KeyValueMap, Map, MapApply, MapIndexed, MapThread, Comap, AssociationComap, ComapApply, MemberQ, Pick, Scan, Select and Through.
  • Parallelize[iter] parallelizes the iterators Array, Do, Product, Sum, Table.
  • Parallelize[list] evaluates the elements of list in parallel.
  • Parallelize[f[…]] can parallelize listable and associative functions and inner and outer products. »
  • Parallelize[cmd1;cmd2;…] wraps Parallelize around each cmdi and evaluates these in sequence. »
  • Parallelize[s=expr] is converted to s=Parallelize[expr].
  • Parallelize[expr] evaluates expr sequentially if expr is not one of the cases recognized by Parallelize.

Examples

open all close all

Basic Examples  (4)

Map a function in parallel:

Wolfram Language code: Parallelize[Map[Composition[Framed, FactorInteger], {1, 11, 111, 1111, 11111, 111111}]]

Generate a table in parallel:

Wolfram Language code: Parallelize[Table[Length[FactorInteger[10 ^ 50 + n]], {n, 20}]]

Functions defined interactively can immediately be used in parallel:

Wolfram Language code: f1[n_] := Length[FactorInteger[(10 ^ n - 1) / 9]]
Wolfram Language code: Parallelize[Map[f1, Range[50, 60]]]

Longer computations display information about their progress and estimated time to completion:

Wolfram Language code: res = Parallelize[Map[PrimeQ[2 ^ # - 1]&, Range[9601, 12000]]];

Scope  (23)

Listable Functions  (1)

All listable functions with one argument will automatically parallelize when applied to a list:

Wolfram Language code: Parallelize[Prime[{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}]]

Implicitly defined lists:

Wolfram Language code: Parallelize[Prime[Range[10]]]
Wolfram Language code: Parallelize[Prime[Table[i, {i, 10}]]]

Structure-Preserving Functions  (8)

Many functional programming constructs that preserve list structure parallelize:

Wolfram Language code: Parallelize[Map[f, {a, b, c, d}]]
Wolfram Language code: Parallelize[Scan[Print, Range[5]]]
Wolfram Language code: Parallelize[MapIndexed[List, {a, b, c, d}]]
Wolfram Language code: Parallelize@MapIndexed[f, <|"a" -> 1, "b" -> 2|>]
Wolfram Language code: Parallelize[MapThread[f, {{a, b, c}, {u, v, w}}]]
Wolfram Language code: Parallelize[Apply[f, {{a, b, c}, {u, v, w}, {x, y}}, 1]]
Wolfram Language code: Parallelize[MapApply[f, {{a, b, c}, {u, v, w}, {x, y}}]]

f@@@list is equivalent to MapApply[f,list]:

Wolfram Language code: Parallelize[f@@@{{a, b, c}, {u, v, w}, {x, y}}]
Wolfram Language code: Parallelize[Comap[{f, g, h}, x]]
Wolfram Language code: Parallelize[ComapApply[{f, g, h}, {1, 2}]]
Wolfram Language code: Parallelize[Through[{f, g, h}[a, b]]]

The result need not have the same length as the input:

Wolfram Language code: Parallelize[Cases[Range[100], _ ? PrimeQ]]
Wolfram Language code: Parallelize[Select[Range[200!, 200! + 2000], PrimeQ]] - 200!
Wolfram Language code: Parallelize[Pick[{a, b, c, d}, {1, 0, 1, 1}, 1]]

Without a function, Parallelize simply evaluates the elements in parallel:

Wolfram Language code: Parallelize[{1 + 2, Sin[1.0], Print[3], $KernelID}]

Reductions  (4)

Count the number of primes up to one million:

Wolfram Language code: Parallelize[Count[Range[10 ^ 6], _ ? PrimeQ]]

Check whether 93 occurs in a list of the first 100 primes:

Wolfram Language code: Parallelize[MemberQ[Array[Prime, 100], 93]]

Check whether a list is free of 5:

Wolfram Language code: Parallelize[FreeQ[Range[10 ^ 6], 5]]

The argument does not have to be an explicit List:

Wolfram Language code: Parallelize[FreeQ[foo[1, 2, 3, 4, 5], 5]]

Inner and Outer Products  (2)

Inner products automatically parallelize:

Wolfram Language code: Parallelize[Inner[f, {{a1, a2}, {b1, b2}, {c1, c2}, {d1, d2}}, {x1, x2}]]
Wolfram Language code: Parallelize[Dot[{a, b, c}, {x, y, z}]]

Outer products automatically parallelize:

Wolfram Language code: Parallelize[Outer[StringJoin, {"", "re", "un"}, {"cover", "draw", "wind"}, {"", "ing", "s"}]]

Iterators  (3)

Evaluate a table in parallel, with or without an iterator variable:

Wolfram Language code: Parallelize[Table[i, {i, 2, 21, 2}]]
Wolfram Language code: Parallelize[Table[RandomReal[], {10}, {2}]]

Generate an array in parallel:

Wolfram Language code: Parallelize[Array[Prime, 20]]

Evaluate sums and products in parallel:

Wolfram Language code: Parallelize[Product[i, {i, 100}]]
Wolfram Language code: Parallelize[Sum[N[Pi ^ (1 / i), 100], {i, 100}]]

The evaluation of the function happens in parallel:

Wolfram Language code: Sum[Pause[1]; i, {i, 4}]//AbsoluteTiming
Wolfram Language code: Parallelize[Sum[Pause[1]; i, {i, 4}]]//AbsoluteTiming

The list of file names is expanded locally on the subkernels:

Wolfram Language code: Parallelize[Count[FileNames["*.m", $InstallationDirectory, Infinity], f_ /; FileByteCount[f] > 500000]]

Associative Functions  (1)

Functions with the attribute Flat automatically parallelize:

Wolfram Language code: Parallelize[a + b + c + d + e + f]
Wolfram Language code: Parallelize[a * b * c * d]
Wolfram Language code: Parallelize[LCM[1, 2, 3, 4, 5, 6]]

Functions for Associations  (4)

Parallelize AssociationMap:

Wolfram Language code: Parallelize[AssociationMap[Prime, Range[10]]]

Parallelize KeyMap:

Wolfram Language code: Parallelize[KeyMap[Prime, AssociationMap[Identity, Range[10]]]]

Parallelize KeySelect:

Wolfram Language code: Parallelize[KeySelect[AssociationMap[Identity, Range[100]], PrimeQ]]

Parallelize KeyValueMap:

Wolfram Language code: Parallelize[KeyValueMap[List, AssociationMap[Prime, Range[20]]]]

Generalizations & Extensions  (4)

Listable functions of several arguments:

Wolfram Language code: Parallelize[MapThread[Labeled[Framed[f[##]], $KernelID]&, {{a, b, c}, {x, y, z}}]]

Only the right side of an assignment is parallelized:

Wolfram Language code: Parallelize[primes = Select[Range[10 ^ 10, 10 ^ 10 + 100], PrimeQ]]

Elements of a compound expression are parallelized one after the other:

Wolfram Language code: Parallelize[ primes = Table[Prime[10 ^ i], {i, 11}];IntegerLength /@ primes]

Parallelize the generation of video frames:

Wolfram Language code: Parallelize[VideoGenerator[Plot[Sin[# x], {x, 0, 10}, PlotLabel -> ("Plot[Sin[a x]] a = " <> ToString[N@#]), ImageSize -> {320, 240}]&, 5]]

Options  (13)

DistributedContexts  (5)

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

Wolfram Language code: remote[x_] := {$KernelID, x ^ 3}
Wolfram Language code: Parallelize[Table[remote[i], {i, 4}]]

Do not distribute any definitions of functions:

Wolfram Language code: local[x_] := {$KernelID, x ^ 2}
Wolfram Language code: Parallelize[Table[local[i], {i, 4}], DistributedContexts -> None]

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

Wolfram Language code: a`f[x_] := {$KernelID, x} b`f[x_] := {$KernelID, -x}
Wolfram Language code: Parallelize[{a`f[1], b`f[1]}, DistributedContexts -> Automatic]

Distribute only definitions in the given contexts:

Wolfram Language code: a`g[x_] := {$KernelID, x} b`g[x_] := {$KernelID, -x}
Wolfram Language code: Parallelize[{a`g[1], b`g[1]}, DistributedContexts -> {"a`"}]

Restore the value of the DistributedContexts option to its default:

Wolfram Language code: SetOptions[Parallelize, DistributedContexts :> $Context]

Method  (6)

Break the computation into the smallest possible subunits:

Wolfram Language code: Parallelize[Map[Labeled[Framed[#], $KernelID]&, Range[10]], Method -> "FinestGrained"]

Break the computation into as many pieces as there are available kernels:

Wolfram Language code: Parallelize[Map[Labeled[Framed[#], $KernelID]&, Range[10]], Method -> "CoarsestGrained"]

Break the computation into at most 2 evaluations per kernel for the entire job:

Wolfram Language code: Parallelize[Table[Labeled[Framed[i], $KernelID], {i, 12}], Method -> "EvaluationsPerKernel" -> 2]

Break the computation into evaluations of at most 5 elements each:

Wolfram Language code: Parallelize[Table[Labeled[Framed[i], $KernelID], {i, 18}], Method -> "ItemsPerEvaluation" -> 5]

The default option setting balances evaluation size and number of evaluations:

Wolfram Language code: Parallelize[Table[Labeled[Framed[i], $KernelID], {i, 20}], Method -> Automatic]

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

Wolfram Language code: Parallelize[Select[Range[4000, 5000], PrimeQ[2 ^ # - 1]&], Method -> "FinestGrained"]

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

Wolfram Language code: BinCounts[Parallelize[Map[Mod[Floor[# * Pi], 10]&, Range[10000]], Method -> "CoarsestGrained"], {0, 10}]

ProgressReporting  (2)

Do not show a temporary progress report:

Wolfram Language code: res = Parallelize[Map[PrimeQ[2 ^ # - 1]&, Range[9601, 12000]], ProgressReporting -> False];

Use Method"FinestGrained" for the most accurate progress report:

Wolfram Language code: res = Parallelize[Select[Range[9000, 10000], PrimeQ[2 ^ # - 1]&], Method -> "FinestGrained", ProgressReporting -> True];

Applications  (4)

Search for Mersenne primes:

Wolfram Language code: Parallelize[Select[Range[9000, 10000], PrimeQ[2 ^ # - 1]&], Method -> "FinestGrained"]

Watch the results appear as they are found:

Wolfram Language code: SetSharedVariable[primes]
Wolfram Language code: primes = {}; Monitor[Parallelize[Scan[If[PrimeQ[2 ^ # - 1], AppendTo[primes, #]]&, Range[1000, 5000]], Method -> "FinestGrained"], primes]; primes

Compute a whole table of visualizations:

Wolfram Language code: Parallelize[Table[StreamPlot[ {x^i y^j, x^jy^i}, {x, -3, 3}, {y, -3, 3}, ImageSize -> 100], {i, 2}, {j, 2}]]
Wolfram Language code: $TrigFunctions = {Sin, Cos, Sec, Csc, Tan, Cot, ArcSin, ArcCos, ArcSec, ArcCsc, ArcTan, ArcCot};
Wolfram Language code: Parallelize@Table[Plot3D[Abs[f[x + I y]], {x, -2, 2}, {y, -2, 2}, MeshFunctions -> Function@@@{{{x, y, z}, Re[f[x + I y]]}, {{x, y, z}, Im[f[x + I y]]}}, MeshShading -> {{Orange, None}, {None, Green}}, PlotLabel -> f, Ticks -> None, ImageSize -> 100], {f, $TrigFunctions}]

Search a range in parallel for local minima:

Wolfram Language code: res = Parallelize[Apply[Function[{x0, x1}, FindMinimum[Cos[x]Sin[Sqrt[10]x]Exp[-0.01x], {x, x0, x1}]], Partition[Range[0, 30, 3], 2, 1], {1}]]

Choose the best one:

Wolfram Language code: res[[Ordering[res, 1]]][[1]]

Use a shared function to record timing results as they are generated:

Wolfram Language code: record[k_, t_] := AppendTo[counts[[k]], t]; SetSharedFunction[record]

Set up a dynamic bar chart with the timing results:

Wolfram Language code: ids = ParallelEvaluate[$KernelID];mi = Max[ids]; counts = Table[{0}, {mi}]; Dynamic[BarChart[counts[[ids]], PerformanceGoal -> "Speed", ChartLayout -> "Stacked", ChartLabels -> {ids, None}]]

Run a series of calculations with vastly varying runtimes:

Wolfram Language code: Parallelize[Table[Module[{t}, t = Timing[Plus@@FactorInteger[2 ^ i - 1][[All, 2]]]; record[$KernelID, t[[1]]];t[[2]]], {i, 192, 160, -1}], Method -> "FinestGrained"]

Properties & Relations  (7)

For data parallel functions, Parallelize is implemented in terms of ParallelCombine:

Wolfram Language code: Parallelize[Select[Range[100], PrimeQ]]
Wolfram Language code: ParallelCombine[Select[#, PrimeQ]&, Range[100]]
Wolfram Language code: Parallelize[Count[Range[100], _ ? PrimeQ]]
Wolfram Language code: ParallelCombine[Count[#, _ ? PrimeQ]&, Range[100], Plus]

Parallel speedup can be measured with a calculation that takes a known amount of time:

Wolfram Language code: AbsoluteTiming[Parallelize[Table[Pause[1];$KernelID, {8}]]]

Define a number of tasks with known runtimes:

Wolfram Language code: tasks = Range[0.1, 1, 0.05]

The time for a sequential execution is the sum of the individual times:

Wolfram Language code: sequentialTime = Total[tasks]
Wolfram Language code: speedup[parallelTime_] := sequentialTime / parallelTime

Measure the speedup for parallel execution:

Wolfram Language code: speedup @ First[AbsoluteTiming[Parallelize[Map[Pause, tasks]]]]

Finest-grained scheduling gives better load balancing and higher speedup:

Wolfram Language code: speedup@First[AbsoluteTiming[Parallelize[Map[Pause, tasks], Method -> "FinestGrained"]]]

Scheduling large tasks first gives even better results:

Wolfram Language code: speedup @ First[AbsoluteTiming[Parallelize[Map[Pause, Reverse[tasks]], Method -> "FinestGrained"]]]

Form the arithmetic expression 1⊗2⊗3⊗4⊗5⊗6⊗7⊗8⊗9 for ⊗ chosen from +, –, *, /:

Wolfram Language code: form[ops_List] := StringJoin[Riffle[Range[Length[ops] + 1], ops] /. {Plus -> "+", Times -> "*", Subtract -> "-", Divide -> "/", i_Integer :> ToString[i]}]

Each list of arithmetic operations gives a simple calculation:

Wolfram Language code: form[{Plus, Times, Plus}]

Evaluating it is easy:

Wolfram Language code: ToExpression[%]

Find all sequences of arithmetic operations that give 0:

Wolfram Language code: zero = Parallelize[Select[Tuples[{Plus, Times, Subtract, Divide}, 8], ToExpression[form[#]] == 0&]]; Length[zero]

Display the corresponding expressions:

Wolfram Language code: Style[form /@ zero, 10]

Functions defined interactively are automatically distributed to all kernels when needed:

Wolfram Language code: ftest[n_] := Labeled[Framed[PrimeQ[2 ^ n - 1]], $KernelID]
Wolfram Language code: Parallelize[Map[ftest, Range[1275, 1285]]]

Distribute definitions manually and disable automatic distribution:

Wolfram Language code: gtest[n_] := Labeled[Framed[PrimeQ[2 ^ n - 1]], $KernelID]
Wolfram Language code: DistributeDefinitions[gtest];
Wolfram Language code: Parallelize[Map[ftest, Range[1275, 1285]], DistributedContexts -> None]

For functions from a package, use ParallelNeeds rather than DistributeDefinitions:

Wolfram Language code: Needs["FiniteFields`"]
Wolfram Language code: Table[GF[7][{3}] ^ i, {i, 7}]
Wolfram Language code: ParallelNeeds["FiniteFields`"]
Wolfram Language code: Parallelize[Table[GF[7][{3}] ^ i, {i, 7}]]

Set up a random number generator that is suitable for parallel use and initialize each kernel:

Wolfram Language code: ParallelEvaluate[SeedRandom[1, Method -> {"ParallelMersenneTwister", "Index" -> $KernelID}]];
Wolfram Language code: Join@@ParallelEvaluate[RandomReal[1, 10]]

Possible Issues  (8)

Expressions that cannot be parallelized are evaluated normally:

Wolfram Language code: Parallelize[Integrate[1 / (x - 1), x]]
Wolfram Language code: Parallelize[Map[f, {a, b, c}, 0]]

Side effects cannot be used in the function mapped in parallel:

Wolfram Language code: primes = {}; Parallelize[Scan[If[PrimeQ[2 ^ # - 1], AppendTo[primes, #]]&, Range[1000, 4000]]]; primes

Use a shared variable to support side effects:

Wolfram Language code: SetSharedVariable[primes]
Wolfram Language code: primes = {}; Parallelize[Scan[If[PrimeQ[2 ^ # - 1], AppendTo[primes, #]]&, Range[1000, 4000]]]; primes

If no subkernels are available, the result is computed on the master kernel:

Wolfram Language code: CloseKernels[];
Wolfram Language code: Parallelize[Map[f, {a, b, c}]]

If a function used is not distributed first, the result may still appear to be correct:

Wolfram Language code: ftest[n_] := Labeled[Framed[PrimeQ[2 ^ n - 1]], $KernelID]
Wolfram Language code: Parallelize[Map[ftest, Range[1275, 1285]], DistributedContexts -> None]

Only if the function is distributed is the result actually calculated on the available kernels:

Wolfram Language code: DistributeDefinitions[ftest]
Wolfram Language code: Parallelize[Map[ftest, Range[1275, 1285]], DistributedContexts -> None]

Definitions of functions in the current context are distributed automatically:

Wolfram Language code: gtest[n_] := Labeled[Framed[PrimeQ[2 ^ n - 1]], $KernelID]
Wolfram Language code: Parallelize[Map[gtest, Range[1275, 1285]]]

Definitions from contexts other than the default context are not distributed automatically:

Wolfram Language code: ctx`gtest[n_] := Labeled[Framed[PrimeQ[2 ^ n - 1]], $KernelID]
Wolfram Language code: Parallelize[Map[ctx`gtest, Range[1275, 1285]]]

Use DistributeDefinitions to distribute such definitions:

Wolfram Language code: DistributeDefinitions[ctx`gtest];
Wolfram Language code: Parallelize[Map[ctx`gtest, Range[1275, 1285]]]

Alternatively, set the DistributedContexts option to include all contexts:

Wolfram Language code: cty`gtest[n_] := Labeled[Framed[PrimeQ[2 ^ n - 1]], $KernelID]
Wolfram Language code: Parallelize[Map[cty`gtest, Range[1275, 1285]], DistributedContexts -> Automatic]

Explicitly distribute the definition of a function:

Wolfram Language code: f[i_] := {i, $KernelID} DistributeDefinitions[f];

Modify the definition:

Wolfram Language code: Clear[f]

The modified definition is automatically distributed:

Wolfram Language code: Parallelize[Map[f, Range[8]]]

Suppress the automatic distribution of definitions:

Wolfram Language code: g[i_] := {i, $KernelID} DistributeDefinitions[g];
Wolfram Language code: Clear[g]
Wolfram Language code: Parallelize[Map[g, Range[8]], DistributedContexts -> None]

Symbols defined only on the subkernels are not distributed automatically:

Wolfram Language code: ParallelEvaluate[h[i_] := {i, $KernelID}];
Wolfram Language code: Parallelize[Map[h, Range[8]]]

The value of $DistributedContexts is not used in Parallelize:

Wolfram Language code: $DistributedContexts = None;
Wolfram Language code: local1[x_] := {$KernelID, x ^ 2}
Wolfram Language code: Parallelize[Table[local1[i], {i, 4}]]

Set the value of the DistributedContexts option of Parallelize:

Wolfram Language code: SetOptions[Parallelize, DistributedContexts -> None]
Wolfram Language code: local2[x_] := {$KernelID, x ^ 3}
Wolfram Language code: Parallelize[Table[local2[i], {i, 4}]]

Restore all settings to their default values:

Wolfram Language code: $DistributedContexts := $Context
Wolfram Language code: SetOptions[Parallelize, DistributedContexts :> $Context]

Trivial operations may take longer when parallelized:

Wolfram Language code: AbsoluteTiming[Parallelize[Table[N[Sin[x]], {x, 0, 1000}]];]
Wolfram Language code: AbsoluteTiming[Table[N[Sin[x]], {x, 0, 1000}];]

Neat Examples  (1)

Display nontrivial automata as they are found:

Wolfram Language code: Module[{auto = {}}, SetSharedVariable[auto]; (* Progress *) PrintTemporary@Dynamic[GraphicsGrid[Partition[auto, 3, 3, 1, {}], Frame -> All, ImageSize -> 500]]; (* Compute *) Parallelize[Scan[(out = Position[CellularAutomaton[{#, {2, 1}, {1, 1, 1}}, {{{{1}}}, 0}, {{{8}}}], 1];If[Length[out] > 50, AppendTo[auto, Graphics3D[{Cuboid /@ out}, Boxed -> False]]];)&, Range[2, 50, 2]]]; (* Output *) GraphicsGrid[Partition[auto, 3, 3, 1, {}], Frame -> All, ImageSize -> 500]]

See Also

ParallelEvaluate  ParallelTry  ParallelMap  LaunchKernels  DistributeDefinitions

Related Guides

    ▪
  • Parallel Computing
  • ▪
  • Data Parallelism
  • ▪
  • Tuning & Debugging
  • ▪
  • Managing Remote and Parallel Kernels

Related Workflows

    Related Workflows
    ▪
  • Run a Computation in Parallel

History

Introduced in 2008 (7.0) | Updated in 2010 (8.0) ▪ 2021 (13.0)

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

Text

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

CMS

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

APA

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

BibTeX

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

BibLaTeX

@online{reference.wolfram_2026_parallelize, organization={Wolfram Research}, title={Parallelize}, year={2021}, url={https://reference.wolfram.com/language/ref/Parallelize.html}, note=[Accessed: 01-September-2026]}

Top
Introduction for Programmers
Introductory Book
Wolfram Function Repository | Wolfram Data Repository | Wolfram Data Drop | Wolfram Language Products
Top
  • Products
  • Wolfram|One
  • Mathematica
  • AI Access
  • Compute Services
  • System Modeler

  • Wolfram|Alpha Notebook Edition
  • Wolfram|Alpha Pro
  • Mobile Apps

  • Wolfram Engine
  • Wolfram Player

  • Volume & Site Licensing
  • Server Deployment Options
  • Consulting
  • Wolfram Consulting
  • Repositories
  • Data Repository
  • Function Repository
  • Community Paclet Repository
  • Neural Net Repository
  • Prompt Repository

  • Wolfram Language Example Repository
  • Notebook Archive
  • Wolfram GitHub
  • Learning
  • Wolfram U
  • Wolfram Language Documentation
  • Webinars & Training
  • Educational Programs

  • Wolfram Language Introduction
  • Fast Introduction for Programmers
  • Fast Introduction for Math Students
  • Books

  • Wolfram Community
  • Wolfram Blog
  • Public Resources
  • Wolfram|Alpha
  • Wolfram Problem Generator
  • Wolfram Challenges

  • Computer-Based Math
  • Computational Thinking
  • Computational Adventures

  • Demonstrations Project
  • Wolfram Data Drop
  • MathWorld
  • Wolfram Science
  • Wolfram Media Publishing
  • Customer Resources
  • Store
  • Product Downloads
  • User Portal
  • Your Account
  • Organization Access

  • Support FAQ
  • Contact Support
  • Company
  • About Wolfram
  • Careers
  • Contact
  • Events
Wolfram Community Wolfram Blog
Legal & Privacy Policy
WolframAlpha.com | WolframCloud.com
© 2026 Wolfram
© 2026 Wolfram | Legal & Privacy Policy |
English