You should be able to run MPI programs on any of the CS department's Linux machines, including those in HAS 228 (Janusxx, where xx ranges from 00 through 21), those in HAS 340 (Xenaxx, where xx ranges from 00 through 21), those in HAS 329 (Atlasxx, where xx ranges from 00 through 09), and a cluster of Linux-only machines (SnowWhite and Dwarfn, where n ranges from 1 through 7). Note that multiboot machines must be running Linux to be usable for this purpose.
As of Spring 2002, the version of Linux installed on these machines includes two implementations of MPI, MPICH and LAM MPI. For completeness, this document describes how to use both. Preliminary investigation suggests that the LAM implementation is faster, but can be slightly more trouble to use.
In order for MPI to start processes on other machines, your account must be set up so that MPI can remotely log into the other machines without prompting for a password. The easiest way to ensure this is by creating a file .rhosts in your home directory containing a list of machine/username combinations from which such logins should be allowed. The file should look something like this with yourUserName replaced by your username.
Warning: To avoid a serious security hole, BE SURE that the permissions on this file do not allow others to modify it! You can be sure this is the case with the following command:
chmod go= .rhosts
The MPI-related commands for the LAM implementation are installed in one of the standard system directories (/usr/bin), so if you simply type, for example, mpicc to invoke the MPI C compiler, you will get the compiler for the LAM implementation. The equivalent commands for the MPICH implementation are installed in /usr/local/mpich-1.2.1/bin. It is probably easiest to invoke them by specifying the full path name (e.g., /usr/local/mpich-1.2.1/bin/mpicc). You can use a Makefile and scripts to avoid actually having to type out the full pathname every time you compile or run a program. See the sample programs page for examples.
Use the command mpicc to compile C programs using MPI functions.
mpicc -o foo foo.c
Use the command mpiCC to compile C++ programs using MPI functions.
mpiCC -o bar bar.cpp
mpiCC -o bar bar.cpp -llammpi++.
Use the command mpirun to run an MPI program.
mpirun -np 10 foobar
(Starts 10 processes, each running executable foobar.)
mpirun -np 10 -machinefile MPIhosts foobar
The file MPIhosts should look something like this.
All the machines in MPIhosts should be ``up'' when this command is run. You can use script make-MPIhosts to generate this file based on machines that are currently up.
Before running an MPI program using the LAM implementation, use the command lamboot to start up the runtime environment. (You only need to do this once per login session. When you are finished running MPI programs, use the lamhalt command to shut things down again.)
lamboot -b -v MPIhosts
where MPIhosts specifies the hostnames of machines to be used; in its simplest form, it can look like the file used for a similar purpose in the MPICH implementation, i.e., like this.
After running MPI programs using the LAM implementation, use the command lamhalt to shut down the processes started by lamboot.
lamhalt
wipe -b -v MPIhosts
if [ ! -z "`ps aux | grep lamd | grep $USER | grep -v grep`" ]
then
lamhalt
fi
Use the command man to display UNIX-style man pages for MPI-related commands and routines.
man MPI_Send
man -M /usr/local/mpich-1.2.1/man MPI_Send
The MPICH implementation also provides a command mpiman that allows Web-style browsing of documentation for all MPI-related commands and functions.
mpiman -netscape