Q:

Open MPI, determine rank of process to send to

I have two different executables each with a specific role. One of the two processes sends the other information by calling MPI_isend. But how do I know the rank of the other process?
I found out that when I run my stack as follows, that exe1, the receiving process, seems to always have rank 0, exe2 seems to always have rank 1. Therefore, if I send to rank 0 from exe2, the message is received. But am I missing anything here, it seems so complicated?
mpirun -np 1 exe1 : -np 1 exe2

A:

Mapping of processes to ranks in Open MPI can be controlled with various CLI arguments to mpiexec with newer versions (like 1.7.x) supporting much finer control than older versions. By default ranks follow the order in which processes are placed in the slots provided. Therefore -np 1 exe1 : -np 1 exe2 will always result in exe1 being rank 0 and exe2 being rank 1 in MPI_COMM_WORLD. If you use -np 3 exe1 : -np 2 exe2 instead, you will get the following:
rank    executable
------------------
0       exe1
1       exe1
2       exe1
3       exe2
4       exe2

It is also possible to start exe1 and exe2 as separate MPI jobs and make them connect to each other over an intercommunicator but that is considered an advanced MPI topic.

