[mpich-discuss] How to terminate MPI_Comm_accept

Lu, Huiwei huiweilu at mcs.anl.gov
Tue Oct 7 08:18:43 CDT 2014


Hi, Hirak,

It looks like there is no need for Thread 2 to do an additional MPI_Comm_connect before communicating with Thread 1. Thread 1 and Thread 2 are already in the same communicator, MPI_COMM_SELF. Why not directly send a message from Thread 2 (MPI_Isend, MPI_Wait) to Thread 1 (MPI_Irecv, MPI_Wait) using MPI_COMM_SELF?

Moreover, since Thread 1 and 2 share the same address space, they can directly write to each other’s memory, so MPI_Isend/MPI_Irecv can be replaced by shared memory write/read. Let Thread 1 and 2 share one flag=0. After Thread 2 finishes, it can set flag=1. Thread 1 checks the flag in its loop, if flag=1, it can then terminate.

Regards,
—
Huiwei

On Oct 7, 2014, at 6:17 AM, Roy, Hirak <Hirak_Roy at mentor.com> wrote:

> Hi All,
>  
> I am working on a MPI based server-client application.
> The number of clients are not fixed.
> The clients can come up at any time and will connect to server.
>  
> The server runs two threads.
>  
> Thread 1: opens a port, calls MPI_Comm_accept on a loop on MPI_COMM_SELF.
> Thread 2: Distributes works among the clients.
>  
> When the client comes up, it calls MPI_Comm_connect to server.
>  
> The problem I am facing is : how to terminate the blocking MPI_Comm_accept of Therad 1, once Thread2 is done with all the work?
>  
> I tried the following thing which might not be legal to do:
>  
> Thread2 calls MPI_Comm_connect (MPI_COMM_SELF) to Thread1’s port. (created a new inter-communicator newComm)
> However, when I tried to send a non-blocking message to close the port from Thread2 (MPI_Isend, MPI_Wait)  to Thread1 (MPI_Irecv, MPI_Wait)  using newComm, the two threads wait forever.
>  
> Any help regarding the termination of MPI_Comm_accept will be appreciated.
>  
> Regards,
> Hirak
> _______________________________________________
> discuss mailing list     discuss at mpich.org
> To manage subscription options or unsubscribe:
> https://lists.mpich.org/mailman/listinfo/discuss

_______________________________________________
discuss mailing list     discuss at mpich.org
To manage subscription options or unsubscribe:
https://lists.mpich.org/mailman/listinfo/discuss


More information about the discuss mailing list