Commit 8098f89c authored by Xin Zhao's avatar Xin Zhao
Browse files

Avoid memcpy if we decided to drop current op data.

No reviewer.
parent 45afd1fd
......@@ -738,7 +738,9 @@ int MPID_nem_handle_pkt(MPIDI_VC_t *vc, char *buf, MPIDI_msg_sz_t buflen)
{
size_t iov_len = iov->MPID_IOV_LEN;
MPIU_DBG_MSG_D(CH3_CHANNEL, VERBOSE, " %d", (int)iov_len);
MPIU_Memcpy (iov->MPID_IOV_BUF, buf, iov_len);
if (rreq->dev.drop_data == FALSE) {
MPIU_Memcpy (iov->MPID_IOV_BUF, buf, iov_len);
}
buflen -= iov_len;
buf += iov_len;
......@@ -751,7 +753,9 @@ int MPID_nem_handle_pkt(MPIDI_VC_t *vc, char *buf, MPIDI_msg_sz_t buflen)
if (buflen > 0)
{
MPIU_DBG_MSG_D(CH3_CHANNEL, VERBOSE, " " MPIDI_MSG_SZ_FMT, buflen);
MPIU_Memcpy (iov->MPID_IOV_BUF, buf, buflen);
if (rreq->dev.drop_data == FALSE) {
MPIU_Memcpy (iov->MPID_IOV_BUF, buf, buflen);
}
iov->MPID_IOV_BUF = (void *)((char *)iov->MPID_IOV_BUF + buflen);
iov->MPID_IOV_LEN -= buflen;
buflen = 0;
......
......@@ -345,6 +345,7 @@ extern MPIDI_Process_t MPIDI_Process;
(sreq_)->dev.match.parts.context_id = comm->context_id + context_offset; \
(sreq_)->dev.user_buf = (void *) buf; \
(sreq_)->dev.user_count = count; \
(sreq_)->dev.drop_data = FALSE; \
(sreq_)->dev.datatype = datatype; \
(sreq_)->dev.datatype_ptr = NULL; \
(sreq_)->dev.segment_ptr = NULL; \
......@@ -384,6 +385,7 @@ extern MPIDI_Process_t MPIDI_Process;
(rreq_)->dev.iov_offset = 0; \
(rreq_)->dev.OnDataAvail = NULL; \
(rreq_)->dev.OnFinal = NULL; \
(rreq_)->dev.drop_data = FALSE; \
MPIDI_CH3_REQUEST_INIT(rreq_);\
}
......
......@@ -374,6 +374,7 @@ typedef struct MPIDI_Request {
void *user_buf;
int user_count;
MPI_Datatype datatype;
int drop_data;
/* segment, segment_first, and segment_size are used when processing
non-contiguous datatypes */
......
......@@ -417,6 +417,7 @@ static inline int enqueue_lock_origin(MPID_Win *win_ptr, MPIDI_VC_t *vc,
/* fill in area in req that will be used in Receive_data_found() */
if (lock_discarded || data_discarded) {
req->dev.drop_data = TRUE;
req->dev.user_buf = NULL;
req->dev.user_count = target_count;
req->dev.datatype = target_dtp;
......
......@@ -148,7 +148,9 @@ int MPIDI_CH3U_Receive_data_found(MPID_Request *rreq, char *buf, MPIDI_msg_sz_t
{
MPIU_DBG_MSG(CH3_OTHER,VERBOSE,"Copying contiguous data to user buffer");
/* copy data out of the receive buffer */
MPIU_Memcpy((char*)(rreq->dev.user_buf) + dt_true_lb, buf, data_sz);
if (rreq->dev.drop_data == FALSE) {
MPIU_Memcpy((char*)(rreq->dev.user_buf) + dt_true_lb, buf, data_sz);
}
*buflen = data_sz;
*complete = TRUE;
}
......
......@@ -1462,6 +1462,9 @@ int MPIDI_CH3_ReqHandler_PiggybackLockOpRecvComplete( MPIDI_VC_t *vc,
/* This handler is triggered when we received all data of a lock queue
entry */
/* Note that if we decided to drop op data, here we just need to complete this
request; otherwise we try to get the lock again in this handler. */
if (rreq->dev.drop_data == FALSE) {
MPIU_Assert(lock_queue_entry != NULL);
/* Mark all data received in lock queue entry */
......@@ -1487,6 +1490,7 @@ int MPIDI_CH3_ReqHandler_PiggybackLockOpRecvComplete( MPIDI_VC_t *vc,
/* If try acquiring lock failed, just leave the lock queue entry in the queue with
all_data_recved marked as 1, release_lock() function will traverse the queue
and find entry with all_data_recved being 1 to grant the lock. */
}
/* mark receive data transfer as complete and decrement CC in receive
request */
......
......@@ -93,6 +93,7 @@ MPID_Request * MPID_Request_create(void)
req->dev.OnFinal = NULL;
req->dev.user_buf = NULL;
req->dev.final_user_buf = NULL;
req->dev.drop_data = FALSE;
#ifdef MPIDI_CH3_REQUEST_INIT
MPIDI_CH3_REQUEST_INIT(req);
#endif
......
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