# FACE_SPMD SPMD Labs Cooperate to Find a Boundary

FACE_SPMD is a MATLAB program which uses the SPMD (single program, multiple data) command so that multiple MATLAB workers or "labs" can cooperate in a task.

A rectangular box, of dimensions 1x1x3, has been subdivided into tetrahedral elements. These elements are defined by

• x, a list of 3D point coordinates.
• e_conn, a list of sets of 4 point indices, representing the four points that define each tetrahedron.

It is desired to determine the triangular faces that lie on a boundary face of the box. The boundary face is described by the variable (one of X, Y, or Z) that is held constant, along with bounds for the other two variables. Thus, the output of the program will be a list of triples of point indices, with each triple representing a triangular face of a tetrahedron.

The function has the form:

F_conn = face_fun ( x, e_conn, ii, val_ii, xj_lb, xj_ub, xk_lb, xk_ub )
where
• x, the list of 3D point coordinates.
• e_conn, a list of sets of 4 point indices, representing the four points that define each tetrahedron.
• ii, the index of the "I" variable, which is constant on the boundary plane. If the constant variable is X, then II is 1, and so on.
• val_ii, the value of the constant "I" variable.
• xj_lb, xj_ub, the upper and lower bounds for the "J" nonconstant variable.
• xk_lb, xk_ub, the upper and lower bounds for the "K" nonconstant variable.
The "J" and "K" variables are the first and second variables to follow the "I" variable, assuming that we are counting with wrap around. There are thus three possibilities for I, J and K:
```    I  J  K
-- -- --
1  2  3
2  3  1
3  1  2
```

Depending on the situation, the function could be executed in parallel:

• interactively, and locally, using the matlabpool command;
• indirectly, and locally, using the batch command;
• indirectly, and on the Ithaca cluster, using the batch command;

### Languages:

FACE_SPMD is available in a MATLAB version.

### Related Data and Programs:

CONTRAST_SPMD, a MATLAB program which demonstrates the SPMD parallel programming feature for image operations; the client reads an image, the workers increase contrast over separate portions, and the client assembles and displays the results.

CONTRAST2_SPMD, a MATLAB program which demonstrates the SPMD parallel programming feature for image operations; this improves the contrast_spmd program by allowing the workers to share some data; this makes it possible to eliminate artificial "seams" in the processed image.

DIJKSTRA_SPMD, a MATLAB program which uses the SPMD feature to parallelize a simple example of Dijkstra's minimum distance algorithm for graphs.

FD2D_HEAT_EXPLICIT_SPMD, a MATLAB program which uses the finite difference method and explicit time stepping to solve the time dependent heat equation in 2D. A black and white image is used as the "initial condition". MATLAB's SPMD facility is used to carry out the computation in parallel.

FMINCON_PARALLEL, 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.

IMAGE_DENOISE_SPMD, a MATLAB program which demonstrates the SPMD parallel programming feature for image operations; the client reads an image, the workers process portions of it, and the client assembles and displays the results.

LINEAR_SOLVE_DISTRIBUTED, 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.

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

MATRIX_ASSEMBLE_SPMD, a MATLAB program which demonstrates the SPMD parallel programming feature by having each worker assemble part of the Hilbert matrix, which is then combined into one array by the client program.

PLOT_SPMD, a MATLAB library which demonstrates the SPMD parallel programming feature, by having a number of labs compute parts of a sine plot, which is then displayed by the client process.

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

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

### Reference:

The User's Guide for the Parallel Computing Toolbox is available at http://www.mathworks.com/access/helpdesk/help/pdf_doc/distcomp/distcomp.pdf

• Gaurav Sharma, Jos Martin,
MATLAB: A Language for Parallel Computing,
International Journal of Parallel Programming,
Volume 37, Number 1, pages 3-36, February 2009.

### Source Code:

• face_fun.m, a MATLAB function which carries out the operation.
• face_pool.m a script which uses the MATLABPOOL command to run the function locally and interactively.
• face_script.m, a MATLAB script file which simply invokes the function.
• face_batch_local.m, a batch command to run the job indirectly on the local system, plus a few more commands to monitor its progress, print the diary, and destroy the job at the end.
• face_batch_ithaca.m, a batch command to run the job indirectly on the Ithaca cluster, plus a few more commands to monitor its progress, print the diary, and destroy the job at the end.
• GRID.mat, a MAT file containing the coordinates of points, and the list of point indices that define tetrahedrons.
• channel.png, an image of the 3D region, dissected into tetrahedrons, with the Z=3 face highlighted.
• face.png, an image of the 2D boundary face Z=3, and the triangular faces that touch it.

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

Last revised on 22 June 2010.