Practical details
There are several MPI-systems available. I have fetched and
compiled
the Open MPI-system
(an older version comes with the installed RedHat-system).
Update: May 17. There is a problem with OpenMPI and broadcasts. Use shared memory communication, so -mca btl
sm,self . It
works on the remote-computers and the math lab-computers. I don't know
yet what happens if you try to use more than one system.
This is how you use it:
- I have set up Open MPI in
/chalmers/sw/unsup/openmpi-1.4.1/bin
on the system
(not
www). You want
this path to come before
the
default version already installed in the system. Your LD_LIBRARY_PATH
must contain /chalmers/sw/unsup/openmpi-1.4.1/lib
. You find documentation on the web or under /chalmers/sw/unsup/openmpi-1.4.1/share
.
- Compile your program:
mpicc my_prog.c
or
mpiCC
my_prog.cc
or mpif90 my_prog.f90
or mpif77 my_prog.f
- To run on your own lab-computer (you can run several
processes even if the computer only has one CPU, but you do not get
true parallel computing of course, nor do you expect a speedup). In
this example we run two (-n 2) processes:
mpirun -n 2 -mca btl
tcp,self ./a.out
Using the mca-flag (MPI Component Architecture)
you can control how mpirun should do certain
things, e.g. what kind of communication software/hardware that
should be used. -btl tcp,self (btl
= byte transfer layer) informs mpirun
that tcp (transmission control protocol)
should be used, tcp is available on almost all
systems but may not be very fast. self is nedded
so that a process may communicate with itself. If your CPUs can
communicate through shared memory, you can try -mca btl
sm,self instead. On a more expensive system a high
performance network, like Infiniband may be available.
- To run on several computers, create a hostfile (named hostfile
in the example) containing a list of names of computers, one name per
row.
Suppose you want to run on one
of our parallel machines,
having four cpus. Login on such a machine and give the command hostname
,
this gives you the full Internet domain name of the parallel computer.
mpirun
-n 2 -hostfile hostfile -mca btl tcp,self ./a.out
Open MPI has many more options but the above are sufficient for this course.
