I have a very simple MPI program where node 0 sends a character to node 1, but the send and receive are getting stuck whenever I use two or more different machines. The program works fine when I use several processes in only one machine. It seems to be a communication problem, but I can't figure it out what it is.....
Here's the code:
int main(int argc, char *argv[]) {
int numtasks, rank, tag = 1;
char inmsg, outmsg = 'x';
MPI_Status stat;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &numtasks);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if ( rank == 0 ) {
MPI_Send(&outmsg, 1, MPI_CHAR, 1, tag, MPI_COMM_WORLD);
}
else if ( rank == 1 ) {
MPI_Recv(&inmsg, 1, MPI_CHAR, 0, tag, MPI_COMM_WORLD, &stat);
}
MPI_Finalize();
}
Also, here's some important notes:
- I'm using a cluster of 2 Virtual Machines inside Google Compute Engine: mpi-test-uaiw and mpi-test-130b;
- I have already configured the passwordless ssh between the two VMs, that is, from mpi-test-uaiw I can just type ssh mpi-test-130b and it works fine (the opposite also works);
- The simple "Hello World" using MPI works with this cluster, but it does not contain any send or receive operations;
- Firewall is deactivated.
Any help would be appreciated. Thanks!