Running an MPI Program


Up: Contents Next: Special Considerations for Running on a Network of Workstations Previous: Building multiple devices or architectures

In order to make running programs on parallel machines nearly as portable as writing them, the environment distributed with mpich contains a script for doing so. It is the mpirun command, found in the mpich/bin directory. Several of the examples directories already have symbolic links to this command, but eventually you might want to add it to your path, with (assuming your shell is the C shell)

set path=($path /home/me/mpich/bin) 
More details on mpirun can be found in Section  mpirun, a Portable Startup Script . If you are going to run on a network of workstations, you will need a machines.xxxx file in mpich/util/machines; see Section Special Considerations for Running on a Network of Workstations for details. Systems that use various kinds of filesystem automounters may need to make small changes to these programs; these are detailed in Section Dealing with automounters .

Some simple MPI programs will have been built during the compilation process. They are in the directory mpich/examples/basic and contain a C and a Fortran program for estimating . So change to that directory and do

mpirun -np 4 cpi 
to run the C version, and
mpirun -np 4 fpi 
to run the Fortran version. At this point, you have minimally tested your installation of mpich. You might also want to check out the performance of MPI on your system. You can do a crude check by running the program systest, also found in the examples/basic directory. To try it, do:
make systest 
    mpirun -np 2 systest 
For a more precise benchmark, see Section Benchmarking  mpich .

Another program in the examples/basic subdirectory is cpilog. This program uses some of the routines from the MPE library; you must have configured with the -mpe option. If you make it and run it, it will produce a simple log file that can be viewed with the program analysis tool upshot. To do so, you may need to build upshot with

make upshot 
in the top level MPICH directory. Note that upshot requires the tk shell wish. To use upshot to view a log file, do
make cpilog 
    mpirun -np 4 cpilog  
    upshot cpilog.log 
The log file produced by cpilog is not very interesting, since cpi is such a simple program. Many interesting logfiles can be found in the profiling/upshot/logfiles subdirectory. The file cpilog.c demonstrates how to instrument your own code for producing such logs. The Users guide [5] describes how to link with a version of mpich that produces them automatically. For a short description of the programs in the examples/basic directory, see the README file there. The logging routines are part of mpe, so be sure that your configuration has been done with the -mpe option.



Up: Contents Next: Special Considerations for Running on a Network of Workstations Previous: Building multiple devices or architectures