Legacy Documentation

Parallel Computing Toolkit (2000)

This is documentation for an obsolete product.
Current products and services
Previous section-----Next section

Parallel Computing Toolkit — Examples

Large Calculations

Preparation

Make sure you have at least two kernels available.

Infinite Search

Introduction

If you want to verify that the polynomials i xi-1 for n=1,2,... are all irreducible (an open conjecture), factor the polynomials and then check that the length of the list of factors is 2, one factor being the overall numerical factor.
This computation will continue forever. To stop it, abort the local evaluation by pressing . or choosing Kernel Abort Evaluation. After the abort, collect any waiting results, as follows.
Here is the definition of the polynomial in x with degree n.

Parallel Search

Here you make the definition known to all remote kernels.
Now you can start the computation, requiring that it print each result as it continues. To stop the computation, abort it by choosing Kernel Abort Evaluation or pressing ..

Cleanup

After the abort, you can either wait for the currently running calculations,
or you can abort the remote kernels.

Handling the Abort

You can use CheckAbort[] to handle the abort in your program and define the cleanup code in the abort handler.

Instrumented Version

Here is a version of the code suitable for a longer calculation. It generates output only if it finds a reducible polynomial. To monitor its operation, it also prints progress reports. The results returned from the remote kernels include the number of factors and the time the factorization took for later analysis.

Setup

Here is a sequential test of the remote code.

The Main Loop

Analysis

The results are stored as downvalues of the symbol results. Here we check whether any degree has more than one factor.
Here we plot the time it took to factor the polynomials (meaningful only if all remote processors are similar).

Batch Processing

Large calculations should be run in batch mode by using the Mathematica kernel alone without the front end. Here is a step-by-step guide for turning the interactive calculation described in the previous sections of this notebook into a batch program that can be run unattended and writes results to a file.

Collect the Code

Prepare a notebook or a section in a notebook, such as this one, that contains all code necessary to perform the calculation without human intervention. For smaller problems, you can put all definitions and initializations directly into consecutive input cells. For larger problems, you can develop packages for subproblems and then load these packages into this notebook with Needs["Package`"].
Note that all code cells are marked as initialization cells. Make sure that no other cells in the notebook (such as test examples) are marked as initialization cells.

Set Up PCT

Set up the remote machines to be used for the calculation. For this test, only one local kernel is used.
You may also have to define $RemoteCommand.
Start all remote kernels.

Problem-Specific Definitions

Here is the code to search for factors of the polynomials from the previous section.

Start the Calculation

As in the previous section, this calculation does not terminate. The code here handles an external interrupt (^C) delivered to the running kernel.

Cleanup

Depending on how the interrupt was delivered, this section might not be reached.
Stop remote kernels.

Test the Code

To test the code in the previous subsection, restart the kernel if necessary, then evaluate the initialization of this notebook choosing the corresponding Kernel Evaluation menu command.
If you handle interrupts in your code, you can check it with the Kernel Abort Evaluation menu command.

Write the Package File

Every time you save this notebook, a corresponding package (.m) file is written that contains all initialization cells. (If this does not happen, the notebook option AutoGeneratedPackage needs to be set to Automatic.)

Run the Calculation with the Kernel Alone

You can start a Mathematica kernel and give it the package.m file as input. The details depend on the operating system you are using. See the information in the Documentation Center.