changing list so to imbed a lam_list_item_t as the head and tail in the
list, rather than pointer to these - simpler and faster logic, but more memory usage. This commit was SVN r315.
Этот коммит содержится в:
родитель
f5039f70e1
Коммит
223b49aee5
@ -38,7 +38,10 @@ void lam_list_item_init(lam_list_item_t *item)
|
||||
void lam_list_init(lam_list_t *list)
|
||||
{
|
||||
SUPER_INIT(list, lam_list_cls.cls_parent);
|
||||
list->lam_list_head = list->lam_list_tail = 0;
|
||||
list->lam_list_head.lam_list_next=&(list->lam_list_tail);
|
||||
list->lam_list_head.lam_list_prev=(lam_list_item_t *)NULL;
|
||||
list->lam_list_tail.lam_list_prev=(lam_list_item_t *)NULL;
|
||||
list->lam_list_tail.lam_list_prev=&(list->lam_list_head);
|
||||
list->lam_list_type = 0;
|
||||
list->lam_list_length = 0;
|
||||
}
|
||||
@ -46,43 +49,39 @@ void lam_list_init(lam_list_t *list)
|
||||
void lam_list_destroy(lam_list_t *list)
|
||||
{
|
||||
/* release all items in list */
|
||||
lam_list_empty_list(list);
|
||||
lam_list_init(list);
|
||||
SUPER_DESTROY(list, lam_list_cls.cls_parent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adds item to the end of the list.
|
||||
*
|
||||
* @param list List accepting new item (IN/OUT)
|
||||
*
|
||||
* @param item Item being put on the new list (IN)
|
||||
*
|
||||
*/
|
||||
void lam_list_append(lam_list_t *list, lam_list_item_t *item)
|
||||
{
|
||||
/* Adds item to the end of the list. */
|
||||
item->lam_list_next = 0;
|
||||
item->lam_list_prev = list->lam_list_tail;
|
||||
if ( !(list->lam_list_head) )
|
||||
list->lam_list_head = item;
|
||||
if ( list->lam_list_tail )
|
||||
list->lam_list_tail->lam_list_next = item;
|
||||
|
||||
list->lam_list_tail = item;
|
||||
|
||||
/* set new element's previous pointer */
|
||||
item->lam_list_prev=list->lam_list_tail.lam_list_prev;
|
||||
|
||||
/* reset previous pointer on current last element */
|
||||
list->lam_list_tail.lam_list_prev->lam_list_next=item;
|
||||
|
||||
/* reset new element's next pointer */
|
||||
item->lam_list_next=&(list->lam_list_tail);
|
||||
|
||||
/* reset the list's tail element previous pointer */
|
||||
list->lam_list_tail.lam_list_prev = item;
|
||||
|
||||
/* increment list element counter */
|
||||
list->lam_list_length++;
|
||||
}
|
||||
|
||||
void lam_list_empty_list(lam_list_t *list)
|
||||
{
|
||||
/* Since we don't retain the items, simply set
|
||||
each item's next and prev pointers to 0. */
|
||||
lam_list_item_t *ptr, *next;
|
||||
|
||||
ptr = list->lam_list_head;
|
||||
while ( ptr )
|
||||
{
|
||||
next = ptr->lam_list_next;
|
||||
ptr->lam_list_next = ptr->lam_list_prev = 0;
|
||||
ptr = next;
|
||||
}
|
||||
list->lam_list_head = list->lam_list_tail = 0;
|
||||
list->lam_list_length = 0;
|
||||
}
|
||||
|
||||
|
||||
int lam_list_insert(lam_list_t *list, lam_list_item_t *item, long long idx)
|
||||
{
|
||||
/* Adds item to list at index and retains item. */
|
||||
@ -98,7 +97,7 @@ int lam_list_insert(lam_list_t *list, lam_list_item_t *item, long long idx)
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr = list->lam_list_head;
|
||||
ptr = list->lam_list_head.lam_list_next;
|
||||
for ( i = 0; i < idx; i++ )
|
||||
ptr = ptr->lam_list_next;
|
||||
|
||||
@ -113,14 +112,30 @@ int lam_list_insert(lam_list_t *list, lam_list_item_t *item, long long idx)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds item to the front of the list and retains item.
|
||||
*
|
||||
* @param list List accepting new item (IN/OUT)
|
||||
*
|
||||
* @param item Item being put on the new list (IN)
|
||||
*
|
||||
*/
|
||||
void lam_list_prepend(lam_list_t *list, lam_list_item_t *item)
|
||||
{
|
||||
/* Adds item to the front of the list and retains item. */
|
||||
item->lam_list_next = list->lam_list_head;
|
||||
item->lam_list_prev = 0;
|
||||
if ( list->lam_list_head )
|
||||
list->lam_list_head->lam_list_prev = item;
|
||||
list->lam_list_head = item;
|
||||
/* reset item's next pointer */
|
||||
item->lam_list_next = list->lam_list_head.lam_list_next;
|
||||
|
||||
/* reset item's previous pointer */
|
||||
item->lam_list_prev = &(list->lam_list_head);
|
||||
|
||||
/* reset previous first element's previous poiner */
|
||||
list->lam_list_head.lam_list_next->lam_list_prev = item;
|
||||
|
||||
/* reset head's next pointer */
|
||||
list->lam_list_head.lam_list_next = item;
|
||||
|
||||
/* increment list element counter */
|
||||
list->lam_list_length++;
|
||||
}
|
||||
|
||||
lam_list_item_t *lam_list_remove_first(lam_list_t *list)
|
||||
@ -131,19 +146,23 @@ lam_list_item_t *lam_list_remove_first(lam_list_t *list)
|
||||
*/
|
||||
lam_list_item_t *item;
|
||||
if ( 0 == list->lam_list_length )
|
||||
return 0;
|
||||
return (lam_list_item_t *)NULL;
|
||||
|
||||
list->lam_list_length--;
|
||||
item = list->lam_list_head;
|
||||
list->lam_list_head = item->lam_list_next;
|
||||
if ( list->lam_list_length )
|
||||
{
|
||||
item->lam_list_next->lam_list_prev = 0;
|
||||
}
|
||||
else
|
||||
list->lam_list_tail = 0;
|
||||
|
||||
item->lam_list_next = item->lam_list_prev = 0;
|
||||
/* get pointer to first element on the list */
|
||||
item = list->lam_list_head.lam_list_next;
|
||||
|
||||
/* reset previous pointer of next item on the list */
|
||||
item->lam_list_next->lam_list_prev=item->lam_list_prev;
|
||||
|
||||
/* reset the head next pointer */
|
||||
list->lam_list_head.lam_list_next=item->lam_list_next;
|
||||
|
||||
#ifdef LAM_ENABLE_DEBUG
|
||||
/* debug code */
|
||||
item->lam_list_prev=(lam_list_item_t *)NULL;
|
||||
item->lam_list_next=(lam_list_item_t *)NULL;
|
||||
#endif
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
@ -156,16 +175,25 @@ lam_list_item_t *lam_list_remove_last(lam_list_t *list)
|
||||
lam_list_item_t *item;
|
||||
|
||||
if ( 0 == list->lam_list_length )
|
||||
return 0;
|
||||
return (lam_list_item_t *)NULL;
|
||||
|
||||
/* reset list length counter */
|
||||
list->lam_list_length--;
|
||||
item = list->lam_list_head;
|
||||
list->lam_list_tail = item->lam_list_prev;
|
||||
if ( list->lam_list_length )
|
||||
item->lam_list_prev->lam_list_next = 0;
|
||||
else
|
||||
list->lam_list_head = 0;
|
||||
item->lam_list_next = item->lam_list_prev = 0;
|
||||
|
||||
/* get item */
|
||||
item = list->lam_list_tail.lam_list_prev;
|
||||
|
||||
/* reset previous pointer on next to last pointer */
|
||||
item->lam_list_prev->lam_list_next=item->lam_list_next;
|
||||
|
||||
/* reset tail's previous pointer */
|
||||
list->lam_list_tail.lam_list_prev=item->lam_list_prev;
|
||||
|
||||
#ifdef LAM_ENABLE_DEBUG
|
||||
/* debug code */
|
||||
item->lam_list_next = item->lam_list_prev = (lam_list_item_t *)NULL;
|
||||
#endif
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
@ -50,8 +50,8 @@ void lam_list_item_destroy(lam_list_item_t *item);
|
||||
typedef struct lam_list
|
||||
{
|
||||
lam_object_t super;
|
||||
lam_list_item_t *lam_list_head;
|
||||
lam_list_item_t *lam_list_tail;
|
||||
lam_list_item_t lam_list_head;
|
||||
lam_list_item_t lam_list_tail;
|
||||
lam_list_type_t lam_list_type;
|
||||
volatile size_t lam_list_length;
|
||||
} lam_list_t;
|
||||
@ -79,6 +79,11 @@ static inline size_t lam_list_get_size(lam_list_t* list)
|
||||
return list->lam_list_length;
|
||||
}
|
||||
|
||||
static inline void lam_list_set_size(lam_list_t* list, size_t size)
|
||||
{
|
||||
list->lam_list_length=size;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns first item on list, but does not remove it from the list.
|
||||
@ -116,14 +121,6 @@ void lam_list_append(lam_list_t *list, lam_list_item_t *item);
|
||||
*/
|
||||
lam_list_item_t* lam_list_remove(lam_list_t *list, lam_list_item_t *item);
|
||||
|
||||
|
||||
/*
|
||||
* Removes all items in list and sets each
|
||||
* item's next and prev pointer to 0.
|
||||
*/
|
||||
void lam_list_empty_list(lam_list_t *list);
|
||||
|
||||
|
||||
/* Adds item to list at index and retains item.
|
||||
Returns 1 if successful, 0 otherwise.
|
||||
0 <= idx < length_m
|
||||
|
@ -174,7 +174,7 @@ int mca_ptl_base_match(mca_pml_base_reliable_hdr_t *frag_header,
|
||||
* @param frag_header Matching data from recived fragment (IN)
|
||||
*
|
||||
* @param pml_comm Pointer to the communicator structure used for
|
||||
* matching purposes.
|
||||
* matching purposes. (IN)
|
||||
*
|
||||
* @return Matched receive
|
||||
*
|
||||
@ -193,6 +193,7 @@ mca_pml_base_recv_request_t *mca_ptl_base_check_recieves_for_match
|
||||
|
||||
/* initialization */
|
||||
return_match=(mca_pml_base_recv_request_t *)NULL;
|
||||
|
||||
/*
|
||||
* figure out what sort of matching logic to use, if need to
|
||||
* look only at "specific" recieves, or "wild" receives,
|
||||
@ -221,3 +222,86 @@ mca_pml_base_recv_request_t *mca_ptl_base_check_recieves_for_match
|
||||
|
||||
return return_match;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Try and match the incoming message fragment to the list of
|
||||
* "wild" receies
|
||||
*
|
||||
* @param frag_header Matching data from recived fragment (IN)
|
||||
*
|
||||
* @param pml_comm Pointer to the communicator structure used for
|
||||
* matching purposes. (IN)
|
||||
*
|
||||
* @return Matched receive
|
||||
*
|
||||
* This routine assumes that the appropriate matching locks are
|
||||
* set by the upper level routine.
|
||||
*/
|
||||
mca_pml_base_recv_request_t *check_wild_receives_for_match(
|
||||
mca_pml_base_reliable_hdr_t *frag_header,
|
||||
mca_pml_comm_t *pml_comm)
|
||||
{
|
||||
/* local parameters */
|
||||
mca_pml_base_recv_request_t *return_match;
|
||||
mca_pml_base_recv_request_t *wild_recv;
|
||||
int frag_user_tag;
|
||||
|
||||
/* initialization */
|
||||
return_match=(mca_pml_base_recv_request_t *)NULL;
|
||||
frag_user_tag=frag_header->hdr_base.hdr_user_tag;
|
||||
|
||||
#if (0)
|
||||
/*
|
||||
* Loop over the wild irecvs.
|
||||
* wild_receives
|
||||
*/
|
||||
for(wild_recv = (mca_pml_base_recv_request_t *)
|
||||
lam_list_get_first(&(pml_comm->wild_receives));
|
||||
privateQueues.PostedWildRecv.begin();
|
||||
wild_recv !=
|
||||
(RecvDesc_t *) privateQueues.PostedWildRecv.end();
|
||||
wild_recv = (RecvDesc_t *) wild_recv->next) {
|
||||
// sanity check
|
||||
assert(wild_recv->WhichQueue == POSTEDWILDIRECV);
|
||||
|
||||
//
|
||||
// If we have a match...
|
||||
//
|
||||
int PostedIrecvTag = wild_recv->posted_m.tag_m;
|
||||
if ((FragUserTag == PostedIrecvTag) ||
|
||||
(PostedIrecvTag == ULM_ANY_TAG)) {
|
||||
if (PostedIrecvTag == ULM_ANY_TAG && FragUserTag < 0) {
|
||||
continue;
|
||||
}
|
||||
//
|
||||
// fill in received data information
|
||||
//
|
||||
wild_recv->isendSeq_m = rec->isendSeq_m;
|
||||
wild_recv->reslts_m.length_m = rec->msgLength_m;
|
||||
wild_recv->reslts_m.peer_m = rec->srcProcID_m;
|
||||
wild_recv->reslts_m.tag_m = rec->tag_m;
|
||||
//
|
||||
// Mark that this is the matching irecv, and go
|
||||
// to process it.
|
||||
//
|
||||
return_match = wild_recv;
|
||||
|
||||
// remove this irecv from the postd wild ireceive list
|
||||
privateQueues.PostedWildRecv.RemoveLinkNoLock(wild_recv);
|
||||
|
||||
// add this descriptor to the matched wild ireceive list
|
||||
wild_recv->WhichQueue = WILDMATCHEDIRECV;
|
||||
privateQueues.MatchedRecv[rec->srcProcID_m]->
|
||||
Append(wild_recv);
|
||||
|
||||
// exit the loop
|
||||
break;
|
||||
}
|
||||
}
|
||||
//
|
||||
|
||||
#endif /* if(0) */
|
||||
|
||||
return return_match;
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user