Mathematica 9 is now available
Previous section-----Next section

Parallel Computing Toolkit — Examples

Exact Single-Image Stereograms

Preparation

Make sure you have at least two kernels available.

Sequential Code

This material is taken from The Mathematica Programmer II, Chapter 12.
Reference: Roman E. Maeder, The Mathematica Programmer II, New York: Academic Press, 1996.

Original Code

This package is an excerpt from MathProg`SIS`. To work with the examples, you need to evaluate this whole section.

Example

Parallelization

The main part of the SIS function is a giant Table[] command, which we want to replace with ParallelTable[]. However, we have to make sure we do not access any nonlocal variables in the body of the table command because these will not be known on the remote kernels. Here is a code template that shows a nonlocal variable being used in a Table[].
There are two ways to solve this problem.
The first is to instantiate all nonlocal variables with a construct like
The second is to export all nonlocal variables to the remote kernels.
In the body of the table there is also a local function next[] that in turn uses some nonlocal variables inside its body. We can treat it in the same way and then export it, too.

The Parallel Code

Here is the code of ParallelSIS[], with the modifications highlighted in color. The code is packaged as an extension of MathProg`SIS`. Be sure to evaluate this package in the section Sequential Code first.

Examples

The Bessel Function with Random Dots

An Example with Random Characters

Randomly Colored Dots

A High-Resolution Image



Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.