MD_PARALLEL
Batch Execution of a Parallel MATLAB Program


MD_PARALLEL is a directory which illustrates how a parallelized MATLAB program can be run using the batch command.

The MATLAB program is a version of the MD molecular dynamics program. A single for statement in the compute function was replaced by a parfor. Also, the program was simplified so that it takes no input arguments (the former input quantities are hard-coded internally) and returns three numbers as function results, namely the values, at the final time step, of the potential energy, kinetic energy, and the relative energy error.

Thus, the basic program md_parallel.m looks like a MATLAB function of the form

function [potential, kinetic, energy_lost] = md_parallel ( )

To run the program, we are going to use a batch command, and the batch command only accepts a MATLAB script file. Thus we must write a one line script, md_script.m, of the following form:

[ pe, ke, e_lost ] = md_parallel ( )

Finally, we can invoke the batch command. We could do this directly from the MATLAB command line, by a single command such as

job_id = batch ( 'md_script', 'configuration', 'ithaca_2009b', 'FileDependencies', 'md_parallel', 'matlabpool', 7 )
or we might wish to include various timings and checks in a script file, such as the example script file md_wrap.m, which issues a variety of commands and manages the cleanup of the job. This script file allows the user to invoke it with a desired number of workers:
results = md_wrap ( n_labs )
where the variable results will contain the 3 values returned by the underlying call to md_parallel. Because MD_WRAP does not specify a particular configuration, the user can run it locally or on Ithaca, simply by going to MATLAB's parallel menu and designating the particular configuration that is to be used as the default.

Related Data and Programs:

BIRTHDAY_REMOTE, a MATLAB program which runs a Monte Carlo simulation of the birthday paradox, and includes instructions on how to run the job, via MATLAB's BATCH facility, on a remote system such as Virginia Tech's ITHACA cluster.

COLLATZ_PARALLEL is a MATLAB program which seeks the maximum Collatz sequence between 1 and N; it runs in parallel using MATLAB's "parfor" facility.

COLOR_REMOTE, a MATLAB program which carries out the color segmentation of an image in parallel, via SPMD commands; this includes instructions on how to run the job, via MATLAB's BATCH facility, on a remote system such as Virginia Tech's ITHACA cluster.

FDI_OPT, a MATLAB program which demonstrates the use of MATLAB's FMINCON constrained minimization function, taking advantage of MATLAB's Parallel Computing Toolbox for faster execution.

JTB_CODIST, a MATLAB program which demonstrates how the linear system associated with a finite element problem can be treated as a codistributed array whose entries are assigned to different MATLAB workers, so that the matrix is assembled in parallel.

KNAPSACK_REMOTE, a MATLAB program which runs in parallel, seeking solutions of the "subset sum" version of the knapsack problem. Instructions are available on how to run the job, via MATLAB's BATCH facility, on a remote system such as Virginia Tech's ITHACA cluster.

LINEAR_SOLVE_DISTRIBUTED is a MATLAB program which solves a linear system A*x=b using MATLAB's spmd facility, so that the matrix A is "distributed" across multiple MATLAB workers.

LYRICS_REMOTE, a MATLAB program which runs in parallel, using three workers which cooperate "systolically", that is, as through they were on an assembly line. The output from worker 1 is passed to worker 2 for further processing, and so on. This includes instructions on how to run the job, via MATLAB's BATCH facility, on a remote system such as Virginia Tech's ITHACA cluster.

MATLAB_COMMANDLINE, MATLAB programs which illustrate how MATLAB can be run from the UNIX command line, that is, not with the usual MATLAB command window.

MATLAB_DISTCOMP, a MATLAB program which remotely runs a set of 5 jobs on the Ithaca cluster. These jobs are equivalent to the BIRTHDAY_REMOTE, COLOR_REMOTE, KNAPSACK_REMOTE, LYRICS_REMOTE and MD_REMOTE jobs.

MATLAB_PARALLEL, examples which illustrate "local" parallel programming on a single computer with MATLAB's Parallel Computing Toolbox.

MATLAB_REMOTE, examples which illustrate the use of remote job execution, in which a desktop copy of MATLAB sends programs and data to a remote machine for execution. Included is information needed to properly configure the local machine.

MD is a MATLAB program which carries out a molecular dynamics simulation, and is intended as a starting point for implementing a parallel version.

PRIME_NUMBER_PARALLEL is a MATLAB program which counts the number of primes between 1 and N; it runs in parallel using MATLAB's "parfor" facility.

PRIME_NUMBER_SPMD is a MATLAB program which counts the number of primes between 1 and N; running in parallel using MATLAB's "SPMD" feature.

QUAD_SPMD is a MATLAB program which estimates an integral using quadrature; running in parallel using MATLAB's "SPMD" feature.

SATISFIABILITY_PARALLEL is a MATLAB program which demonstrates, for a particular circuit, an exhaustive search for solutions of the circuit satisfiability problem, running in parallel using MATLAB's "PARFOR" feature.

TIMING_PARALLEL is a directory of MATLAB programs which illustrates how to time a parallel MATLAB program.

Reference:

MathWorks documentation for the Parallel Computing Toolbox is available at http://www.mathworks.com/products/parallel-computing/.

Examples and Tests:

You can go up one level to the MATLAB source codes.


Last revised on 04 February 2010.