From 9b0687e6df7fe40b1a467ec6f222d35e75591b51 Mon Sep 17 00:00:00 2001 From: Rich Graham Date: Fri, 15 Feb 2008 03:59:14 +0000 Subject: [PATCH] add buffer allocation and deallocation calls to the allreduce routine, so I can start debugging the memory management code. The allreduce fucntion does nothing at this stage. This commit was SVN r17466. --- ompi/mca/coll/sm2/coll_sm2.h | 9 +++++++++ ompi/mca/coll/sm2/coll_sm2_allreduce.c | 16 ++++++++++++++-- ompi/mca/coll/sm2/coll_sm2_component.c | 3 +++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ompi/mca/coll/sm2/coll_sm2.h b/ompi/mca/coll/sm2/coll_sm2.h index 8a12d17d32..416aa11d3e 100644 --- a/ompi/mca/coll/sm2/coll_sm2.h +++ b/ompi/mca/coll/sm2/coll_sm2.h @@ -282,6 +282,15 @@ BEGIN_C_DECLS mca_coll_sm2_nb_request_process_private_mem_t *request, struct mca_coll_base_module_1_1_0_t *module); + /* allocate working buffer */ + char *alloc_sm2_shared_buffer(mca_coll_sm2_module_t *module); + + /* free working buffer - it is assumed that buffers are released in + * the order they are allocated. We can assume this because each + * communiator will have only one outstanding collective at a given + * time, and we ensure that operations are completed in order. */ + int free_sm2_shared_buffer(mca_coll_sm2_module_t *module); + /** * Macro to setup flag usage */ diff --git a/ompi/mca/coll/sm2/coll_sm2_allreduce.c b/ompi/mca/coll/sm2/coll_sm2_allreduce.c index d471fd42fe..989106e47c 100644 --- a/ompi/mca/coll/sm2/coll_sm2_allreduce.c +++ b/ompi/mca/coll/sm2/coll_sm2_allreduce.c @@ -25,13 +25,18 @@ int mca_coll_sm2_allreduce_intra(void *sbuf, void *rbuf, int count, struct mca_coll_base_module_1_1_0_t *module) { /* local variables */ - int ret; + int rc; char *sm_buffer; mca_coll_sm2_module_t *sm_module; sm_module=(mca_coll_sm2_module_t *) module; /* get a pointer to the shared-memory working buffer */ + sm_buffer=alloc_sm2_shared_buffer(sm_module); + if( NULL == sm_buffer) { + rc=OMPI_ERR_OUT_OF_RESOURCE; + goto Error; + } if( 0 != (op->o_flags & OMPI_OP_FLAGS_COMMUTE)) { /* Commutative Operation */ @@ -39,7 +44,14 @@ int mca_coll_sm2_allreduce_intra(void *sbuf, void *rbuf, int count, /* Non-Commutative Operation */ } + /* "free" the shared-memory working buffer */ + rc=alloc_sm2_shared_buffer(sm_module); + if( OMPI_SUCCESS != rc ) { + goto Error; + } + return OMPI_SUCCESS; - +Error: + return rc; } diff --git a/ompi/mca/coll/sm2/coll_sm2_component.c b/ompi/mca/coll/sm2/coll_sm2_component.c index e9a5b10216..91bf286b83 100644 --- a/ompi/mca/coll/sm2/coll_sm2_component.c +++ b/ompi/mca/coll/sm2/coll_sm2_component.c @@ -130,6 +130,9 @@ static int sm2_open(void) /* set component priority */ cs->sm2_priority= mca_coll_sm2_param_register_int("sm_priority",0); + /* debug */ + fprintf(stderr," DDDD cs->sm2_priority %d \n",cs->sm2_priority); + /* end debub */ /* set control region size (bytes), per proc */ cs->sm2_ctl_size_per_proc=