To run an MPI program, use the mpirun command, which is located in
/usr/local/mpich/bin . For almost all systems,
you can use the command
mpirun -np 4 a.outto run the program a.out on four processors. The command mpirun -help gives you a complete list of options, which may also be found in Appendix Options for mpirun .
On exit, mpirun returns a status of zero unless mpirun detected a problem, in which case it returns a non-zero status (currently, all are one, but this may change in the future).
When using a cluster of symmetrix multiprocessors (SMPs) with the ch_p4
device (configured with -comm=shared, you can control the number of
processes that communicate with shared memory on each SMP node.
First, you need to modify the machines file (see
Section Workstation clusters
) to indicate the number of processes that should
be started on each host. Normally this number should be no greater than the
number of processors; on SMPs with large numbers of processors, the number
should be one less than the number of processors in order to leave one
processor for the operating system. The format is simple: each line of the
machines file specifies a hostname, optionally followed by a colon (:)
and the number of processes to allow. For example, the file containing the
lines
mercury venus earth mars:2 jupiter:15specifies three single process machines (mercury, venus, and earth), a 2 process machine (mars), and a 15 process machine (jupiter).
By default, mpirun will only use one process on each machine (more precisely, it will not use shared memory to communicate between processes). By setting the environment variable MPI_MAX_CLUSTER_SIZE to a positive integer value, mpirun will use upto that many processes, sharing memory for communication, on a host. For example, if MPI_MAX_CLUSTER_SIZE had the value 4, then mpirun -np 9 with the above machine file create one process on each of mercury, venus, and earth, 2 on mars (2 because the machines file specifies that mars may have 2 processes sharing memory) and 4 on jupiter (because jupiter may have 15 processes and only 4 more are needed). If 10 processes were needed, mpirun would start over from the beginning of the machines file, creating an additional process on mercury; the value of MPI_MAX_CLUSTER_SIZE prevents mpirun from starting a fifth process sharing memory on jupiter.
When using the p4 device in workstation clusters,
multiple architectures may be handled by giving multiple -arch
and
-np arguments. For example, to run a program on 2 sun4s and 3 rs6000s,
with the local machine being a sun4, use
mpirun -arch sun4 -np 2 -arch rs6000 -np 3 programThis assumes that program will run on both architectures. If different executables are needed, the string '%a' will be replaced with the arch name. For example, if the programs are program.sun4 and program.rs6000, then the command is
mpirun -arch sun4 -np 2 -arch rs6000 -np 3 program.%aIf instead the execuables are in different directories; for example, /tmp/me/sun4 and /tmp/me/rs6000, then the command is
mpirun -arch sun4 -np 2 -arch rs6000 -np 3 /tmp/me/%a/programIt is important to specify the architecture with -arch before specifying the number of processors. Also, the first arch command must refer to the processor on which the job will be started. Specifically, if -nolocal is not specified, then the first -arch must refer to the processor from which mpirun is running.
When running on multiple machines using the globus2 device, mpirun is also used, but different techniques are used to control how executables are selected. See Section Computational Grids: the globus2 device and Appendix mpirun and Globus for details.