Commit cb4ca983 authored by David Goodell's avatar David Goodell
Browse files

[svn-r6925] notes about recv_pending_count, plus fix a related race

No reviewer.
parent 0f7306c0
......@@ -249,8 +249,16 @@ typedef struct MPIDI_Request {
unsigned int state;
int cancel_pending;
/* FIXME the precise meaning of this field is unclear, comments/docs
about it should be added */
/* This field seems to be used for unexpected messages. Unexpected messages
* need to go through two steps: matching and receiving the data. These
* steps could happen in either order though, so this field is initialized
* to 2. It is decremented when the request is matched and also when all of
* the data is available. Once it reaches 0 it should be safe to copy from
* the temporary buffer (if there is one) to the user buffer. This field is
* related to, but not quite the same thing as the completion counter (cc). */
/* MT access should be controlled by the MSGQUEUE CS when the req is still
* unexpected, exclusive access otherwise */
int recv_pending_count;
/* The next 8 are for RMA */
......
......@@ -458,6 +458,9 @@ int MPIDI_CH3_PktHandler_EagerShortSend( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
/* These next two indicate that once matched, there is
one more step (the unpack into the user buffer) to perform. */
rreq->dev.OnDataAvail = MPIDI_CH3_ReqHandler_UnpackUEBufComplete;
/* normally starts at 2, but we are implicitly decrementing it
* because all of the data arrived in the pkt (see mpidpre.h) */
rreq->dev.recv_pending_count = 1;
}
......
......@@ -84,23 +84,27 @@ int MPID_Irecv(void * buf, int count, MPI_Datatype datatype, int rank, int tag,
recv_pending_count of at least 1 */
MPIDI_Request_decr_pending(rreq);
MPIDI_Request_check_pending(rreq, &recv_pending);
if (!recv_pending)
{
/* All of the data has arrived, we need to copy the data and
then free the buffer. */
/* FIXME: if the user buffer is contiguous, just move the
data without using a separate routine call */
if (rreq->dev.recv_data_sz > 0)
{
MPIDI_CH3U_Request_unpack_uebuf(rreq);
MPIU_Free(rreq->dev.tmpbuf);
}
mpi_errno = rreq->status.MPI_ERROR;
goto fn_exit;
}
if (MPID_Request_is_complete(rreq)) {
/* is it ever possible to have (cc==0 && recv_pending>0) ? */
MPIU_Assert(!recv_pending);
/* All of the data has arrived, we need to copy the data and
then free the buffer. */
if (rreq->dev.recv_data_sz > 0)
{
MPIDI_CH3U_Request_unpack_uebuf(rreq);
MPIU_Free(rreq->dev.tmpbuf);
}
mpi_errno = rreq->status.MPI_ERROR;
goto fn_exit;
}
else
{
/* there should never be outstanding completion events for an unexpected
* recv without also having a "pending recv" */
MPIU_Assert(recv_pending);
/* The data is still being transfered across the net. We'll
leave it to the progress engine to handle once the
entire message has arrived. */
......
......@@ -73,32 +73,39 @@ int MPID_Recv(void * buf, int count, MPI_Datatype datatype, int rank, int tag,
}
/* the request was found in the unexpected queue, so it has a
recv_pending_count of at least 1 */
recv_pending_count of at least 1, corresponding to this matching */
MPIDI_Request_decr_pending(rreq);
MPIDI_Request_check_pending(rreq, &recv_pending);
if (!recv_pending)
{
/* All of the data has arrived, we need to unpack the data and
then free the buffer and the request. */
if (rreq->dev.recv_data_sz > 0)
{
MPIDI_CH3U_Request_unpack_uebuf(rreq);
MPIU_Free(rreq->dev.tmpbuf);
}
mpi_errno = rreq->status.MPI_ERROR;
if (status != MPI_STATUS_IGNORE)
{
*status = rreq->status;
}
MPID_Request_release(rreq);
rreq = NULL;
goto fn_exit;
}
if (MPID_Request_is_complete(rreq)) {
/* is it ever possible to have (cc==0 && recv_pending>0) ? */
MPIU_Assert(!recv_pending);
/* All of the data has arrived, we need to unpack the data and
then free the buffer and the request. */
if (rreq->dev.recv_data_sz > 0)
{
MPIDI_CH3U_Request_unpack_uebuf(rreq);
MPIU_Free(rreq->dev.tmpbuf);
}
mpi_errno = rreq->status.MPI_ERROR;
if (status != MPI_STATUS_IGNORE)
{
*status = rreq->status;
}
MPID_Request_release(rreq);
rreq = NULL;
goto fn_exit;
}
else
{
/* there should never be outstanding completion events for an unexpected
* recv without also having a "pending recv" */
MPIU_Assert(recv_pending);
/* The data is still being transfered across the net.
We'll leave it to the progress engine to handle once the
entire message has arrived. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment