Commit 344bf958 authored by Xin Zhao's avatar Xin Zhao
Browse files

Simplify code: not using flag MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP for GACC/FOP.



Flag MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP is used to tell the target
if the response packet of current GET, GACC and FOP should use
IMMED packet type. We use IMMED packet type only when
origin/target/result datatypes are all basic types.
Since the target does not know origin/result datatypes, origin
process needs to set a flag to inform the target.

However, this usage is redundant for GACC and FOP packets. The
reason is that, when we use IMMED packet type for GACC/FOP packets,
origin/target/result datatypes must be basic types,
in such case, we must use IMMED packet type for response packets
as well, and usage of MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP and
related code is not necessary. In short,
flag MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP is useful only for GET operation.
Signed-off-by: Pavan Balaji's avatarPavan Balaji <balaji@anl.gov>
parent 42b5fcf1
......@@ -226,12 +226,7 @@ int MPIDI_CH3_ReqHandler_GaccumRecvComplete(MPIDI_VC_t * vc, MPID_Request * rreq
MPID_Win_get_ptr(rreq->dev.target_win_handle, win_ptr);
if ((rreq->dev.flags) & MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP) {
MPIDI_Pkt_init(get_accum_resp_pkt, MPIDI_CH3_PKT_GET_ACCUM_RESP_IMMED);
}
else {
MPIDI_Pkt_init(get_accum_resp_pkt, MPIDI_CH3_PKT_GET_ACCUM_RESP);
}
MPIDI_Pkt_init(get_accum_resp_pkt, MPIDI_CH3_PKT_GET_ACCUM_RESP);
get_accum_resp_pkt->request_handle = rreq->dev.resp_request_handle;
get_accum_resp_pkt->target_rank = win_ptr->comm_ptr->rank;
get_accum_resp_pkt->flags = MPIDI_CH3_PKT_FLAG_NONE;
......@@ -249,44 +244,30 @@ int MPIDI_CH3_ReqHandler_GaccumRecvComplete(MPIDI_VC_t * vc, MPID_Request * rreq
MPIU_ERR_CHKANDJUMP(resp_req == NULL, mpi_errno, MPI_ERR_OTHER, "**nomemreq");
MPIU_Object_set_ref(resp_req, 1);
if (!((rreq->dev.flags) & MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP)) {
MPIU_CHKPMEM_MALLOC(resp_req->dev.user_buf, void *, rreq->dev.user_count * type_size,
mpi_errno, "GACC resp. buffer");
}
MPIU_CHKPMEM_MALLOC(resp_req->dev.user_buf, void *, rreq->dev.user_count * type_size,
mpi_errno, "GACC resp. buffer");
if (win_ptr->shm_allocated == TRUE)
MPIDI_CH3I_SHM_MUTEX_LOCK(win_ptr);
if ((rreq->dev.flags) & MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP) {
void *src = (void *) (rreq->dev.real_user_buf), *dest =
(void *) (get_accum_resp_pkt->info.data);
mpi_errno = immed_copy(src, dest, rreq->dev.user_count * type_size);
if (mpi_errno != MPI_SUCCESS) {
if (win_ptr->shm_allocated == TRUE)
MPIDI_CH3I_SHM_MUTEX_UNLOCK(win_ptr);
MPIU_ERR_POP(mpi_errno);
}
if (MPIR_DATATYPE_IS_PREDEFINED(rreq->dev.datatype)) {
MPIU_Memcpy(resp_req->dev.user_buf, rreq->dev.real_user_buf,
rreq->dev.user_count * type_size);
}
else {
if (MPIR_DATATYPE_IS_PREDEFINED(rreq->dev.datatype)) {
MPIU_Memcpy(resp_req->dev.user_buf, rreq->dev.real_user_buf,
rreq->dev.user_count * type_size);
}
else {
MPID_Segment *seg = MPID_Segment_alloc();
MPI_Aint last = type_size * rreq->dev.user_count;
MPID_Segment *seg = MPID_Segment_alloc();
MPI_Aint last = type_size * rreq->dev.user_count;
if (seg == NULL) {
if (win_ptr->shm_allocated == TRUE)
MPIDI_CH3I_SHM_MUTEX_UNLOCK(win_ptr);
}
MPIU_ERR_CHKANDJUMP1(seg == NULL, mpi_errno, MPI_ERR_OTHER, "**nomem", "**nomem %s",
"MPID_Segment");
MPID_Segment_init(rreq->dev.real_user_buf, rreq->dev.user_count, rreq->dev.datatype,
seg, 0);
MPID_Segment_pack(seg, 0, &last, resp_req->dev.user_buf);
MPID_Segment_free(seg);
if (seg == NULL) {
if (win_ptr->shm_allocated == TRUE)
MPIDI_CH3I_SHM_MUTEX_UNLOCK(win_ptr);
}
MPIU_ERR_CHKANDJUMP1(seg == NULL, mpi_errno, MPI_ERR_OTHER, "**nomem", "**nomem %s",
"MPID_Segment");
MPID_Segment_init(rreq->dev.real_user_buf, rreq->dev.user_count, rreq->dev.datatype, seg,
0);
MPID_Segment_pack(seg, 0, &last, resp_req->dev.user_buf);
MPID_Segment_free(seg);
}
/* accumulate data from tmp_buf into user_buf */
......@@ -308,19 +289,11 @@ int MPIDI_CH3_ReqHandler_GaccumRecvComplete(MPIDI_VC_t * vc, MPID_Request * rreq
* operation are completed when counter reaches zero. */
win_ptr->at_completion_counter++;
if ((rreq->dev.flags) & MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP) {
/* All origin data is in packet header, issue the header. */
iov[0].MPID_IOV_BUF = (MPID_IOV_BUF_CAST) get_accum_resp_pkt;
iov[0].MPID_IOV_LEN = sizeof(*get_accum_resp_pkt);
iovcnt = 1;
}
else {
iov[0].MPID_IOV_BUF = (MPID_IOV_BUF_CAST) get_accum_resp_pkt;
iov[0].MPID_IOV_LEN = sizeof(*get_accum_resp_pkt);
iov[1].MPID_IOV_BUF = (MPID_IOV_BUF_CAST) ((char *) resp_req->dev.user_buf);
iov[1].MPID_IOV_LEN = rreq->dev.user_count * type_size;
iovcnt = 2;
}
iov[0].MPID_IOV_BUF = (MPID_IOV_BUF_CAST) get_accum_resp_pkt;
iov[0].MPID_IOV_LEN = sizeof(*get_accum_resp_pkt);
iov[1].MPID_IOV_BUF = (MPID_IOV_BUF_CAST) ((char *) resp_req->dev.user_buf);
iov[1].MPID_IOV_LEN = rreq->dev.user_count * type_size;
iovcnt = 2;
MPIU_THREAD_CS_ENTER(CH3COMM, vc);
mpi_errno = MPIDI_CH3_iSendv(vc, resp_req, iov, iovcnt);
......@@ -372,8 +345,6 @@ int MPIDI_CH3_ReqHandler_FOPRecvComplete(MPIDI_VC_t * vc, MPID_Request * rreq, i
MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3_REQHANDLER_FOPRECVCOMPLETE);
MPIU_Assert(!(rreq->dev.flags & MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP));
MPID_Win_get_ptr(rreq->dev.target_win_handle, win_ptr);
MPID_Datatype_get_size_macro(rreq->dev.datatype, type_size);
......@@ -583,8 +554,6 @@ int MPIDI_CH3_ReqHandler_GaccumDerivedDTRecvComplete(MPIDI_VC_t * vc ATTRIBUTE((
MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3_REQHANDLER_GACCUMDERIVEDDTRECVCOMPLETE);
MPIU_Assert(!(rreq->dev.flags & MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP));
/* create derived datatype */
create_derived_datatype(rreq, &new_dtp);
......@@ -1106,7 +1075,7 @@ static inline int perform_get_acc_in_lock_queue(MPID_Win * win_ptr,
/* Copy data into a temporary buffer */
MPID_Datatype_get_size_macro(get_accum_pkt->datatype, type_size);
if (!(get_accum_pkt->flags & MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP))
if (get_accum_pkt->type == MPIDI_CH3_PKT_GET_ACCUM)
sreq->dev.user_buf = (void *) MPIU_Malloc(get_accum_pkt->count * type_size);
else {
MPIDI_Pkt_init(get_accum_resp_pkt, MPIDI_CH3_PKT_GET_ACCUM_RESP_IMMED);
......@@ -1119,7 +1088,7 @@ static inline int perform_get_acc_in_lock_queue(MPID_Win * win_ptr,
if (win_ptr->shm_allocated == TRUE)
MPIDI_CH3I_SHM_MUTEX_LOCK(win_ptr);
if (get_accum_pkt->flags & MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP) {
if (get_accum_pkt->type == MPIDI_CH3_PKT_GET_ACCUM_IMMED) {
void *src = (void *) (get_accum_pkt->addr), *dest =
(void *) (get_accum_resp_pkt->info.data);
mpi_errno = immed_copy(src, dest, len);
......@@ -1174,7 +1143,7 @@ static inline int perform_get_acc_in_lock_queue(MPID_Win * win_ptr,
* operation are completed when counter reaches zero. */
win_ptr->at_completion_counter++;
if (!(get_accum_pkt->flags & MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP)) {
if (get_accum_pkt->type == MPIDI_CH3_PKT_GET_ACCUM) {
MPIDI_Pkt_init(get_accum_resp_pkt, MPIDI_CH3_PKT_GET_ACCUM_RESP);
}
get_accum_resp_pkt->request_handle = get_accum_pkt->request_handle;
......@@ -1187,7 +1156,7 @@ static inline int perform_get_acc_in_lock_queue(MPID_Win * win_ptr,
get_accum_resp_pkt->flags |= MPIDI_CH3_PKT_FLAG_RMA_FLUSH_ACK;
get_accum_resp_pkt->target_rank = win_ptr->comm_ptr->rank;
if (get_accum_pkt->flags & MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP) {
if (get_accum_pkt->type == MPIDI_CH3_PKT_GET_ACCUM_IMMED) {
/* All origin data is in packet header, issue the header. */
iov[0].MPID_IOV_BUF = (MPID_IOV_BUF_CAST) get_accum_resp_pkt;
iov[0].MPID_IOV_LEN = sizeof(*get_accum_resp_pkt);
......@@ -1236,7 +1205,7 @@ static inline int perform_fop_in_lock_queue(MPID_Win * win_ptr, MPIDI_RMA_Lock_e
MPID_Datatype_get_size_macro(fop_pkt->datatype, type_size);
if (fop_pkt->flags & MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP) {
if (fop_pkt->flags & MPIDI_CH3_PKT_FOP_IMMED) {
MPIDI_Pkt_init(fop_resp_pkt, MPIDI_CH3_PKT_FOP_RESP_IMMED);
}
else {
......@@ -1253,7 +1222,7 @@ static inline int perform_fop_in_lock_queue(MPID_Win * win_ptr, MPIDI_RMA_Lock_e
(fop_pkt->flags & MPIDI_CH3_PKT_FLAG_RMA_UNLOCK))
fop_resp_pkt->flags |= MPIDI_CH3_PKT_FLAG_RMA_FLUSH_ACK;
if (!(fop_pkt->flags & MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP)) {
if (fop_pkt->type == MPIDI_CH3_PKT_FOP) {
resp_req = MPID_Request_create();
if (resp_req == NULL) {
MPIU_ERR_SETANDJUMP(mpi_errno, MPI_ERR_OTHER, "**nomemreq");
......@@ -1276,7 +1245,7 @@ static inline int perform_fop_in_lock_queue(MPID_Win * win_ptr, MPIDI_RMA_Lock_e
if (win_ptr->shm_allocated == TRUE)
MPIDI_CH3I_SHM_MUTEX_LOCK(win_ptr);
if (fop_pkt->flags & MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP) {
if (fop_pkt->type == MPIDI_CH3_PKT_FOP_IMMED) {
/* copy data to resp pkt header */
void *src = fop_pkt->addr, *dest = fop_resp_pkt->info.data;
mpi_errno = immed_copy(src, dest, type_size);
......@@ -1308,7 +1277,7 @@ static inline int perform_fop_in_lock_queue(MPID_Win * win_ptr, MPIDI_RMA_Lock_e
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
if (fop_pkt->flags & MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP) {
if (fop_pkt->type == MPIDI_CH3_PKT_FOP_IMMED) {
/* send back the original data */
MPIU_THREAD_CS_ENTER(CH3COMM, lock_entry->vc);
mpi_errno =
......
......@@ -762,9 +762,9 @@ int MPIDI_CH3I_Get_accumulate(const void *origin_addr, int origin_count,
else {
MPIDI_CH3_Pkt_get_accum_t *get_accum_pkt;
MPI_Aint origin_type_size, target_type_size;
size_t immed_len, orig_len, tar_len;
int use_immed_pkt = FALSE, use_immed_resp_pkt = FALSE;
MPI_Aint origin_type_size;
size_t immed_len, orig_len;
int use_immed_pkt = FALSE;
/******************** Setting operation struct areas ***********************/
......@@ -803,9 +803,6 @@ int MPIDI_CH3I_Get_accumulate(const void *origin_addr, int origin_count,
MPID_Datatype_get_size_macro(origin_datatype, origin_type_size);
MPIU_Assign_trunc(orig_len, origin_count * origin_type_size, size_t);
MPID_Datatype_get_size_macro(target_datatype, target_type_size);
MPIU_Assign_trunc(tar_len, target_count * target_type_size, size_t);
/* Judge if we can use IMMED data packet */
if (!new_ptr->is_dt) {
MPIU_Assign_trunc(immed_len,
......@@ -813,12 +810,6 @@ int MPIDI_CH3I_Get_accumulate(const void *origin_addr, int origin_count,
size_t);
if (orig_len <= immed_len)
use_immed_pkt = TRUE;
MPIU_Assign_trunc(immed_len,
(MPIDI_RMA_IMMED_BYTES / target_type_size) * target_type_size,
size_t);
if (tar_len <= immed_len)
use_immed_resp_pkt = TRUE;
}
/* Judge if this operation is a piggyback candidate */
......@@ -852,8 +843,6 @@ int MPIDI_CH3I_Get_accumulate(const void *origin_addr, int origin_count,
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
}
if (use_immed_resp_pkt)
get_accum_pkt->flags |= MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP;
}
MPIR_T_PVAR_TIMER_END(RMA, rma_rmaqueue_set);
......@@ -1265,7 +1254,7 @@ int MPIDI_Fetch_and_op(const void *origin_addr, void *result_addr,
MPIDI_CH3_Pkt_fop_t *fop_pkt;
MPI_Aint type_size;
size_t immed_len;
int use_immed_pkt = FALSE, use_immed_resp_pkt = FALSE;
int use_immed_pkt = FALSE;
/******************** Setting operation struct areas ***********************/
......@@ -1287,7 +1276,6 @@ int MPIDI_Fetch_and_op(const void *origin_addr, void *result_addr,
MPIU_Assign_trunc(immed_len, (MPIDI_RMA_IMMED_BYTES / type_size) * type_size, size_t);
if (type_size <= immed_len) {
use_immed_pkt = TRUE;
use_immed_resp_pkt = TRUE;
}
fop_pkt = &(new_ptr->pkt.fop);
......@@ -1310,8 +1298,6 @@ int MPIDI_Fetch_and_op(const void *origin_addr, void *result_addr,
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
}
if (use_immed_resp_pkt)
fop_pkt->flags |= MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP;
}
MPIR_T_PVAR_TIMER_END(RMA, rma_rmaqueue_set);
......
......@@ -776,14 +776,6 @@ int MPIDI_CH3_PktHandler_GetAccumulate(MPIDI_VC_t * vc, MPIDI_CH3_Pkt_t * pkt,
resp_req->dev.OnDataAvail = MPIDI_CH3_ReqHandler_GaccumSendComplete;
resp_req->dev.OnFinal = MPIDI_CH3_ReqHandler_GaccumSendComplete;
resp_req->kind = MPID_REQUEST_SEND;
if (!(get_accum_pkt->flags & MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP)) {
tmp_buf = MPIU_Malloc(get_accum_pkt->count * type_size);
if (!tmp_buf) {
MPIU_ERR_SETANDJUMP1(mpi_errno, MPI_ERR_OTHER, "**nomem", "**nomem %d",
get_accum_pkt->count * type_size);
}
resp_req->dev.user_buf = tmp_buf;
}
/* here we increment the Active Target counter to guarantee the GET-like
* operation are completed when counter reaches zero. */
......@@ -792,13 +784,7 @@ int MPIDI_CH3_PktHandler_GetAccumulate(MPIDI_VC_t * vc, MPIDI_CH3_Pkt_t * pkt,
/* Calculate the length of reponse data, ensure that it fits into immed packet. */
MPIU_Assign_trunc(len, get_accum_pkt->count * type_size, size_t);
if (get_accum_pkt->flags & MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP) {
MPIDI_Pkt_init(get_accum_resp_pkt, MPIDI_CH3_PKT_GET_ACCUM_RESP_IMMED);
}
else {
MPIDI_Pkt_init(get_accum_resp_pkt, MPIDI_CH3_PKT_GET_ACCUM_RESP);
}
MPIDI_Pkt_init(get_accum_resp_pkt, MPIDI_CH3_PKT_GET_ACCUM_RESP_IMMED);
get_accum_resp_pkt->request_handle = get_accum_pkt->request_handle;
get_accum_resp_pkt->target_rank = win_ptr->comm_ptr->rank;
get_accum_resp_pkt->flags = MPIDI_CH3_PKT_FLAG_NONE;
......@@ -812,19 +798,13 @@ int MPIDI_CH3_PktHandler_GetAccumulate(MPIDI_VC_t * vc, MPIDI_CH3_Pkt_t * pkt,
if (win_ptr->shm_allocated == TRUE)
MPIDI_CH3I_SHM_MUTEX_LOCK(win_ptr);
if (get_accum_resp_pkt->type == MPIDI_CH3_PKT_GET_ACCUM_RESP_IMMED) {
/* copy data from target buffer to response packet header */
src = (void *) (get_accum_pkt->addr), dest = (void *) (get_accum_resp_pkt->info.data);
mpi_errno = immed_copy(src, dest, len);
if (mpi_errno != MPI_SUCCESS) {
if (win_ptr->shm_allocated == TRUE)
MPIDI_CH3I_SHM_MUTEX_UNLOCK(win_ptr);
MPIU_ERR_POP(mpi_errno);
}
}
else {
MPIU_Memcpy(resp_req->dev.user_buf, get_accum_pkt->addr,
get_accum_pkt->count * type_size);
/* copy data from target buffer to response packet header */
src = (void *) (get_accum_pkt->addr), dest = (void *) (get_accum_resp_pkt->info.data);
mpi_errno = immed_copy(src, dest, len);
if (mpi_errno != MPI_SUCCESS) {
if (win_ptr->shm_allocated == TRUE)
MPIDI_CH3I_SHM_MUTEX_UNLOCK(win_ptr);
MPIU_ERR_POP(mpi_errno);
}
/* perform accumulate operation. */
......@@ -838,18 +818,9 @@ int MPIDI_CH3_PktHandler_GetAccumulate(MPIDI_VC_t * vc, MPIDI_CH3_Pkt_t * pkt,
if (mpi_errno)
MPIU_ERR_POP(mpi_errno);
if (get_accum_resp_pkt->type == MPIDI_CH3_PKT_GET_ACCUM_RESP_IMMED) {
iov[0].MPID_IOV_BUF = (MPID_IOV_BUF_CAST) get_accum_resp_pkt;
iov[0].MPID_IOV_LEN = sizeof(*get_accum_resp_pkt);
iovcnt = 1;
}
else {
iov[0].MPID_IOV_BUF = (MPID_IOV_BUF_CAST) get_accum_resp_pkt;
iov[0].MPID_IOV_LEN = sizeof(*get_accum_resp_pkt);
iov[1].MPID_IOV_BUF = (MPID_IOV_BUF_CAST) ((char *) resp_req->dev.user_buf);
iov[1].MPID_IOV_LEN = get_accum_pkt->count * type_size;
iovcnt = 2;
}
iov[0].MPID_IOV_BUF = (MPID_IOV_BUF_CAST) get_accum_resp_pkt;
iov[0].MPID_IOV_LEN = sizeof(*get_accum_resp_pkt);
iovcnt = 1;
MPIU_THREAD_CS_ENTER(CH3COMM, vc);
mpi_errno = MPIDI_CH3_iSendv(vc, resp_req, iov, iovcnt);
......@@ -1198,8 +1169,6 @@ int MPIDI_CH3_PktHandler_FOP(MPIDI_VC_t * vc, MPIDI_CH3_Pkt_t * pkt,
if (pkt->type == MPIDI_CH3_PKT_FOP_IMMED) {
MPIU_Assert(fop_pkt->flags & MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP);
MPIDI_Pkt_init(fop_resp_pkt, MPIDI_CH3_PKT_FOP_RESP_IMMED);
fop_resp_pkt->request_handle = fop_pkt->request_handle;
fop_resp_pkt->target_rank = win_ptr->comm_ptr->rank;
......@@ -1269,8 +1238,6 @@ int MPIDI_CH3_PktHandler_FOP(MPIDI_VC_t * vc, MPIDI_CH3_Pkt_t * pkt,
else {
MPIU_Assert(pkt->type == MPIDI_CH3_PKT_FOP);
MPIU_Assert(!(fop_pkt->flags & MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP));
MPID_Request *req = NULL;
char *data_buf = NULL;
MPIDI_msg_sz_t data_len;
......
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