From dee243c58d0c79faa445b3c12685fc02def27085 Mon Sep 17 00:00:00 2001 From: George Bosilca Date: Fri, 28 Nov 2014 18:26:36 -0500 Subject: [PATCH] ompi_proc_finalize has an interesting side effect. A proc is inserted in the ompi_proc_list as soon as it is created and it is removed only upon the call to the destructor. In ompi_proc_finalize we loop over all procs in ompi_proc_finalize and release them once. However, as a proc is not removed from this list right away, we decrease the ref count for each proc until it reach zero and the proc is finally removed. Thus, we cannot clean the BML/BTL after the call the ompi_proc_finalize. A quick fix is to delay the call to ompi_proc_finalize until all other frameworks have been finalized, and then the behavior depicted above will give the expected outcome. --- ompi/runtime/ompi_mpi_finalize.c | 10 +++++----- opal/mca/btl/tcp/btl_tcp_proc.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ompi/runtime/ompi_mpi_finalize.c b/ompi/runtime/ompi_mpi_finalize.c index 9e81200981..1ae880dc7e 100644 --- a/ompi/runtime/ompi_mpi_finalize.c +++ b/ompi/runtime/ompi_mpi_finalize.c @@ -341,11 +341,6 @@ int ompi_mpi_finalize(void) return ret; } - /* free proc resources */ - if ( OMPI_SUCCESS != (ret = ompi_proc_finalize())) { - return ret; - } - /* finalize the pubsub functions */ if (OMPI_SUCCESS != (ret = mca_base_framework_close(&ompi_pubsub_base_framework) ) ) { return ret; @@ -420,6 +415,11 @@ int ompi_mpi_finalize(void) return ret; } + /* free proc resources */ + if ( OMPI_SUCCESS != (ret = ompi_proc_finalize())) { + return ret; + } + if (NULL != ompi_mpi_main_thread) { OBJ_RELEASE(ompi_mpi_main_thread); ompi_mpi_main_thread = NULL; diff --git a/opal/mca/btl/tcp/btl_tcp_proc.c b/opal/mca/btl/tcp/btl_tcp_proc.c index fdccee42b5..bd06ec1574 100644 --- a/opal/mca/btl/tcp/btl_tcp_proc.c +++ b/opal/mca/btl/tcp/btl_tcp_proc.c @@ -84,8 +84,8 @@ void mca_btl_tcp_proc_destruct(mca_btl_tcp_proc_t* tcp_proc) opal_proc_table_remove_value(&mca_btl_tcp_component.tcp_procs, tcp_proc->proc_opal->proc_name); OPAL_THREAD_UNLOCK(&mca_btl_tcp_component.tcp_lock); - /* Do not OBJ_RELEASE the proc_opal ! */ - /* OBJ_RELEASE(tcp_proc->proc_opal); */ + OBJ_RELEASE(tcp_proc->proc_opal); + tcp_proc->proc_opal = NULL; } /* release resources */ if(NULL != tcp_proc->proc_endpoints) {