From 8823069fe9a0235f0e38a03adf6f88d12cc36ed8 Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Fri, 4 Dec 2015 08:26:57 -0800 Subject: [PATCH] Provide a mechanism by which a tool can request async progress thread support for ORTE --- orte/mca/ess/base/ess_base_std_tool.c | 7 ---- orte/mca/ess/tool/ess_tool.h | 7 +++- orte/mca/ess/tool/ess_tool_component.c | 49 ++++++++++++++++++-------- orte/mca/ess/tool/ess_tool_module.c | 27 +++++++++++++- 4 files changed, 66 insertions(+), 24 deletions(-) diff --git a/orte/mca/ess/base/ess_base_std_tool.c b/orte/mca/ess/base/ess_base_std_tool.c index 198b9d38e2..ea60dc72d8 100644 --- a/orte/mca/ess/base/ess_base_std_tool.c +++ b/orte/mca/ess/base/ess_base_std_tool.c @@ -37,7 +37,6 @@ #include "opal/mca/event/event.h" #include "opal/runtime/opal.h" #include "opal/runtime/opal_cr.h" -#include "opal/runtime/opal_progress_threads.h" #include "opal/util/arch.h" #include "opal/util/proc.h" @@ -64,7 +63,6 @@ #include "orte/mca/ess/base/base.h" -static bool progress_thread_running = false; int orte_ess_base_tool_setup(void) { @@ -275,10 +273,5 @@ int orte_ess_base_tool_finalize(void) (void) mca_base_framework_close(&orte_schizo_base_framework); (void) mca_base_framework_close(&orte_errmgr_base_framework); - /* release the event base */ - if (progress_thread_running) { - opal_progress_thread_finalize("orte"); - progress_thread_running = false; - } return ORTE_SUCCESS; } diff --git a/orte/mca/ess/tool/ess_tool.h b/orte/mca/ess/tool/ess_tool.h index 62c2655cce..e2eacc12c5 100644 --- a/orte/mca/ess/tool/ess_tool.h +++ b/orte/mca/ess/tool/ess_tool.h @@ -9,6 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2015 Intel, Inc. All rights reserved * $COPYRIGHT$ * * Additional copyrights may follow @@ -28,8 +29,12 @@ int orte_ess_tool_component_open(void); int orte_ess_tool_component_close(void); int orte_ess_tool_component_query(mca_base_module_t **module, int *priority); +typedef struct { + orte_ess_base_component_t super; + bool async; +} orte_ess_tool_component_t; -ORTE_MODULE_DECLSPEC extern orte_ess_base_component_t mca_ess_tool_component; +ORTE_MODULE_DECLSPEC extern orte_ess_tool_component_t mca_ess_tool_component; END_C_DECLS diff --git a/orte/mca/ess/tool/ess_tool_component.c b/orte/mca/ess/tool/ess_tool_component.c index ad81fbe72a..8836464ba2 100644 --- a/orte/mca/ess/tool/ess_tool_component.c +++ b/orte/mca/ess/tool/ess_tool_component.c @@ -12,6 +12,7 @@ * All rights reserved. * Copyright (c) 2015 Los Alamos National Security, LLC. All rights * reserved. + * Copyright (c) 2015 Intel, Inc. All rights reserved * $COPYRIGHT$ * * Additional copyrights may follow @@ -35,30 +36,48 @@ extern orte_ess_base_module_t orte_ess_tool_module; +static int tool_component_register(void); + /* * Instantiate the public struct with all of our public information * and pointers to our public functions in it */ -orte_ess_base_component_t mca_ess_tool_component = { - .base_version = { - ORTE_ESS_BASE_VERSION_3_0_0, +orte_ess_tool_component_t mca_ess_tool_component = { + { + .base_version = { + ORTE_ESS_BASE_VERSION_3_0_0, - /* Component name and version */ - .mca_component_name = "tool", - MCA_BASE_MAKE_VERSION(component, ORTE_MAJOR_VERSION, ORTE_MINOR_VERSION, - ORTE_RELEASE_VERSION), + /* Component name and version */ + .mca_component_name = "tool", + MCA_BASE_MAKE_VERSION(component, ORTE_MAJOR_VERSION, ORTE_MINOR_VERSION, + ORTE_RELEASE_VERSION), - /* Component open and close functions */ - .mca_open_component = orte_ess_tool_component_open, - .mca_close_component = orte_ess_tool_component_close, - .mca_query_component = orte_ess_tool_component_query, - }, - .base_data = { - /* The component is checkpoint ready */ - MCA_BASE_METADATA_PARAM_CHECKPOINT + /* Component open and close functions */ + .mca_open_component = orte_ess_tool_component_open, + .mca_close_component = orte_ess_tool_component_close, + .mca_query_component = orte_ess_tool_component_query, + .mca_register_component_params = tool_component_register, + }, + .base_data = { + /* The component is checkpoint ready */ + MCA_BASE_METADATA_PARAM_CHECKPOINT + }, }, + .async = false }; +static int tool_component_register(void) +{ + mca_base_component_t *c = &mca_ess_tool_component.super.base_version; + + mca_ess_tool_component.async = false; + (void) mca_base_component_var_register (c, "async_progress", "Setup an async progress thread", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_2, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_ess_tool_component.async); + return ORTE_SUCCESS; +} int orte_ess_tool_component_open(void) diff --git a/orte/mca/ess/tool/ess_tool_module.c b/orte/mca/ess/tool/ess_tool_module.c index d18ccc23ab..45189b3be6 100644 --- a/orte/mca/ess/tool/ess_tool_module.c +++ b/orte/mca/ess/tool/ess_tool_module.c @@ -31,6 +31,8 @@ #include #endif +#include "opal/runtime/opal_progress_threads.h" + #include "orte/util/show_help.h" #include "orte/mca/plm/base/base.h" #include "orte/mca/plm/base/plm_private.h" @@ -45,15 +47,17 @@ static int rte_init(void); static void rte_abort(int status, bool report) __opal_attribute_noreturn__; +static int rte_finalize(void); orte_ess_base_module_t orte_ess_tool_module = { rte_init, - orte_ess_base_tool_finalize, + rte_finalize, rte_abort, NULL /* ft_event */ }; +static bool progress_thread_running = false; static int rte_init(void) { @@ -103,6 +107,14 @@ static int rte_init(void) ORTE_PROC_MY_NAME->vpid = 0; } + /* if requested, get an async event base - we use the + * opal_async one so we don't startup extra threads if + * not needed */ + if (mca_ess_tool_component.async) { + orte_event_base = opal_progress_thread_init(NULL); + progress_thread_running = true; + } + /* do the rest of the standard tool init */ if (ORTE_SUCCESS != (ret = orte_ess_base_tool_setup())) { ORTE_ERROR_LOG(ret); @@ -122,6 +134,19 @@ static int rte_init(void) return ret; } +static int rte_finalize(void) +{ + /* use the std finalize routing */ + orte_ess_base_tool_finalize(); + + /* release the event base */ + if (progress_thread_running) { + opal_progress_thread_finalize(NULL); + progress_thread_running = false; + } + return ORTE_SUCCESS; +} + /* * If we are a tool-without-name, then we look just like the HNP. * In that scenario, it could be beneficial to get a core file, so