From 4747a4bb539b7b4d7cf76e42634160ce55f6770d Mon Sep 17 00:00:00 2001 From: George Bosilca Date: Wed, 11 Feb 2009 21:48:11 +0000 Subject: [PATCH] ompi_comm_all allocate memory and retain the objects. Therefore, after each call to ompi_comm_all we should parse the communicator list and release the objects ... This commit was SVN r20525. --- ompi/mca/bml/r2/bml_r2.c | 24 +++++++++++++++++------- ompi/mca/pml/ob1/pml_ob1.c | 13 +++++++++++-- ompi/mca/pml/ob1/pml_ob1_component.c | 4 +++- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/ompi/mca/bml/r2/bml_r2.c b/ompi/mca/bml/r2/bml_r2.c index 2c226427d3..faff82c6bb 100644 --- a/ompi/mca/bml/r2/bml_r2.c +++ b/ompi/mca/bml/r2/bml_r2.c @@ -1,8 +1,9 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ /* * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2008 The University of Tennessee and The University + * Copyright (c) 2004-2009 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, @@ -620,11 +621,16 @@ int mca_bml_r2_finalize( void ) bml_r2_remove_btl_progress(btl); /* dont use this btl for any peers */ - for(p=0; pbtl_module); } } + /* Release the procs as the ompi_proc_all increase their ref_count */ + for( p = 0; p < num_procs; p++ ) { + OBJ_RELEASE(procs[p]); + } + free(procs); CLEANUP: mca_bml_r2.num_btl_modules = 0; @@ -658,15 +664,15 @@ static int mca_bml_r2_del_btl(mca_btl_base_module_t* btl) mca_btl_base_module_t** modules; bool found = false; + if(opal_list_get_size(&mca_btl_base_modules_initialized) == 2) { + opal_output(0, "only one BTL left, can't failover"); + return OMPI_SUCCESS; + } + procs = ompi_proc_all(&num_procs); if(NULL == procs) return OMPI_SUCCESS; - if(opal_list_get_size(&mca_btl_base_modules_initialized) == 2) { - opal_output(0, "only one BTL left, can't failover"); - goto CLEANUP; - } - /* Get rid of the associated progress function */ bml_r2_remove_btl_progress(btl); @@ -706,6 +712,10 @@ static int mca_bml_r2_del_btl(mca_btl_base_module_t* btl) /* cleanup */ btl->btl_finalize(btl); CLEANUP: + /* Decrease the ref_count increased by the call to ompi_proc_all */ + for( p = 0; p < num_procs; p++ ) { + OBJ_RELEASE(procs[p]); + } free(procs); return OMPI_SUCCESS; } diff --git a/ompi/mca/pml/ob1/pml_ob1.c b/ompi/mca/pml/ob1/pml_ob1.c index 0b28f5b437..b933bfb26f 100644 --- a/ompi/mca/pml/ob1/pml_ob1.c +++ b/ompi/mca/pml/ob1/pml_ob1.c @@ -1,8 +1,9 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ /* * Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2008 The University of Tennessee and The University + * Copyright (c) 2004-2009 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, @@ -76,7 +77,9 @@ void mca_pml_ob1_error_handler( struct mca_btl_base_module_t* btl, int mca_pml_ob1_enable(bool enable) { - if( false == enable ) return OMPI_SUCCESS; + if( false == enable ) { + return OMPI_SUCCESS; + } OBJ_CONSTRUCT(&mca_pml_ob1.lock, opal_mutex_t); @@ -600,6 +603,9 @@ int mca_pml_ob1_ft_event( int state ) opal_output(0, "pml:ob1: ft_event(Restart): proc_refresh Failed %d", ret); + for(p = 0; p < (int)num_procs; ++p) { + OBJ_RELEASE(procs[p]); + } free (procs); return ret; } @@ -636,6 +642,9 @@ int mca_pml_ob1_ft_event( int state ) opal_output(0, "pml:ob1: ft_event(Restart): proc_refresh Failed %d", ret); + for(p = 0; p < (int)num_procs; ++p) { + OBJ_RELEASE(procs[p]); + } free (procs); return ret; } diff --git a/ompi/mca/pml/ob1/pml_ob1_component.c b/ompi/mca/pml/ob1/pml_ob1_component.c index 9df4bf406b..7518d004a4 100644 --- a/ompi/mca/pml/ob1/pml_ob1_component.c +++ b/ompi/mca/pml/ob1/pml_ob1_component.c @@ -1,8 +1,9 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ /* * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2007 The University of Tennessee and The University + * Copyright (c) 2004-2009 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, @@ -127,6 +128,7 @@ static int mca_pml_ob1_component_open(void) opal_output(0, "mca_pml_ob1_component_open: can't find allocator: %s\n", mca_pml_ob1.allocator_name); return OMPI_ERROR; } + mca_pml_ob1.allocator = allocator_component->allocator_init(true, mca_pml_ob1_seg_alloc, mca_pml_ob1_seg_free, NULL);