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

Bug-fix: add true_lb when directly issuing contiguous derived data.



In RMA communication, when data to be sent is derived datatype but
contiguous, we can avoid copy/packing but directly issue it from
the user buffer. However, the data may have non-zero lb and we should
add the true lb when calculating the starting address. This patch
fixes this issue.
Signed-off-by: Pavan Balaji's avatarPavan Balaji <balaji@anl.gov>
parent c292eca9
......@@ -176,6 +176,7 @@ static int issue_from_origin_buffer(MPIDI_RMA_Op_t * rma_op, MPIDI_VC_t * vc,
int *blocklens = NULL;
MPI_Aint *displaces = NULL;
MPI_Datatype *datatypes = NULL;
MPI_Aint dt_true_lb;
int mpi_errno = MPI_SUCCESS;
MPIDI_STATE_DECL(MPID_STATE_ISSUE_FROM_ORIGIN_BUFFER);
......@@ -201,7 +202,10 @@ static int issue_from_origin_buffer(MPIDI_RMA_Op_t * rma_op, MPIDI_VC_t * vc,
}
MPID_Datatype_get_size_macro(rma_op->origin_datatype, origin_type_size);
/* check if origin data is contiguous and get true lb */
MPID_Datatype_is_contig(rma_op->origin_datatype, &is_origin_contig);
MPID_Datatype_get_true_lb(rma_op->origin_datatype, &dt_true_lb);
iov[0].MPID_IOV_BUF = (MPID_IOV_BUF_CAST) & (rma_op->pkt);
iov[0].MPID_IOV_LEN = sizeof(rma_op->pkt);
......@@ -212,7 +216,7 @@ static int issue_from_origin_buffer(MPIDI_RMA_Op_t * rma_op, MPIDI_VC_t * vc,
/* basic datatype on origin */
int iovcnt = 2;
iov[1].MPID_IOV_BUF = (MPID_IOV_BUF_CAST) ((char *) rma_op->origin_addr);
iov[1].MPID_IOV_BUF = (MPID_IOV_BUF_CAST) ((char *) rma_op->origin_addr + dt_true_lb);
iov[1].MPID_IOV_LEN = rma_op->origin_count * origin_type_size;
MPIU_THREAD_CS_ENTER(CH3COMM, vc);
......@@ -363,6 +367,7 @@ static int issue_from_origin_buffer_stream(MPIDI_RMA_Op_t * rma_op, MPIDI_VC_t *
int *blocklens = NULL;
MPI_Aint *displaces = NULL;
MPI_Datatype *datatypes = NULL;
MPI_Aint dt_true_lb;
int mpi_errno = MPI_SUCCESS;
MPIDI_STATE_DECL(MPID_STATE_ISSUE_FROM_ORIGIN_BUFFER_STREAM);
......@@ -389,7 +394,9 @@ static int issue_from_origin_buffer_stream(MPIDI_RMA_Op_t * rma_op, MPIDI_VC_t *
MPID_Datatype_get_ptr(rma_op->origin_datatype, origin_dtp);
}
/* check if origin data is contiguous and get true lb */
MPID_Datatype_is_contig(rma_op->origin_datatype, &is_origin_contig);
MPID_Datatype_get_true_lb(rma_op->origin_datatype, &dt_true_lb);
iov[0].MPID_IOV_BUF = (MPID_IOV_BUF_CAST) & (rma_op->pkt);
iov[0].MPID_IOV_LEN = sizeof(rma_op->pkt);
......@@ -401,7 +408,7 @@ static int issue_from_origin_buffer_stream(MPIDI_RMA_Op_t * rma_op, MPIDI_VC_t *
int iovcnt = 2;
iov[1].MPID_IOV_BUF =
(MPID_IOV_BUF_CAST) ((char *) rma_op->origin_addr + stream_offset);
(MPID_IOV_BUF_CAST) ((char *) rma_op->origin_addr + dt_true_lb + stream_offset);
iov[1].MPID_IOV_LEN = stream_size;
MPIU_THREAD_CS_ENTER(CH3COMM, vc);
......
......@@ -232,6 +232,7 @@ int MPIDI_CH3_ReqHandler_GaccumRecvComplete(MPIDI_VC_t * vc, MPID_Request * rreq
int is_contig;
MPI_Datatype basic_type;
MPI_Aint predef_count, predef_dtp_size;
MPI_Aint dt_true_lb;
MPIU_CHKPMEM_DECL(1);
MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_REQHANDLER_GACCUMRECVCOMPLETE);
......@@ -261,7 +262,9 @@ int MPIDI_CH3_ReqHandler_GaccumRecvComplete(MPIDI_VC_t * vc, MPID_Request * rreq
(rreq->dev.flags & MPIDI_CH3_PKT_FLAG_RMA_UNLOCK))
get_accum_resp_pkt->flags |= MPIDI_CH3_PKT_FLAG_RMA_FLUSH_ACK;
/* check if data is contiguous and get true lb */
MPID_Datatype_is_contig(rreq->dev.datatype, &is_contig);
MPID_Datatype_get_true_lb(rreq->dev.datatype, &dt_true_lb);
resp_req = MPID_Request_create();
MPIU_ERR_CHKANDJUMP(resp_req == NULL, mpi_errno, MPI_ERR_OTHER, "**nomemreq");
......@@ -280,8 +283,8 @@ int MPIDI_CH3_ReqHandler_GaccumRecvComplete(MPIDI_VC_t * vc, MPID_Request * rreq
if (is_contig) {
MPIU_Memcpy(resp_req->dev.user_buf,
(void *) ((char *) rreq->dev.real_user_buf + rreq->dev.stream_offset),
rreq->dev.recv_data_sz);
(void *) ((char *) rreq->dev.real_user_buf + dt_true_lb +
rreq->dev.stream_offset), rreq->dev.recv_data_sz);
}
else {
MPID_Segment *seg = MPID_Segment_alloc();
......
......@@ -565,6 +565,20 @@ do { \
} \
} while (0)
/* helper macro: takes an MPI_Datatype handle value and returns true_lb in
* (*true_lb_) */
#define MPID_Datatype_get_true_lb(dtype_, true_lb_) \
do { \
if (HANDLE_GET_KIND(dtype_) == HANDLE_KIND_BUILTIN) { \
*(true_lb_) = 0; \
} \
else { \
MPID_Datatype *dtp_ = NULL; \
MPID_Datatype_get_ptr((dtype_), dtp_); \
*(true_lb_) = dtp_->true_lb; \
} \
} while (0)
/* Datatype functions */
int MPID_Type_commit(MPI_Datatype *type);
......
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