From 62ade993ca8375be5f9bdd09a20c358b48a6ca95 Mon Sep 17 00:00:00 2001 From: Galen Shipman Date: Tue, 9 Oct 2007 15:28:56 +0000 Subject: [PATCH] Seperate finalize and close for the PML, this gives the PML a chance to complete any outstanding operations prior to close. Before this change we just called pml_finalize in pml_close which causes problems if there are outstanding events that a BTL/MTL needs to progress during finalize. The problem is that MPI_COMM_WORLD and others were destroyed prior to closing the PML, pml_close would call pml_finalize, events would progress in the BTL, and these events expected MPI_COMM_WORLD to still be around.. This commit was SVN r16405. --- ompi/mca/pml/base/base.h | 2 ++ ompi/mca/pml/base/pml_base_close.c | 14 ++++++++++---- ompi/runtime/ompi_mpi_finalize.c | 4 ++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ompi/mca/pml/base/base.h b/ompi/mca/pml/base/base.h index ea3fa327ec..ae02cdff58 100644 --- a/ompi/mca/pml/base/base.h +++ b/ompi/mca/pml/base/base.h @@ -51,6 +51,8 @@ OMPI_DECLSPEC int mca_pml_base_pml_check_selected(const char *my_pml, struct ompi_proc_t **procs, size_t nprocs); +OMPI_DECLSPEC int mca_pml_base_finalize(void); + OMPI_DECLSPEC int mca_pml_base_close(void); OMPI_DECLSPEC int mca_pml_base_ft_event(int state); diff --git a/ompi/mca/pml/base/pml_base_close.c b/ompi/mca/pml/base/pml_base_close.c index 87ed5a4482..6ffe4bdc18 100644 --- a/ompi/mca/pml/base/pml_base_close.c +++ b/ompi/mca/pml/base/pml_base_close.c @@ -28,6 +28,15 @@ #include "ompi/mca/pml/base/pml_base_request.h" #include "opal/runtime/opal_progress.h" + +int mca_pml_base_finalize(void) { + if (NULL != mca_pml_base_selected_component.pmlm_finalize) { + return mca_pml_base_selected_component.pmlm_finalize(); + } + return OMPI_SUCCESS; +} + + int mca_pml_base_close(void) { /* turn off the progress code for the pml */ @@ -46,10 +55,7 @@ int mca_pml_base_close(void) OBJ_DESTRUCT(&mca_pml_base_recv_requests); mca_pml.pml_progress = mca_pml_base_progress; - if (NULL != mca_pml_base_selected_component.pmlm_finalize) { - mca_pml_base_selected_component.pmlm_finalize(); - } - + OBJ_DESTRUCT(&mca_pml_base_pml); /* Close all remaining available modules (may be one if this is a diff --git a/ompi/runtime/ompi_mpi_finalize.c b/ompi/runtime/ompi_mpi_finalize.c index 4f4ba78676..ecaa33dbb8 100644 --- a/ompi/runtime/ompi_mpi_finalize.c +++ b/ompi/runtime/ompi_mpi_finalize.c @@ -183,6 +183,10 @@ int ompi_mpi_finalize(void) return ret; } + /* free pml resource */ + if(OMPI_SUCCESS != (ret = mca_pml_base_finalize())) { + return ret; + } /* free communicator resources */ if (OMPI_SUCCESS != (ret = ompi_comm_finalize())) { return ret;