Prerequisites

Parallel computing on your multicore desktop or laptop requires Wolfram Mathematica, Parallel Computing (Toolkit^®), and the appropriate ((gridMathematica)^™) licenses.

Launching Worker Kernels

First, load Parallel Computing Toolkit into the master kernel. (The kernel connected to your Mathematica front end that controls the parallel computation is called the master kernel.)

Needs["Parallel`Debug`"]
Needs["Parallel`"]

On a multicore or other multiprocessor machine, all worker kernels are local, running on the same machine as the master kernel. On a machine with four cores, you can launch up to four worker kernels for best performance (in addition to the master kernel); on a dual-core machine, we suggest launching two worker kernels.

Table[LaunchSlave["localhost"],{4}]

Simple Parallel Computations

Here four definite integrals with different lower bounds are computed in parallel.

ParallelTable[Integrate[((Sin[x])/(Sqrt[x])),{x,i π,∞}],{i,0,4}]

Housekeeping

Once you have successfully started at least one worker kernel, you can begin to use Parallel Computing Toolkit.

Status

First, you can ask each worker kernel to identify itself. The result is a list of each kernel’s unique ID, the corresponding host’s name, Mathematica’s identifier for the remote operating system, the kernel’s process ID, the Mathematica version, and information on CPU time usage and memory.

TableForm[RemoteEvaluate[{$ProcessorID,$MachineName,$SystemID,$Version,TimeUsed[], MaxMemoryUsed[]}],TableHeadings->{None,{"ID","host", "OS","Mathematica Version", "CPU Time","Memory"}}]

Recovery

To recover after an abort of the master kernel, you may have to reset all worker kernels.

ResetSlaves[]

To clear all shared variables and exported definitions, use ClearSlaves[].

ClearSlaves[]

Termination

Before quitting the master kernel, you should terminate all worker kernels.

CloseSlaves[]

The tutorial will provide many more examples of typical parallel computations you can perform with the help of Parallel Computing Toolkit.

© 2007 Wolfram Research, Inc. Mathematica and Parallel Computing Toolkit are registered trademarks and gridMathematica is a trademark of Wolfram Research, Inc. All other trademarks are the property of their respective owners. Mathematica is not associated with Mathematica Policy Research, Inc. or MathTech, Inc.