What's New - Still a dummy text...?

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nam iaculis adipiscing mi. Nulla vulputate mi at lorem. Fusce tincidunt dui non lectus euismod faucibus.

Learn more…

MPI Overview

July 29, 2010

This is a short introduction to configuring and using the Message Passing Interface for distribution of processing tasks on multiple processing entities (called "processor"). Later, processes are assigned to processors (which process on what processor is decided by the MPI implementation).

The processors may be assigned to a single physical CPU, to multiple cores on a single PC or even to multile cores on distributed resources. At startup of a distributed application, we only specify how many processors are to be used. Per default, MPI then decides on which physical machine the processors get instantiated.

Configuring Your MPI Environment

August 3, 2010

By now, you should have installed the MPICH2 implementation of the Message Passing Interface standard. If you haven't done that yet, read the tutorial on third-party dependencies or simple type into a terminal:

sudo aptitude install libmpich2-dev

Thereafter, all necessary tools should be available on your system. So we can now start to configure the environment. Basically, we just need to create a secret configuration file on all connected PCs and run the MPI-daemon.

  1. Create the MPI configuration file in your home directory:
    cd $HOME
    touch .mpd.conf
    chmod 600 .mpd.conf
    and then use an editor to insert a line like:
    MPD_SECRETWORD=[mysecretword]
  2. Start the MPI-daemon with something like:
    mpd --listenport=12345 &
  3. Start it on the slaves (make other computers join the ring):
    mpd --host=[master] --port=12345 --ifhn=[local-ip] --listenport=12345 &
  4. Check for connected ring-members with (should be only one - the master at this point):
    mpdtrace -l
  5. To disconnect a computer from the MPI-ring you can use mpdexit or mpdallexit, to shutdown the MPI daemon. For mpdexit, you can obtain the identifier for a computer with mpdtrace -l:
    mpdexit [computer]

The following scripts can be used to start the MPI-ring master and slaves. The script checks whether an instance of the daemon is running and starts it on port 12345, if this is not the case. It uses the IP-address obtained from your first Ethernet-device eth0.

Execution of Distributed Programs

August 3, 2010

Before being able to execute a program within an MPI-ring, we need to make sure that the resources (the executable) is available on all members of the ring.

Most likely, this means you have a network file-server computer somewhere, probably running Samba. If this is the case, you only need to mount a network share to your local filesystem using smbmount:

sudo smbmount \
//[server-ip]/[share] $HOME/Cluster -o username=[user],uid=1000,mask=000

NB: The above command fails, if the folder $HOME/Cluster doesn't exist, so create it before you try to mount!

Now we can run a distributed application invoking the mpiexec command from the MPICH2 pacakge. For example, the following command shows how to run a program on two processors, not passing any arguments to the application:

mpiexec -n 2 $HOME/Cluster/[executable]

Advanced Distributed Execution

August 3, 2010

Sometimes it is useful, to install an application completely to the $HOME/Cluster folder, in order to make it available for everyone. In this way, you can for example also provide additional, specific libraries to your application or provide a data-folder for IO-operations. The following folder structure is suggested for this purpose:

$HOME/Cluster/
            |-- bin/
            |-- lib/
            |-- data/ 

Let's say you built your application (see the Getting-Started tutorial for details) and you use dynamic linking to a library libMyLib.so available from $HOME/Cluster/lib/libMyLib.so. To make the system discover that library, you need to modify the LD_LIBRARY_PATH and pass it to the mpiexec tool:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"$HOME/Cluster/lib"
mpiexec -genvlist LD_LIBRARY_PATH -n 2 [executable]

The mpiexec offers a lot more options, to learn more about them, type man mpiexec into a terminal.

For using command-line arguments with mpiexec, you just append them to the command. For example, if you want to pass the path to a file configuration.xml, you could do something like:

cd $HOME
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"$HOME/Cluster/lib"
mpiexec -genvlist LD_LIBRARY_PATH -n 2 [executable] configuration.xml

A last remark: if you want to debug a MPI-application, you can attach the executable to gdb on all processors (it displays outputs on your localhost with:

mpiexec -gdb -genvlist LD_LIBRARY_PATH -n 2 [executable] [args]*

Having learnt so much about MPI, you may now want to setup your IDE and build your first application with the Flexible Robotics Framework.