Running with mpirun


Up: Linking and running programs Next: More detailed control Previous: The mpicc and mpif77 commands

To run an MPI program, use the mpirun command, which is located in /usr/local/mpi/bin. For almost all systems, you can use the command

mpirun -np 4 a.out 
to 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).

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 program 
This 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.%a 
If 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/program 
It 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.



Up: Linking and running programs Next: More detailed control Previous: The mpicc and mpif77 commands