Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: [OMPI users] OpenMPI Nonblocking Send/Recv
From: Xin Tong Utoronto (x.tong_at_[hidden])
Date: 2011-09-13 12:49:40

I am new to openmpi. I am not sure whether my logic below will work or not.
Can someone please confirm for me on that ? Basically, what this does is
trying to check whether there are anything to send, if there are, send it
right away and set sentinit to true. Then check whether there are anything
to receive, if there are receive it. I am running this on a client-server
model (2 nodes sending and receiving data between each other)

for (;;) {
               if (sendinit && MPI_Test(&sendreq, &sendcomplete,
&sendstatus)) {
                      if (sendcomplete) {
                         if (pollv[1].revents & POLLIN) {
                             printf("Trying to send in rank %d\n", rank);
                             vdestream_mpisend(vdestream,sendbuff, nx,
GET_PAIR_RANK(rank), &sendreq);
                         } else {
                             // no in-flight request.
                             sendinit = false;
                   } else {
                      // no in-flight request. try to start one
                      if (!sendinit && pollv[1].revents & POLLIN) {
                           printf("Trying to send in rank %d\n", rank );
                           vdestream_mpisend(vdestream,sendbuff, nx,
GET_PAIR_RANK(rank), &sendreq);
                           sendinit = true;

                   if (recvinit && MPI_Test(&recvreq, &recvcomplete,
&recvstatus)) {
                      if (recvcomplete) {
                          printf("Receive completed\n");
                          // get the actual number of byet received.
                          MPI_Get_count(&recvstatus, MPI_CHAR, &recvcount);
                          vdestream_recv(vdestream, recvbuff, recvcount);
                          // no more in-flight recv.
                          recvinit = false;
                   } else {
                      if (!recvinit) {
                         printf("Trying to receive in rank %d\n", rank);
                         // no in-flight recv. try to start one.
                         vdestream_mpirecv(vdestream, recvbuff, BUFSIZE-2,
GET_PAIR_RANK(rank), &recvreq);
                         recvinit = true;

Kind Regards
Xin Tong