ParallelComputing
LAM/MPI
In order to use the LAM (Local Area Multicomputer) implementation of the MPI (Message Passing Interface) standard, a user specifies a set of machines and cpus to include in their LAM/MPI virtual cluster. The user then creates (aka "boots") the virtual cluster (aka "world") and proceeds to run LAM specific applications in this virtual world. Special commands are used to compile c, c++, and fortran applications to be run in a LAM world. The user must be sure to halt the world when they are finished using it, or LAM processes will continue to run on the cluster nodes.
- Hostfile: This is a text file containing the list of clients that will be used. Include the number of CPU per client and whether a node can be used to run jobs or whether it is a controller node. Sample entries from a host file are included below.
-
kimclust43 cpu=2
kimclust44 cpu=1
kimclust45 cpu=2
kimclust10 schedule=no
- Compile applications: To compile an application for use in a LAM world, the user must use the LAM/MPI specific compilers.
-
mpicc
mpiCC or mpic++
mpif77
- Launch the LAM world:
lamboot {hostfile}
- Run program on node X:
mpirun nX {app}
- Run program on cpu X:
mpirun cX {app}
- Run a non-MPI program (ex 'uptime' or 'hostname'):
lamexec [C|N|-np {num}] {app}
- View running tasks:
mpitask
- View list of nodes and cpus in world:
lamnodes
- Ping each of the nodes in the world:
tping N
- Remove all running programs within a world (useful when a program crashes):
lamclean
- Close a LAM world:
lamhalt
- Execute LAM application without launching the world:
mpiexec -machinefile {hostfile} {app}
- Execute LAM application on every CPU in LAM world:
mpiexec -machinefile {hostfile} C {app}
- Execute LAM application on every NODE in LAM world:
mpiexec -machinefile {hostfile} N {app}
- Execute LAM application on specific number of nodes in LAM world:
mpiexec -machinefile {hostfile} -np {num} {app}
- Environment variables that begin with "LAM_MPI_" are passed to all remote nodes.
- PDF documentation can be viewed here. Other useful documentation can be found at:
http://www.lam-mpi.org/about/overview/
- Sample C applications can be found in /home/public/lam on the kim cluster. A makefile is included in this directory and can be used to compile these programs. It is recommended that the user copy these files to their own directory and experiment with them.
- hello.c: This is a simple "Hello world" type application.
- endless.c: This is a simple application that will continuously run. The user must manually kill the application.
- simple.c: This application demonstrates message passing between nodes.
- comples.c: This application demonstrates how to create a master/slave type interaction across nodes.
An example of compiling and running the hello.c program:
- Create the list of machines to include in the LAM virtual world.
-
[fisher@kimclust11 tmp]$ echo "kimclust42 cpu=1" > hosts
[fisher@kimclust11 tmp]$ echo "kimclust43 cpu=1" >> hosts
- Copy hello.c from the public directory to the current directory and compile the program (producing the executable "a.out").
-
[fisher@kimclust11 tmp]$ cp /home/public/lam/hello.c .
[fisher@kimclust11 tmp]$ mpicc hello.c
- Run the executable in the virtual world. Using the command "mpiexec" instead of "lamboot", simplifies the running of a single program. If you need to run multiple programs or want to have more control over the running processes, then you should use "lamboot" to create the virtual world and "lamhalt" to destroy the virtual world when you are finished. It is not necessary to use "lamhalt" when you use "mpiexec".
-
[fisher@kimclust11 tmp]$ mpiexec -machinefile hosts a.out