diff --git a/src/lam/os/linux/i686/atomic.h b/src/lam/os/linux/i686/atomic.h index a23bdb235b..5df0c00db7 100644 --- a/src/lam/os/linux/i686/atomic.h +++ b/src/lam/os/linux/i686/atomic.h @@ -24,7 +24,7 @@ typedef struct { */ typedef struct { lam_lock_data_t lock; - volatile unsigned long long data; + volatile uint64_t data; } bigAtomicUnsignedInt; /* JMS This section is commented out */ diff --git a/src/mca/mpi/pml/base/pml_base_close.c b/src/mca/mpi/pml/base/pml_base_close.c index 35c1c14a07..c5a0249b3f 100644 --- a/src/mca/mpi/pml/base/pml_base_close.c +++ b/src/mca/mpi/pml/base/pml_base_close.c @@ -27,3 +27,4 @@ int mca_pml_base_close(void) return LAM_SUCCESS; } + diff --git a/src/mca/mpi/pml/base/pml_base_request.h b/src/mca/mpi/pml/base/pml_base_request.h index c974204f8e..d5613b3a32 100644 --- a/src/mca/mpi/pml/base/pml_base_request.h +++ b/src/mca/mpi/pml/base/pml_base_request.h @@ -33,6 +33,10 @@ typedef enum { typedef struct { /* base request */ lam_request_t super; + /* pointer to application buffer */ + void *req_addr; + /* length of application buffer */ + size_t req_length; /* peer process - rank w/in this communicator */ int32_t req_peer; /* user defined tag */ @@ -45,10 +49,6 @@ typedef struct { mca_pml_base_request_type_t req_type; /* MPI request status */ mca_pml_base_request_status_t req_status; - /* pointer to application buffer */ - void *req_addr; - /* length of application buffer */ - size_t req_length; /* persistence indicating if the this is a persistent request */ bool req_persistent; /* flag indicating if MPI is done with this request called */ diff --git a/src/mca/mpi/pml/teg/src/pml_teg.h b/src/mca/mpi/pml/teg/src/pml_teg.h index 5978b905f0..c4efb7e57e 100644 --- a/src/mca/mpi/pml/teg/src/pml_teg.h +++ b/src/mca/mpi/pml/teg/src/pml_teg.h @@ -37,6 +37,7 @@ struct mca_pml_teg_t { int teg_free_list_max; /* maximum size of free list */ int teg_free_list_inc; /* number of elements to grow free list */ lam_free_list_t teg_recv_requests; + mca_ptl_base_sequence_t teg_recv_sequence; }; typedef struct mca_pml_teg_t mca_pml_teg_t; diff --git a/src/mca/mpi/pml/teg/src/pml_teg_module.c b/src/mca/mpi/pml/teg/src/pml_teg_module.c index c5c58d7b1b..25b74f86f6 100644 --- a/src/mca/mpi/pml/teg/src/pml_teg_module.c +++ b/src/mca/mpi/pml/teg/src/pml_teg_module.c @@ -59,11 +59,11 @@ static inline int mca_pml_teg_param_register_int( int mca_pml_teg_module_open(void) { mca_pml_teg.teg_free_list_num = - mca_pml_teg_param_register_int("free-list-num", 256); + mca_pml_teg_param_register_int("free_list_num", 256); mca_pml_teg.teg_free_list_max = - mca_pml_teg_param_register_int("free-list-max", -1); + mca_pml_teg_param_register_int("free_list_max", -1); mca_pml_teg.teg_free_list_inc = - mca_pml_teg_param_register_int("free-list-inc", 256); + mca_pml_teg_param_register_int("free_list_inc", 256); return LAM_SUCCESS; } @@ -97,6 +97,7 @@ mca_pml_t* mca_pml_teg_module_init(int* priority, int* min_thread, int* max_thre lam_list_init(&mca_pml_teg.teg_incomplete_sends); lam_mutex_init(&mca_pml_teg.teg_lock); + mca_pml_teg.teg_recv_sequence = 0; return &mca_pml_teg.super; } diff --git a/src/mca/mpi/pml/teg/src/pml_teg_proc.c b/src/mca/mpi/pml/teg/src/pml_teg_proc.c index de9dbbe329..ebe6f611f9 100644 --- a/src/mca/mpi/pml/teg/src/pml_teg_proc.c +++ b/src/mca/mpi/pml/teg/src/pml_teg_proc.c @@ -13,23 +13,24 @@ lam_class_info_t mca_pml_teg_proc_cls = { (class_destroy_t) mca_pml_teg_proc_destroy }; -static int mca_pml_teg_procs_init = 0; -lam_list_t mca_pml_teg_procs; +static lam_list_t mca_pml_teg_procs; void mca_pml_teg_proc_init(mca_pml_proc_t* proc) { - if(fetchNset(&mca_pml_teg_procs_init,1) == 0) - lam_list_init(&mca_pml_teg_procs); + static int init = 0; + if(fetchNset(&init,1) == 0) + STATIC_INIT(mca_pml_teg_procs, &lam_list_cls); SUPER_INIT(proc, &lam_list_item_cls); mca_ptl_array_init(&proc->proc_ptl_first); mca_ptl_array_init(&proc->proc_ptl_next); - lam_list_append(&mca_pml_teg_procs, &proc->super); + lam_list_append(&mca_pml_teg_procs, (lam_list_item_t*)proc); } void mca_pml_teg_proc_destroy(mca_pml_proc_t* proc) { + lam_list_remove_item(&mca_pml_teg_procs, (lam_list_item_t*)proc); SUPER_DESTROY(proc, &lam_list_item_cls); } diff --git a/src/mca/mpi/pml/teg/src/pml_teg_recvreq.c b/src/mca/mpi/pml/teg/src/pml_teg_recvreq.c index 3e5aba1b39..fe01e2bcf1 100644 --- a/src/mca/mpi/pml/teg/src/pml_teg_recvreq.c +++ b/src/mca/mpi/pml/teg/src/pml_teg_recvreq.c @@ -1,9 +1,19 @@ +#include "mca/mpi/ptl/base/ptl_base_comm.h" #include "pml_teg_recvreq.h" int mca_pml_teg_recv_request_start(mca_ptl_base_recv_request_t* req) { - return LAM_ERROR; + int rc; + THREAD_SCOPED_LOCK(&mca_pml_teg.teg_lock, + (req->req_sequence = mca_pml_teg.teg_recv_sequence++)); + + req->super.req_status = MCA_PML_STATUS_INCOMPLETE; + if(req->super.req_peer == LAM_ANY_TAG) { + rc = mca_ptl_base_recv_request_match_wild(req); + } else { + rc = mca_ptl_base_recv_request_match_specific(req); + } + return rc; } - diff --git a/src/mca/mpi/pml/teg/src/pml_teg_recvreq.h b/src/mca/mpi/pml/teg/src/pml_teg_recvreq.h index a74ac5d0e1..ec2523bc86 100644 --- a/src/mca/mpi/pml/teg/src/pml_teg_recvreq.h +++ b/src/mca/mpi/pml/teg/src/pml_teg_recvreq.h @@ -19,8 +19,9 @@ static inline mca_ptl_base_recv_request_t* mca_pml_teg_recv_request_alloc(int *r return (mca_ptl_base_recv_request_t*)lam_free_list_get(&mca_pml_teg.teg_recv_requests, rc); } -static void mca_pml_teg_recv_request_return(mca_ptl_base_recv_request_t* request) +static inline void mca_pml_teg_recv_request_return(mca_ptl_base_recv_request_t* request) { + request->super.req_status = MCA_PML_STATUS_INVALID; lam_free_list_return(&mca_pml_teg.teg_recv_requests, (lam_list_item_t*)request); } diff --git a/src/mca/mpi/pml/teg/src/pml_teg_sendreq.h b/src/mca/mpi/pml/teg/src/pml_teg_sendreq.h index 975a8d7f2e..bcc51a796e 100644 --- a/src/mca/mpi/pml/teg/src/pml_teg_sendreq.h +++ b/src/mca/mpi/pml/teg/src/pml_teg_sendreq.h @@ -6,6 +6,7 @@ #define LAM_PML_TEG_SEND_REQUEST_H #include "pml_teg_proc.h" +#include "mca/mpi/ptl/ptl.h" #include "mca/mpi/ptl/base/ptl_base_sendreq.h" #include "mca/mpi/ptl/base/ptl_base_sendfrag.h" @@ -26,24 +27,23 @@ static inline mca_ptl_base_send_request_t* mca_pml_teg_send_request_alloc( THREAD_SCOPED_LOCK(&proc->proc_lock, (ptl_proc = mca_ptl_array_get_next(&proc->proc_ptl_first))); ptl = ptl_proc->ptl; - *rc = ptl->ptl_request_alloc(ptl,&sendreq); if(NULL != sendreq) - sendreq->req_owner = ptl_proc; - return LAM_SUCCESS; + sendreq->req_peer = ptl_proc->ptl_peer; + return sendreq; } static inline void mca_ptl_base_send_request_return( mca_ptl_base_send_request_t* request) { - + request->super.req_status = MCA_PML_STATUS_INVALID; + request->req_owner->ptl_request_return(request->req_owner, request); } static inline int mca_pml_teg_send_request_start( mca_ptl_base_send_request_t* req) { - mca_ptl_proc_t* ptl_proc = req->req_owner; - mca_ptl_t* ptl = ptl_proc->ptl; + mca_ptl_t* ptl = req->req_owner; size_t first_fragment_size = ptl->ptl_first_frag_size; int rc; bool complete; @@ -51,7 +51,7 @@ static inline int mca_pml_teg_send_request_start( // start the first fragment if(req->req_length < first_fragment_size) first_fragment_size = req->req_length; - rc = ptl->ptl_send(ptl, ptl_proc->ptl_peer, req, first_fragment_size, &complete); + rc = ptl->ptl_send(ptl, req->req_peer, req, first_fragment_size, &complete); if(rc != LAM_SUCCESS) return rc; diff --git a/src/mca/mpi/ptl/base/ptl_base_comm.c b/src/mca/mpi/ptl/base/ptl_base_comm.c index 7ae1dad04d..bde9bb482f 100644 --- a/src/mca/mpi/ptl/base/ptl_base_comm.c +++ b/src/mca/mpi/ptl/base/ptl_base_comm.c @@ -11,7 +11,8 @@ lam_class_info_t mca_pml_ptl_comm_cls = { void mca_pml_ptl_comm_init(mca_pml_comm_t* comm) { SUPER_INIT(comm, &lam_object_cls); - lam_list_init(&comm->wild_receives); + STATIC_INIT(comm->c_wild_receives, &lam_list_cls); + lam_mutex_init(&comm->c_wild_lock); } void mca_pml_ptl_comm_destroy(mca_pml_comm_t* comm) @@ -19,11 +20,11 @@ void mca_pml_ptl_comm_destroy(mca_pml_comm_t* comm) LAM_FREE(comm->c_msg_seq); LAM_FREE(comm->c_next_msg_seq); LAM_FREE(comm->c_matching_lock); - LAM_FREE(comm->unexpected_frags); - LAM_FREE(comm->unexpected_frags_lock); - LAM_FREE(comm->frags_cant_match); - LAM_FREE(comm->specific_receives); - lam_list_destroy(&comm->wild_receives); + LAM_FREE(comm->c_unexpected_frags); + LAM_FREE(comm->c_unexpected_frags_lock); + LAM_FREE(comm->c_frags_cant_match); + LAM_FREE(comm->c_specific_receives); + lam_list_destroy(&comm->c_wild_receives); SUPER_DESTROY(comm, &lam_object_cls); } @@ -50,32 +51,32 @@ int mca_pml_ptl_comm_init_size(mca_pml_comm_t* comm, size_t size) lam_mutex_init(comm->c_matching_lock+i); /* unexpected fragments queues */ - comm->unexpected_frags = (lam_list_t*)LAM_MALLOC(sizeof(lam_list_t) * size); - if(NULL == comm->unexpected_frags) + comm->c_unexpected_frags = (lam_list_t*)LAM_MALLOC(sizeof(lam_list_t) * size); + if(NULL == comm->c_unexpected_frags) return LAM_ERR_OUT_OF_RESOURCE; for(i=0; iunexpected_frags+i); + lam_list_init(comm->c_unexpected_frags+i); /* these locks are needed to avoid a probe interfering with a match */ - comm->unexpected_frags_lock = (lam_mutex_t*)LAM_MALLOC(sizeof(lam_mutex_t) * size); - if(NULL == comm->unexpected_frags_lock) + comm->c_unexpected_frags_lock = (lam_mutex_t*)LAM_MALLOC(sizeof(lam_mutex_t) * size); + if(NULL == comm->c_unexpected_frags_lock) return LAM_ERR_OUT_OF_RESOURCE; for(i=0; iunexpected_frags_lock+i); + lam_mutex_init(comm->c_unexpected_frags_lock+i); /* out-of-order fragments queues */ - comm->frags_cant_match = (lam_list_t*)LAM_MALLOC(sizeof(lam_list_t) * size); - if(NULL == comm->frags_cant_match) + comm->c_frags_cant_match = (lam_list_t*)LAM_MALLOC(sizeof(lam_list_t) * size); + if(NULL == comm->c_frags_cant_match) return LAM_ERR_OUT_OF_RESOURCE; for(i=0; ifrags_cant_match+i); + lam_list_init(comm->c_frags_cant_match+i); /* queues of unmatched specific (source process specified) receives */ - comm->specific_receives = (lam_list_t*)LAM_MALLOC(sizeof(lam_list_t) * size); - if(NULL == comm->specific_receives) + comm->c_specific_receives = (lam_list_t*)LAM_MALLOC(sizeof(lam_list_t) * size); + if(NULL == comm->c_specific_receives) return LAM_ERR_OUT_OF_RESOURCE; for(i=0; ispecific_receives+i); + lam_list_init(comm->c_specific_receives+i); return LAM_SUCCESS; } diff --git a/src/mca/mpi/ptl/base/ptl_base_comm.h b/src/mca/mpi/ptl/base/ptl_base_comm.h index 312faec783..29e4c8ec66 100644 --- a/src/mca/mpi/ptl/base/ptl_base_comm.h +++ b/src/mca/mpi/ptl/base/ptl_base_comm.h @@ -25,21 +25,24 @@ struct mca_pml_comm_t { lam_mutex_t *c_matching_lock; /* unexpected fragments queues */ - lam_list_t *unexpected_frags; + lam_list_t *c_unexpected_frags; /* these locks are needed to avoid a probe interfering with a match */ - lam_mutex_t *unexpected_frags_lock; + lam_mutex_t *c_unexpected_frags_lock; /* out-of-order fragments queues */ - lam_list_t *frags_cant_match; + lam_list_t *c_frags_cant_match; /* queues of unmatched specific (source process specified) receives * sorted by source process */ - lam_list_t *specific_receives; + lam_list_t *c_specific_receives; /* queue of unmatched wild (source process not specified) receives * */ - lam_list_t wild_receives; + lam_list_t c_wild_receives; + + /* protect access to wild receives */ + lam_mutex_t c_wild_lock; }; typedef struct mca_pml_comm_t mca_pml_comm_t; diff --git a/src/mca/mpi/ptl/base/ptl_base_match.c b/src/mca/mpi/ptl/base/ptl_base_match.c index f5a5f42c32..6036756190 100644 --- a/src/mca/mpi/ptl/base/ptl_base_match.c +++ b/src/mca/mpi/ptl/base/ptl_base_match.c @@ -17,6 +17,32 @@ #include "mca/mpi/ptl/base/ptl_base_header.h" #include "mca/mpi/ptl/base/ptl_base_match.h" + +/* + * Specialized matching routines for internal use only. + */ + +static mca_ptl_base_recv_request_t *mca_ptl_base_check_recieves_for_match( + mca_ptl_base_header_t *frag_header, + mca_pml_comm_t *ptl_comm); + +static mca_ptl_base_recv_request_t *mca_ptl_base_check_wild_receives_for_match( + mca_ptl_base_header_t *frag_header, + mca_pml_comm_t *ptl_comm); + +static mca_ptl_base_recv_request_t *mca_ptl_base_check_specific_receives_for_match( + mca_ptl_base_header_t *frag_header, + mca_pml_comm_t *ptl_comm); + +static mca_ptl_base_recv_request_t *mca_ptl_base_check_specific_and_wild_receives_for_match( + mca_ptl_base_header_t *frag_header, + mca_pml_comm_t *ptl_comm); + +static void mca_ptl_base_check_cantmatch_for_match( + lam_list_t *additional_matches, + mca_pml_comm_t *pml_comm, int frag_src); + + /** * RCS/CTS receive side matching * @@ -116,21 +142,21 @@ int mca_ptl_base_match(mca_ptl_base_header_t *frag_header, /* if no match found, place on unexpected queue - need to * lock to prevent probe from interfering with updating * the list */ - THREAD_LOCK((pml_comm->unexpected_frags_lock)+frag_src); - lam_list_append( ((pml_comm->unexpected_frags)+frag_src), + THREAD_LOCK((pml_comm->c_unexpected_frags_lock)+frag_src); + lam_list_append( ((pml_comm->c_unexpected_frags)+frag_src), (lam_list_item_t *)frag_desc); - THREAD_UNLOCK((pml_comm->unexpected_frags_lock)+frag_src); + THREAD_UNLOCK((pml_comm->c_unexpected_frags_lock)+frag_src); } /* * Now that new message has arrived, check to see if - * any fragments on the c_frags_cant_match list + * any fragments on the c_c_frags_cant_match list * may now be used to form new matchs */ - if (0 < lam_list_get_size((pml_comm->frags_cant_match)+frag_src)) { + if (0 < lam_list_get_size((pml_comm->c_frags_cant_match)+frag_src)) { - lam_check_cantmatch_for_match(additional_matches,pml_comm,frag_src); + mca_ptl_base_check_cantmatch_for_match(additional_matches,pml_comm,frag_src); } @@ -149,7 +175,7 @@ int mca_ptl_base_match(mca_ptl_base_header_t *frag_header, * This message comes after the next expected, so it * is ahead of sequence. Save it for later. */ - lam_list_append( ((pml_comm->frags_cant_match)+frag_src), + lam_list_append( ((pml_comm->c_frags_cant_match)+frag_src), (lam_list_item_t *)frag_desc); /* now that the fragment is on the list, ok to @@ -177,7 +203,7 @@ int mca_ptl_base_match(mca_ptl_base_header_t *frag_header, * This routine assumes that the appropriate matching locks are * set by the upper level routine. */ -mca_ptl_base_recv_request_t *mca_ptl_base_check_recieves_for_match +static mca_ptl_base_recv_request_t *mca_ptl_base_check_recieves_for_match (mca_ptl_base_header_t *frag_header, mca_pml_comm_t *pml_comm) { /* local parameters */ @@ -194,23 +220,28 @@ mca_ptl_base_recv_request_t *mca_ptl_base_check_recieves_for_match */ frag_src = frag_header->hdr_frag_seq; - if (lam_list_get_size((pml_comm->specific_receives)+frag_src) == 0 ){ + if (lam_list_get_size((pml_comm->c_specific_receives)+frag_src) == 0 ){ /* * There are only wild irecvs, so specialize the algorithm. */ - return_match = check_wild_receives_for_match(frag_header, pml_comm); - } else if (lam_list_get_size(&(pml_comm->wild_receives)) == 0 ) { + THREAD_LOCK(&pml_comm->c_wild_lock); + return_match = mca_ptl_base_check_wild_receives_for_match(frag_header, pml_comm); + THREAD_UNLOCK(&pml_comm->c_wild_lock); + + } else if (lam_list_get_size(&(pml_comm->c_wild_receives)) == 0 ) { /* * There are only specific irecvs, so specialize the algorithm. */ - return_match = check_specific_receives_for_match(frag_header, + return_match = mca_ptl_base_check_specific_receives_for_match(frag_header, pml_comm); } else { /* * There are some of each. */ - return_match = check_specific_and_wild_receives_for_match(frag_header, + THREAD_LOCK(&pml_comm->c_wild_lock); + return_match = mca_ptl_base_check_specific_and_wild_receives_for_match(frag_header, pml_comm); + THREAD_UNLOCK(&pml_comm->c_wild_lock); } return return_match; @@ -231,7 +262,7 @@ mca_ptl_base_recv_request_t *mca_ptl_base_check_recieves_for_match * This routine assumes that the appropriate matching locks are * set by the upper level routine. */ -mca_ptl_base_recv_request_t *check_wild_receives_for_match( +static mca_ptl_base_recv_request_t *mca_ptl_base_check_wild_receives_for_match( mca_ptl_base_header_t *frag_header, mca_pml_comm_t *pml_comm) { @@ -249,9 +280,9 @@ mca_ptl_base_recv_request_t *check_wild_receives_for_match( * change this list. */ for(wild_recv = (mca_ptl_base_recv_request_t *) - lam_list_get_first(&(pml_comm->wild_receives)); + lam_list_get_first(&(pml_comm->c_wild_receives)); wild_recv != (mca_ptl_base_recv_request_t *) - lam_list_get_end(&(pml_comm->wild_receives)); + lam_list_get_end(&(pml_comm->c_wild_receives)); wild_recv = (mca_ptl_base_recv_request_t *) ((lam_list_item_t *)wild_recv)->lam_list_next) { @@ -271,7 +302,7 @@ mca_ptl_base_recv_request_t *check_wild_receives_for_match( return_match = wild_recv; /* remove this irecv from the postd wild ireceive list */ - lam_list_remove_item(&(pml_comm->wild_receives), + lam_list_remove_item(&(pml_comm->c_wild_receives), (lam_list_item_t *)wild_recv); /* found match - no need to continue */ @@ -298,7 +329,7 @@ mca_ptl_base_recv_request_t *check_wild_receives_for_match( * This routine assumes that the appropriate matching locks are * set by the upper level routine. */ -mca_ptl_base_recv_request_t *check_specific_receives_for_match( +static mca_ptl_base_recv_request_t *mca_ptl_base_check_c_specific_receives_for_match( mca_ptl_base_header_t *frag_header, mca_pml_comm_t *pml_comm) { @@ -316,9 +347,9 @@ mca_ptl_base_recv_request_t *check_specific_receives_for_match( * Loop over the specific irecvs. */ for(specific_recv = (mca_ptl_base_recv_request_t *) - lam_list_get_first((pml_comm->specific_receives)+frag_src); + lam_list_get_first((pml_comm->c_specific_receives)+frag_src); specific_recv != (mca_ptl_base_recv_request_t *) - lam_list_get_end((pml_comm->specific_receives)+frag_src); + lam_list_get_end((pml_comm->c_specific_receives)+frag_src); specific_recv = (mca_ptl_base_recv_request_t *) ((lam_list_item_t *)specific_recv)->lam_list_next) { /* @@ -334,7 +365,7 @@ mca_ptl_base_recv_request_t *check_specific_receives_for_match( return_match = specific_recv; /* remove descriptor from posted specific ireceive list */ - lam_list_remove_item((pml_comm->specific_receives)+frag_src, + lam_list_remove_item((pml_comm->c_specific_receives)+frag_src, (lam_list_item_t *)specific_recv); break; @@ -360,7 +391,7 @@ mca_ptl_base_recv_request_t *check_specific_receives_for_match( * This routine assumes that the appropriate matching locks are * set by the upper level routine. */ -mca_ptl_base_recv_request_t *check_specific_and_wild_receives_for_match( +static mca_ptl_base_recv_request_t *mca_ptl_base_check_specific_and_wild_receives_for_match( mca_ptl_base_header_t *frag_header, mca_pml_comm_t *pml_comm) { @@ -379,9 +410,9 @@ mca_ptl_base_recv_request_t *check_specific_and_wild_receives_for_match( * have been posted. */ specific_recv = (mca_ptl_base_recv_request_t *) - lam_list_get_first((pml_comm->specific_receives)+frag_src); + lam_list_get_first((pml_comm->c_specific_receives)+frag_src); wild_recv = (mca_ptl_base_recv_request_t *) - lam_list_get_first(&(pml_comm->wild_receives)); + lam_list_get_first(&(pml_comm->c_wild_receives)); specific_recv_seq = specific_recv->req_sequence; wild_recv_seq = wild_recv->req_sequence; @@ -404,7 +435,7 @@ mca_ptl_base_recv_request_t *check_specific_and_wild_receives_for_match( return_match=wild_recv; /* remove this recv from the wild receive queue */ - lam_list_remove_item(&(pml_comm->wild_receives), + lam_list_remove_item(&(pml_comm->c_wild_receives), (lam_list_item_t *)wild_recv); return return_match; @@ -421,9 +452,9 @@ mca_ptl_base_recv_request_t *check_specific_and_wild_receives_for_match( * rest of the specific ones. */ if (wild_recv == (mca_ptl_base_recv_request_t *) - lam_list_get_end(&(pml_comm->wild_receives)) ) + lam_list_get_end(&(pml_comm->c_wild_receives)) ) { - return_match = check_specific_receives_for_match(frag_header, + return_match = mca_ptl_base_check_c_specific_receives_for_match(frag_header, pml_comm); return return_match; @@ -450,7 +481,7 @@ mca_ptl_base_recv_request_t *check_specific_and_wild_receives_for_match( return_match = specific_recv; /* remove descriptor from specific receive list */ - lam_list_remove_item((pml_comm->specific_receives)+frag_src, + lam_list_remove_item((pml_comm->c_specific_receives)+frag_src, (lam_list_item_t *)specific_recv); return return_match; @@ -467,9 +498,9 @@ mca_ptl_base_recv_request_t *check_specific_and_wild_receives_for_match( * rest of the wild ones. */ if (specific_recv == (mca_ptl_base_recv_request_t *) - lam_list_get_end((pml_comm->specific_receives)+frag_src) ) + lam_list_get_end((pml_comm->c_specific_receives)+frag_src) ) { - return_match = check_wild_receives_for_match(frag_header, + return_match = mca_ptl_base_check_wild_receives_for_match(frag_header, pml_comm); return return_match; @@ -492,7 +523,7 @@ mca_ptl_base_recv_request_t *check_specific_and_wild_receives_for_match( * frags. * * @param additional_matches List to hold new matches with fragments - * from the frags_cant_match list. (IN/OUT) + * from the c_frags_cant_match list. (IN/OUT) * * @param pml_comm Pointer to the communicator structure used for * matching purposes. (IN) @@ -501,7 +532,7 @@ mca_ptl_base_recv_request_t *check_specific_and_wild_receives_for_match( * set by the upper level routine. */ -void lam_check_cantmatch_for_match(lam_list_t *additional_matches, +static void mca_ptl_base_check_cantmatch_for_match(lam_list_t *additional_matches, mca_pml_comm_t *pml_comm, int frag_src) { /* local parameters */ @@ -518,11 +549,11 @@ void lam_check_cantmatch_for_match(lam_list_t *additional_matches, /* * Loop over all the out of sequence messages. No ordering is assumed - * in the frags_cant_match list. + * in the c_frags_cant_match list. */ match_found = 1; - while ((0 < lam_list_get_size((pml_comm->frags_cant_match)+frag_src)) && + while ((0 < lam_list_get_size((pml_comm->c_frags_cant_match)+frag_src)) && match_found) { /* initialize match flag for this search */ @@ -535,11 +566,11 @@ void lam_check_cantmatch_for_match(lam_list_t *additional_matches, * number next_msg_seq_expected */ for(frag_desc = (mca_pml_base_recv_frag_t *) - lam_list_get_first((pml_comm->frags_cant_match)+frag_src); + lam_list_get_first((pml_comm->c_frags_cant_match)+frag_src); frag_desc != (mca_pml_base_recv_frag_t *) - lam_list_get_end((pml_comm->frags_cant_match)+frag_src); + lam_list_get_end((pml_comm->c_frags_cant_match)+frag_src); frag_desc = (mca_pml_base_recv_frag_t *) - ((lam_list_item_t *)frags_cant_match)->lam_list_next) + ((lam_list_item_t *)c_frags_cant_match)->lam_list_next) { /* * If the message has the next expected seq from that proc... @@ -566,7 +597,7 @@ void lam_check_cantmatch_for_match(lam_list_t *additional_matches, /* * remove frag_desc from list */ - lam_list_remove_item((pml_comm->frags_cant_match)+frag_src, + lam_list_remove_item((pml_comm->c_frags_cant_match)+frag_src, (lam_list_item_t *)frag_desc); /* @@ -593,14 +624,14 @@ void lam_check_cantmatch_for_match(lam_list_t *additional_matches, /* if no match found, place on unexpected queue - need to * lock to prevent probe from interfering with updating * the list */ - THREAD_LOCK((pml_comm->unexpected_frags_lock)+frag_src); - lam_list_append( ((pml_comm->unexpected_frags)+frag_src), + THREAD_LOCK((pml_comm->c_unexpected_frags_lock)+frag_src); + lam_list_append( ((pml_comm->c_unexpected_frags)+frag_src), (lam_list_item_t *)frag_desc); - THREAD_UNLOCK((pml_comm->unexpected_frags_lock)+frag_src); + THREAD_UNLOCK((pml_comm->c_unexpected_frags_lock)+frag_src); } - /* frags_cant_match is not an ordered list, so exit loop + /* c_frags_cant_match is not an ordered list, so exit loop * and re-start search for next sequence number */ break; diff --git a/src/mca/mpi/ptl/base/ptl_base_match.h b/src/mca/mpi/ptl/base/ptl_base_match.h index e1f6730cc9..80960ae10f 100644 --- a/src/mca/mpi/ptl/base/ptl_base_match.h +++ b/src/mca/mpi/ptl/base/ptl_base_match.h @@ -6,27 +6,8 @@ #define MCA_PTL_BASE_MATCH_H int mca_ptl_base_match(mca_ptl_base_header_t *frag_header, - mca_ptl_base_recv_frag_t *frag_desc, int *match_made, - lam_list_t *additional_matches); - -mca_ptl_base_recv_request_t *mca_ptl_base_check_recieves_for_match( - mca_ptl_base_header_t *frag_header, - mca_pml_comm_t *ptl_comm); - -mca_ptl_base_recv_request_t *check_wild_receives_for_match( - mca_ptl_base_header_t *frag_header, - mca_pml_comm_t *ptl_comm); - -mca_ptl_base_recv_request_t *check_specific_receives_for_match( - mca_ptl_base_header_t *frag_header, - mca_pml_comm_t *ptl_comm); - -mca_ptl_base_recv_request_t *check_specific_and_wild_receives_for_match( - mca_ptl_base_header_t *frag_header, - mca_pml_comm_t *ptl_comm); - -void lam_check_cantmatch_for_match(lam_list_t *additional_matches, - mca_pml_comm_t *pml_comm, int frag_src); + mca_ptl_base_recv_frag_t *frag_desc, int *match_made, + lam_list_t *additional_matches); #endif /* MCA_PTL_BASE_MATCH_H */ diff --git a/src/mca/mpi/ptl/base/ptl_base_recvreq.c b/src/mca/mpi/ptl/base/ptl_base_recvreq.c index 5cca273fbd..d3c0c603ad 100644 --- a/src/mca/mpi/ptl/base/ptl_base_recvreq.c +++ b/src/mca/mpi/ptl/base/ptl_base_recvreq.c @@ -3,8 +3,10 @@ */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +#include "mca/mpi/ptl/base/ptl_base_comm.h" #include "mca/mpi/ptl/base/ptl_base_recvreq.h" + lam_class_info_t mca_ptl_base_recv_request_cls = { "mca_ptl_base_recv_request_t", &mca_pml_base_request_cls, @@ -23,3 +25,27 @@ void mca_ptl_base_recv_request_destroy(mca_ptl_base_recv_request_t* req) SUPER_DESTROY(req, &mca_pml_base_request_cls); } + +int mca_ptl_base_recv_request_match_specific(mca_ptl_base_recv_request_t* req) +{ + mca_pml_comm_t* comm = req->super.req_communicator->c_pml_comm; + int req_peer = req->super.req_peer; + /* FIX - need to check for matching fragments */ + THREAD_LOCK(comm->c_matching_lock+req_peer); + lam_list_append(comm->c_specific_receives+req_peer, (lam_list_item_t*)req); + THREAD_UNLOCK(comm->c_matching_lock+req->super.req_peer); + return LAM_SUCCESS; +} + + +int mca_ptl_base_recv_request_match_wild(mca_ptl_base_recv_request_t* req) +{ + mca_pml_comm_t* comm = req->super.req_communicator->c_pml_comm; + /* FIX - need to check for matching fragments */ + THREAD_LOCK(&comm->c_wild_lock); + lam_list_append(&comm->c_wild_receives, (lam_list_item_t*)req); + THREAD_UNLOCK(&comm->c_wild_lock); + return LAM_SUCCESS; +} + + diff --git a/src/mca/mpi/ptl/base/ptl_base_recvreq.h b/src/mca/mpi/ptl/base/ptl_base_recvreq.h index 470667ad95..ff99f8869b 100644 --- a/src/mca/mpi/ptl/base/ptl_base_recvreq.h +++ b/src/mca/mpi/ptl/base/ptl_base_recvreq.h @@ -19,6 +19,9 @@ typedef struct { void mca_ptl_base_recv_request_init(mca_ptl_base_recv_request_t*); void mca_ptl_base_recv_request_destroy(mca_ptl_base_recv_request_t*); +int mca_ptl_base_recv_request_match_wild(mca_ptl_base_recv_request_t*); +int mca_ptl_base_recv_request_match_specific(mca_ptl_base_recv_request_t*); + static inline void mca_ptl_base_recv_request_reinit( mca_ptl_base_recv_request_t *request, @@ -38,6 +41,7 @@ static inline void mca_ptl_base_recv_request_reinit( request->super.req_tag = tag; request->super.req_communicator = comm; request->super.req_type = MCA_PML_REQUEST_RECV; + request->super.req_status = MCA_PML_STATUS_INITED; request->super.req_persistent = persistent; request->super.req_mpi_done = false; request->super.req_pml_layer_done = false; diff --git a/src/mca/mpi/ptl/base/ptl_base_sendreq.c b/src/mca/mpi/ptl/base/ptl_base_sendreq.c index 28a09291bf..2228d50ff4 100644 --- a/src/mca/mpi/ptl/base/ptl_base_sendreq.c +++ b/src/mca/mpi/ptl/base/ptl_base_sendreq.c @@ -15,7 +15,7 @@ lam_class_info_t mca_ptl_base_send_request_cls = { void mca_ptl_base_send_request_init(mca_ptl_base_send_request_t* req) { SUPER_INIT(req, &mca_pml_base_request_cls); - lam_list_init(&req->req_unacked_frags); + STATIC_INIT(req->req_unacked_frags, &lam_list_cls); } void mca_ptl_base_send_request_destroy(mca_ptl_base_send_request_t* req) diff --git a/src/mca/mpi/ptl/base/ptl_base_sendreq.h b/src/mca/mpi/ptl/base/ptl_base_sendreq.h index 65aa3553e3..b1dd925099 100644 --- a/src/mca/mpi/ptl/base/ptl_base_sendreq.h +++ b/src/mca/mpi/ptl/base/ptl_base_sendreq.h @@ -38,7 +38,9 @@ struct mca_ptl_base_send_request_t { /* queue of fragments that are waiting to be acknowledged */ mca_ptl_base_queue_t req_unacked_frags; /* PTL that allocated this descriptor */ - struct mca_ptl_proc_t* req_owner; + struct mca_ptl_t* req_owner; + /* PTL peer instance that will be used for first fragment */ + struct mca_ptl_peer_t* req_peer; }; typedef struct mca_ptl_base_send_request_t mca_ptl_base_send_request_t; @@ -71,6 +73,7 @@ static inline void mca_ptl_base_send_request_reinit( request->super.req_tag = tag; request->super.req_communicator = comm; request->super.req_type = MCA_PML_REQUEST_SEND; + request->super.req_status = MCA_PML_STATUS_INITED; request->super.req_persistent = persistent; request->super.req_mpi_done = false; request->super.req_pml_layer_done = false; diff --git a/src/mca/mpi/ptl/ptl.h b/src/mca/mpi/ptl/ptl.h index ad09e9453f..965d45d59e 100644 --- a/src/mca/mpi/ptl/ptl.h +++ b/src/mca/mpi/ptl/ptl.h @@ -116,7 +116,7 @@ typedef int (*mca_ptl_base_request_alloc_fn_t)( struct mca_ptl_base_send_request_t** request ); -typedef int (*mca_ptl_base_request_return_fn_t)( +typedef void (*mca_ptl_base_request_return_fn_t)( struct mca_ptl_t* ptl, struct mca_ptl_base_send_request_t* request ); diff --git a/src/mca/mpi/ptl/tcp/src/ptl_tcp.c b/src/mca/mpi/ptl/tcp/src/ptl_tcp.c index c03e2fd315..90777e84c3 100644 --- a/src/mca/mpi/ptl/tcp/src/ptl_tcp.c +++ b/src/mca/mpi/ptl/tcp/src/ptl_tcp.c @@ -7,6 +7,7 @@ #include "lam/util/if.h" #include "mca/mpi/pml/pml.h" #include "mca/mpi/ptl/ptl.h" +#include "mca/mpi/ptl/base/ptl_base_sendreq.h" #include "mca/lam/base/mca_base_module_exchange.h" #include "ptl_tcp.h" #include "ptl_tcp_addr.h" @@ -105,7 +106,11 @@ int mca_ptl_tcp_fini(struct mca_ptl_t* ptl) int mca_ptl_tcp_request_alloc(struct mca_ptl_t* ptl, struct mca_ptl_base_send_request_t** request) { int rc; - *request = (struct mca_ptl_base_send_request_t*)lam_free_list_get(&mca_ptl_tcp_module.tcp_send_requests, &rc); + mca_ptl_base_send_request_t* sendreq = + (mca_ptl_base_send_request_t*)lam_free_list_get(&mca_ptl_tcp_module.tcp_send_requests, &rc); + if(NULL != sendreq) + sendreq->req_owner = ptl; + *request = sendreq; return rc; } diff --git a/src/mca/mpi/ptl/tcp/src/ptl_tcp_module.c b/src/mca/mpi/ptl/tcp/src/ptl_tcp_module.c index 94732d60ab..801a367682 100644 --- a/src/mca/mpi/ptl/tcp/src/ptl_tcp_module.c +++ b/src/mca/mpi/ptl/tcp/src/ptl_tcp_module.c @@ -103,28 +103,30 @@ int mca_ptl_tcp_module_open(void) { /* register TCP module parameters */ mca_ptl_tcp_module.tcp_if_include = - mca_ptl_tcp_param_register_string("if-include", ""); + mca_ptl_tcp_param_register_string("if_include", ""); mca_ptl_tcp_module.tcp_if_exclude = - mca_ptl_tcp_param_register_string("if-exclude", ""); + mca_ptl_tcp_param_register_string("if_exclude", ""); mca_ptl_tcp_module.tcp_free_list_num = - mca_ptl_tcp_param_register_int("free-list-num", 256); + mca_ptl_tcp_param_register_int("free_list_num", 256); mca_ptl_tcp_module.tcp_free_list_max = - mca_ptl_tcp_param_register_int("free-list-max", -1); + mca_ptl_tcp_param_register_int("free_list_max", -1); mca_ptl_tcp_module.tcp_free_list_inc = - mca_ptl_tcp_param_register_int("free-list-inc", 256); + mca_ptl_tcp_param_register_int("free_list_inc", 256); mca_ptl_tcp.super.ptl_exclusivity = mca_ptl_tcp_param_register_int("exclusivity", 0); mca_ptl_tcp.super.ptl_first_frag_size = - mca_ptl_tcp_param_register_int("first-frag-size", 16*1024); + mca_ptl_tcp_param_register_int("first_frag_size", 16*1024); mca_ptl_tcp.super.ptl_min_frag_size = - mca_ptl_tcp_param_register_int("min-frag-size", 64*1024); + mca_ptl_tcp_param_register_int("min_frag_size", 64*1024); mca_ptl_tcp.super.ptl_max_frag_size = - mca_ptl_tcp_param_register_int("max-frag-size", -1); + mca_ptl_tcp_param_register_int("max_frag_size", -1); return LAM_SUCCESS; } int mca_ptl_tcp_module_close(void) { + LAM_FREE(mca_ptl_tcp_module.tcp_if_include); + LAM_FREE(mca_ptl_tcp_module.tcp_if_exclude); return LAM_SUCCESS; } @@ -249,12 +251,8 @@ static int mca_ptl_tcp_module_exchange(void) addrs[i].addr_port = mca_ptl_tcp_module.tcp_listen; addrs[i].addr_inuse = 0; } -#if TIM_HASNT_IMPLEMENTED_THIS_YET return mca_base_modex_send(&mca_ptl_tcp_module.super.ptlm_version, addrs, sizeof(mca_ptl_tcp_t),mca_ptl_tcp_module.tcp_num_ptls); -#else - return LAM_ERROR; -#endif } /* diff --git a/src/mca/mpi/ptl/tcp/src/ptl_tcp_peer.c b/src/mca/mpi/ptl/tcp/src/ptl_tcp_peer.c index 83f22da976..b3d2a23f02 100644 --- a/src/mca/mpi/ptl/tcp/src/ptl_tcp_peer.c +++ b/src/mca/mpi/ptl/tcp/src/ptl_tcp_peer.c @@ -52,7 +52,7 @@ void mca_ptl_tcp_peer_init(mca_ptl_peer_t* ptl_peer) ptl_peer->peer_recv_frag = 0; ptl_peer->peer_state = MCA_PTL_TCP_CLOSED; ptl_peer->peer_retries = 0; - lam_list_init(&ptl_peer->peer_frags); + STATIC_INIT(ptl_peer->peer_frags, &lam_list_cls); lam_mutex_init(&ptl_peer->peer_lock); } diff --git a/src/mca/mpi/ptl/tcp/src/ptl_tcp_proc.c b/src/mca/mpi/ptl/tcp/src/ptl_tcp_proc.c index 0682741a9b..b1068ab515 100644 --- a/src/mca/mpi/ptl/tcp/src/ptl_tcp_proc.c +++ b/src/mca/mpi/ptl/tcp/src/ptl_tcp_proc.c @@ -1,6 +1,7 @@ /* * $HEADER$ */ +#include "lam/atomic.h" #include "lam/lfc/hash_table.h" #include "mca/lam/base/mca_base_module_exchange.h" #include "ptl_tcp.h" @@ -26,7 +27,7 @@ mca_ptl_tcp_proc_t* mca_ptl_tcp_proc_self = 0; void mca_ptl_tcp_proc_init(mca_ptl_tcp_proc_t* proc) { static int inited = 0; - if(inited++ == 0) { + if(fetchNset(&inited, 1) == 0) { lam_list_init(&mca_ptl_tcp_procs); lam_mutex_init(&mca_ptl_tcp_proc_mutex); }