From a831729d6fc1e31920c2188738ff12124d1e7181 Mon Sep 17 00:00:00 2001 From: Tim Woodall Date: Fri, 15 Apr 2005 17:04:57 +0000 Subject: [PATCH] split close into finalize/close so that rmgr can finalize all sub-components prior to entering close. moved pls logic to wait on children from close to finalize. This commit was SVN r5392. --- src/mca/pls/base/base.h | 1 + src/mca/pls/base/pls_base_close.c | 12 +++++----- src/mca/pls/base/pls_base_select.c | 10 +++++++- src/mca/pls/fork/pls_fork_component.c | 9 ------- src/mca/pls/fork/pls_fork_module.c | 8 +++++++ src/mca/pls/rsh/pls_rsh_component.c | 8 ------- src/mca/pls/rsh/pls_rsh_module.c | 8 +++++++ src/mca/ras/base/base.h | 1 + src/mca/ras/base/ras_base_close.c | 9 ++++--- src/mca/rds/base/base.h | 1 + src/mca/rds/base/rds_base_close.c | 5 +++- src/mca/rmaps/base/base.h | 1 + src/mca/rmaps/base/rmaps_base_close.c | 5 +++- src/mca/rmgr/urm/rmgr_urm.c | 34 +++++++++++++++++++++++++++ 14 files changed, 83 insertions(+), 29 deletions(-) diff --git a/src/mca/pls/base/base.h b/src/mca/pls/base/base.h index 47d00d2fef..87792ea7b4 100644 --- a/src/mca/pls/base/base.h +++ b/src/mca/pls/base/base.h @@ -85,6 +85,7 @@ extern "C" { /** * Close the pls framework */ + OMPI_DECLSPEC int orte_pls_base_finalize(void); OMPI_DECLSPEC int orte_pls_base_close(void); /** * Utility routine to get/set proces pid diff --git a/src/mca/pls/base/pls_base_close.c b/src/mca/pls/base/pls_base_close.c index a7e8a587b1..c6a3ce9a23 100644 --- a/src/mca/pls/base/pls_base_close.c +++ b/src/mca/pls/base/pls_base_close.c @@ -25,13 +25,11 @@ #include "util/output.h" -int orte_pls_base_close(void) +int orte_pls_base_finalize(void) { - ompi_list_item_t* item; - /* Finalize all available modules */ - if (orte_pls_base.pls_available_valid) { + ompi_list_item_t* item; while (NULL != (item = ompi_list_remove_first(&orte_pls_base.pls_available))) { orte_pls_base_cmp_t* cmp = (orte_pls_base_cmp_t*) item; @@ -45,15 +43,17 @@ int orte_pls_base_close(void) } } orte_pls_base.pls_available_valid = false; +} + +int orte_pls_base_close(void) +{ /* Close all remaining open components */ - if (orte_pls_base.pls_opened_valid) { mca_base_components_close(orte_pls_base.pls_output, &orte_pls_base.pls_opened, NULL); } orte_pls_base.pls_opened_valid = false; - return ORTE_SUCCESS; } diff --git a/src/mca/pls/base/pls_base_select.c b/src/mca/pls/base/pls_base_select.c index 13c78a612a..9f85af42f9 100644 --- a/src/mca/pls/base/pls_base_select.c +++ b/src/mca/pls/base/pls_base_select.c @@ -71,6 +71,7 @@ static orte_pls_base_module_t *select_preferred(char *name) mca_base_component_list_item_t *cli; orte_pls_base_component_t *component; orte_pls_base_module_t *module; + orte_pls_base_cmp_t *cmp; int priority; /* Look for a matching selected name */ @@ -100,6 +101,13 @@ static orte_pls_base_module_t *select_preferred(char *name) "orte:base:open: component %s returns priority %d", component->pls_version.mca_component_name, priority); + + cmp = OBJ_NEW(orte_pls_base_cmp_t); + cmp->component = component; + cmp->module = module; + cmp->priority = priority; + + ompi_list_append(&orte_pls_base.pls_available, &cmp->super); return module; } } @@ -119,8 +127,8 @@ static orte_pls_base_module_t *select_any(void) mca_base_component_list_item_t *cli; orte_pls_base_component_t *component; orte_pls_base_module_t *module; - int priority; orte_pls_base_cmp_t *cmp; + int priority; /* Query all the opened components and see if they want to run */ diff --git a/src/mca/pls/fork/pls_fork_component.c b/src/mca/pls/fork/pls_fork_component.c index 8e853ce4f9..2dec50374f 100644 --- a/src/mca/pls/fork/pls_fork_component.c +++ b/src/mca/pls/fork/pls_fork_component.c @@ -129,15 +129,6 @@ orte_pls_base_module_t *orte_pls_fork_component_init(int *priority) int orte_pls_fork_component_close(void) { - if(mca_pls_fork_component.reap) { - OMPI_THREAD_LOCK(&mca_pls_fork_component.lock); - while(mca_pls_fork_component.num_children > 0) { - ompi_condition_wait(&mca_pls_fork_component.cond, - &mca_pls_fork_component.lock); - } - OMPI_THREAD_UNLOCK(&mca_pls_fork_component.lock); - } - OBJ_DESTRUCT(&mca_pls_fork_component.lock); OBJ_DESTRUCT(&mca_pls_fork_component.cond); return ORTE_SUCCESS; diff --git a/src/mca/pls/fork/pls_fork_module.c b/src/mca/pls/fork/pls_fork_module.c index c5bf8dad7a..3564ef6435 100644 --- a/src/mca/pls/fork/pls_fork_module.c +++ b/src/mca/pls/fork/pls_fork_module.c @@ -349,6 +349,14 @@ int orte_pls_fork_terminate_proc(const orte_process_name_t* proc) int orte_pls_fork_finalize(void) { + if(mca_pls_fork_component.reap) { + OMPI_THREAD_LOCK(&mca_pls_fork_component.lock); + while(mca_pls_fork_component.num_children > 0) { + ompi_condition_wait(&mca_pls_fork_component.cond, + &mca_pls_fork_component.lock); + } + OMPI_THREAD_UNLOCK(&mca_pls_fork_component.lock); + } return ORTE_ERR_NOT_IMPLEMENTED; } diff --git a/src/mca/pls/rsh/pls_rsh_component.c b/src/mca/pls/rsh/pls_rsh_component.c index e9f6b3965a..1629e0d444 100644 --- a/src/mca/pls/rsh/pls_rsh_component.c +++ b/src/mca/pls/rsh/pls_rsh_component.c @@ -191,14 +191,6 @@ orte_pls_base_module_t *orte_pls_rsh_component_init(int *priority) int orte_pls_rsh_component_close(void) { - if(mca_pls_rsh_component.reap) { - OMPI_THREAD_LOCK(&mca_pls_rsh_component.lock); - while(mca_pls_rsh_component.num_children > 0) { - ompi_condition_wait(&mca_pls_rsh_component.cond, &mca_pls_rsh_component.lock); - } - OMPI_THREAD_UNLOCK(&mca_pls_rsh_component.lock); - } - /* cleanup state */ OBJ_DESTRUCT(&mca_pls_rsh_component.lock); OBJ_DESTRUCT(&mca_pls_rsh_component.cond); diff --git a/src/mca/pls/rsh/pls_rsh_module.c b/src/mca/pls/rsh/pls_rsh_module.c index 4976742f45..3e362bf152 100644 --- a/src/mca/pls/rsh/pls_rsh_module.c +++ b/src/mca/pls/rsh/pls_rsh_module.c @@ -543,6 +543,14 @@ int orte_pls_rsh_terminate_proc(const orte_process_name_t* proc) int orte_pls_rsh_finalize(void) { + if(mca_pls_rsh_component.reap) { + OMPI_THREAD_LOCK(&mca_pls_rsh_component.lock); + while(mca_pls_rsh_component.num_children > 0) { + ompi_condition_wait(&mca_pls_rsh_component.cond, &mca_pls_rsh_component.lock); + } + OMPI_THREAD_UNLOCK(&mca_pls_rsh_component.lock); + } + /* cleanup any pending recvs */ orte_rml.recv_cancel(ORTE_RML_NAME_ANY, ORTE_RML_TAG_RMGR_CLNT); return ORTE_SUCCESS; diff --git a/src/mca/ras/base/base.h b/src/mca/ras/base/base.h index 2012413898..4c794871e2 100644 --- a/src/mca/ras/base/base.h +++ b/src/mca/ras/base/base.h @@ -56,6 +56,7 @@ typedef struct orte_ras_base_cmp_t orte_ras_base_cmp_t; * function definitions */ ORTE_DECLSPEC int orte_ras_base_open(void); +ORTE_DECLSPEC int orte_ras_base_finalize(void); ORTE_DECLSPEC int orte_ras_base_close(void); ORTE_DECLSPEC orte_ras_base_module_t* orte_ras_base_select(const char*); ORTE_DECLSPEC int orte_ras_base_allocate(orte_jobid_t job); diff --git a/src/mca/ras/base/ras_base_close.c b/src/mca/ras/base/ras_base_close.c index 3c4ab74bf4..ec36b78c09 100644 --- a/src/mca/ras/base/ras_base_close.c +++ b/src/mca/ras/base/ras_base_close.c @@ -26,17 +26,20 @@ #include "mca/ras/base/base.h" -int orte_ras_base_close(void) +int orte_ras_base_finalize(void) { ompi_list_item_t* item; - + /* Finalize all available modules */ while((item = ompi_list_remove_first(&orte_ras_base.ras_available)) != NULL) { orte_ras_base_cmp_t* cmp = (orte_ras_base_cmp_t*)item; cmp->module->finalize(); OBJ_RELEASE(cmp); } - +} + +int orte_ras_base_close(void) +{ /* Close all remaining available components (may be one if this is a Open RTE program, or [possibly] multiple if this is ompi_info) */ diff --git a/src/mca/rds/base/base.h b/src/mca/rds/base/base.h index 7b871b392d..3ca9377ed7 100644 --- a/src/mca/rds/base/base.h +++ b/src/mca/rds/base/base.h @@ -54,6 +54,7 @@ OMPI_DECLSPEC OBJ_CLASS_DECLARATION(orte_rds_base_selected_t); */ OMPI_DECLSPEC int orte_rds_base_open(void); OMPI_DECLSPEC int orte_rds_base_select(void); +OMPI_DECLSPEC int orte_rds_base_finalize(void); OMPI_DECLSPEC int orte_rds_base_close(void); OMPI_DECLSPEC int orte_rds_base_query(void); diff --git a/src/mca/rds/base/rds_base_close.c b/src/mca/rds/base/rds_base_close.c index 9f0ab02bd3..0786475c69 100644 --- a/src/mca/rds/base/rds_base_close.c +++ b/src/mca/rds/base/rds_base_close.c @@ -25,7 +25,7 @@ #include "mca/rds/base/base.h" -int orte_rds_base_close(void) +int orte_rds_base_finalize(void) { ompi_list_item_t* item; @@ -35,7 +35,10 @@ int orte_rds_base_close(void) selected->module->finalize(); OBJ_RELEASE(selected); } +} +int orte_rds_base_close(void) +{ /* Close all remaining available components (may be one if this is a Open RTE program, or [possibly] multiple if this is ompi_info) */ diff --git a/src/mca/rmaps/base/base.h b/src/mca/rmaps/base/base.h index e33298aea1..98ceeb3423 100644 --- a/src/mca/rmaps/base/base.h +++ b/src/mca/rmaps/base/base.h @@ -99,6 +99,7 @@ extern "C" { /** * Close down the rmaps framework */ + OMPI_DECLSPEC int orte_rmaps_base_finalize(void); OMPI_DECLSPEC int orte_rmaps_base_close(void); #if defined(c_plusplus) || defined(__cplusplus) diff --git a/src/mca/rmaps/base/rmaps_base_close.c b/src/mca/rmaps/base/rmaps_base_close.c index 776d7287d1..0a1f2b2784 100644 --- a/src/mca/rmaps/base/rmaps_base_close.c +++ b/src/mca/rmaps/base/rmaps_base_close.c @@ -26,7 +26,7 @@ #include "mca/rmaps/base/base.h" -int orte_rmaps_base_close(void) +int orte_rmaps_base_finalize(void) { ompi_list_item_t* item; @@ -43,7 +43,10 @@ int orte_rmaps_base_close(void) } OBJ_RELEASE(cmp); } +} +int orte_rmaps_base_close(void) +{ /* Close all remaining open components */ mca_base_components_close(orte_rmaps_base.rmaps_output, diff --git a/src/mca/rmgr/urm/rmgr_urm.c b/src/mca/rmgr/urm/rmgr_urm.c index b901540b5b..ccbee62e4d 100644 --- a/src/mca/rmgr/urm/rmgr_urm.c +++ b/src/mca/rmgr/urm/rmgr_urm.c @@ -299,6 +299,40 @@ static int orte_rmgr_urm_spawn( static int orte_rmgr_urm_finalize(void) { + int rc; + + /** + * Finalize Process Launch Subsystem (PLS) + */ + if (ORTE_SUCCESS != (rc = orte_pls_base_finalize())) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /** + * Finalize Resource Mapping Subsystem (RMAPS) + */ + if (ORTE_SUCCESS != (rc = orte_rmaps_base_finalize())) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /** + * Finalize Resource Allocation Subsystem (RAS) + */ + if (ORTE_SUCCESS != (rc = orte_ras_base_finalize())) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /** + * Finalize Resource Discovery Subsystem (RDS) + */ + if (ORTE_SUCCESS != (rc = orte_rds_base_finalize())) { + ORTE_ERROR_LOG(rc); + return rc; + } + /* Cancel pending receive. */ orte_rml.recv_cancel(ORTE_RML_NAME_ANY, ORTE_RML_TAG_RMGR_SVC);