Commit 37cb95b1 authored by Xin Zhao's avatar Xin Zhao Committed by Pavan Balaji
Browse files

Make do_accumulate_op() perform correctly when op is MPI_NO_OP.



Originally before do_accumulate_op() is called, there is a separate
IF branch to deal with MPI_NO_OP, which is gross. Here we modify
do_accumulate_op() to make sure it works correctly for MPI_NO_OP,
and delete those IF branches.
Signed-off-by: Pavan Balaji's avatarPavan Balaji <balaji@anl.gov>
parent 092d6c8e
......@@ -439,11 +439,16 @@ static inline int MPIDI_CH3I_Shm_get_acc_op(const void *origin_addr, int origin_
MPI_Aint total_len, rest_len;
MPI_Aint origin_dtp_size;
MPID_Datatype *origin_dtp_ptr = NULL;
int is_empty_origin = FALSE;
int mpi_errno = MPI_SUCCESS;
MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_SHM_GET_ACC_OP);
MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPIDI_CH3I_SHM_GET_ACC_OP);
/* Judge if origin buffer is empty */
if (op == MPI_NO_OP)
is_empty_origin = TRUE;
if (win_ptr->shm_allocated == TRUE) {
int local_target_rank = win_ptr->comm_ptr->intranode_table[target_rank];
MPIU_Assert(local_target_rank >= 0);
......@@ -464,17 +469,7 @@ static inline int MPIDI_CH3I_Shm_get_acc_op(const void *origin_addr, int origin_
MPIU_ERR_POP(mpi_errno);
}
/* NO_OP: Don't perform the accumulate */
if (op == MPI_NO_OP) {
if (shm_locked) {
MPIDI_CH3I_SHM_MUTEX_UNLOCK(win_ptr);
shm_locked = 0;
}
goto fn_exit;
}
if (MPIR_DATATYPE_IS_PREDEFINED(origin_datatype)) {
if (is_empty_origin == TRUE || MPIR_DATATYPE_IS_PREDEFINED(origin_datatype)) {
mpi_errno = do_accumulate_op((void*)origin_addr, origin_count, origin_datatype,
(void*)((char *)base+disp_unit*target_disp), target_count, target_datatype,
......
......@@ -808,14 +808,21 @@ static inline int do_accumulate_op(void *source_buf, int source_count, MPI_Datat
{
int mpi_errno = MPI_SUCCESS;
MPI_User_function *uop = NULL;
MPI_Aint source_dtp_size, source_dtp_extent;
MPI_Aint source_dtp_size = 0, source_dtp_extent = 0;
int is_empty_source = FALSE;
MPIDI_STATE_DECL(MPID_STATE_DO_ACCUMULATE_OP);
MPIDI_FUNC_ENTER(MPID_STATE_DO_ACCUMULATE_OP);
MPIU_Assert(MPIR_DATATYPE_IS_PREDEFINED(source_dtp));
MPID_Datatype_get_size_macro(source_dtp, source_dtp_size);
MPID_Datatype_get_extent_macro(source_dtp, source_dtp_extent);
/* first Judge if source buffer is empty */
if (acc_op == MPI_NO_OP)
is_empty_source = TRUE;
if (is_empty_source == FALSE) {
MPIU_Assert(MPIR_DATATYPE_IS_PREDEFINED(source_dtp));
MPID_Datatype_get_size_macro(source_dtp, source_dtp_size);
MPID_Datatype_get_extent_macro(source_dtp, source_dtp_extent);
}
if (acc_op != MPI_REPLACE) {
if (HANDLE_GET_KIND(acc_op) == HANDLE_KIND_BUILTIN) {
......@@ -833,13 +840,19 @@ static inline int do_accumulate_op(void *source_buf, int source_count, MPI_Datat
}
if (MPIR_DATATYPE_IS_PREDEFINED(target_dtp)) {
/* apply op if target dtp is predefined dtp */
MPIU_Assert(source_dtp == target_dtp);
if (is_empty_source == TRUE || MPIR_DATATYPE_IS_PREDEFINED(target_dtp)) {
/* directly apply op if target dtp is predefined dtp OR source buffer is empty */
MPI_Aint real_stream_offset;
void *curr_target_buf;
MPI_Aint real_stream_offset = (stream_offset / source_dtp_size) * source_dtp_extent;
void *curr_target_buf = (void *) ((char *) target_buf + real_stream_offset);
if (is_empty_source == FALSE) {
MPIU_Assert(source_dtp == target_dtp);
real_stream_offset = (stream_offset / source_dtp_size) * source_dtp_extent;
curr_target_buf = (void *) ((char *) target_buf + real_stream_offset);
}
else {
curr_target_buf = target_buf;
}
if (acc_op == MPI_REPLACE) {
mpi_errno = MPIR_Localcopy(source_buf, source_count, source_dtp,
......
......@@ -445,11 +445,8 @@ int MPIDI_CH3_ReqHandler_FOPRecvComplete(MPIDI_VC_t * vc, MPID_Request * rreq, i
}
/* Perform accumulate computation */
if (rreq->dev.op != MPI_NO_OP) {
mpi_errno = do_accumulate_op(rreq->dev.user_buf, 1, rreq->dev.datatype,
rreq->dev.real_user_buf, 1, rreq->dev.datatype, 0,
rreq->dev.op);
}
mpi_errno = do_accumulate_op(rreq->dev.user_buf, 1, rreq->dev.datatype,
rreq->dev.real_user_buf, 1, rreq->dev.datatype, 0, rreq->dev.op);
if (win_ptr->shm_allocated == TRUE)
MPIDI_CH3I_SHM_MUTEX_UNLOCK(win_ptr);
......@@ -1514,15 +1511,13 @@ static inline int perform_fop_in_lock_queue(MPID_Win * win_ptr, MPIDI_RMA_Lock_e
}
/* Apply the op */
if (fop_pkt->op != MPI_NO_OP) {
if (fop_pkt->type == MPIDI_CH3_PKT_FOP_IMMED) {
mpi_errno = do_accumulate_op(fop_pkt->info.data, 1, fop_pkt->datatype,
fop_pkt->addr, 1, fop_pkt->datatype, 0, fop_pkt->op);
}
else {
mpi_errno = do_accumulate_op(lock_entry->data, 1, fop_pkt->datatype,
fop_pkt->addr, 1, fop_pkt->datatype, 0, fop_pkt->op);
}
if (fop_pkt->type == MPIDI_CH3_PKT_FOP_IMMED) {
mpi_errno = do_accumulate_op(fop_pkt->info.data, 1, fop_pkt->datatype,
fop_pkt->addr, 1, fop_pkt->datatype, 0, fop_pkt->op);
}
else {
mpi_errno = do_accumulate_op(lock_entry->data, 1, fop_pkt->datatype,
fop_pkt->addr, 1, fop_pkt->datatype, 0, fop_pkt->op);
}
if (win_ptr->shm_allocated == TRUE)
......
......@@ -1356,10 +1356,8 @@ int MPIDI_CH3_PktHandler_FOP(MPIDI_VC_t * vc, MPIDI_CH3_Pkt_t * pkt,
}
/* Apply the op */
if (fop_pkt->op != MPI_NO_OP) {
mpi_errno = do_accumulate_op(fop_pkt->info.data, 1, fop_pkt->datatype,
fop_pkt->addr, 1, fop_pkt->datatype, 0, fop_pkt->op);
}
mpi_errno = do_accumulate_op(fop_pkt->info.data, 1, fop_pkt->datatype,
fop_pkt->addr, 1, fop_pkt->datatype, 0, fop_pkt->op);
if (win_ptr->shm_allocated == TRUE)
MPIDI_CH3I_SHM_MUTEX_UNLOCK(win_ptr);
......
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