8.8.0. MPI: Message Passing Interface 1.1 |
This package enables Lush to utilize the MPI library. It's built on MPI standard 1.1 , and tested on RedHat 9, which comes with an MPI implementation named LAM/MPI version 6.5.8-4.
More information about the MPI Standard is available at http://www-unix.mcs.anl.gov/mpi/mpi-standard/mpi-report-1.1/mpi-report.html . Information about the LAM/MPI implementation is available at http://www.lam-mpi.org .
8.8.0.0. Installation |
First, you need to install the LAM/MPI (or any other MPI implementation). And start the MPI demon, e.g. under LAM:
lamboot -v hostfile
Then, configure and re-compile Lush with MPI support, on all the MPI hosts:
($LUSHDIR)/configure --with-mpi ($LUSHDIR)/make
Test the Lush/MPI by:
cd ($LUSHDIR)/packages/mpi/demos mpirun -np ($NUM_NODES) ($LUSHDIR)/bin/lush test00.lshand you should see greetings from computers participating the computing.
Currently, you cannot run Lush/MPI in interactive mode. You need only run a written script.
8.8.0.1. Programming |
(libload "mpi/mpi") (mpi-init) (setq a (int-matrix)) (mpi-comm-rank MPI_COMM_WORLD (idx-ptr a)) (if (= 1 (a)) (progn (printf "hello from 1.\n")) (printf "hello from 0.\n")) (mpi-finalize)
To use the MPI, first load in the Lush/MPI interface, as shown in the first line. Then initialize and finalize the MPI library as shown in the second and the last line.
The Lush/MPI interface follows strictly the MPI standard. For example, the MPI_Comm_rank function in the MPI standard is prototyped as:
int MPI_Comm_rank(MPI_Comm comm, int *rank);
And its Lush interface is defined as:
(de MPI_Comm_rank (comm rank) ((MPI_Comm) comm) ((-gptr- "int *") rank) (int #{ MPI_Comm_rank($comm, $rank) #}))
Therefore, in the script, you can write:
(setq a (int-matrix)) (mpi-comm-rank MPI_COMM_WORLD (idx-ptr a))where MPI_COMM_WORLD is a constant of type MPI_Comm , and (idx-ptr a) returns an integer pointer.
8.8.0.2. Different MPI implementations |
If you prefer to use other MPI implementation, say, MPICH , you need to modify the mpi-config.lsh file. Mostly, the job is to modify the implementation-dependent types:
MPI_Datatype MPI_Comm MPI_Aint MPI_Op MPI_Group MPI_Errhandler MPI_Request
For example, Change:
(defvar MPI_Datatype -gptr-) (defvar to-mpi-datatype to-gptr)to:
(defvar MPI_Datatype -int-) (defvar to-mpi-datatype to-int)since in MPICH , MPI_Datatype is typedef-ed as integer, instead of a generic pointer.