[mpich-discuss] MPI_Comm_connect and MPI_Comm_accept running simultaneously

Rajeev Thakur thakur at mcs.anl.gov
Sat Aug 25 22:36:34 CDT 2012


Did you call MPI_Init_thread with MPI_THREAD_MULTIPLE instead of MPI_Init?

On Aug 25, 2012, at 3:59 AM, toufik hadjazi wrote:

> Hi you all,
> 
> I'm working on a client server application, the architecture of the server and the client is pretty much the same; the scheme is : each application have three threads (receiver, worker and sender), the only difference between the two applications is in the worker thread(the processing), when I run only the two threads, the worker and (reciever or sender), it works fine, but when I start the third one, the program hangs on the instruction "MPI_Comm_connect" or "MPI_Comm_accept" with no error message just it indicates that "client.exe has stopped working".
> I'm wondering if the problem is in "MPI_Comm_connect" and "MPI_Comm_accept" running in the same time, I thought that maybe when a thread is blocking on one of those functions, we can't switch to another thread even if his quantum is done. is it true? and is these functions can be interrupted safely?
> P.S: I'm working with Visual C++ and QT.
> 
> the sender Thread:
> while(true)
>  {
>  // wait up for a new message
>  printf("receiver thread : waiting for connections...\n"); fflush(stdout);
> 
>  MPI_Comm_accept(localPort, MPI_INFO_NULL, 0, MPI_COMM_SELF, &client);
>  
>  MPI_Recv(&message, 1, MessageType, MPI_ANY_SOURCE, MPI_ANY_TAG, client, &status);
>  
>  //insert the message into the fifo
>  DIH.InFifo.Insert(message);
>  printf("A messaage has been received\n"); fflush(stdout);
>  
>  //disconnect from the current client
>  MPI_Barrier(client);
>  MPI_Comm_disconnect(&client);
>  }
>  
> the sender Thread:
> while(true)
>  {
>  message = DIH.OutFifo.Mov();
>  
>  // send a new message
>  printf("Sender thread trying to connect to port <%s>...\n", port); fflush(stdout);
>  MPI_Comm_connect(port, MPI_INFO_NULL, 0, MPI_COMM_SELF, &client);
>  
>  MPI_Send(&message, 1, MessageType, 0, 0, client);
>  
>  //insert the message into the fifo
>  printf("the messaage has been sent\n"); fflush(stdout);
>  
>  //disconnect from the current client
>  MPI_Barrier(client);
>  MPI_Comm_disconnect(&client);
>  }
>  
> the worker Thread:
> while(true)
>  {
>  message = DIH.InFifo.Mov();
> 
>  printf("worker thread gonna treat a new message...\n"); fflush(stdout);
>  switch (message.Command)
>  {
>  case Insertion : 
> {
>  printf("\ninsertion running...\n"); fflush(stdout);
>  sleep(1);
>  }
>  break;
>  case Suppression:
>  break;
>  case ExactMatchQuery:
>  break;
>  case RangeQuery:
>  break;
>  default:
>  printf("command not recognized!\n");
>  }
>  DIH.OutFifo.Insert(message);
>  }
>  
> _______________________________________________
> mpich-discuss mailing list     mpich-discuss at mcs.anl.gov
> To manage subscription options or unsubscribe:
> https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss



More information about the mpich-discuss mailing list