<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body>
<div class="BodyFragment"><font size="2"><span style="font-size:10pt;">
<div class="PlainText">Hi Hirak,<br>
<br>
I can reproduce your error with the attached program using one process:<br>
<br>
mpicc -g -o mpi_comm_accept mpi_comm_accept.c -pthread<br>
mpiexec -n 1 ./mpi_comm_accept<br>
<br>
I found MPI_Send and MPI_Recv were not using the same communicator to communicate, that’s why MPI_Recv will never receive the message. So either the communicator creation was wrong or the application was wrong.<br>
<br>
The standard said MPI_Comm_accept and MPI_Comm_connect are used for “establishing contact between two groups of processes that do not share an existing communicator”. But in this case, thread 1 and 2 do share an existing communicator and want to create a new
communicator based on the common communicator. I don’t know if it is allowed. If it is allowed, then MPI_Comm_accept and MPI_Comm_connect should be fixed to support multiple thread case; if it is not allowed, we may need to change the application to use another
way to terminate MPI_Comm_accept.<br>
<br>
Thanks,<br>
<br>
</div>
</span></font></div>
<div class="BodyFragment"><font size="2"><span style="font-size:10pt;">
<div class="PlainText"><br>
—<br>
Huiwei<br>
<br>
On Oct 8, 2014, at 12:14 AM, Roy, Hirak <Hirak_Roy@mentor.com> wrote:<br>
<br>
> Hi Pavan,<br>
> <br>
> Here is my code for thread2 :<br>
> <br>
> do {<br>
> MPI_Comm newComm ;<br>
> MPI_Comm_accept (m_serverPort.c_str(), MPI_INFO_NULL, 0, MPI_COMM_SELF, &newComm);<br>
> Log ("Accepted a connection");<br>
> int buf = 0 ;<br>
> MPI_Status status ;<br>
> MPI_Recv(&buf, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, newComm, &status);<br>
> <br>
> if (status.MPI_TAG == MPI_MSG_TAG_NEW_CONN) {<br>
> m_clientComs[m_clientCount] = newComm ;<br>
> m_clientCount++;<br>
> } else if (status.MPI_TAG == MPI_MSG_TAG_SHUTDOWN) {<br>
> Log ("Shutdown");<br>
> //MPI_Comm_disconnect (&newComm);<br>
> Log ("Disconnect");<br>
> break;<br>
> } else {<br>
> Log ("Unmatched Receive");<br>
> } <br>
> } while(1) ;<br>
> <br>
> <br>
> Here is my code for thread1 to terminate thread2 :<br>
> <br>
> MPI_Comm newComm ;<br>
> MPI_Comm_connect (m_serverPort.c_str(), MPI_INFO_NULL, 0, MPI_COMM_SELF, &newComm);<br>
> Log ("Connect to Self");<br>
> int val = 0 ;<br>
> MPI_Request req ;<br>
> MPI_Send(&val, 1, MPI_INT, 0, MPI_MSG_TAG_SHUTDOWN, newComm);<br>
> Log ("Successful");<br>
> //MPI_Status stat ;<br>
> //MPI_Wait(&req, &stat);<br>
> Log ("Complete");<br>
> <br>
> //MPI_Comm_disconnect(&newComm);<br>
> <br>
> <br>
> <br>
> <br>
> The MPI_Send/Recv waits.<br>
> I am using sock channel.<br>
> For nemesis, I get the following crash : <br>
> Assertion failed in file ./src/mpid/ch3/channels/nemesis/include/mpid_nem_inline.h at line 58: vc_ch->is_local<br>
> internal ABORT - process 0<br>
> <br>
> I tried non-blocking send and receive followed by wait. However, that also does not solve the problem.<br>
> <br>
> Thanks,<br>
> Hirak<br>
> <br>
> <br>
> <br>
> -----<br>
> <br>
> Hirak,<br>
> <br>
> Your approach should work fine. I’m not sure what issue you are facing. I assume thread 1 is doing this:<br>
> <br>
> while (1) {<br>
> MPI_Comm_accept(..);<br>
> MPI_Recv(.., tag, ..);<br>
> if (tag == REGULAR_CONNECTION)<br>
> continue;<br>
> else if (tag == TERMINATION) {<br>
> MPI_Send(..);<br>
> break;<br>
> }<br>
> }<br>
> <br>
> In this case, all clients do an MPI_Comm_connect and then send a message with tag = REGULAR_CONNECTION. When thread 2 is done with its work, it’ll do an MPI_Comm_connect and then send a message with tag = TERMINATION, wait for a response from thread 1, and
call finalize.<br>
> <br>
> — Pavan<br>
> <br>
> _______________________________________________<br>
> discuss mailing list discuss@mpich.org<br>
> To manage subscription options or unsubscribe:<br>
> <a href="https://lists.mpich.org/mailman/listinfo/discuss">https://lists.mpich.org/mailman/listinfo/discuss</a><br>
<br>
</div>
</span></font></div>
</body>
</html>