none
Deadlock with MPI_Isend RRS feed

  • Question

  • I have the following c/c++ code with Microsoft MPI

    #include <stdio.h>
    #include <stdlib.h>
    #include "mpi.h"
    int main (int argc, char *argv[])
     {
      int  err, numtasks, taskid;
      int out=0,val;
      MPI_Status status;
      MPI_Request req;

      err=MPI_Init(&argc, &argv);
      err=MPI_Comm_size(MPI_COMM_WORLD, &numtasks);
      err=MPI_Comm_rank(MPI_COMM_WORLD, &taskid);


      int receiver=(taskid+1)% numtasks;
      int sender= (taskid-1+numtasks)% numtasks;
      printf("sender %d, receiver %d, rank %d\n",sender,receiver, taskid);

      val=50;   
      MPI_Isend(&val, 1, MPI_INT, receiver, 1, MPI_COMM_WORLD, &req);
      MPI_Irecv(&out, 1, MPI_INT, sender, 1, MPI_COMM_WORLD, &req);
      printf ("Rank: %d , Value: %d\n", taskid, out );
      err=MPI_Finalize();
      return 0;
     }

    The application goes in deadlock if launched with more than 2 processes. With 2 processes the application works but no write on "out" is performed. This code works with a linux mpi distribution, the problem seems to be only in the microsoft version. Any help ?

    Tuesday, January 26, 2016 4:47 PM

All replies

  • Pandemia000

    The code you posted is not MPI-standard compliant as is:

    - In a non-blocking receive there's no guarantee that the receive buffer will have correct data until the communication has completed by calling MPI_WAIT (see p.84 -p.52 of the hardcopy- of the MPI 3.1 spec)

    - The behavior of MPI_Finalize() is undefined when there are outstanding send/recvs which is the case with the code above (see p.389 -p.357 of the hardcopy- of the MPI 3.1 spec)

    MPI spec is @ http://www.mpi-forum.org/docs/mpi-3.1/mpi31-report.pdf

    Thanks

    Thursday, January 28, 2016 8:10 PM