Commit 8b1a69b9 authored by Xin Zhao's avatar Xin Zhao
Browse files

Code-refactoring: wrapping up action of finishing op on target.



Here we wrap up common action when one RMA op is finished on target
into a function to make code structure cleaner.
Signed-off-by: Pavan Balaji's avatarPavan Balaji <balaji@anl.gov>
parent 8b277d9f
......@@ -476,6 +476,67 @@ static inline int check_piggyback_lock(MPID_Win *win_ptr, MPIDI_CH3_Pkt_t *pkt,
goto fn_exit;
}
static inline int finish_op_on_target(MPID_Win *win_ptr, MPIDI_VC_t *vc,
MPIDI_CH3_Pkt_type_t type,
MPIDI_CH3_Pkt_flags_t flags,
MPI_Win source_win_handle) {
int mpi_errno = MPI_SUCCESS;
if (type == MPIDI_CH3_PKT_PUT || type == MPIDI_CH3_PKT_ACCUMULATE) {
/* This is PUT or ACC */
if (flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK_GRANTED) {
if (!(flags & MPIDI_CH3_PKT_FLAG_RMA_FLUSH) &&
!(flags & MPIDI_CH3_PKT_FLAG_RMA_UNLOCK)) {
mpi_errno = MPIDI_CH3I_Send_lock_granted_pkt(vc, win_ptr, source_win_handle);
if (mpi_errno != MPI_SUCCESS) MPIU_ERR_POP(mpi_errno);
MPIDI_CH3_Progress_signal_completion();
}
}
if (flags & MPIDI_CH3_PKT_FLAG_RMA_FLUSH) {
mpi_errno = MPIDI_CH3I_Send_flush_ack_pkt(vc, win_ptr, flags,
source_win_handle);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIDI_CH3_Progress_signal_completion();
}
if (flags & MPIDI_CH3_PKT_FLAG_RMA_DECR_AT_COUNTER) {
win_ptr->at_completion_counter--;
MPIU_Assert(win_ptr->at_completion_counter >= 0);
/* Signal the local process when the op counter reaches 0. */
if (win_ptr->at_completion_counter == 0)
MPIDI_CH3_Progress_signal_completion();
}
if (flags & MPIDI_CH3_PKT_FLAG_RMA_UNLOCK) {
mpi_errno = MPIDI_CH3I_Release_lock(win_ptr);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
mpi_errno = MPIDI_CH3I_Send_flush_ack_pkt(vc, win_ptr, flags,
source_win_handle);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIDI_CH3_Progress_signal_completion();
}
}
else {
/* This is GACC / GET / CAS / FOP */
if (flags & MPIDI_CH3_PKT_FLAG_RMA_UNLOCK) {
mpi_errno = MPIDI_CH3I_Release_lock(win_ptr);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIDI_CH3_Progress_signal_completion();
}
if (flags & MPIDI_CH3_PKT_FLAG_RMA_DECR_AT_COUNTER) {
win_ptr->at_completion_counter--;
MPIU_Assert(win_ptr->at_completion_counter >= 0);
/* Signal the local process when the op counter reaches 0. */
if (win_ptr->at_completion_counter == 0)
MPIDI_CH3_Progress_signal_completion();
}
}
fn_exit:
return mpi_errno;
fn_fail:
goto fn_exit;
}
static inline int wait_progress_engine(void)
{
......
......@@ -86,35 +86,9 @@ int MPIDI_CH3_ReqHandler_PutRecvComplete( MPIDI_VC_t *vc,
MPID_Win_get_ptr(rreq->dev.target_win_handle, win_ptr);
if (rreq->dev.flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK_GRANTED) {
if (!(rreq->dev.flags & MPIDI_CH3_PKT_FLAG_RMA_FLUSH) &&
!(rreq->dev.flags & MPIDI_CH3_PKT_FLAG_RMA_UNLOCK)) {
mpi_errno = MPIDI_CH3I_Send_lock_granted_pkt(vc, win_ptr, rreq->dev.source_win_handle);
if (mpi_errno != MPI_SUCCESS) MPIU_ERR_POP(mpi_errno);
MPIDI_CH3_Progress_signal_completion();
}
}
if (rreq->dev.flags & MPIDI_CH3_PKT_FLAG_RMA_FLUSH) {
mpi_errno = MPIDI_CH3I_Send_flush_ack_pkt(vc, win_ptr, rreq->dev.flags,
rreq->dev.source_win_handle);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIDI_CH3_Progress_signal_completion();
}
if (rreq->dev.flags & MPIDI_CH3_PKT_FLAG_RMA_DECR_AT_COUNTER) {
win_ptr->at_completion_counter--;
MPIU_Assert(win_ptr->at_completion_counter >= 0);
/* Signal the local process when the op counter reaches 0. */
if (win_ptr->at_completion_counter == 0)
MPIDI_CH3_Progress_signal_completion();
}
if (rreq->dev.flags & MPIDI_CH3_PKT_FLAG_RMA_UNLOCK) {
mpi_errno = MPIDI_CH3I_Release_lock(win_ptr);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
mpi_errno = MPIDI_CH3I_Send_flush_ack_pkt(vc, win_ptr, rreq->dev.flags,
rreq->dev.source_win_handle);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIDI_CH3_Progress_signal_completion();
}
mpi_errno = finish_op_on_target(win_ptr, vc, MPIDI_CH3_PKT_PUT,
rreq->dev.flags, rreq->dev.source_win_handle);
if (mpi_errno != MPI_SUCCESS) MPIU_ERR_POP(mpi_errno);
/* mark data transfer as complete and decrement CC */
MPIDI_CH3U_Request_complete(rreq);
......@@ -164,34 +138,9 @@ int MPIDI_CH3_ReqHandler_AccumRecvComplete( MPIDI_VC_t *vc,
MPIR_Type_get_true_extent_impl(rreq->dev.datatype, &true_lb, &true_extent);
MPIU_Free((char *) rreq->dev.final_user_buf + true_lb);
if (rreq->dev.flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK_GRANTED) {
if (!(rreq->dev.flags & MPIDI_CH3_PKT_FLAG_RMA_FLUSH) &&
!(rreq->dev.flags & MPIDI_CH3_PKT_FLAG_RMA_UNLOCK)) {
mpi_errno = MPIDI_CH3I_Send_lock_granted_pkt(vc, win_ptr, rreq->dev.source_win_handle);
if (mpi_errno != MPI_SUCCESS) MPIU_ERR_POP(mpi_errno);
MPIDI_CH3_Progress_signal_completion();
}
}
if (rreq->dev.flags & MPIDI_CH3_PKT_FLAG_RMA_FLUSH) {
mpi_errno = MPIDI_CH3I_Send_flush_ack_pkt(vc, win_ptr, rreq->dev.flags,
rreq->dev.source_win_handle);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIDI_CH3_Progress_signal_completion();
}
if (rreq->dev.flags & MPIDI_CH3_PKT_FLAG_RMA_DECR_AT_COUNTER) {
win_ptr->at_completion_counter--;
MPIU_Assert(win_ptr->at_completion_counter >= 0);
/* Signal the local process when the op counter reaches 0. */
if (win_ptr->at_completion_counter == 0)
MPIDI_CH3_Progress_signal_completion();
}
if (rreq->dev.flags & MPIDI_CH3_PKT_FLAG_RMA_UNLOCK) {
mpi_errno = MPIDI_CH3I_Release_lock(win_ptr);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
mpi_errno = MPIDI_CH3I_Send_flush_ack_pkt(vc, win_ptr, rreq->dev.flags,
rreq->dev.source_win_handle);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
mpi_errno = finish_op_on_target(win_ptr, vc, MPIDI_CH3_PKT_ACCUMULATE,
rreq->dev.flags, rreq->dev.source_win_handle);
if (mpi_errno != MPI_SUCCESS) MPIU_ERR_POP(mpi_errno);
/* mark data transfer as complete and decrement CC */
MPIDI_CH3U_Request_complete(rreq);
......
......@@ -52,18 +52,9 @@ int MPIDI_CH3_ReqHandler_GetSendComplete( MPIDI_VC_t *vc ATTRIBUTE((unused)),
MPID_Win_get_ptr(sreq->dev.target_win_handle, win_ptr);
if (sreq->dev.flags & MPIDI_CH3_PKT_FLAG_RMA_UNLOCK) {
mpi_errno = MPIDI_CH3I_Release_lock(win_ptr);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIDI_CH3_Progress_signal_completion();
}
if (sreq->dev.flags & MPIDI_CH3_PKT_FLAG_RMA_DECR_AT_COUNTER) {
win_ptr->at_completion_counter--;
MPIU_Assert(win_ptr->at_completion_counter >= 0);
/* Signal the local process when the op counter reaches 0. */
if (win_ptr->at_completion_counter == 0)
MPIDI_CH3_Progress_signal_completion();
}
mpi_errno = finish_op_on_target(win_ptr, vc, MPIDI_CH3_PKT_GET,
sreq->dev.flags, sreq->dev.source_win_handle);
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. */
......@@ -101,24 +92,16 @@ int MPIDI_CH3_ReqHandler_GaccumLikeSendComplete( MPIDI_VC_t *vc,
MPID_Win_get_ptr(rreq->dev.target_win_handle, win_ptr);
mpi_errno = finish_op_on_target(win_ptr, vc, MPIDI_CH3_PKT_GET_ACCUM,
rreq->dev.flags, rreq->dev.source_win_handle);
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->at_completion_counter--;
MPIU_Assert(win_ptr->at_completion_counter >= 0);
if (rreq->dev.flags & MPIDI_CH3_PKT_FLAG_RMA_UNLOCK) {
mpi_errno = MPIDI_CH3I_Release_lock(win_ptr);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIDI_CH3_Progress_signal_completion();
}
if (rreq->dev.flags & MPIDI_CH3_PKT_FLAG_RMA_DECR_AT_COUNTER) {
win_ptr->at_completion_counter--;
MPIU_Assert(win_ptr->at_completion_counter >= 0);
/* Signal the local process when the op counter reaches 0. */
if (win_ptr->at_completion_counter == 0)
MPIDI_CH3_Progress_signal_completion();
}
MPIDI_CH3U_Request_complete(rreq);
*complete = TRUE;
......@@ -130,6 +113,7 @@ int MPIDI_CH3_ReqHandler_GaccumLikeSendComplete( MPIDI_VC_t *vc,
goto fn_exit;
}
int MPIDI_CH3_ReqHandler_SendReloadIOV( MPIDI_VC_t *vc ATTRIBUTE((unused)), MPID_Request *sreq,
int *complete )
{
......
......@@ -936,18 +936,9 @@ int MPIDI_CH3_PktHandler_CAS(MPIDI_VC_t * vc, MPIDI_CH3_Pkt_t * pkt,
MPID_Request_release(req);
}
if (cas_pkt->flags & MPIDI_CH3_PKT_FLAG_RMA_UNLOCK) {
mpi_errno = MPIDI_CH3I_Release_lock(win_ptr);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIDI_CH3_Progress_signal_completion();
}
if (cas_pkt->flags & MPIDI_CH3_PKT_FLAG_RMA_DECR_AT_COUNTER) {
win_ptr->at_completion_counter--;
MPIU_Assert(win_ptr->at_completion_counter >= 0);
/* Signal the local process when the op counter reaches 0. */
if (win_ptr->at_completion_counter == 0)
MPIDI_CH3_Progress_signal_completion();
}
mpi_errno = finish_op_on_target(win_ptr, vc, MPIDI_CH3_PKT_CAS,
cas_pkt->flags, cas_pkt->source_win_handle);
if (mpi_errno != MPI_SUCCESS) MPIU_ERR_POP(mpi_errno);
fn_exit:
MPIR_T_PVAR_TIMER_END(RMA, rma_rmapkt_cas);
......@@ -1104,18 +1095,9 @@ int MPIDI_CH3_PktHandler_FOP(MPIDI_VC_t * vc, MPIDI_CH3_Pkt_t * pkt,
}
}
if (fop_pkt->flags & MPIDI_CH3_PKT_FLAG_RMA_UNLOCK) {
mpi_errno = MPIDI_CH3I_Release_lock(win_ptr);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIDI_CH3_Progress_signal_completion();
}
if (fop_pkt->flags & MPIDI_CH3_PKT_FLAG_RMA_DECR_AT_COUNTER) {
win_ptr->at_completion_counter--;
MPIU_Assert(win_ptr->at_completion_counter >= 0);
if (win_ptr->at_completion_counter == 0)
MPIDI_CH3_Progress_signal_completion();
}
mpi_errno = finish_op_on_target(win_ptr, vc, MPIDI_CH3_PKT_FOP,
fop_pkt->flags, fop_pkt->source_win_handle);
if (mpi_errno != MPI_SUCCESS) MPIU_ERR_POP(mpi_errno);
fn_exit:
MPIR_T_PVAR_TIMER_END(RMA, rma_rmapkt_fop);
......
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