1
1

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.
Этот коммит содержится в:
Ralph Castain 2012-10-25 18:39:37 +00:00
родитель 094d6f3143
Коммит 79e36413c2
3 изменённых файлов: 14 добавлений и 6 удалений

Просмотреть файл

@ -32,6 +32,7 @@
#include "orte/runtime/orte_globals.h" #include "orte/runtime/orte_globals.h"
#include "orte/runtime/runtime.h" #include "orte/runtime/runtime.h"
#include "orte/runtime/orte_locks.h" #include "orte/runtime/orte_locks.h"
#include "orte/util/name_fns.h"
#include "orte/util/show_help.h" #include "orte/util/show_help.h"
/** /**
@ -44,7 +45,13 @@
*/ */
int orte_finalize(void) 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; return ORTE_SUCCESS;
} }
@ -99,6 +106,5 @@ int orte_finalize(void)
/* finalize the opal utilities */ /* finalize the opal utilities */
opal_finalize(); opal_finalize();
orte_initialized = false;
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }

Просмотреть файл

@ -50,7 +50,7 @@
/* /*
* Whether we have completed orte_init or we are in orte_finalize * 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_finalizing = false;
bool orte_debug_flag = false; bool orte_debug_flag = false;
int orte_debug_verbosity; int orte_debug_verbosity;
@ -96,9 +96,12 @@ int orte_init(int* pargc, char*** pargv, orte_proc_type_t flags)
int ret; int ret;
char *error = NULL; char *error = NULL;
if (orte_initialized) { if (0 < orte_initialized) {
/* track number of times we have been called */
orte_initialized++;
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }
orte_initialized++;
/* initialize the opal layer */ /* initialize the opal layer */
if (ORTE_SUCCESS != (ret = opal_init(pargc, pargv))) { 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 */ /* All done */
orte_initialized = true;
return ORTE_SUCCESS; return ORTE_SUCCESS;
error: error:

Просмотреть файл

@ -41,7 +41,7 @@ ORTE_DECLSPEC extern const char orte_version_string[];
/** /**
* Whether ORTE is initialized or we are in orte_finalize * 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 bool orte_finalizing;
ORTE_DECLSPEC extern int orte_debug_output; ORTE_DECLSPEC extern int orte_debug_output;
ORTE_DECLSPEC extern bool orte_debug_flag; ORTE_DECLSPEC extern bool orte_debug_flag;