You should be able to run MPI programs on any of our Linux machines. (Note that to use a machine as one of the MPI “hosts” it must be running Linux. You can check availability with the command ruptime; machines that show as “up” are available. Note however that output of this command includes both generally-available machines and some special-purpose machines such as faculty desktops and research machines to which you may not have access.)
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. See my notes on passwordless login for notes on how to do this.
If your account is set up according to our default scheme, the commands needed to compile and execute MPI programs will not be in the search path. This is deliberate, at least in part because more than one version of MPI is installed:
To get access to the version of MPI from the standard repositories, use the command
module load openmpi-default(See my notes on the “Modules package” for more about the module command.)
To get access to the latest version of MPI (which also uses the latest versions of the various compilers), use the command
module load openmpi-latestIf you do this, it's probably safest to also use the latest version of GCC as well; see my notes on the GNU compilers for how to do that.
Use the command mpicc to compile C programs using MPI functions. Simple usage:
mpicc -o foo foo.cRefer to the man page for other options. If you want to use make to compile, as recommended in my notes on the GNU compilers, a way to do so is by adding the following line to the Makefile:
CC=mpicc
To compile C++ programs using MPI functions, use mpiCC, mpic++, or mpicxx. (I'm not sure how these commands differ, if at all.) To compile using make, add the following line to the Makefile:
CXX=mpicxx
For those few of you who've heard of Fortran, be advised that you can use MPI from Fortran as well; compile with mpif77 or mpif90, depending on the version of Fortran.
Use the command mpirun to run an MPI program. Examples:
mpirun -np 4 --host host1,host2,host3,host4 ./foobarBoth commands start 4 processes, each running executable foobar. The first command starts them on machines listed, one process per machine. The second command reads machine names from the file list-of-hosts.txt. By default it seems to start multiple processes per machine, spreading them out as little as possible. The option -map-by node instead places them round-robin style using the list of machines. Refer to the man page for other options.
mpirun -np 4 --hostfile list-of-hosts.txt ./foobar
Note: If the list of “hosts” includes anything other than the machine on which you execute mpirun, MPI may not be able to find your programs and its libraries. (Symptoms of failure can vary, but the error messages seem to say in some way that there are executables that aren't being found.)
To fix this, you can either add the appropriate module load command to your .bashrc file, as described in my notes on the “Modules package”, or you can include the -prefix option, as in the following example:
mpirun -prefix $MPI_HOME -np 2 --host host1,host2 foobar($MPI_HOME is an environment variable set by the MPI modules.)
As with the C library functions, there are man pages for MPI-related commands and functions, though man will only find them if you've executed a module load command to get access to a version of MPI.