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

Use a request array in RMA operation.



Because we may cut one RMA operation into multiple packets,
and each packet needs a request object to track the completion,
here we use a request array instead of single request in
RMA operation structure.
Signed-off-by: Pavan Balaji's avatarPavan Balaji <balaji@anl.gov>
parent 1a3e661f
This diff is collapsed.
......@@ -47,7 +47,8 @@ static inline MPIDI_RMA_Op_t *MPIDI_CH3I_Win_op_alloc(MPID_Win * win_ptr)
}
e->dataloop = NULL;
e->request = NULL;
e->reqs = NULL;
e->reqs_size = 0;
e->ureq = NULL;
e->is_dt = 0;
e->piggyback_lock_candidate = 0;
......@@ -334,6 +335,7 @@ static inline int MPIDI_CH3I_RMA_Cleanup_ops_target(MPID_Win * win_ptr, MPIDI_RM
MPIDI_RMA_Op_t **op_list = NULL, **op_list_tail = NULL;
int read_flag = 0, write_flag = 0;
int mpi_errno = MPI_SUCCESS;
int i;
(*local_completed) = 0;
(*remote_completed) = 0;
......@@ -375,14 +377,27 @@ static inline int MPIDI_CH3I_RMA_Cleanup_ops_target(MPID_Win * win_ptr, MPIDI_RM
curr_op = *op_list;
while (curr_op != NULL) {
if (MPID_Request_is_complete(curr_op->request)) {
/* If there's an error, return it */
mpi_errno = curr_op->request->status.MPI_ERROR;
MPIU_ERR_CHKANDJUMP(mpi_errno, mpi_errno, MPI_ERR_OTHER, "**ch3|rma_msg");
for (i = 0; i < curr_op->reqs_size; i++) {
if (curr_op->reqs[i] == NULL)
continue;
/* No errors, free the request */
MPID_Request_release(curr_op->request);
if (MPID_Request_is_complete(curr_op->reqs[i])) {
/* If there's an error, return it */
mpi_errno = curr_op->reqs[i]->status.MPI_ERROR;
MPIU_ERR_CHKANDJUMP(mpi_errno, mpi_errno, MPI_ERR_OTHER, "**ch3|rma_msg");
/* No errors, free the request */
MPID_Request_release(curr_op->reqs[i]);
curr_op->reqs[i] = NULL;
win_ptr->active_req_cnt--;
}
else
break;
}
if (i == curr_op->reqs_size) {
/* Release user request */
if (curr_op->ureq) {
/* User request must be completed by progress engine */
......@@ -392,10 +407,14 @@ static inline int MPIDI_CH3I_RMA_Cleanup_ops_target(MPID_Win * win_ptr, MPIDI_RM
MPID_Request_release(curr_op->ureq);
}
/* free request array in op struct */
MPIU_Free(curr_op->reqs);
curr_op->reqs = NULL;
curr_op->reqs_size = 0;
/* dequeue the operation and free it */
MPL_LL_DELETE(*op_list, *op_list_tail, curr_op);
MPIDI_CH3I_Win_op_free(win_ptr, curr_op);
win_ptr->active_req_cnt--;
if (*op_list == NULL) {
if (read_flag == 1) {
......
......@@ -60,7 +60,9 @@ typedef struct MPIDI_RMA_Op {
int result_count;
MPI_Datatype result_datatype;
struct MPID_Request *request;
struct MPID_Request **reqs;
int reqs_size;
MPIDI_RMA_dtype_info dtype_info;
void *dataloop;
......
......@@ -585,6 +585,7 @@ static inline int adjust_op_piggybacked_with_lock(MPID_Win * win_ptr,
MPIDI_RMA_Target_t *target = NULL;
MPIDI_RMA_Op_t *op = NULL;
MPIDI_CH3_Pkt_flags_t op_flags = MPIDI_CH3_PKT_FLAG_NONE;
int i;
int mpi_errno = MPI_SUCCESS;
mpi_errno = MPIDI_CH3I_Win_find_target(win_ptr, target_rank, &target);
......@@ -607,7 +608,8 @@ static inline int adjust_op_piggybacked_with_lock(MPID_Win * win_ptr,
MPIU_ERR_POP(mpi_errno);
}
if (!op->request) {
if (op->reqs_size == 0) {
MPIU_Assert(op->reqs == NULL);
MPIDI_CH3I_RMA_Ops_free_elem(win_ptr, &(target->pending_op_list),
&(target->pending_op_list_tail), op);
}
......@@ -636,10 +638,19 @@ static inline int adjust_op_piggybacked_with_lock(MPID_Win * win_ptr,
/* We need to re-transmit this operation, so we destroy
* the internal request and erase all flags in current
* operation. */
if (op->request) {
MPIDI_CH3_Request_destroy(op->request);
op->request = NULL;
win_ptr->active_req_cnt--;
if (op->reqs_size > 0) {
MPIU_Assert(op->reqs != NULL);
for (i = 0; i < op->reqs_size; i++) {
if (op->reqs[i] != NULL) {
MPIDI_CH3_Request_destroy(op->reqs[i]);
op->reqs[i] = NULL;
win_ptr->active_req_cnt--;
}
}
/* free req array in this op */
MPIU_Free(op->reqs);
op->reqs = NULL;
op->reqs_size = 0;
}
MPIDI_CH3_PKT_RMA_ERASE_FLAGS(op->pkt, mpi_errno);
......
......@@ -393,7 +393,8 @@ static inline int issue_ops_target(MPID_Win * win_ptr, MPIDI_RMA_Target_t * targ
MPIU_ERR_POP(mpi_errno);
}
if (!curr_op->request) {
if (curr_op->reqs_size == 0) {
MPIU_Assert(curr_op->reqs == NULL);
/* Sending is completed immediately. */
MPIDI_CH3I_RMA_Ops_free_elem(win_ptr, &(target->pending_op_list),
&(target->pending_op_list_tail), curr_op);
......@@ -560,12 +561,24 @@ int MPIDI_CH3I_RMA_Free_ops_before_completion(MPID_Win * win_ptr)
/* free all ops in the list since we do not need to maintain them anymore */
for (curr_op = *op_list; curr_op != NULL;) {
MPID_Request_release(curr_op->request);
if (curr_op->reqs_size > 0) {
MPIU_Assert(curr_op->reqs != NULL);
for (i = 0; i < curr_op->reqs_size; i++) {
if (curr_op->reqs[i] != NULL) {
MPID_Request_release(curr_op->reqs[i]);
curr_op->reqs[i] = NULL;
win_ptr->active_req_cnt--;
}
}
/* free req array in this op */
MPIU_Free(curr_op->reqs);
curr_op->reqs = NULL;
curr_op->reqs_size = 0;
}
MPL_LL_DELETE(*op_list, *op_list_tail, curr_op);
MPIDI_CH3I_Win_op_free(win_ptr, curr_op);
win_ptr->active_req_cnt--;
if (*op_list == NULL) {
if (read_flag == 1) {
op_list = &curr_target->write_op_list;
......
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