There was some discussion of this at an earlier time, but we never got around to doing it - so make orte behave more like a regular library, counting the number of times init is called, and executing finalize when all those are exhausted.
This commit was SVN r27484.
This commit is contained in:
parent
094d6f3143
commit
79e36413c2
@ -32,6 +32,7 @@
|
||||
#include "orte/runtime/orte_globals.h"
|
||||
#include "orte/runtime/runtime.h"
|
||||
#include "orte/runtime/orte_locks.h"
|
||||
#include "orte/util/name_fns.h"
|
||||
#include "orte/util/show_help.h"
|
||||
|
||||
/**
|
||||
@ -44,7 +45,13 @@
|
||||
*/
|
||||
int orte_finalize(void)
|
||||
{
|
||||
if (!orte_initialized) {
|
||||
--orte_initialized;
|
||||
if (0 != orte_initialized) {
|
||||
/* check for mismatched calls */
|
||||
if (0 > orte_initialized) {
|
||||
opal_output(0, "%s MISMATCHED CALLS TO ORTE FINALIZE",
|
||||
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME));
|
||||
}
|
||||
return ORTE_SUCCESS;
|
||||
}
|
||||
|
||||
@ -99,6 +106,5 @@ int orte_finalize(void)
|
||||
/* finalize the opal utilities */
|
||||
opal_finalize();
|
||||
|
||||
orte_initialized = false;
|
||||
return ORTE_SUCCESS;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@
|
||||
/*
|
||||
* Whether we have completed orte_init or we are in orte_finalize
|
||||
*/
|
||||
bool orte_initialized = false;
|
||||
int orte_initialized = 0;
|
||||
bool orte_finalizing = false;
|
||||
bool orte_debug_flag = false;
|
||||
int orte_debug_verbosity;
|
||||
@ -96,9 +96,12 @@ int orte_init(int* pargc, char*** pargv, orte_proc_type_t flags)
|
||||
int ret;
|
||||
char *error = NULL;
|
||||
|
||||
if (orte_initialized) {
|
||||
if (0 < orte_initialized) {
|
||||
/* track number of times we have been called */
|
||||
orte_initialized++;
|
||||
return ORTE_SUCCESS;
|
||||
}
|
||||
orte_initialized++;
|
||||
|
||||
/* initialize the opal layer */
|
||||
if (ORTE_SUCCESS != (ret = opal_init(pargc, pargv))) {
|
||||
@ -196,7 +199,6 @@ int orte_init(int* pargc, char*** pargv, orte_proc_type_t flags)
|
||||
}
|
||||
|
||||
/* All done */
|
||||
orte_initialized = true;
|
||||
return ORTE_SUCCESS;
|
||||
|
||||
error:
|
||||
|
@ -41,7 +41,7 @@ ORTE_DECLSPEC extern const char orte_version_string[];
|
||||
/**
|
||||
* Whether ORTE is initialized or we are in orte_finalize
|
||||
*/
|
||||
ORTE_DECLSPEC extern bool orte_initialized;
|
||||
ORTE_DECLSPEC extern int orte_initialized;
|
||||
ORTE_DECLSPEC extern bool orte_finalizing;
|
||||
ORTE_DECLSPEC extern int orte_debug_output;
|
||||
ORTE_DECLSPEC extern bool orte_debug_flag;
|
||||
|
Loading…
x
Reference in New Issue
Block a user