I'm learning MPI_Send, but I'm confused about this method. I wrote a simple pingpong program which the rank-0 node send the message to rank-1 node, and then the latter one returns a message to the former one.
if (rank == 0) {   /* Send Ping, Receive Pong */
  dest = 2;
  source = 2;
  rc = MPI_Send(pingmsg, strlen(pingmsg)+1, MPI_CHAR, dest, tag, MPI_COMM_WORLD);
  rc = MPI_Recv(buff, strlen(pongmsg)+1, MPI_CHAR, source, tag, MPI_COMM_WORLD, &Stat);
   printf("Rank0 Sent: %s & Received: %s\n", pingmsg, buff);
  }
else if (rank == 2) { /* Receive Ping, Send Pong */
  dest = 0;
  source = 0;
  rc = MPI_Recv(buff, strlen(pingmsg)+1, MPI_CHAR, source, tag, 开发者_如何学PythonMPI_COMM_WORLD, &Stat);
  printf("Rank1 received: %s & Sending: %s\n", buff, pongmsg);
  rc = MPI_Send(pongmsg, strlen(pongmsg)+1, MPI_CHAR, dest, tag, MPI_COMM_WORLD);
  }
I run this program on a 3 nodes environment. However, the system displays:
Fatal error in MPI_Send: Other MPI error, error stack:
MPI_Send(173)..............: MPI_Send(buf=0xbffffb90, count=10, MPI_CHAR, dest=2, tag=1, MPI_COMM_WORLD) failed
MPID_nem_tcp_connpoll(1811): Communication error with rank 2: Unknown error 4294967295
I'm wondering why I can send a message from rank-0 node to rank-1 node, but an error occurs when changed from rank-0 node to rank-1 node? Thanks.
Actually have you checked whether strlen(pingmsg) is the same in both MPI_SEND and MPI_RECV
The amount of data sent using MPI_SEND should be less than or equal to the amount of data to be received by MPI_RECV or else it will lead to an error.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论