Commit c673fec4 authored by Xin Zhao's avatar Xin Zhao
Browse files

Bug-fix: correct decrementing counter in GET-like operations.



For GET-like operations, We should increment the Active Target counter
when the process of sending back data is not completed immediately on
target and a response request is created. We should decrement the counter
when the process of sending back data is completed on target side.
Signed-off-by: Pavan Balaji's avatarPavan Balaji <balaji@anl.gov>
parent d6996640
......@@ -89,6 +89,8 @@ int MPIDI_CH3_ReqHandler_PutAccumRespComplete( MPIDI_VC_t *vc,
MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3_REQHANDLER_PUTACCUMRESPCOMPLETE);
MPID_Win_get_ptr(rreq->dev.target_win_handle, win_ptr);
/* Perform get in get-accumulate */
if (rreq->dev.resp_request_handle != MPI_REQUEST_NULL) {
MPI_Aint type_size;
......@@ -128,6 +130,10 @@ int MPIDI_CH3_ReqHandler_PutAccumRespComplete( MPIDI_VC_t *vc,
resp_req->dev.target_win_handle = rreq->dev.target_win_handle;
resp_req->dev.flags = rreq->dev.flags;
/* here we increment the Active Target counter to guarantee the GET-like
operation are completed when counter reaches zero. */
win_ptr->my_counter++;
iov[0].MPID_IOV_BUF = (MPID_IOV_BUF_CAST) get_accum_resp_pkt;
iov[0].MPID_IOV_LEN = sizeof(*get_accum_resp_pkt);
......@@ -146,8 +152,6 @@ int MPIDI_CH3_ReqHandler_PutAccumRespComplete( MPIDI_VC_t *vc,
get_acc_flag = 1;
}
MPID_Win_get_ptr(rreq->dev.target_win_handle, win_ptr);
if (MPIDI_Request_get_type(rreq) == MPIDI_REQUEST_TYPE_ACCUM_RESP) {
if (win_ptr->shm_allocated == TRUE)
......@@ -168,13 +172,6 @@ int MPIDI_CH3_ReqHandler_PutAccumRespComplete( MPIDI_VC_t *vc,
if (mpi_errno) { MPIU_ERR_POP(mpi_errno); }
}
if (get_acc_flag) {
/* here we decrement the Active Target counter to guarantee the GET-like
operation are completed when counter reaches zero. */
win_ptr->my_counter--;
MPIU_Assert(win_ptr->my_counter >= 0);
}
/* mark data transfer as complete and decrement CC */
MPIDI_CH3U_Request_complete(rreq);
*complete = TRUE;
......@@ -333,6 +330,11 @@ int MPIDI_CH3_ReqHandler_GetAccumRespComplete( MPIDI_VC_t *vc,
MPI_WIN_NULL);
if (mpi_errno) { MPIU_ERR_POP(mpi_errno); }
/* here we decrement the Active Target counter to guarantee the GET-like
operation are completed when counter reaches zero. */
win_ptr->my_counter--;
MPIU_Assert(win_ptr->my_counter >= 0);
MPIDI_CH3U_Request_complete(rreq);
*complete = TRUE;
fn_exit:
......@@ -525,6 +527,8 @@ int MPIDI_CH3_ReqHandler_FOPComplete( MPIDI_VC_t *vc,
MPIDI_Pkt_init(fop_resp_pkt, MPIDI_CH3_PKT_FOP_RESP);
fop_resp_pkt->request_handle = rreq->dev.request_handle;
MPID_Win_get_ptr(rreq->dev.target_win_handle, win_ptr);
/* Copy original data into the send buffer. If data will fit in the
header, use that. Otherwise allocate a temporary buffer. */
if (len <= sizeof(fop_resp_pkt->data)) {
......@@ -539,13 +543,15 @@ int MPIDI_CH3_ReqHandler_FOPComplete( MPIDI_VC_t *vc,
resp_req->dev.flags = rreq->dev.flags;
resp_req->dev.OnDataAvail = MPIDI_CH3_ReqHandler_GetAccumRespComplete;
/* here we increment the Active Target counter to guarantee the GET-like
operation are completed when counter reaches zero. */
win_ptr->my_counter++;
MPIDI_CH3U_SRBuf_alloc(resp_req, len);
MPIU_ERR_CHKANDJUMP(resp_req->dev.tmpbuf_sz < len, mpi_errno, MPI_ERR_OTHER, "**nomemreq");
MPIU_Memcpy( resp_req->dev.tmpbuf, rreq->dev.real_user_buf, len );
}
MPID_Win_get_ptr(rreq->dev.target_win_handle, win_ptr);
/* Apply the op */
if (rreq->dev.op != MPI_NO_OP) {
uop = MPIR_OP_HDL_TO_FN(rreq->dev.op);
......@@ -573,6 +579,11 @@ int MPIDI_CH3_ReqHandler_FOPComplete( MPIDI_VC_t *vc,
resp_req->dev.target_win_handle = rreq->dev.target_win_handle;
resp_req->dev.flags = rreq->dev.flags;
resp_req->dev.OnDataAvail = MPIDI_CH3_ReqHandler_GetAccumRespComplete;
/* here we increment the Active Target counter to guarantee the GET-like
operation are completed when counter reaches zero. */
win_ptr->my_counter++;
MPID_Request_release(resp_req);
goto finish_up;
}
......@@ -607,11 +618,6 @@ int MPIDI_CH3_ReqHandler_FOPComplete( MPIDI_VC_t *vc,
MPIU_Free(rreq->dev.user_buf);
}
/* here we decrement the Active Target counter to guarantee the GET-like
operation are completed when counter reaches zero. */
win_ptr->my_counter--;
MPIU_Assert(win_ptr->my_counter >= 0);
*complete = 1;
fn_exit:
......
......@@ -4738,12 +4738,6 @@ int MPIDI_CH3_PktHandler_Accumulate( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
MPIU_Object_set_ref(req, 1);
*rreqp = req;
if (accum_pkt->type == MPIDI_CH3_PKT_GET_ACCUM) {
/* here we increment the Active Target counter to guarantee the GET-like
operation are completed when counter reaches zero. */
win_ptr->my_counter++;
}
req->dev.user_count = accum_pkt->count;
req->dev.op = accum_pkt->op;
req->dev.real_user_buf = accum_pkt->addr;
......@@ -5015,6 +5009,11 @@ int MPIDI_CH3_PktHandler_CAS( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
req->dev.target_win_handle = cas_pkt->target_win_handle;
req->dev.flags = cas_pkt->flags;
req->dev.OnDataAvail = MPIDI_CH3_ReqHandler_GetAccumRespComplete;
/* here we increment the Active Target counter to guarantee the GET-like
operation are completed when counter reaches zero. */
win_ptr->my_counter++;
MPID_Request_release(req);
goto fn_exit;
}
......@@ -5106,10 +5105,6 @@ int MPIDI_CH3_PktHandler_FOP( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
MPIU_Object_set_ref(req, 1); /* Ref is held by progress engine */
*rreqp = NULL;
/* here we increment the Active Target counter to guarantee the GET-like
operation are completed when counter reaches zero. */
win_ptr->my_counter++;
req->dev.user_buf = NULL; /* will be set later */
req->dev.user_count = 1;
req->dev.datatype = fop_pkt->datatype;
......
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