ParadisEO - PEO Technical introduction
The aim of this webpage is to show you in easy steps how to run an already implemented MPI program with ParadisEO-PEO. The attention of the reader is drawn to the fact that the current explanations are library dependent which is, in our case, MPICH2. The user who is using another MPI2 library might want to refer to its documentation to run his programs. However, the major guidelines here are implementation independent.
The ParadisEO-PEO package and the library MPICH2 or MPICH-G2 (the MPI implementation dedicated to Globus environment) have to be installed on your computer.
Mapping of resource
To be able to communicate, the various processes need to follow a mapping of communication. This mapping is defined by an XML file called schema.xml
<group scheduler="0"> <node name="0" num_workers="0"> </node> <node name="1" num_workers="0"> <runner>1</runner> </node> <node name="2" num_workers="1"> </node> <node name="3" num_workers="1"> </node> </group>
There are four nodes here. The first one has the role of scheduler. The second one is the node on which the algorithm is actually executed. The third and the fourth ones are slave nodes.
If you want to use an other slave node, add:
<node name="4" num_workers="1"> </node>
If you want to use an other algorithm (island model), add:
Non-distributed <node name="1" num_workers="0"> <runner>1</runner> <runner>2</runner> </node> Distributed <node name="1" num_workers="0"> <runner>1</runner> </node> <node name="2" num_workers="0"> <runner>2</runner> </node>
Now you need to configure your environment to run your program. To do so, you need :
First step : A password free environment
When running a program on several machines, it is quite tedious to have to enter your password for each machine each time. To avoid doing this, you first need to go to your .ssh/ directory and generate a public key using the ssh keygen command
ssh-keygen -t rsa -f identity
A file identity.pub is created containing your key. You need, then, to copy your ssh key into the authorized_keys file. If no authorized_keys file is present, this should create one
cat identity.pub >> authorized_keys
Eventually, your public key should now be copied in all the machines you want to run your program on. This can be done by typing
scp ~/.ssh/identity.pub user@machine1:~/.ssh/ scp ~/.ssh/identity.pub user@machine2:~/.ssh/ . . . scp ~/.ssh/identity.pub user@machineN:~/.ssh/
and then adding the public key into the authorized_keys in the same way we did it on our local machine.
Second step: Launch MPD deamons
To run your MPI program, you need to launch an MPD deamon. If you wish to do so on your own machine, then, this can be done simply by typing either
If, however, you want to use more than one machine, it is important to know these options:
mpdboot --totalnum=<n_to_start> --file=<hosts>
or as a short hand
mpdboot -n n_to_start -f hosts
--totalnum specifies the total number of mpds to start; at least one mpd will be started locally, and others on the machines specified by the file argument; by default, only one mpd per host will be started even if the hostname occurs multiple times in the hosts file --file specifies the file of machines to start the rest of the mpds on; it defaults to mpd.hosts
The host file should look something like this, i.e, one IP address per line:
22.214.171.124 126.96.36.199 188.8.131.52 184.108.40.206
The parameter -n N must be lower or equal to the number of machines in the host file. If it is strictly lower than the number of machines it starts MPD deamon on the N first hosts in the host file.
Third step: Run the program
To run a program, we need to use mpiexec. The call of mpiexec is done as follow:
mpiexec [global args] [local args] executable [args]
As for mpdboot, there are some important parameters one should know. For instance, for global arguments, it is worthwhile to highlight
-machinefile # file mapping procs to machines -gdb # run procs under gdb
and for local arguments, one must know
-n <n> or -np <n> # number of processes to start -wdir <dirname> # working directory to start in
The machine file maps hosts to processes, i.e, it tells mpiexec how many processes to run on each host. An example of such a file could be
hostA hostB:2 hostC:4 hostD
hostX is an IP address or a local alias of a machine. Let us say, for the sake of example, that our machine file is called hosts and that we have to run a program called myProgram
mpiexec -machinefile hosts -n 8 myProgram
Hence, the process of rank 0 is to be executed on hostA, processes of rank 1 and 2 are run on hostB, process rank from 3 to 6 are run on hostC and finally the last process of rank 7 is run on hostD. The option -gdb is particularly useful when debugging an MPI program. The -wdir option is very useful when your program needs to first go to some directory and then run the executable. It actually goes beyond that, suppose you need to run different programs on different machines, e.g., myProgram1, myProgram2 and myProgram3 which all are in different directories, let us say, directory1, directory2 and directory3. Then,
mpiexec -machinefile hosts -wdir directory1 -n 2 myProgram1 : -wdir directory2 -n 4 myProgram2 : -wdir directory3 -n 2 myProgram3
This tells to mpiexec to "cd" first to directory1 on host1 in the hosts file and then run myProgram1 with two processes. The same process is repeated on all hosts, e.g, on host2 mpiexec moves to directory2 and run myProgram2 wih four processes. On host3, it goes to directory3 and run myProgram3 with 2 processes.
In the tutorials included, we tackle the Quadratic Assignment Problem. Therefore, looking at the explanation in the quick start? would greatly help your understanding. Of course, if you are familiar with this problem you can go ahead to lesson 1?