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

Code-refactoring: move completion judgement code out of GC function.



In this patch, we move the judgement of local/remote completion
out of GC function to separate macros, so that GC function only
does the garbage collection work.
Signed-off-by: Pavan Balaji's avatarPavan Balaji <balaji@anl.gov>
parent 77c07868
......@@ -22,6 +22,26 @@ extern MPIDI_RMA_Target_t *global_rma_target_pool, *global_rma_target_pool_tail,
MPIR_T_PVAR_DOUBLE_TIMER_DECL_EXTERN(RMA, rma_rmaqueue_alloc);
#define MPIDI_CH3I_RMA_ops_completion(win_, target_, local_completed_, remote_completed_) \
do { \
local_completed_ = 0; \
remote_completed_ = 0; \
if (win_->states.access_state != MPIDI_RMA_FENCE_ISSUED && \
win_->states.access_state != MPIDI_RMA_PSCW_ISSUED && \
win_->states.access_state != MPIDI_RMA_LOCK_ALL_ISSUED && \
target_->access_state != MPIDI_RMA_LOCK_CALLED && \
target_->access_state != MPIDI_RMA_LOCK_ISSUED && \
target_->pending_op_list_head == NULL && \
target_->issued_read_op_list_head == NULL && \
target_->issued_write_op_list_head == NULL && \
target_->issued_dt_op_list_head == NULL) { \
local_completed_ = 1; \
if (target_->sync.sync_flag == MPIDI_RMA_SYNC_NONE && \
target_->sync.outstanding_acks == 0) \
remote_completed_ = 1; \
} \
} while (0)
/* MPIDI_CH3I_Win_op_alloc(): get a new op element from op pool and
* initialize it. If we cannot get one, return NULL. */
#undef FUNCNAME
......@@ -329,8 +349,7 @@ static inline int MPIDI_CH3I_Win_target_dequeue_and_free(MPID_Win * win_ptr, MPI
#define FUNCNAME MPIDI_CH3I_RMA_Cleanup_ops_target
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
static inline int MPIDI_CH3I_RMA_Cleanup_ops_target(MPID_Win * win_ptr, MPIDI_RMA_Target_t * target,
int *local_completed, int *remote_completed)
static inline int MPIDI_CH3I_RMA_Cleanup_ops_target(MPID_Win * win_ptr, MPIDI_RMA_Target_t * target)
{
MPIDI_RMA_Op_t *curr_op = NULL;
MPIDI_RMA_Op_t **op_list_head = NULL, **op_list_tail = NULL;
......@@ -338,9 +357,6 @@ static inline int MPIDI_CH3I_RMA_Cleanup_ops_target(MPID_Win * win_ptr, MPIDI_RM
int mpi_errno = MPI_SUCCESS;
int i;
(*local_completed) = 0;
(*remote_completed) = 0;
if (win_ptr->states.access_state == MPIDI_RMA_FENCE_ISSUED ||
win_ptr->states.access_state == MPIDI_RMA_PSCW_ISSUED ||
win_ptr->states.access_state == MPIDI_RMA_LOCK_ALL_ISSUED)
......@@ -356,7 +372,7 @@ static inline int MPIDI_CH3I_RMA_Cleanup_ops_target(MPID_Win * win_ptr, MPIDI_RM
if (target->pending_op_list_head == NULL &&
target->issued_read_op_list_head == NULL && target->issued_write_op_list_head == NULL &&
target->issued_dt_op_list_head == NULL)
goto cleanup_target;
goto fn_exit;
/* go over issued_read_op_list, issued_write_op_list,
* issued_dt_op_list, start from issued_read_op_list. */
......@@ -433,21 +449,6 @@ static inline int MPIDI_CH3I_RMA_Cleanup_ops_target(MPID_Win * win_ptr, MPIDI_RM
curr_op = *op_list_head;
}
cleanup_target:
if (target->pending_op_list_head == NULL &&
target->issued_read_op_list_head == NULL && target->issued_write_op_list_head == NULL &&
target->issued_dt_op_list_head == NULL) {
(*local_completed) = 1;
/* for the conditions that need to be satisfied before we free the
* target, see the MPIDI_RMA_Target definition in
* mpid_rma_types.h */
if (target->sync.sync_flag == MPIDI_RMA_SYNC_NONE && target->sync.outstanding_acks == 0) {
(*remote_completed) = 1;
}
}
fn_exit:
return mpi_errno;
fn_fail:
......@@ -473,10 +474,12 @@ static inline int MPIDI_CH3I_RMA_Cleanup_ops_win(MPID_Win * win_ptr,
for (target = win_ptr->slots[i].target_list_head; target;) {
int local = 0, remote = 0;
mpi_errno = MPIDI_CH3I_RMA_Cleanup_ops_target(win_ptr, target, &local, &remote);
mpi_errno = MPIDI_CH3I_RMA_Cleanup_ops_target(win_ptr, target);
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
MPIDI_CH3I_RMA_ops_completion(win_ptr, target, local, remote);
num_targets++;
local_completed_targets += local;
remote_completed_targets += remote;
......
......@@ -628,7 +628,7 @@ int MPIDI_CH3I_RMA_Free_ops_before_completion(MPID_Win * win_ptr)
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int MPIDI_CH3I_RMA_Cleanup_ops_aggressive(MPID_Win * win_ptr)
{
int i, local_completed = 0, remote_completed = 0;
int i, local_completed = 0, remote_completed ATTRIBUTE((unused)) = 0;
int mpi_errno = MPI_SUCCESS;
MPIDI_RMA_Target_t *curr_target = NULL;
int made_progress = 0;
......@@ -663,10 +663,12 @@ int MPIDI_CH3I_RMA_Cleanup_ops_aggressive(MPID_Win * win_ptr)
/* Wait for local completion. */
do {
mpi_errno = MPIDI_CH3I_RMA_Cleanup_ops_target(win_ptr, curr_target,
&local_completed, &remote_completed);
mpi_errno = MPIDI_CH3I_RMA_Cleanup_ops_target(win_ptr, curr_target);
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
MPIDI_CH3I_RMA_ops_completion(win_ptr, curr_target, local_completed, remote_completed);
if (!local_completed) {
mpi_errno = wait_progress_engine();
if (mpi_errno != MPI_SUCCESS)
......@@ -687,7 +689,7 @@ int MPIDI_CH3I_RMA_Cleanup_ops_aggressive(MPID_Win * win_ptr)
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int MPIDI_CH3I_RMA_Cleanup_target_aggressive(MPID_Win * win_ptr, MPIDI_RMA_Target_t ** target)
{
int i, local_completed = 0, remote_completed = 0;
int i, local_completed ATTRIBUTE((unused)) = 0, remote_completed = 0;
int made_progress = 0;
MPIDI_RMA_Target_t *curr_target = NULL;
int mpi_errno = MPI_SUCCESS;
......@@ -743,10 +745,12 @@ int MPIDI_CH3I_RMA_Cleanup_target_aggressive(MPID_Win * win_ptr, MPIDI_RMA_Targe
/* Wait for remote completion. */
do {
mpi_errno = MPIDI_CH3I_RMA_Cleanup_ops_target(win_ptr, curr_target,
&local_completed, &remote_completed);
mpi_errno = MPIDI_CH3I_RMA_Cleanup_ops_target(win_ptr, curr_target);
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
MPIDI_CH3I_RMA_ops_completion(win_ptr, curr_target, local_completed, remote_completed);
if (!remote_completed) {
mpi_errno = wait_progress_engine();
if (mpi_errno != MPI_SUCCESS)
......
......@@ -1050,7 +1050,7 @@ int MPIDI_Win_lock(int lock_type, int dest, int assert, MPID_Win * win_ptr)
int MPIDI_Win_unlock(int dest, MPID_Win * win_ptr)
{
int made_progress = 0;
int local_completed = 0, remote_completed = 0;
int local_completed ATTRIBUTE((unused)) = 0, remote_completed = 0;
MPIDI_RMA_Target_t *target = NULL;
enum MPIDI_RMA_sync_types sync_flag;
int progress_engine_triggered = 0;
......@@ -1098,10 +1098,12 @@ int MPIDI_Win_unlock(int dest, MPID_Win * win_ptr)
/* Wait for remote completion. */
do {
mpi_errno = MPIDI_CH3I_RMA_Cleanup_ops_target(win_ptr, target,
&local_completed, &remote_completed);
mpi_errno = MPIDI_CH3I_RMA_Cleanup_ops_target(win_ptr, target);
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
MPIDI_CH3I_RMA_ops_completion(win_ptr, target, local_completed, remote_completed);
if (!remote_completed) {
mpi_errno = wait_progress_engine();
if (mpi_errno != MPI_SUCCESS)
......@@ -1165,7 +1167,7 @@ int MPIDI_Win_unlock(int dest, MPID_Win * win_ptr)
int MPIDI_Win_flush(int dest, MPID_Win * win_ptr)
{
int made_progress = 0;
int local_completed = 0, remote_completed = 0;
int local_completed ATTRIBUTE((unused)) = 0, remote_completed = 0;
int rank = win_ptr->comm_ptr->rank;
MPIDI_RMA_Target_t *target = NULL;
int progress_engine_triggered = 0;
......@@ -1218,10 +1220,12 @@ int MPIDI_Win_flush(int dest, MPID_Win * win_ptr)
/* Wait for remote completion. */
do {
mpi_errno = MPIDI_CH3I_RMA_Cleanup_ops_target(win_ptr, target,
&local_completed, &remote_completed);
mpi_errno = MPIDI_CH3I_RMA_Cleanup_ops_target(win_ptr, target);
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
MPIDI_CH3I_RMA_ops_completion(win_ptr, target, local_completed, remote_completed);
if (!remote_completed) {
mpi_errno = wait_progress_engine();
if (mpi_errno != MPI_SUCCESS)
......@@ -1329,10 +1333,12 @@ int MPIDI_Win_flush_local(int dest, MPID_Win * win_ptr)
/* Wait for local completion. */
do {
mpi_errno = MPIDI_CH3I_RMA_Cleanup_ops_target(win_ptr, target,
&local_completed, &remote_completed);
mpi_errno = MPIDI_CH3I_RMA_Cleanup_ops_target(win_ptr, target);
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
MPIDI_CH3I_RMA_ops_completion(win_ptr, target, local_completed, remote_completed);
if ((target->sync.upgrade_flush_local && !remote_completed) ||
(!target->sync.upgrade_flush_local && !local_completed)) {
mpi_errno = wait_progress_engine();
......@@ -1790,11 +1796,13 @@ int MPIDI_Win_flush_local_all(MPID_Win * win_ptr)
for (i = 0; i < win_ptr->num_slots; i++) {
curr_target = win_ptr->slots[i].target_list_head;
while (curr_target != NULL) {
mpi_errno = MPIDI_CH3I_RMA_Cleanup_ops_target(win_ptr, curr_target,
&local_completed, &remote_completed);
mpi_errno = MPIDI_CH3I_RMA_Cleanup_ops_target(win_ptr, curr_target);
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
MPIDI_CH3I_RMA_ops_completion(win_ptr, curr_target, local_completed,
remote_completed);
if (curr_target->sync.upgrade_flush_local) {
if (remote_completed) {
remote_completed_cnt++;
......
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