Run MPI On Grid'5000: Difference between revisions

From Grid5000
Jump to navigation Jump to search
No edit summary
Line 6: Line 6:
= Running MPI on Grid'5000 =
= Running MPI on Grid'5000 =
When attempting to run MPI on Grid'5000 you'll be faced with a number of challenges, ranging from classical setup problems for MPI software to problems specific to Grid'5000. This practical session aims at driving you through the most common uses cases, which are
When attempting to run MPI on Grid'5000 you'll be faced with a number of challenges, ranging from classical setup problems for MPI software to problems specific to Grid'5000. This practical session aims at driving you through the most common uses cases, which are
* setting up and starting mpich-2 on a default environment using allow_classic_ssh  
* setting up and starting openMPI on a default environment using allow_classic_ssh  
* setting up and starting mpich-2 on a default environment using oash
* setting up and starting openMPI on a default environment using oarsh
* setting up and starting mpich-2 on a kadeploy image
* setting up and starting openMPI on a kadeploy image
* setting up and starting mpich-2 to use high performance interconnect
* setting up and starting openMPI to use high performance interconnect
* setting up openMPI to accept private networks as routable between hosts


=Pre-requisite=
=Pre-requisite=
* Basic knowledge of MPI; if you don't know MPI, you can read: [[Grid_computation]]
* Basic knowledge of MPI; if you don't know MPI, you can read: [[Grid_computation]]
* Get Mpich2 here : http://www.mcs.anl.gov/research/projects/mpich2/downloads/index.php?s=downloads
* Get OpenMPI here : http://www.open-mpi.org/software/ompi/v1.4/
 
=Overwiew
Currently, the default environment is not the same on every sites, therefore, you don't have the same version of openmpi on every site. If you want to use OpenMPI for a grid experiment, you will have to install your own MPI version; You have two possibility:
* install  Openmpi on your home dir (but you should recompile and install on a all the sites you want to use! )
* use the same kadeploy image and deploy it on the the sites you want to use
 
If you are only interested on a single site experiement, you may use the version providede by the default environment.
 
=Compilation=
* Make a reservation (or connect to the compilation machine if available (compil.<node>.site.grid5000.fr) and compile it with the option you like.
* Make a reservation (or connect to the compilation machine if available (compil.<node>.site.grid5000.fr) and compile it with the option you like.
  mkdir -p $HOME/src/mpi
  mkdir -p $HOME/src/mpi
  oarsub -I   
  oarsub -I   
  ./configure --enable-echo --prefix=$HOME/mpich2-1.0.8 --enable-sharedlibs=none
  ./configure --prefix=$HOME/openmpi/  --with-memory-manager=none
  make
  make -j4
* Install it on your home directory
* Install it on your home directory
  make install
  make install
* Setup the libraries
Add specific environment variable to be able to use you mpich2 version :
$ vi ~/.bashrc
export LIBDIR=$PATH:$HOME/mpich2-1.0.8/lib
export PATH=$PATH:$HOME/mpich2-1.0.8/bin:$HOME/mpich2-1.0.8/sbin
* Setup mpd (you may have a more complex configuration)
echo MPD_SECRETWORD=password >>$HOME/.mpd.conf


=Setting up and starting mpich-2 on a default environment using allow_classic_ssh=
=Setting up and starting OpenMPI on a default environment using allow_classic_ssh=
* oarsub -I -t allow_classic_ssh -l nodes=3
* oarsub -I -t allow_classic_ssh -l nodes=3
* Code to test :
* Code to test :
Line 63: Line 64:


* Compile your code  
* Compile your code  
  $ $HOME/mpich2-1.0.8/bin/mpicc src/mpi/tp.c -o src/mpi/tp
  $ $HOME/openmpi/bin/mpicc src/mpi/tp.c -o src/mpi/tp


* Use this script to launch
* Use this script to launch
Line 70: Line 71:
  NPROCS=`wc -l < $OAR_NODEFILE | tr -d ' '`
  NPROCS=`wc -l < $OAR_NODEFILE | tr -d ' '`
  echo "nprocs= $NPROCS"
  echo "nprocs= $NPROCS"
  $HOME/mpich2-1.0.8/bin/mpdboot --rsh=ssh --totalnum=$NODES --file=$OAR_NODEFILE
  $HOME/openmpi/bin/mpdboot --rsh=ssh --totalnum=$NODES --file=$OAR_NODEFILE
  sleep 1
  sleep 1
  $HOME/mpich2-1.0.8/bin/mpirun -n $NPROCS $HOME/src/mpi/tp
  $HOME/openmpi/bin/mpirun -n $NPROCS $HOME/src/mpi/tp


= Setting up and starting mpich-2 on a default environment using <code class=command>oarsh</code> =
= Setting up and starting mpich-2 on a default environment using <code class=command>oarsh</code> =
Line 82: Line 83:
Now, you can try to create a kadeploy environment with mpich2 installed on it an then deploy a set of three machines to launch the mpi code in the previous section.
Now, you can try to create a kadeploy environment with mpich2 installed on it an then deploy a set of three machines to launch the mpi code in the previous section.


= Setting up and starting mpich-2 to use high performance interconnect =
= Setting up and starting OpenMPI to use high performance interconnect =
== Myrinet hardware : [http://www.myri.com/scs/download-mpichmx.html MPICH-MX] ==
== Myrinet hardware : [http://www.myri.com/scs/download-mpichmx.html MPICH-MX] ==
* oarsub -I -l nodes=3 -p "myri2g='YES'"
* oarsub -I -l nodes=3 -p "myri2g='YES'"

Revision as of 16:52, 2 February 2010

Warning.png Warning

Practical session under construction.

Running MPI on Grid'5000

When attempting to run MPI on Grid'5000 you'll be faced with a number of challenges, ranging from classical setup problems for MPI software to problems specific to Grid'5000. This practical session aims at driving you through the most common uses cases, which are

  • setting up and starting openMPI on a default environment using allow_classic_ssh
  • setting up and starting openMPI on a default environment using oarsh
  • setting up and starting openMPI on a kadeploy image
  • setting up and starting openMPI to use high performance interconnect

Pre-requisite

=Overwiew Currently, the default environment is not the same on every sites, therefore, you don't have the same version of openmpi on every site. If you want to use OpenMPI for a grid experiment, you will have to install your own MPI version; You have two possibility:

  • install Openmpi on your home dir (but you should recompile and install on a all the sites you want to use! )
  • use the same kadeploy image and deploy it on the the sites you want to use

If you are only interested on a single site experiement, you may use the version providede by the default environment.

Compilation

  • Make a reservation (or connect to the compilation machine if available (compil.<node>.site.grid5000.fr) and compile it with the option you like.
mkdir -p $HOME/src/mpi
oarsub -I  
./configure --prefix=$HOME/openmpi/  --with-memory-manager=none
make -j4
  • Install it on your home directory
make install

Setting up and starting OpenMPI on a default environment using allow_classic_ssh

  • oarsub -I -t allow_classic_ssh -l nodes=3
  • Code to test :
$ mkdir -p $HOME/src/mpi
$ vi $HOME/src/mpi/tp.c
#include <stdio.h>
#include <mpi.h>
#include <time.h> /* for the work function only */

int main (int argc, char *argv []) {
       char hostname[257];
       int size, rank;
       int i, pid;
       int bcast_value = 1;

       gethostname (hostname, sizeof hostname);
       MPI_Init (&argc, &argv);
       MPI_Comm_rank (MPI_COMM_WORLD, &rank);
       MPI_Comm_size (MPI_COMM_WORLD, &size);
       if (!rank) {
            bcast_value = 42;
       }
       MPI_Bcast (&bcast_value,1 ,MPI_INT, 0, MPI_COMM_WORLD );
       printf("%s\t- %d - %d - %d\n", hostname, rank, size, bcast_value);
       fflush(stdout);

       MPI_Barrier (MPI_COMM_WORLD);
       MPI_Finalize ();
       return 0;
}


  • Compile your code
$ $HOME/openmpi/bin/mpicc src/mpi/tp.c -o src/mpi/tp
  • Use this script to launch
NODES=`uniq < $OAR_NODEFILE | wc -l | tr -d ' '`
echo "nodes = $NODES"
NPROCS=`wc -l < $OAR_NODEFILE | tr -d ' '`
echo "nprocs= $NPROCS"
$HOME/openmpi/bin/mpdboot --rsh=ssh --totalnum=$NODES --file=$OAR_NODEFILE
sleep 1
$HOME/openmpi/bin/mpirun -n $NPROCS $HOME/src/mpi/tp

Setting up and starting mpich-2 on a default environment using oarsh

  • oarsub -I -l nodes=3

oarsh is the default connector used when you reserve a node. To be able to use this connector, you need to specify it on the mpdboot command line. So you can use exactly the same script than for the previous allow_classic_ssh part and replacing --rsh=ssh by --rsh=oarsh.

Setting up and starting mpich-2 on a kadeploy image

  • oarsub -I -t deploy -l nodes=3

Now, you can try to create a kadeploy environment with mpich2 installed on it an then deploy a set of three machines to launch the mpi code in the previous section.

Setting up and starting OpenMPI to use high performance interconnect

Myrinet hardware : MPICH-MX

  • oarsub -I -l nodes=3 -p "myri2g='YES'"

or

  • oarsub -I -l nodes=3 -p "myri10g='YES'"

Infiniband hardware : MVAPICH

  • oarsub -I -l nodes=3 -p "ib10g='YES'"

or

  • oarsub -I -l nodes=3 -p "ib20g='YES'"

Setting up openMPI to accept private networks as routable between hosts

OpenMpi site : OpenMPI

  • Connect on one site and reserve a node
ssh nancy.grid5000.fr
oarsub -I
  • Connect to another site and reserve a node
ssh rennes.grid5000.fr
oarsub -I
  • Try to launch the code that you previously create between the two reserved nodes