Commit 8d6208ab authored by James Dinan's avatar James Dinan
Browse files

[svn-r10437] Refactored RMA ops list free code

Added a new inline function to free the ops list.  This is much clearer than
how it was done previously and should make it easier to see when/where we
can assume the ops list has been totally emptied.

Reviewer: goodell
parent c8f360b2
......@@ -137,8 +137,9 @@ static inline int MPIDI_CH3I_Win_ops_alloc_tail(MPID_Win *win_ptr,
/* This assertion can fail because the tail pointer is not maintainted (see
free_and_next). If this happens, consider refactoring to a previous
element pointer (instead of prevNext) or a better list. */
MPIU_Assert(win_ptr->rma_ops_list_tail != NULL);
element pointer (instead of a pointer to the prevous next pointer) or a
doubly-linked list. */
MPIU_Assert(MPIDI_CH3I_Win_ops_isempty(win_ptr) || win_ptr->rma_ops_list_tail != NULL);
/* FIXME: We should use a pool allocator here */
MPIU_CHKPMEM_MALLOC(tmp_ptr, MPIDI_RMA_ops *, sizeof(MPIDI_RMA_ops),
......@@ -214,6 +215,33 @@ static inline void MPIDI_CH3I_Win_ops_free_and_next(MPID_Win *win_ptr,
MPIU_Free( tmp_ptr );
}
/* Free the entire RMA operations list.
*/
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3I_Win_ops_free
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
static inline void MPIDI_CH3I_Win_ops_free(MPID_Win *win_ptr)
{
MPIDI_RMA_ops *curr_ptr = win_ptr->rma_ops_list_head;
while (curr_ptr != NULL) {
MPIDI_RMA_ops *tmp_ptr = curr_ptr->next;
/* Free this ops list entry */
if (curr_ptr->dataloop != NULL)
MPIU_Free(tmp_ptr->dataloop);
MPIU_Free( curr_ptr );
curr_ptr = tmp_ptr;
}
win_ptr->rma_ops_list_tail = NULL;
win_ptr->rma_ops_list_head = NULL;
}
#undef FUNCNAME
#undef FCNAME
......
......@@ -1888,7 +1888,7 @@ int MPIDI_Win_unlock(int dest, MPID_Win *win_ptr)
lock, we can do nothing and return. */
if (rma_op && rma_op->type == MPIDI_RMA_LOCK && rma_op->next == NULL &&
win_ptr->remote_lock_state == MPIDI_CH3_WIN_LOCK_NONE) {
MPIDI_CH3I_Win_ops_free_and_next(win_ptr, &win_ptr->rma_ops_list_head, &win_ptr->rma_ops_list_head);
MPIDI_CH3I_Win_ops_free(win_ptr);
goto fn_exit;
}
......@@ -2770,12 +2770,7 @@ static int MPIDI_CH3I_Send_lock_put_or_acc(MPID_Win *win_ptr)
/* Free MPIDI_RMA_ops_list - the lock packet should still be in place, so
* we have to free two elements. */
{
MPIDI_RMA_ops *tmpptr = win_ptr->rma_ops_list_head;
MPIDI_CH3I_Win_ops_free_and_next(win_ptr, &tmpptr, &win_ptr->rma_ops_list_head);
MPIDI_CH3I_Win_ops_free_and_next(win_ptr, &tmpptr, &win_ptr->rma_ops_list_head);
MPIU_Assert(MPIDI_CH3I_Win_ops_isempty(win_ptr));
}
MPIDI_CH3I_Win_ops_free(win_ptr);
fn_fail:
MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPIDI_CH3I_SEND_LOCK_PUT_OR_ACC);
......@@ -2894,12 +2889,7 @@ static int MPIDI_CH3I_Send_lock_get(MPID_Win *win_ptr)
/* Free MPIDI_RMA_ops_list - the lock packet should still be in place, so
* we have to free two elements. */
{
MPIDI_RMA_ops *tmpptr = win_ptr->rma_ops_list_head;
MPIDI_CH3I_Win_ops_free_and_next(win_ptr, &tmpptr, &win_ptr->rma_ops_list_head);
MPIDI_CH3I_Win_ops_free_and_next(win_ptr, &tmpptr, &win_ptr->rma_ops_list_head);
MPIU_Assert(MPIDI_CH3I_Win_ops_isempty(win_ptr));
}
MPIDI_CH3I_Win_ops_free(win_ptr);
fn_fail:
MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPIDI_CH3I_SEND_LOCK_GET);
......
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