diff --git a/src/lam/lfc/list.h b/src/lam/lfc/list.h index 93c23dffcd..30db2d6571 100644 --- a/src/lam/lfc/list.h +++ b/src/lam/lfc/list.h @@ -5,6 +5,8 @@ #ifndef LAM_LIST_H #define LAM_LIST_H +#include + #include "lam/lfc/object.h" /* @@ -84,13 +86,12 @@ 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. */ static inline lam_list_item_t* lam_list_get_first(lam_list_t* list) { - return 0; + return list->lam_list_head.lam_list_next; } /* @@ -98,7 +99,7 @@ static inline lam_list_item_t* lam_list_get_first(lam_list_t* list) */ static inline lam_list_item_t* lam_list_get_last(lam_list_t* list) { - return 0; + return list->lam_list_tail.lam_list_prev; } /* @@ -106,9 +107,43 @@ static inline lam_list_item_t* lam_list_get_last(lam_list_t* list) */ static inline lam_list_item_t* lam_list_get_end(lam_list_t* list) { - return 0; + return &(list->lam_list_tail); } +/* + * Removes the specified item from the list + */ +static inline void lam_list_remove_item(lam_list_t *list, lam_list_item_t *item){ +#ifdef LAM_ENABLE_DEBUG + lam_list_item_t *item_ptr; + int found=0; +#endif + +#ifdef LAM_ENABLE_DEBUG + /* check to see that the item is in the list */ + for(item_ptr = lam_list_get_first(list); + item_ptr != lam_list_get_end(list); + item_ptr = item_ptr->lam_list_next) { + if( item_ptr == item ) { + found=1; + break; + } + } + if( 1 != found){ + fprintf(stderr," Warning :: lam_list_remove_item - the item %p is not on the list %p \n",item,list); + fflush(stderr); + } + +#endif + + /* reset next pointer of previous element */ + item->lam_list_prev->lam_list_next=item->lam_list_next; + + /* reset previous pointer of next element */ + item->lam_list_next->lam_list_prev=item->lam_list_prev; + + return; +} /* * Adds item to the end of the list but does not retain item. diff --git a/src/mca/mpi/pml/pml.h b/src/mca/mpi/pml/pml.h index 2363c4f11d..b7bc532f2e 100644 --- a/src/mca/mpi/pml/pml.h +++ b/src/mca/mpi/pml/pml.h @@ -13,6 +13,7 @@ #include "mpi/datatype/datatype.h" #include "mpi/request/request.h" #include "mca/mca.h" +#include "mpi.h" /* needed for MPI_ANY_TAG */ /* @@ -44,6 +45,8 @@ struct mca_pml_base_status_t { }; typedef struct mca_pml_base_status_t mca_pml_base_status_t; +#define LAM_ANY_TAG MPI_ANY_TAG + /* * PML interface functions diff --git a/src/mca/mpi/ptl/base/ptl_base_match.c b/src/mca/mpi/ptl/base/ptl_base_match.c index 492b63ffa8..84b5f23a6c 100644 --- a/src/mca/mpi/ptl/base/ptl_base_match.c +++ b/src/mca/mpi/ptl/base/ptl_base_match.c @@ -15,6 +15,7 @@ #include "mca/mpi/pml/base/pml_base_comm.h" #include "lam/lfc/list.h" #include "mca/mpi/ptl/base/ptl_base_match.h" +#include "mca/mpi/pml/pml.h" /** * RCS/CTS receive side matching @@ -245,63 +246,48 @@ mca_pml_base_recv_request_t *check_wild_receives_for_match( /* local parameters */ mca_pml_base_recv_request_t *return_match; mca_pml_base_recv_request_t *wild_recv; - int frag_user_tag; + int frag_user_tag,recv_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 + * Loop over the wild irecvs - no need to lock, the upper level + * locking is protecting from having other threads trying to + * change this list. */ 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); + wild_recv != (mca_pml_base_recv_request_t *) + lam_list_get_end(&(pml_comm->wild_receives)); + wild_recv = (mca_pml_base_recv_request_t *) + ((lam_list_item_t *)wild_recv)->lam_list_next) { - // - // 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. - // + recv_user_tag = wild_recv->super.req_tag; + if ( + /* exact tag match */ + (frag_user_tag == recv_user_tag) || + /* wild tag match - negative tags (except for + * LAM_ANY_TAG) are reserved for internal use, and will + * not be matched with LAM_ANY_TAG */ + ( (recv_user_tag == LAM_ANY_TAG) && (0 <= frag_user_tag) ) ) + + { + /* + * 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); + /* remove this irecv from the postd wild ireceive list */ + lam_list_remove_item(&(pml_comm->wild_receives), + (lam_list_item_t *)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 + /* found match - no need to continue */ break; } } // -#endif /* if(0) */ - return return_match; }