CSCI 3366 (Introduction to Parallel and Distributed Processing), Spring 2009:
Using MPI on the Linux Lab Machines

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 the new 16-processor machine (Dione00). Note that multiboot machines must be running Linux to be usable for this purpose.

Setting up your account

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. Generate a key for SSH with the following command:

ssh-keygen -t dsa

This creates files $HOME/.ssh/id_dsa and $HOME/.ssh/id_dsa.pub. Add the new key to the list of authorized keys by editing file $HOME/.ssh/authorized_keys2 and inserting the text from $HOME/.ssh/id_dsa.pub (as a separate line).

Check that all of this is set up properly by using ssh to execute a simple command on another machine, e.g.,

ssh xena00 hostname

If everything is set up properly, the command will execute and you will not be prompted for a password. (The first time you try this for each machine, you'll get some messages ending with a prompt ``are you sure'' etc. Answer ``yes'', and the next time you should not be prompted.)

If you still get prompted for a password, the problem may be file/directory permissions. A setup that works is to make the .ssh directory and its contents accessible only to you (chmod -R go= ~/.ssh) and to make sure your home directory is not group-writable (chmod g-w ~).

Compiling MPI programs

Use the command mpicc to compile C programs using MPI functions. Typical usage:

mpicc -o foo foo.c

Refer to the man page for other options.

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 Fortran programs using MPI functions, use mpif77 or mpif90.

Running MPI programs

Use the command mpirun to run an MPI program. Typical usage:

mpirun -np 10 -host host1,host2 foobar

mpirun -np 10 -hostfile list-of-hosts foobar

Both commands start 10 processes, each running executable foobar. The first command starts them on machines host1 and host2; the second command reads machine names from the file list-of-hosts. Refer to the man page for other options.

Online documentation

Use the command man to display UNIX-style man pages for MPI-related commands and routines. Typical usage:

man MPI_Send

Useful links



Berna Massingill
2009-01-27