From 1e678c3f55f36783ddcf607b640620ea00e5c55a Mon Sep 17 00:00:00 2001 From: Josh Hursey Date: Thu, 24 May 2007 21:54:58 +0000 Subject: [PATCH] per conversation with Ralph and Jeff take out the opal_init_only logic. This commit moves the initalization/finalization of opal_event and opal_progress to opal_init/finalize. These were previously init/final in ORTE which is an abstraction violation. After talking about it we concluded that there are no ordering issues that require these to be init/final in ORTE instead of OPAL. I ran the IBM test suite against this commit and it didn't turn up any new failures so I think it is good to go. Let us know if this causes problems. This commit was SVN r14773. --- ompi/runtime/ompi_mpi_init.c | 6 -- opal/runtime/opal.h | 11 ---- opal/runtime/opal_cr.c | 16 +++++ opal/runtime/opal_finalize.c | 10 ++-- opal/runtime/opal_init.c | 63 ++++++++++---------- orte/runtime/orte_init.c | 6 -- orte/runtime/orte_init_stage1.c | 17 ------ orte/runtime/orte_system_finalize.c | 4 -- orte/tools/orte-checkpoint/orte-checkpoint.c | 1 - 9 files changed, 50 insertions(+), 84 deletions(-) diff --git a/ompi/runtime/ompi_mpi_init.c b/ompi/runtime/ompi_mpi_init.c index f8002f5c2e..5d63885efd 100644 --- a/ompi/runtime/ompi_mpi_init.c +++ b/ompi/runtime/ompi_mpi_init.c @@ -226,12 +226,6 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided) int num_processors; #endif - /* - * ORTE takes the responsibility of starting the progress and event - * (and other) engines. - */ - opal_init_only = false; - /* Join the run-time environment - do the things that don't hit the registry */ diff --git a/opal/runtime/opal.h b/opal/runtime/opal.h index ec68df7d6f..af63f588ef 100644 --- a/opal/runtime/opal.h +++ b/opal/runtime/opal.h @@ -27,17 +27,6 @@ extern "C" { #endif -/** - * Determine if this is an OPAL level applicaiton or something else. - * If something else (e.g., ORTE) then we don't want to start the - * event and progress engines since ORTE does that during it's init. - * - * So if we are only doing opal_init, and not someone elses as well. - * See the opal_init() function for the components that needed to be - * called if you are going to set this value to 'false'. - */ -OPAL_DECLSPEC extern bool opal_init_only; - /** * Initialize the OPAL layer, including the MCA system. * diff --git a/opal/runtime/opal_cr.c b/opal/runtime/opal_cr.c index 94e085bae7..894e798b95 100644 --- a/opal/runtime/opal_cr.c +++ b/opal/runtime/opal_cr.c @@ -130,6 +130,8 @@ int opal_cr_set_enabled(bool en) return OPAL_SUCCESS; } +int opal_cr_initalized = 0; + int opal_cr_init(void ) { int ret, exit_status = OPAL_SUCCESS; @@ -137,6 +139,13 @@ int opal_cr_init(void ) opal_cr_coord_callback_fn_t prev_coord_func; int val; + if( ++opal_cr_initalized != 1 ) { + if( opal_cr_initalized < 1 ) { + return OPAL_ERROR; + } + return OPAL_SUCCESS; + } + /* * Some startup MCA parameters */ @@ -298,6 +307,13 @@ int opal_cr_finalize(void) { int exit_status = OPAL_SUCCESS; + if( --opal_cr_initalized != 0 ) { + if( opal_cr_initalized < 0 ) { + return OPAL_ERROR; + } + return OPAL_SUCCESS; + } + if( !opal_cr_is_tool ) { #if OPAL_ENABLE_FT_THREAD == 1 /* diff --git a/opal/runtime/opal_finalize.c b/opal/runtime/opal_finalize.c index 8689f369be..169dee20c9 100644 --- a/opal/runtime/opal_finalize.c +++ b/opal/runtime/opal_finalize.c @@ -88,14 +88,12 @@ opal_finalize(void) return OPAL_SUCCESS; } - if( opal_init_only ) { - /* close the checkpoint and restart service */ - opal_cr_finalize(); + /* close the checkpoint and restart service */ + opal_cr_finalize(); - opal_progress_finalize(); + opal_progress_finalize(); - opal_event_fini(); - } + opal_event_fini(); /* close high resolution timers */ opal_timer_base_close(); diff --git a/opal/runtime/opal_init.c b/opal/runtime/opal_init.c index ed155c166b..1b1534ca22 100644 --- a/opal/runtime/opal_init.c +++ b/opal/runtime/opal_init.c @@ -48,7 +48,6 @@ #include "opal/util/sys_limits.h" -bool opal_init_only = true; int opal_initialized = 0; static const char * @@ -260,40 +259,38 @@ opal_init(void) goto return_error; } - if( opal_init_only ) { - /* - * Need to start the event and progress engines if noone else is. - * opal_cr_init uses the progress engine, so it is lumped together - * into this set as well. - */ - /* - * Initialize the event library - */ - if (OPAL_SUCCESS != (ret = opal_event_init())) { - error = "opal_event_init"; - goto return_error; - } + /* + * Need to start the event and progress engines if noone else is. + * opal_cr_init uses the progress engine, so it is lumped together + * into this set as well. + */ + /* + * Initialize the event library + */ + if (OPAL_SUCCESS != (ret = opal_event_init())) { + error = "opal_event_init"; + goto return_error; + } - /* - * Intialize the general progress engine - */ - if (OPAL_SUCCESS != (ret = opal_progress_init())) { - error = "opal_progress_init"; - goto return_error; - } - /* we want to tick the event library whenever possible */ - opal_progress_event_users_increment(); + /* + * Intialize the general progress engine + */ + if (OPAL_SUCCESS != (ret = opal_progress_init())) { + error = "opal_progress_init"; + goto return_error; + } + /* we want to tick the event library whenever possible */ + opal_progress_event_users_increment(); - /* - * Initalize the checkpoint/restart functionality - * Note: Always do this so we can detect if the user - * attempts to checkpoint a non checkpointable job, - * otherwise the tools may hang or not clean up properly. - */ - if (OPAL_SUCCESS != (ret = opal_cr_init() ) ) { - error = "opal_cr_init() failed"; - goto return_error; - } + /* + * Initalize the checkpoint/restart functionality + * Note: Always do this so we can detect if the user + * attempts to checkpoint a non checkpointable job, + * otherwise the tools may hang or not clean up properly. + */ + if (OPAL_SUCCESS != (ret = opal_cr_init() ) ) { + error = "opal_cr_init() failed"; + goto return_error; } return OPAL_SUCCESS; diff --git a/orte/runtime/orte_init.c b/orte/runtime/orte_init.c index 13f7cda323..fc20f01af1 100644 --- a/orte/runtime/orte_init.c +++ b/orte/runtime/orte_init.c @@ -39,12 +39,6 @@ int orte_init(bool infrastructure, bool barrier) { int rc; - /* - * ORTE takes the responsibility of starting the progress and event - * (and other) engines. - */ - opal_init_only = false; - if (orte_initialized) { return ORTE_SUCCESS; } diff --git a/orte/runtime/orte_init_stage1.c b/orte/runtime/orte_init_stage1.c index 019790b3a9..7d5d17db6e 100644 --- a/orte/runtime/orte_init_stage1.c +++ b/orte/runtime/orte_init_stage1.c @@ -145,23 +145,6 @@ int orte_init_stage1(bool infrastructure) /***** ERROR LOGGING NOW AVAILABLE *****/ - /* - * Initialize the event library - */ - if (ORTE_SUCCESS != (ret = opal_event_init())) { - ORTE_ERROR_LOG(ret); - error = "opal_event_init"; - goto error; - } - - /* - * Intialize the general progress engine - */ - if (ORTE_SUCCESS != (ret = opal_progress_init())) { - ORTE_ERROR_LOG(ret); - error = "opal_progress_init"; - goto error; - } /* we want to tick the event library whenever possible */ opal_progress_event_users_increment(); diff --git a/orte/runtime/orte_system_finalize.c b/orte/runtime/orte_system_finalize.c index 75fc3734cd..0f0f16f950 100644 --- a/orte/runtime/orte_system_finalize.c +++ b/orte/runtime/orte_system_finalize.c @@ -107,10 +107,6 @@ int orte_system_finalize(void) orte_rml_base_close(); orte_dss_close(); - opal_progress_finalize(); - - opal_event_fini(); - orte_session_dir_finalize(orte_process_info.my_name); /* clean out the global structures */ diff --git a/orte/tools/orte-checkpoint/orte-checkpoint.c b/orte/tools/orte-checkpoint/orte-checkpoint.c index 8dc71abd76..3cd44957e2 100644 --- a/orte/tools/orte-checkpoint/orte-checkpoint.c +++ b/orte/tools/orte-checkpoint/orte-checkpoint.c @@ -534,7 +534,6 @@ static int ckpt_init(int argc, char *argv[]) { * Note: This must happen before opal_init(). */ opal_cr_set_enabled(false); - opal_init_only = false; /* Select the none component, since we don't actually use a checkpointer */ opal_setenv(mca_base_param_env_var("crs"),