2
votes

I'm using MPI to execute a parallel job over a heterogeneous compute system. The nodes in my network are not all identical.

I would like to specify that machine 'A.univ.edu' has rank 0 and machine 'B.univ.edu' has rank 1.

Is there any way to specify how ranks are assigned to hosts in MPI?

3
Rank assignment in MPI_COMM_WORLD is controlled by mpiexec. The details differ a bit between MPI implementations, so refer to the man page. In the example with the two hosts, you would just list them in that order in the machinefile.Greg Inozemtsev

3 Answers

4
votes

It looks like at least OpenMPI allows you to specify a rankfile

The above example would be as follows

rankfile.txt:
rank 0=A.univ.edu slot=0
rank 1=B.univ.edu slot=0

mpiexec -np 2 -H A.univ.edu,B.univ.edu -rf rankfile.txt executable.exe

http://mirror.its.dal.ca/openmpi/doc/v1.5/man1/mpiexec.1.php#sect9

2
votes

If all else fails, you can always use MPI_Comm_split to create a new communicator in which your processes all have the desired rank. After each process has determined its intended rank (stored in, say, newRank), a call to MPI_Comm_split(MPI_COMM_WORLD, 0, newRank, newComm) will create a communicator in newComm with the proper ordering. You can then use that communicator instead of MPI_COMM_WORLD in all your communication calls.

0
votes

You can use the "-rank-by node" switch. This will cause the processes to be mapped in the order the hosts were specified.