PARALLEL PACKAGE TUTORIAL

Legacy

The parallel computing features of Mathematica entirely replace the Parallel Computing Toolkit that was available up to Mathematica Version 6. As stated in the "Introduction", this has many benefits and will help to drive the usage of parallel computing. This section describes conversion for users of the Parallel Computing Toolkit.

All the key functions for parallel computing have now become System` context symbols, as well as some of them having been renamed. Also, there is additional functionality not present previously. To help resolve these problems, a legacy package is provided.

Legacy Package

The legacy package adds support for functions that were part of Parallel Computing Toolkit, Version 2.1. It can be loaded as shown below. The shadowing warnings when loading the package are intentional, to alert you to incompatible changes.

Load the legacy package.
Launch kernels, in the way you did with Parallel Computing Toolkit.
In[3]:=
Click for copyable input
Out[3]=
Now if you use a command such as , it will work.
In[4]:=
Click for copyable input
Out[4]=
The legacy package adds a number of contexts to $ContextPath to make all functions that were previously available easily accessible.
In[22]:=
Click for copyable input
Out[22]=
A number of lower-level functions are now in a separate context, Parallel`Developer`.

If you load Parallel`V2`, the Parallel`Developer` context is automatically put onto your $ContextPath, so that all compatible functions are found. If you do not load Parallel`V2`, this does not happen automatically.

Access lower-level parallel functions.
Click for copyable input

Name Changes

A summary of the changes in names is shown in the following table.

Old NameNew Name
LaunchSlavesLaunchKernels
LaunchSlaveLaunchKernels
ConnectSlaveParallel`Developer`LaunchKernel
ResetSlavesAbortKernels
ClearSlavesParallel`Developer`ClearKernels
CloseSlavesCloseKernels
$SlavesKernels[]
RemoteEvaluateParallelEvaluate
ParallelEvaluateParallelCombine, Parallelize
RemoteNeedsParallelNeeds
ExportEnvironmentDistributeDefinitions
WaitOneWaitNext
WaitWaitAll
QueueParallelSubmit
SharedVariablesSetSharedVariable
SharedDownValuesSetSharedFunction
$SharedDownValues$SharedFunctions
ClearSharedUnsetShared
$ProcessorID$KernelID

Listing of legacy names from the Parallel Computing Toolkit and their current equivalents.

Ambiguities

The functionality provided with ParallelEvaluate has been split into two functions, ParallelCombine and Parallelize. Some uses of ParallelEvaluate are ambiguous, and it may not always be possible to choose the correct form.

The two- and three-argument forms of ParallelEvaluate are interpreted as instances of new ParallelCombine.
In[18]:=
Click for copyable input
Out[18]=
In[7]:=
Click for copyable input
Out[7]=
The one-argument case is ambiguous. Here it is treated as an instance of new Parallelize.
In[20]:=
Click for copyable input
Out[20]=
In[8]:=
Click for copyable input
Out[8]=
For cases not handled by Parallelize, it is considered an instance of ParallelCombine, with the default function Identity.
In[21]:=
Click for copyable input
Out[21]=
In[9]:=
Click for copyable input
Out[9]=

Unsupported Features

Higher values of $LoadFactor are no longer supported, because they are incompatible with virtual shared memory, which is now always in use.

Kernel Configuration

Parallel Computing Toolkit contained support for launching local kernels, as well as remote kernels launched with a suitable OS command (remote login).

is supported for compatibility.
In[5]:=
Click for copyable input
Out[5]=

In Mathematica 7, configuration of kernels to use is most easily done through the parallel preferences, available from the Evaluation menu. The legacy package tries to support existing configurations, but this may not work in all instances.

Mathematica 7 knows how many processor cores your computer has.
In[67]:=
Click for copyable input
Out[67]=
The legacy package uses this information to provide a default configuration that uses as many kernels as there are compute cores.
In[68]:=
Click for copyable input
Out[68]=
New to Mathematica? Find your learning path »
Have a question? Ask support »