From 103cb6248038a4be39fb700a9e38fa0d5e0e92e7 Mon Sep 17 00:00:00 2001 From: Tim Woodall Date: Mon, 2 Feb 2004 22:58:24 +0000 Subject: [PATCH] cleanup pml/ptl init This commit was SVN r641. --- src/lam/mem/free_list.h | 2 +- src/mca/mpi/pml/teg/src/pml_teg.h | 2 ++ src/mca/mpi/pml/teg/src/pml_teg_module.c | 3 ++- src/mca/mpi/pml/teg/src/pml_teg_proc.c | 16 +++++++++------- src/mca/mpi/ptl/base/ptl_base_match.c | 6 +++--- src/mca/mpi/ptl/base/ptl_base_match.h | 2 +- src/mca/mpi/ptl/tcp/src/ptl_tcp.c | 2 +- src/mca/mpi/ptl/tcp/src/ptl_tcp.h | 1 + src/mca/mpi/ptl/tcp/src/ptl_tcp_module.c | 14 +++++++++----- src/mca/mpi/ptl/tcp/src/ptl_tcp_recvfrag.c | 2 +- 10 files changed, 30 insertions(+), 20 deletions(-) diff --git a/src/lam/mem/free_list.h b/src/lam/mem/free_list.h index 0584f2a354..9a4fc27c88 100644 --- a/src/lam/mem/free_list.h +++ b/src/lam/mem/free_list.h @@ -11,7 +11,7 @@ #include "lam/mem/seg_list.h" #include "lam/mem/mem_pool.h" -extern lam_class_info_t lam_free_lists_cls; +extern lam_class_info_t lam_free_list_cls; struct lam_free_list_t diff --git a/src/mca/mpi/pml/teg/src/pml_teg.h b/src/mca/mpi/pml/teg/src/pml_teg.h index 2c23e6df90..9d586bc148 100644 --- a/src/mca/mpi/pml/teg/src/pml_teg.h +++ b/src/mca/mpi/pml/teg/src/pml_teg.h @@ -30,6 +30,7 @@ struct mca_pml_teg_t { mca_ptl_t** teg_ptls; size_t teg_num_ptls; + lam_list_t teg_procs; lam_list_t teg_incomplete_sends; lam_mutex_t teg_lock; @@ -38,6 +39,7 @@ struct mca_pml_teg_t { 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 f90a97b259..c027563b06 100644 --- a/src/mca/mpi/pml/teg/src/pml_teg_module.c +++ b/src/mca/mpi/pml/teg/src/pml_teg_module.c @@ -98,7 +98,8 @@ mca_pml_t* mca_pml_teg_module_init(int* priority, mca_pml_teg.teg_free_list_inc, NULL); - lam_list_init(&mca_pml_teg.teg_incomplete_sends); + STATIC_INIT(mca_pml_teg.teg_incomplete_sends, &lam_list_cls); + STATIC_INIT(mca_pml_teg.teg_procs, &lam_list_cls); 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 ebe6f611f9..17ef3863d8 100644 --- a/src/mca/mpi/pml/teg/src/pml_teg_proc.c +++ b/src/mca/mpi/pml/teg/src/pml_teg_proc.c @@ -3,6 +3,7 @@ */ #include "lam/atomic.h" +#include "pml_teg.h" #include "pml_teg_proc.h" #include "pml_ptl_array.h" @@ -13,24 +14,25 @@ lam_class_info_t mca_pml_teg_proc_cls = { (class_destroy_t) mca_pml_teg_proc_destroy }; -static lam_list_t mca_pml_teg_procs; - void mca_pml_teg_proc_init(mca_pml_proc_t* proc) { - 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, (lam_list_item_t*)proc); + + THREAD_LOCK(&mca_pml_teg.teg_lock); + lam_list_append(&mca_pml_teg.teg_procs, (lam_list_item_t*)proc); + THREAD_UNLOCK(&mca_pml_teg.teg_lock); } void mca_pml_teg_proc_destroy(mca_pml_proc_t* proc) { - lam_list_remove_item(&mca_pml_teg_procs, (lam_list_item_t*)proc); + THREAD_LOCK(&mca_pml_teg.teg_lock); + lam_list_remove_item(&mca_pml_teg.teg_procs, (lam_list_item_t*)proc); + THREAD_UNLOCK(&mca_pml_teg.teg_lock); + SUPER_DESTROY(proc, &lam_list_item_cls); } diff --git a/src/mca/mpi/ptl/base/ptl_base_match.c b/src/mca/mpi/ptl/base/ptl_base_match.c index 6036756190..0660a5360e 100644 --- a/src/mca/mpi/ptl/base/ptl_base_match.c +++ b/src/mca/mpi/ptl/base/ptl_base_match.c @@ -74,7 +74,7 @@ static void mca_ptl_base_check_cantmatch_for_match( * - this routine may be called simoultaneously by more than one thread */ int mca_ptl_base_match(mca_ptl_base_header_t *frag_header, - mca_ptl_base_recv_frag_t *frag_desc, int *match_made, + mca_ptl_base_recv_frag_t *frag_desc, bool* match_made, lam_list_t *additional_matches) { /* local variables */ @@ -85,7 +85,7 @@ int mca_ptl_base_match(mca_ptl_base_header_t *frag_header, int frag_src; /* initialization */ - *match_made=0; + *match_made=false; /* communicator pointer */ comm_ptr=lam_comm_lookup(frag_header->hdr_contextid); @@ -128,7 +128,7 @@ int mca_ptl_base_match(mca_ptl_base_header_t *frag_header, if (matched_receive) { /* set flag indicating the input fragment was matched */ - *match_made=1; + *match_made=true; /* associate the receive descriptor with the fragment * descriptor */ frag_desc->frag_match=matched_receive; diff --git a/src/mca/mpi/ptl/base/ptl_base_match.h b/src/mca/mpi/ptl/base/ptl_base_match.h index 80960ae10f..128af6dc60 100644 --- a/src/mca/mpi/ptl/base/ptl_base_match.h +++ b/src/mca/mpi/ptl/base/ptl_base_match.h @@ -6,7 +6,7 @@ #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, + mca_ptl_base_recv_frag_t *frag_desc, bool *match_made, lam_list_t *additional_matches); #endif /* MCA_PTL_BASE_MATCH_H */ diff --git a/src/mca/mpi/ptl/tcp/src/ptl_tcp.c b/src/mca/mpi/ptl/tcp/src/ptl_tcp.c index cac65f873a..1c1618b6db 100644 --- a/src/mca/mpi/ptl/tcp/src/ptl_tcp.c +++ b/src/mca/mpi/ptl/tcp/src/ptl_tcp.c @@ -99,7 +99,7 @@ int mca_ptl_tcp_del_proc(struct mca_ptl_t* ptl, struct lam_proc_t *proc, struct int mca_ptl_tcp_finalize(struct mca_ptl_t* ptl) { - + LAM_FREE(ptl); return LAM_SUCCESS; } diff --git a/src/mca/mpi/ptl/tcp/src/ptl_tcp.h b/src/mca/mpi/ptl/tcp/src/ptl_tcp.h index 04c78c5cdb..f249e3bae1 100644 --- a/src/mca/mpi/ptl/tcp/src/ptl_tcp.h +++ b/src/mca/mpi/ptl/tcp/src/ptl_tcp.h @@ -35,6 +35,7 @@ struct mca_ptl_tcp_module_1_0_0_t { lam_free_list_t tcp_send_requests; lam_free_list_t tcp_send_frags; lam_free_list_t tcp_recv_frags; + lam_list_t tcp_procs; }; typedef struct mca_ptl_tcp_module_1_0_0_t mca_ptl_tcp_module_1_0_0_t; typedef struct mca_ptl_tcp_module_1_0_0_t mca_ptl_tcp_module_t; 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 3249f2629b..261912f6b0 100644 --- a/src/mca/mpi/ptl/tcp/src/ptl_tcp_module.c +++ b/src/mca/mpi/ptl/tcp/src/ptl_tcp_module.c @@ -127,6 +127,8 @@ 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); + if (NULL != mca_ptl_tcp_module.tcp_ptls) + LAM_FREE(mca_ptl_tcp_module.tcp_ptls); return LAM_SUCCESS; } @@ -251,8 +253,10 @@ static int mca_ptl_tcp_module_exchange(void) addrs[i].addr_port = mca_ptl_tcp_module.tcp_listen; addrs[i].addr_inuse = 0; } - return mca_base_modex_send(&mca_ptl_tcp_module.super.ptlm_version, + int rc = mca_base_modex_send(&mca_ptl_tcp_module.super.ptlm_version, addrs, sizeof(mca_ptl_tcp_t),mca_ptl_tcp_module.tcp_num_ptls); + LAM_FREE(addrs); + return rc; } /* @@ -271,10 +275,10 @@ mca_ptl_t** mca_ptl_tcp_module_init(int *num_ptls, *have_hidden_threads = false; /* initialize containers */ - lam_reactor_init(&mca_ptl_tcp_module.tcp_reactor); + STATIC_INIT(mca_ptl_tcp_module.tcp_reactor, &lam_reactor_cls); /* initialize free lists */ - lam_free_list_init(&mca_ptl_tcp_module.tcp_send_requests); + STATIC_INIT(mca_ptl_tcp_module.tcp_send_requests, &lam_free_list_cls); lam_free_list_init_with(&mca_ptl_tcp_module.tcp_send_requests, sizeof(mca_ptl_base_send_request_t) + sizeof(mca_ptl_tcp_send_frag_t), &mca_ptl_base_send_request_cls, @@ -283,7 +287,7 @@ mca_ptl_t** mca_ptl_tcp_module_init(int *num_ptls, mca_ptl_tcp_module.tcp_free_list_inc, NULL); /* use default allocator */ - lam_free_list_init(&mca_ptl_tcp_module.tcp_send_frags); + STATIC_INIT(mca_ptl_tcp_module.tcp_send_frags, &lam_free_list_cls); lam_free_list_init_with(&mca_ptl_tcp_module.tcp_send_frags, sizeof(mca_ptl_tcp_send_frag_t), &mca_ptl_tcp_send_frag_cls, @@ -292,7 +296,7 @@ mca_ptl_t** mca_ptl_tcp_module_init(int *num_ptls, mca_ptl_tcp_module.tcp_free_list_inc, NULL); /* use default allocator */ - lam_free_list_init(&mca_ptl_tcp_module.tcp_recv_frags); + STATIC_INIT(mca_ptl_tcp_module.tcp_recv_frags, &lam_free_list_cls); lam_free_list_init_with(&mca_ptl_tcp_module.tcp_recv_frags, sizeof(mca_ptl_tcp_recv_frag_t), &mca_ptl_tcp_recv_frag_cls, diff --git a/src/mca/mpi/ptl/tcp/src/ptl_tcp_recvfrag.c b/src/mca/mpi/ptl/tcp/src/ptl_tcp_recvfrag.c index eac2cb81e8..bae560864c 100644 --- a/src/mca/mpi/ptl/tcp/src/ptl_tcp_recvfrag.c +++ b/src/mca/mpi/ptl/tcp/src/ptl_tcp_recvfrag.c @@ -94,7 +94,7 @@ static bool mca_ptl_tcp_recv_frag_header(mca_ptl_tcp_recv_frag_t* frag, int sd) return false; /* attempt to match a posted recv */ - /* ????? */ + /* FIX */ /* match was not made - so allocate buffer for eager send */ if(NULL == frag->frag_match) {