# How does MPI differentiate between two computers?

I am starting to dabble in MPI. I am fairly new to this area and I am currently reading the MPI standard.

I would like to write my first MPI program, a simple hello world program, on a cluster that I have. I am not sure if anyone is familiar with the IBM bladecenter. Supposedly, there is a midplane that connects all of the blades together (if someone could confirm/deny this in their experience, that would be great). I was going to run a simple program using the send and receive C++ commands. I think that I will run the example program in the point-to-point communication section of the standard. I have typed up the program below.

My main question is this, say I have two computers (computer A and computer B) that are connected to each other in some way (take your pick but in this case, it would be the bladecenter so they are connected via a midplane). Through the MPI standard, how does computer A communicate with computer B through the connection? Also, if I run my program on computer A, will computer B be needing to run the same program? How will MPI know that the rank is on computer B and not on some other thread of computer A? Does MPI_Comm_rank get the rank for every single processor/core that it can see?

Given the example program that I am using, is that meant for 2 processes on the same computer or, would this work for 2 computers? If not, then how would I modify the program to work for 2 computers or n number of computers?

#include "mpi.h"
main(int argc, char **argv)
{
char message{20];
int myRank;
MPI_Status status;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &myRank);
if(myRank == 0)
{
strcpy(message, "Hello, there");
MPI_SEND(message, strlen(message) + 1, MPI_CHAR, 1, 99, MPI_COMM_WORLD);
}
else if(myRank == 1)
{
MPI_Recv(message, 20, MPI_CHAR, 0, 99, MPI_COMM_WORLD, &status);
printf("recieved: %s:\n", message);
}
MPI_Finalize();
}


I apologize if these questions are obvious. Again, this is my first time dealing with MPI and any help would be greatly appreciated, thank you

• Once you follow the startup procedures to launch on multiple computers (commands like mpirun or mpiexec are typically used, but check your library's instructions for launch), you will find that both print statements are executed as expected. There's a typo in your declaration of message that will prevent this code from compiling, BTW. – Bill Barth Mar 9 '16 at 0:35