Message Passing Interface (MPI) is an API for allowing processes to communicate to one another. This page will help you get MPI programs running on the department Linux machines.
For a reference on the API see MPI: The Complete Reference.
Download these files to follow along with the examples:
Makefile
helloworld.c
You can type the following commands into the shell or add them to your .bashrc. If you add them to your .bashrc you will need to source ~/.bashrc or open a new shell before continuing.
Use mpicc to compile, example:
You can also use the provided Makefile. mpicc is basically a wrapper for gcc which adds some libraries necessary for MPI. You can use any flags you would normally use with gcc by passing them to mpicc.
Note: If you get an error like mpicc: command not found, you
did not setup your
environment correctly.
This will run the example program with 2 processes. You should see something
like:
Hello World! My process id is 0 of 2 processes
Hello World! My process id is 1 of 2 processes
Experiment with different
values for -np.
You should note that you can specify as many processes as you want no matter how many processors the machine has. If you launch more processes than the number of processors, some processes will stall until a processor becomes available. Keep this in mind when experimenting with your own code.
The machines list wil let you know how many processors each machine has. It is recommended you run on machines located in 120 (8 core) or 315 (4 core).