Parallel Programming Guide for HP-UX Systems

MPI
Running
Chapter 226
where
#
is the number of processors and
program
is the name of your application.
Suppose you want to build a C application called poisson and run it using five processes to do
the computation. To do this, use the following command sequence:
% $MPI_ROOT/bin/mpicc -o poisson poisson.c
% $MPI_ROOT/bin/mpirun -np 5 poisson
prun also supports running applications with SPMD. Please refer to the prun documentation
at http://www.quadrics.com.
Running MPMD applications A multiple program multiple data (MPMD) application uses
two or more separate programs to functionally decompose a problem.
This style can be used to simplify the application source and reduce the size of spawned
processes. Each process can execute a different program.
To run an MPMD application, the mpirun command must reference an appfile that contains
the list of programs to be run and the number of processes to be created for each program.
A simple invocation of an MPMD application looks like this:
% $MPI_ROOT/bin/mpirun -f
appfile
where
appfile
is the text file parsed by mpirun and contains a list of programs and process
counts.
Suppose you decompose the poisson application into two source files: poisson_master (uses a
single master process) and poisson_child (uses four child processes).
The appfile for the example application contains the two lines shown below (refer to “Creating
an appfile” on page 42 for details).
-np 1 poisson_master
-np 4 poisson_child
To build and run the example application, use the following command sequence:
% $MPI_ROOT/bin/mpicc -o poisson_master poisson_master.c
% $MPI_ROOT/bin/mpicc -o poisson_child poisson_child.c
% $MPI_ROOT/bin/mpirun -f
appfile
See “Creating an appfile” on page 42 for more information about using appfiles.