1212 * Copyright (c) 2008-2012 Cisco Systems, Inc. All rights reserved.
1313 * Copyright (c) 2012-2013 Los Alamos National Security, LLC.
1414 * All rights reserved.
15- * Copyright (c) 2013-2015 Intel, Inc. All rights reserved.
15+ * Copyright (c) 2013-2016 Intel, Inc. All rights reserved.
1616 * $COPYRIGHT$
1717 *
1818 * Additional copyrights may follow
3939#include "opal/util/opal_environ.h"
4040#include "opal/util/output.h"
4141#include "opal/util/argv.h"
42+ #include "opal/runtime/opal_progress_threads.h"
4243#include "opal/class/opal_pointer_array.h"
4344#include "opal/mca/hwloc/base/base.h"
4445#include "opal/util/printf.h"
@@ -73,6 +74,7 @@ orte_ess_base_module_t orte_ess_pmi_module = {
7374static bool added_transport_keys = false;
7475static bool added_num_procs = false;
7576static bool added_app_ctx = false;
77+ static bool progress_thread_running = false;
7678
7779/**** MODULE FUNCTIONS ****/
7880
@@ -97,6 +99,11 @@ static int rte_init(void)
9799 goto error ;
98100 }
99101
102+ /* get an async event base - we use the opal_async one so
103+ * we don't startup extra threads if not needed */
104+ orte_event_base = opal_progress_thread_init (NULL );
105+ progress_thread_running = true;
106+
100107 /* open and setup pmix */
101108 if (OPAL_SUCCESS != (ret = mca_base_framework_open (& opal_pmix_base_framework , 0 ))) {
102109 ORTE_ERROR_LOG (ret );
@@ -109,6 +116,8 @@ static int rte_init(void)
109116 error = "pmix init" ;
110117 goto error ;
111118 }
119+ /* set the event base */
120+ opal_pmix_base_set_evbase (orte_event_base );
112121 /* initialize the selected module */
113122 if (!opal_pmix .initialized () && (OPAL_SUCCESS != (ret = opal_pmix .init ()))) {
114123 /* we cannot run */
@@ -394,6 +403,12 @@ static int rte_init(void)
394403 return ORTE_SUCCESS ;
395404
396405 error :
406+ if (!progress_thread_running ) {
407+ /* can't send the help message, so ensure it
408+ * comes out locally
409+ */
410+ orte_show_help_finalize ();
411+ }
397412 if (ORTE_ERR_SILENT != ret && !orte_report_silent_errors ) {
398413 orte_show_help ("help-orte-runtime.txt" ,
399414 "orte_init:startup:internal-failure" ,
@@ -419,18 +434,23 @@ static int rte_finalize(void)
419434 unsetenv ("OMPI_APP_CTX_NUM_PROCS" );
420435 }
421436
437+ /* use the default app procedure to finish */
438+ if (ORTE_SUCCESS != (ret = orte_ess_base_app_finalize ())) {
439+ ORTE_ERROR_LOG (ret );
440+ return ret ;
441+ }
442+
422443 /* mark us as finalized */
423444 if (NULL != opal_pmix .finalize ) {
424445 opal_pmix .finalize ();
425446 (void ) mca_base_framework_close (& opal_pmix_base_framework );
426447 }
427448
428- /* use the default app procedure to finish */
429- if (ORTE_SUCCESS != ( ret = orte_ess_base_app_finalize ()) ) {
430- ORTE_ERROR_LOG ( ret );
431- return ret ;
449+ /* release the event base */
450+ if (progress_thread_running ) {
451+ opal_progress_thread_finalize ( NULL );
452+ progress_thread_running = false ;
432453 }
433-
434454 return ORTE_SUCCESS ;
435455}
436456
0 commit comments