opal: clean up init/finalize
This commit contains the following changes: - Remove the unused opal_test_init/opal_test_finalize functions. These functions are not used by anything in the code base or MTT. Tests use opal_init_util/opal_finalize_util instead. - Get rid of gotos in opal_init_util and opal_init. Replaced them with a cleaner solution. - Automatically register cleanup functions in init functions. The cleanup functions are executed in the reverse order of the initialization functions. The cleanup functions are run in opal_finalize_util() before tearing down the class system. Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
Этот коммит содержится в:
родитель
c5292a0094
Коммит
0edfd328f8
@ -16,6 +16,8 @@
|
||||
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
|
||||
* Copyright (c) 2017-2018 Research Organization for Information Science
|
||||
* and Technology (RIST). All rights reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -181,7 +183,6 @@ OPAL_DECLSPEC extern const opal_datatype_t opal_datatype_wchar;
|
||||
*/
|
||||
int opal_datatype_register_params(void);
|
||||
OPAL_DECLSPEC int32_t opal_datatype_init( void );
|
||||
OPAL_DECLSPEC int32_t opal_datatype_finalize( void );
|
||||
OPAL_DECLSPEC opal_datatype_t* opal_datatype_create( int32_t expectedSize );
|
||||
OPAL_DECLSPEC int32_t opal_datatype_create_desc( opal_datatype_t * datatype, int32_t expectedSize );
|
||||
OPAL_DECLSPEC int32_t opal_datatype_commit( opal_datatype_t * pData );
|
||||
|
@ -17,6 +17,8 @@
|
||||
* reserved.
|
||||
* Copyright (c) 2015 Research Organization for Information Science
|
||||
* and Technology (RIST). All rights reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -28,6 +30,7 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "opal/runtime/opal.h"
|
||||
#include "opal/util/arch.h"
|
||||
#include "opal/util/output.h"
|
||||
#include "opal/datatype/opal_datatype_internal.h"
|
||||
@ -204,6 +207,21 @@ int opal_datatype_register_params(void)
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
static void opal_datatype_finalize (void)
|
||||
{
|
||||
/* As the synonyms are just copies of the internal data we should not free them.
|
||||
* Anyway they are over the limit of OPAL_DATATYPE_MAX_PREDEFINED so they will never get freed.
|
||||
*/
|
||||
|
||||
/* As they are statically allocated they cannot be released. But we
|
||||
* can call OBJ_DESTRUCT, just to free all internally allocated ressources.
|
||||
*/
|
||||
/* clear all master convertors */
|
||||
opal_convertor_destroy_masters();
|
||||
|
||||
opal_output_close (opal_datatype_dfd);
|
||||
opal_datatype_dfd = -1;
|
||||
}
|
||||
|
||||
int32_t opal_datatype_init( void )
|
||||
{
|
||||
@ -242,27 +260,7 @@ int32_t opal_datatype_init( void )
|
||||
opal_output_set_verbosity(opal_datatype_dfd, opal_ddt_verbose);
|
||||
}
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int32_t opal_datatype_finalize( void )
|
||||
{
|
||||
/* As the synonyms are just copies of the internal data we should not free them.
|
||||
* Anyway they are over the limit of OPAL_DATATYPE_MAX_PREDEFINED so they will never get freed.
|
||||
*/
|
||||
|
||||
/* As they are statically allocated they cannot be released. But we
|
||||
* can call OBJ_DESTRUCT, just to free all internally allocated ressources.
|
||||
*/
|
||||
#if defined(VERBOSE)
|
||||
if( opal_datatype_dfd != -1 )
|
||||
opal_output_close( opal_datatype_dfd );
|
||||
opal_datatype_dfd = -1;
|
||||
#endif /* VERBOSE */
|
||||
|
||||
/* clear all master convertors */
|
||||
opal_convertor_destroy_masters();
|
||||
opal_finalize_register_cleanup (opal_datatype_finalize);
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*- C -*-
|
||||
*
|
||||
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
||||
* University Research and Technology
|
||||
* Corporation. All rights reserved.
|
||||
@ -12,6 +12,8 @@
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved.
|
||||
* Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -357,12 +359,6 @@ OPAL_DECLSPEC int opal_dss_register_vars (void);
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_dss_open(void);
|
||||
|
||||
/**
|
||||
* DSS finalize function
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_dss_close(void);
|
||||
|
||||
|
||||
/**
|
||||
* Copy a data value from one location to another.
|
||||
*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C; c-basic-offset:4 ; -*- */
|
||||
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
|
||||
* University Research and Technology
|
||||
@ -15,6 +15,8 @@
|
||||
* Copyright (c) 2015 Research Organization for Information Science
|
||||
* and Technology (RIST). All rights reserved.
|
||||
* Copyright (c) 2017 IBM Corporation. All rights reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -26,6 +28,7 @@
|
||||
*/
|
||||
#include "opal_config.h"
|
||||
|
||||
#include "opal/runtime/opal.h"
|
||||
#include "opal/mca/base/mca_base_var.h"
|
||||
|
||||
#include "opal/dss/dss_internal.h"
|
||||
@ -312,6 +315,21 @@ int opal_dss_register_vars (void)
|
||||
return (0 > ret) ? ret : OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
static void opal_dss_close (void)
|
||||
{
|
||||
opal_dss_initialized = false;
|
||||
|
||||
for (int i = 0 ; i < opal_pointer_array_get_size(&opal_dss_types) ; ++i) {
|
||||
opal_dss_type_info_t *info = (opal_dss_type_info_t*)opal_pointer_array_get_item(&opal_dss_types, i);
|
||||
if (NULL != info) {
|
||||
opal_pointer_array_set_item(&opal_dss_types, i, NULL);
|
||||
OBJ_RELEASE(info);
|
||||
}
|
||||
}
|
||||
|
||||
OBJ_DESTRUCT(&opal_dss_types);
|
||||
}
|
||||
|
||||
int opal_dss_open(void)
|
||||
{
|
||||
int rc;
|
||||
@ -658,28 +676,8 @@ int opal_dss_open(void)
|
||||
/* All done */
|
||||
|
||||
opal_dss_initialized = true;
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int opal_dss_close(void)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
if (!opal_dss_initialized) {
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
opal_dss_initialized = false;
|
||||
|
||||
for (i = 0 ; i < opal_pointer_array_get_size(&opal_dss_types) ; ++i) {
|
||||
opal_dss_type_info_t *info = (opal_dss_type_info_t*)opal_pointer_array_get_item(&opal_dss_types, i);
|
||||
if (NULL != info) {
|
||||
opal_pointer_array_set_item(&opal_dss_types, i, NULL);
|
||||
OBJ_RELEASE(info);
|
||||
}
|
||||
}
|
||||
|
||||
OBJ_DESTRUCT(&opal_dss_types);
|
||||
opal_finalize_register_cleanup (opal_dss_close);
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
@ -16,6 +16,8 @@
|
||||
* Copyright (c) 2015 Research Organization for Information Science
|
||||
* and Technology (RIST). All rights reserved.
|
||||
* Copyright (c) 2017 IBM Corporation. All rights reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -130,7 +132,7 @@ OPAL_DECLSPEC int mca_base_open(void);
|
||||
* It must be the last MCA function invoked. It is normally invoked
|
||||
* during the finalize stage.
|
||||
*/
|
||||
OPAL_DECLSPEC int mca_base_close(void);
|
||||
OPAL_DECLSPEC void mca_base_close(void);
|
||||
|
||||
/**
|
||||
* A generic select function
|
||||
|
@ -33,35 +33,34 @@ extern int mca_base_opened;
|
||||
/*
|
||||
* Main MCA shutdown.
|
||||
*/
|
||||
int mca_base_close(void)
|
||||
|
||||
void mca_base_close (void)
|
||||
{
|
||||
assert (mca_base_opened);
|
||||
if (!--mca_base_opened) {
|
||||
/* deregister all MCA base parameters */
|
||||
int group_id = mca_base_var_group_find ("opal", "mca", "base");
|
||||
|
||||
if (-1 < group_id) {
|
||||
mca_base_var_group_deregister (group_id);
|
||||
}
|
||||
|
||||
/* release the default paths */
|
||||
if (NULL != mca_base_system_default_path) {
|
||||
free(mca_base_system_default_path);
|
||||
}
|
||||
if (NULL != mca_base_user_default_path) {
|
||||
free(mca_base_user_default_path);
|
||||
}
|
||||
|
||||
/* Close down the component repository */
|
||||
mca_base_component_repository_finalize();
|
||||
|
||||
/* Shut down the dynamic component finder */
|
||||
mca_base_component_find_finalize();
|
||||
|
||||
/* Close opal output stream 0 */
|
||||
opal_output_close(0);
|
||||
if (--mca_base_opened) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* All done */
|
||||
return OPAL_SUCCESS;
|
||||
/* deregister all MCA base parameters */
|
||||
int group_id = mca_base_var_group_find ("opal", "mca", "base");
|
||||
|
||||
if (-1 < group_id) {
|
||||
mca_base_var_group_deregister (group_id);
|
||||
}
|
||||
|
||||
/* release the default paths */
|
||||
free (mca_base_system_default_path);
|
||||
mca_base_system_default_path = NULL;
|
||||
|
||||
free (mca_base_user_default_path);
|
||||
mca_base_user_default_path = NULL;
|
||||
|
||||
/* Close down the component repository */
|
||||
mca_base_component_repository_finalize();
|
||||
|
||||
/* Shut down the dynamic component finder */
|
||||
mca_base_component_find_finalize();
|
||||
|
||||
/* Close opal output stream 0 */
|
||||
opal_output_close(0);
|
||||
}
|
||||
|
@ -5,6 +5,8 @@
|
||||
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2017 IBM Corporation. All rights reserved.
|
||||
* Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -140,6 +142,22 @@ int mca_base_framework_register (struct mca_base_framework_t *framework,
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
int mca_base_framework_register_list (mca_base_framework_t **frameworks, mca_base_register_flag_t flags)
|
||||
{
|
||||
if (NULL == frameworks) {
|
||||
return OPAL_ERR_BAD_PARAM;
|
||||
}
|
||||
|
||||
for (int i = 0 ; frameworks[i] ; ++i) {
|
||||
int ret = mca_base_framework_register (frameworks[i], flags);
|
||||
if (OPAL_UNLIKELY(OPAL_SUCCESS != ret && OPAL_ERR_NOT_AVAILABLE != ret)) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
int mca_base_framework_open (struct mca_base_framework_t *framework,
|
||||
mca_base_open_flag_t flags) {
|
||||
int ret;
|
||||
@ -189,6 +207,22 @@ int mca_base_framework_open (struct mca_base_framework_t *framework,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int mca_base_framework_open_list (mca_base_framework_t **frameworks, mca_base_open_flag_t flags)
|
||||
{
|
||||
if (NULL == frameworks) {
|
||||
return OPAL_ERR_BAD_PARAM;
|
||||
}
|
||||
|
||||
for (int i = 0 ; frameworks[i] ; ++i) {
|
||||
int ret = mca_base_framework_open (frameworks[i], flags);
|
||||
if (OPAL_UNLIKELY(OPAL_SUCCESS != ret && OPAL_ERR_NOT_AVAILABLE != ret)) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
int mca_base_framework_close (struct mca_base_framework_t *framework) {
|
||||
bool is_open = mca_base_framework_is_open (framework);
|
||||
bool is_registered = mca_base_framework_is_registered (framework);
|
||||
@ -247,3 +281,19 @@ int mca_base_framework_close (struct mca_base_framework_t *framework) {
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int mca_base_framework_close_list (mca_base_framework_t **frameworks)
|
||||
{
|
||||
if (NULL == frameworks) {
|
||||
return OPAL_ERR_BAD_PARAM;
|
||||
}
|
||||
|
||||
for (int i = 0 ; frameworks[i] ; ++i) {
|
||||
int ret = mca_base_framework_close (frameworks[i]);
|
||||
if (OPAL_UNLIKELY(OPAL_SUCCESS != ret)) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
* Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights
|
||||
* reserved.
|
||||
* Copyright (c) 2017 IBM Corporation. All rights reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -173,6 +175,20 @@ typedef struct mca_base_framework_t {
|
||||
OPAL_DECLSPEC int mca_base_framework_register (mca_base_framework_t *framework,
|
||||
mca_base_register_flag_t flags);
|
||||
|
||||
/**
|
||||
* Register frameworks with MCA.
|
||||
*
|
||||
* @param[in] framework NULL-terminated list of frameworks to register
|
||||
*
|
||||
* @retval OPAL_SUCCESS Upon success
|
||||
* @retval OPAL_ERROR Upon failure
|
||||
*
|
||||
* Call the MCA variable registration functions of each framework in the
|
||||
* frameworks array.
|
||||
*/
|
||||
OPAL_DECLSPEC int mca_base_framework_register_list (mca_base_framework_t **frameworks,
|
||||
mca_base_register_flag_t flags);
|
||||
|
||||
/**
|
||||
* Open a framework
|
||||
*
|
||||
@ -186,6 +202,19 @@ OPAL_DECLSPEC int mca_base_framework_register (mca_base_framework_t *framework,
|
||||
OPAL_DECLSPEC int mca_base_framework_open (mca_base_framework_t *framework,
|
||||
mca_base_open_flag_t flags);
|
||||
|
||||
/**
|
||||
* Open frameworks
|
||||
*
|
||||
* @param[in] frameworks NULL-terminated array of framework to open
|
||||
*
|
||||
* @retval OPAL_SUCCESS Upon success
|
||||
* @retval OPAL_ERROR Upon failure
|
||||
*
|
||||
* Call the open function on multiple frameworks
|
||||
*/
|
||||
OPAL_DECLSPEC int mca_base_framework_open_list (mca_base_framework_t **frameworks,
|
||||
mca_base_open_flag_t flags);
|
||||
|
||||
/**
|
||||
* Close a framework
|
||||
*
|
||||
@ -198,6 +227,17 @@ OPAL_DECLSPEC int mca_base_framework_open (mca_base_framework_t *framework,
|
||||
*/
|
||||
OPAL_DECLSPEC int mca_base_framework_close (mca_base_framework_t *framework);
|
||||
|
||||
/**
|
||||
* Close frameworks
|
||||
*
|
||||
* @param[in] frameworks NULL-terminated array of framework to close
|
||||
*
|
||||
* @retval OPAL_SUCCESS Upon success
|
||||
* @retval OPAL_ERROR Upon failure
|
||||
*
|
||||
* Call the close function on multiple frameworks
|
||||
*/
|
||||
OPAL_DECLSPEC int mca_base_framework_close_list (mca_base_framework_t **frameworks);
|
||||
|
||||
/**
|
||||
* Check if a framework is already registered
|
||||
|
@ -15,6 +15,8 @@
|
||||
* reserved.
|
||||
* Copyright (c) 2017 IBM Corporation. All rights reserved.
|
||||
* Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -33,6 +35,7 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "opal/runtime/opal.h"
|
||||
#include "opal/mca/installdirs/installdirs.h"
|
||||
#include "opal/util/output.h"
|
||||
#include "opal/util/printf.h"
|
||||
@ -164,6 +167,8 @@ int mca_base_open(void)
|
||||
|
||||
/* Open up the component repository */
|
||||
|
||||
opal_finalize_register_cleanup (mca_base_close);
|
||||
|
||||
return mca_base_component_repository_init();
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,8 @@
|
||||
* and Technology (RIST). All rights reserved.
|
||||
* Copyright (c) 2017 IBM Corporation. All rights reserved.
|
||||
* Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -144,6 +146,7 @@ static int read_files (char *file_list, opal_list_t *file_values, char sep);
|
||||
static int var_set_initial (mca_base_var_t *var, mca_base_var_t *original);
|
||||
static int var_get (int vari, mca_base_var_t **var_out, bool original);
|
||||
static int var_value_string (mca_base_var_t *var, char **value_string);
|
||||
static void mca_base_var_finalize (void);
|
||||
|
||||
/*
|
||||
* classes
|
||||
@ -293,6 +296,8 @@ int mca_base_var_init(void)
|
||||
|
||||
}
|
||||
|
||||
opal_finalize_register_cleanup (mca_base_var_finalize);
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1103,7 +1108,7 @@ int mca_base_var_build_env(char ***env, int *num_env, bool internal)
|
||||
* Shut down the MCA parameter system (normally only invoked by the
|
||||
* MCA framework itself).
|
||||
*/
|
||||
int mca_base_var_finalize(void)
|
||||
static void mca_base_var_finalize (void)
|
||||
{
|
||||
opal_object_t *object;
|
||||
opal_list_item_t *item;
|
||||
@ -1158,10 +1163,6 @@ int mca_base_var_finalize(void)
|
||||
free (mca_base_envar_files);
|
||||
mca_base_envar_files = NULL;
|
||||
}
|
||||
|
||||
/* All done */
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,6 +15,8 @@
|
||||
* reserved.
|
||||
* Copyright (c) 2016 Intel, Inc. All rights reserved.
|
||||
* Copyright (c) 2017 IBM Corporation. All rights reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -709,22 +711,6 @@ OPAL_DECLSPEC int mca_base_var_get_count (void);
|
||||
OPAL_DECLSPEC int mca_base_var_build_env(char ***env, int *num_env,
|
||||
bool internal);
|
||||
|
||||
/**
|
||||
* Shut down the MCA variable system (normally only invoked by the
|
||||
* MCA framework itself).
|
||||
*
|
||||
* @returns OPAL_SUCCESS This function never fails.
|
||||
*
|
||||
* This function shuts down the MCA variable repository and frees all
|
||||
* associated memory. No other mca_base_var*() functions can be
|
||||
* invoked after this function.
|
||||
*
|
||||
* This function is normally only invoked by the MCA framework itself
|
||||
* when the process is shutting down (e.g., during MPI_FINALIZE). It
|
||||
* is only documented here for completeness.
|
||||
*/
|
||||
OPAL_DECLSPEC int mca_base_var_finalize(void);
|
||||
|
||||
typedef enum {
|
||||
/* Dump human-readable strings */
|
||||
MCA_BASE_VAR_DUMP_READABLE = 0,
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "opal/class/opal_list.h"
|
||||
#include "opal/class/opal_object.h"
|
||||
#include "opal/sys/atomic.h"
|
||||
#include "opal/runtime/opal.h"
|
||||
|
||||
/*
|
||||
* local types
|
||||
@ -55,27 +56,23 @@ static opal_list_t release_cb_list;
|
||||
static opal_atomic_lock_t release_lock;
|
||||
static int release_run_callbacks;
|
||||
|
||||
int
|
||||
opal_mem_hooks_init(void)
|
||||
/**
|
||||
* Finalize the memory hooks subsystem
|
||||
*
|
||||
* Finalize the memory hooks subsystem. This is generally called
|
||||
* during opal_finalize() and no other memory hooks functions should
|
||||
* be called after this function is called. opal_mem_hooks_finalize()
|
||||
* will automatically deregister any callbacks that have not already
|
||||
* been deregistered. In a multi-threaded application, it is possible
|
||||
* that one thread will have a memory hook callback while the other
|
||||
* thread is in opal_mem_hooks_finalize(), however, no threads will
|
||||
* receive a callback once the calling thread has exited
|
||||
* opal_mem_hooks_finalize().
|
||||
*
|
||||
* @retval OPAL_SUCCESS Shutdown completed successfully
|
||||
*/
|
||||
static void opal_mem_hooks_finalize(void)
|
||||
{
|
||||
OBJ_CONSTRUCT(&release_cb_list, opal_list_t);
|
||||
|
||||
opal_atomic_lock_init(&release_lock, OPAL_ATOMIC_LOCK_UNLOCKED);
|
||||
|
||||
/* delay running callbacks until there is something in the
|
||||
registration */
|
||||
release_run_callbacks = false;
|
||||
opal_atomic_mb();
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
opal_mem_hooks_finalize(void)
|
||||
{
|
||||
opal_list_item_t *item;
|
||||
|
||||
/* don't try to run callbacks any more */
|
||||
release_run_callbacks = false;
|
||||
opal_atomic_mb();
|
||||
@ -86,17 +83,29 @@ opal_mem_hooks_finalize(void)
|
||||
opal_atomic_lock(&release_lock);
|
||||
|
||||
/* clean out the lists */
|
||||
while (NULL != (item = opal_list_remove_first(&release_cb_list))) {
|
||||
OBJ_RELEASE(item);
|
||||
}
|
||||
OBJ_DESTRUCT(&release_cb_list);
|
||||
OPAL_LIST_DESTRUCT(&release_cb_list);
|
||||
|
||||
opal_atomic_unlock(&release_lock);
|
||||
}
|
||||
|
||||
int opal_mem_hooks_init (void)
|
||||
{
|
||||
OBJ_CONSTRUCT(&release_cb_list, opal_list_t);
|
||||
|
||||
opal_atomic_lock_init(&release_lock, OPAL_ATOMIC_LOCK_UNLOCKED);
|
||||
|
||||
/* delay running callbacks until there is something in the
|
||||
registration */
|
||||
release_run_callbacks = false;
|
||||
opal_atomic_mb();
|
||||
|
||||
opal_finalize_register_cleanup (opal_mem_hooks_finalize);
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* called from memory manager / memory-manager specific hooks */
|
||||
void
|
||||
opal_mem_hooks_set_support(int support)
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
|
||||
* University Research and Technology
|
||||
@ -9,6 +10,8 @@
|
||||
* University of Stuttgart. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -60,24 +63,6 @@ BEGIN_C_DECLS
|
||||
OPAL_DECLSPEC int opal_mem_hooks_init(void);
|
||||
|
||||
|
||||
/**
|
||||
* Finalize the memory hooks subsystem
|
||||
*
|
||||
* Finalize the memory hooks subsystem. This is generally called
|
||||
* during opal_finalize() and no other memory hooks functions should
|
||||
* be called after this function is called. opal_mem_hooks_finalize()
|
||||
* will automatically deregister any callbacks that have not already
|
||||
* been deregistered. In a multi-threaded application, it is possible
|
||||
* that one thread will have a memory hook callback while the other
|
||||
* thread is in opal_mem_hooks_finalize(), however, no threads will
|
||||
* receive a callback once the calling thread has exited
|
||||
* opal_mem_hooks_finalize().
|
||||
*
|
||||
* @retval OPAL_SUCCESS Shutdown completed successfully
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_mem_hooks_finalize(void);
|
||||
|
||||
|
||||
/**
|
||||
* Query level of support provided by memory hooks
|
||||
*
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
|
||||
* University Research and Technology
|
||||
@ -12,6 +13,8 @@
|
||||
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright (c) 2010-2016 Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2014 Intel, Inc. All rights reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -26,6 +29,7 @@
|
||||
|
||||
#include "opal_config.h"
|
||||
#include "opal/types.h"
|
||||
#include "opal/class/opal_list.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
@ -43,6 +47,12 @@ OPAL_DECLSPEC extern int opal_cache_line_size;
|
||||
/** Do we want to be warned on fork or not? */
|
||||
OPAL_DECLSPEC extern bool opal_warn_on_fork;
|
||||
|
||||
/**
|
||||
* @brief list of cleanup functions that should be called as part of opal_finalize_util().
|
||||
* opal_finalize()
|
||||
*/
|
||||
extern opal_list_t opal_finalize_cleanup_fns;
|
||||
|
||||
/**
|
||||
* Initialize the OPAL layer, including the MCA system.
|
||||
*
|
||||
@ -94,42 +104,96 @@ OPAL_DECLSPEC int opal_init_psm(void);
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_finalize_util(void);
|
||||
|
||||
/**
|
||||
* Initialize a very thin OPAL layer solely for use
|
||||
* by unit tests. The purpose of this function is to
|
||||
* provide the absolute bare minimum support required
|
||||
* to open, select, and close a framework. This is
|
||||
* maintained separately from the other OPAL runtime
|
||||
* APIs to avoid conflicts when new frameworks are
|
||||
* added to the normal OPAL init sequence. It has no
|
||||
* other purpose and should not be used outside of
|
||||
* unit tests.
|
||||
*
|
||||
* @retval OPAL_SUCCESS Upon success.
|
||||
* @retval OPAL_ERROR Upon failure.
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_init_test(void);
|
||||
|
||||
/**
|
||||
* Finalize the very thin OPAL layer used solely
|
||||
* by unit tests. The purpose of this function is to
|
||||
* finalize the absolute bare minimum support opened
|
||||
* by its companion opal_init_test API. It has no
|
||||
* other purpose and should not be used outside of
|
||||
* unit tests.
|
||||
*
|
||||
* @retval OPAL_SUCCESS Upon success.
|
||||
* @retval OPAL_ERROR Upon failure.
|
||||
*/
|
||||
OPAL_DECLSPEC void opal_finalize_test(void);
|
||||
|
||||
OPAL_DECLSPEC void opal_warn_fork(void);
|
||||
|
||||
/**
|
||||
* Internal function. Do not call.
|
||||
* Internal function. Only valid when called from opal_init_util().
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_register_params(void);
|
||||
OPAL_DECLSPEC int opal_deregister_params(void);
|
||||
|
||||
/* finalize cleanup */
|
||||
/**
|
||||
* @brief Cleanup domain
|
||||
*
|
||||
* Cleanup domains are made up of a list of functions that need to be
|
||||
* called at finalize. A domain can be allocated/constructed then be
|
||||
* passed to opal_finalize_domain_init() to give it a name. The name
|
||||
* is optional and is used only for debugging purposes (this mean it
|
||||
* *is* optional *but* still recommended. You can then set the
|
||||
* finalize domain using opal_finalize_set_domain(). Once this is
|
||||
* called all cleanup functions registered with
|
||||
* opal_finalize_append_cleanup() will be registered to the set
|
||||
* domain. To call the finalize functions in a domain call
|
||||
* the opal_finalize_cleanup_domain() API.
|
||||
*/
|
||||
struct opal_finalize_domain_t {
|
||||
/** domains are opal lists */
|
||||
opal_list_t super;
|
||||
/** name of this finalize domain */
|
||||
char *domain_name;
|
||||
};
|
||||
typedef struct opal_finalize_domain_t opal_finalize_domain_t;
|
||||
|
||||
OBJ_CLASS_DECLARATION(opal_finalize_domain_t);
|
||||
|
||||
/**
|
||||
* @brief Initialize a finalize domain.
|
||||
*
|
||||
* @param[in] domain Finalize domain to initialize
|
||||
* @param[in] domain_name Name for this finalize domain (may be NULL)
|
||||
*
|
||||
* This function sets the name of a finalize domain. The domain must
|
||||
* have already been initialized by OBJ_CONSTRUCT() or OBJ_NEW().
|
||||
*/
|
||||
void opal_finalize_domain_init (opal_finalize_domain_t *domain, const char *domain_name);
|
||||
|
||||
/**
|
||||
* @brief Set the current finalize domain for opal_finalize_append_cleanup()
|
||||
*
|
||||
* @param[in] domain Finalize domain to use
|
||||
*
|
||||
* This function sets the current finalize domain. This API is not thread safe
|
||||
* and is must be protected from multi-threaded invocation.
|
||||
*/
|
||||
void opal_finalize_set_domain (opal_finalize_domain_t *domain);
|
||||
|
||||
/**
|
||||
* @brief Finalize a domain
|
||||
*
|
||||
* @param[in] domain Finalize domain to cleanup
|
||||
*
|
||||
* This function calls all the finalization functions registered with the
|
||||
* specified domain in reverse-registration order. This function releases
|
||||
* any memory allocated by the relevant calls to opal_finalize_append_cleanup()
|
||||
* and effectively empties the cleanup domain.
|
||||
*/
|
||||
void opal_finalize_cleanup_domain (opal_finalize_domain_t *domain);
|
||||
|
||||
/**
|
||||
* @brief Cleanup domain function
|
||||
*
|
||||
* The argument is optional. It is valid to use the opal_finalize_register_cleanup()
|
||||
* macro to register a function that is of type void (*) (void).
|
||||
*/
|
||||
typedef void (*opal_cleanup_fn_t) (void *);
|
||||
|
||||
/**
|
||||
* @brief Append a cleanup function to the current domain
|
||||
*
|
||||
* @param[in] cleanup_fn Cleanup function to register
|
||||
* @param[in] fn_name Name of the cleanup function (for debugging)
|
||||
* @param[in] user_data User data to pass to the cleanup function
|
||||
*/
|
||||
void opal_finalize_append_cleanup (opal_cleanup_fn_t cleanup_fn, const char *fn_name, void *user_data);
|
||||
|
||||
#define opal_finalize_register_cleanup_3(x, y, z) opal_finalize_append_cleanup((opal_cleanup_fn_t) x, y, z)
|
||||
#define opal_finalize_register_cleanup_arg(x, y) opal_finalize_append_cleanup((opal_cleanup_fn_t) x, # x "(" #y ")", y)
|
||||
#define opal_finalize_register_cleanup(x) opal_finalize_register_cleanup_3((opal_cleanup_fn_t) (x), # x, NULL)
|
||||
|
||||
/* opal cleanup domains */
|
||||
extern opal_finalize_domain_t opal_init_util_domain;
|
||||
extern opal_finalize_domain_t opal_init_domain;
|
||||
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
* Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana
|
||||
* University Research and Technology
|
||||
@ -17,6 +18,8 @@
|
||||
* and Technology (RIST). All rights reserved.
|
||||
* Copyright (c) 2017 Amazon.com, Inc. or its affiliates.
|
||||
* All Rights reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -29,85 +32,124 @@
|
||||
#include "opal_config.h"
|
||||
|
||||
#include "opal/class/opal_object.h"
|
||||
#include "opal/dss/dss.h"
|
||||
#include "opal/util/output.h"
|
||||
#include "opal/util/malloc.h"
|
||||
#include "opal/util/net.h"
|
||||
#include "opal/util/proc.h"
|
||||
#include "opal/util/keyval_parse.h"
|
||||
#include "opal/util/show_help.h"
|
||||
#include "opal/memoryhooks/memory.h"
|
||||
#include "opal/mca/base/base.h"
|
||||
#include "opal/runtime/opal.h"
|
||||
#include "opal/constants.h"
|
||||
#include "opal/datatype/opal_datatype.h"
|
||||
#include "opal/mca/if/base/base.h"
|
||||
#include "opal/mca/installdirs/base/base.h"
|
||||
#include "opal/mca/memchecker/base/base.h"
|
||||
#include "opal/mca/memcpy/base/base.h"
|
||||
#include "opal/mca/backtrace/base/base.h"
|
||||
#include "opal/mca/reachable/base/base.h"
|
||||
#include "opal/mca/timer/base/base.h"
|
||||
#include "opal/mca/hwloc/base/base.h"
|
||||
#include "opal/mca/event/base/base.h"
|
||||
#include "opal/runtime/opal_progress.h"
|
||||
#include "opal/mca/shmem/base/base.h"
|
||||
#if OPAL_ENABLE_FT_CR == 1
|
||||
#include "opal/mca/compress/base/base.h"
|
||||
#endif
|
||||
|
||||
#include "opal/runtime/opal_cr.h"
|
||||
#include "opal/mca/crs/base/base.h"
|
||||
#include "opal/threads/tsd.h"
|
||||
#include "opal/runtime/opal_cr.h"
|
||||
#include "opal/runtime/opal_progress.h"
|
||||
|
||||
extern int opal_initialized;
|
||||
extern int opal_util_initialized;
|
||||
extern bool opal_init_called;
|
||||
|
||||
int
|
||||
opal_finalize_util(void)
|
||||
static opal_mutex_t opal_finalize_cleanup_fns_lock = OPAL_MUTEX_STATIC_INIT;
|
||||
opal_list_t opal_finalize_cleanup_fns = {{0}};
|
||||
|
||||
struct opal_cleanup_fn_item_t {
|
||||
opal_list_item_t super;
|
||||
opal_cleanup_fn_t cleanup_fn;
|
||||
void *user_data;
|
||||
#if OPAL_ENABLE_DEBUG
|
||||
char *cleanup_fn_name;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct opal_cleanup_fn_item_t opal_cleanup_fn_item_t;
|
||||
OBJ_CLASS_DECLARATION(opal_cleanup_fn_item_t);
|
||||
|
||||
static void opal_cleanup_fn_item_construct (opal_cleanup_fn_item_t *item)
|
||||
{
|
||||
if( --opal_util_initialized != 0 ) {
|
||||
if( opal_util_initialized < 0 ) {
|
||||
#if OPAL_ENABLE_DEBUG
|
||||
item->cleanup_fn_name = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void opal_cleanup_fn_item_destruct (opal_cleanup_fn_item_t *item)
|
||||
{
|
||||
#if OPAL_ENABLE_DEBUG
|
||||
free (item->cleanup_fn_name);
|
||||
item->cleanup_fn_name = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
OBJ_CLASS_INSTANCE(opal_cleanup_fn_item_t, opal_list_item_t,
|
||||
opal_cleanup_fn_item_construct, opal_cleanup_fn_item_destruct);
|
||||
|
||||
static void opal_finalize_domain_construct (opal_finalize_domain_t *domain)
|
||||
{
|
||||
domain->domain_name = NULL;
|
||||
}
|
||||
|
||||
static void opal_finalize_domain_destruct (opal_finalize_domain_t *domain)
|
||||
{
|
||||
free (domain->domain_name);
|
||||
domain->domain_name = NULL;
|
||||
}
|
||||
|
||||
OBJ_CLASS_INSTANCE(opal_finalize_domain_t, opal_list_t, opal_finalize_domain_construct,
|
||||
opal_finalize_domain_destruct);
|
||||
|
||||
static opal_finalize_domain_t *current_finalize_domain;
|
||||
opal_finalize_domain_t opal_init_util_domain;
|
||||
opal_finalize_domain_t opal_init_domain;
|
||||
|
||||
void opal_finalize_append_cleanup (opal_cleanup_fn_t cleanup_fn, const char *fn_name, void *user_data)
|
||||
{
|
||||
opal_cleanup_fn_item_t *cleanup_item = OBJ_NEW(opal_cleanup_fn_item_t);
|
||||
assert (NULL != cleanup_item);
|
||||
cleanup_item->cleanup_fn = cleanup_fn;
|
||||
cleanup_item->user_data = user_data;
|
||||
#if OPAL_ENABLE_DEBUG
|
||||
cleanup_item->cleanup_fn_name = strdup (fn_name);
|
||||
assert (NULL != cleanup_item->cleanup_fn_name);
|
||||
#else
|
||||
(void) fn_name;
|
||||
#endif
|
||||
|
||||
opal_mutex_lock (&opal_finalize_cleanup_fns_lock);
|
||||
opal_list_append (¤t_finalize_domain->super, &cleanup_item->super);
|
||||
opal_mutex_unlock (&opal_finalize_cleanup_fns_lock);
|
||||
}
|
||||
|
||||
void opal_finalize_domain_init (opal_finalize_domain_t *domain, const char *domain_name)
|
||||
{
|
||||
free (domain->domain_name);
|
||||
domain->domain_name = domain_name ? strdup (domain_name) : NULL;
|
||||
}
|
||||
|
||||
void opal_finalize_set_domain (opal_finalize_domain_t *domain)
|
||||
{
|
||||
current_finalize_domain = domain;
|
||||
}
|
||||
|
||||
void opal_finalize_cleanup_domain (opal_finalize_domain_t *domain)
|
||||
{
|
||||
opal_cleanup_fn_item_t *cleanup_item, *next;
|
||||
/* call any registered cleanup functions before tearing down OPAL */
|
||||
OPAL_LIST_FOREACH_SAFE_REV(cleanup_item, next, &domain->super, opal_cleanup_fn_item_t) {
|
||||
cleanup_item->cleanup_fn (cleanup_item->user_data);
|
||||
opal_list_remove_item (&domain->super, &cleanup_item->super);
|
||||
OBJ_RELEASE(cleanup_item);
|
||||
}
|
||||
}
|
||||
|
||||
int opal_finalize_util (void)
|
||||
{
|
||||
if (--opal_util_initialized != 0) {
|
||||
if (opal_util_initialized < 0) {
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
/* close interfaces code. */
|
||||
(void) mca_base_framework_close(&opal_if_base_framework);
|
||||
|
||||
(void) mca_base_framework_close(&opal_event_base_framework);
|
||||
|
||||
/* Clear out all the registered MCA params */
|
||||
opal_deregister_params();
|
||||
mca_base_var_finalize();
|
||||
|
||||
opal_net_finalize();
|
||||
|
||||
/* keyval lex-based parser */
|
||||
opal_util_keyval_parse_finalize();
|
||||
|
||||
(void) mca_base_framework_close(&opal_installdirs_base_framework);
|
||||
|
||||
mca_base_close();
|
||||
|
||||
/* finalize the memory allocator */
|
||||
opal_malloc_finalize();
|
||||
|
||||
/* finalize the show_help system */
|
||||
opal_show_help_finalize();
|
||||
|
||||
/* finalize the output system. This has to come *after* the
|
||||
malloc code, as the malloc code needs to call into this, but
|
||||
the malloc code turning off doesn't affect opal_output that
|
||||
much */
|
||||
opal_output_finalize();
|
||||
|
||||
/* close the dss */
|
||||
opal_dss_close();
|
||||
|
||||
opal_datatype_finalize();
|
||||
opal_finalize_cleanup_domain (&opal_init_util_domain);
|
||||
OBJ_DESTRUCT(&opal_init_util_domain);
|
||||
|
||||
/* finalize the class/object system */
|
||||
opal_class_finalize();
|
||||
@ -119,49 +161,17 @@ opal_finalize_util(void)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
opal_finalize(void)
|
||||
int opal_finalize(void)
|
||||
{
|
||||
if( --opal_initialized != 0 ) {
|
||||
if( opal_initialized < 0 ) {
|
||||
if (--opal_initialized != 0) {
|
||||
if (opal_initialized < 0) {
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
opal_progress_finalize();
|
||||
|
||||
/* close the checkpoint and restart service */
|
||||
opal_cr_finalize();
|
||||
|
||||
#if OPAL_ENABLE_FT_CR == 1
|
||||
(void) mca_base_framework_close(&opal_compress_base_framework);
|
||||
#endif
|
||||
|
||||
(void) mca_base_framework_close(&opal_reachable_base_framework);
|
||||
|
||||
(void) mca_base_framework_close(&opal_event_base_framework);
|
||||
|
||||
/* close high resolution timers */
|
||||
(void) mca_base_framework_close(&opal_timer_base_framework);
|
||||
|
||||
(void) mca_base_framework_close(&opal_backtrace_base_framework);
|
||||
(void) mca_base_framework_close(&opal_memchecker_base_framework);
|
||||
|
||||
/* close the memcpy framework */
|
||||
(void) mca_base_framework_close(&opal_memcpy_base_framework);
|
||||
|
||||
/* finalize the memory manager / tracker */
|
||||
opal_mem_hooks_finalize();
|
||||
|
||||
/* close the hwloc framework */
|
||||
(void) mca_base_framework_close(&opal_hwloc_base_framework);
|
||||
|
||||
/* close the shmem framework */
|
||||
(void) mca_base_framework_close(&opal_shmem_base_framework);
|
||||
|
||||
/* cleanup the main thread specific stuff */
|
||||
opal_tsd_keys_destruct();
|
||||
opal_finalize_cleanup_domain (&opal_init_domain);
|
||||
OBJ_DESTRUCT(&opal_init_domain);
|
||||
|
||||
/* finalize util code */
|
||||
opal_finalize_util();
|
||||
@ -169,29 +179,22 @@ opal_finalize(void)
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
static bool fork_warning_issued = false;
|
||||
static bool atfork_called = false;
|
||||
|
||||
void opal_finalize_test(void)
|
||||
static void warn_fork_cb(void)
|
||||
{
|
||||
/* Clear out all the registered MCA params */
|
||||
mca_base_var_finalize();
|
||||
|
||||
(void) mca_base_framework_close(&opal_installdirs_base_framework);
|
||||
|
||||
/* finalize the mca */
|
||||
mca_base_close();
|
||||
|
||||
/* finalize the show_help system */
|
||||
opal_show_help_finalize();
|
||||
|
||||
/* finalize the output system. This has to come *after* the
|
||||
malloc code, as the malloc code needs to call into this, but
|
||||
the malloc code turning off doesn't affect opal_output that
|
||||
much */
|
||||
opal_output_finalize();
|
||||
|
||||
/* close the dss */
|
||||
opal_dss_close();
|
||||
|
||||
/* finalize the class/object system */
|
||||
opal_class_finalize();
|
||||
if (opal_initialized && !fork_warning_issued) {
|
||||
opal_show_help("help-opal-runtime.txt", "opal_init:warn-fork", true,
|
||||
OPAL_NAME_PRINT(OPAL_PROC_MY_NAME), getpid());
|
||||
fork_warning_issued = true;
|
||||
}
|
||||
}
|
||||
|
||||
void opal_warn_fork(void)
|
||||
{
|
||||
if (opal_warn_on_fork && !atfork_called) {
|
||||
pthread_atfork(warn_fork_cb, NULL, NULL);
|
||||
atfork_called = true;
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,8 @@
|
||||
* All Rights reserved.
|
||||
* Copyright (c) 2018 Mellanox Technologies, Inc.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -63,6 +65,7 @@
|
||||
#include "opal/mca/compress/base/base.h"
|
||||
#endif
|
||||
#include "opal/threads/threads.h"
|
||||
#include "opal/threads/tsd.h"
|
||||
|
||||
#include "opal/runtime/opal_cr.h"
|
||||
#include "opal/mca/crs/base/base.h"
|
||||
@ -347,6 +350,19 @@ int opal_init_psm(void)
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
static int opal_init_error (const char *error, int ret)
|
||||
{
|
||||
if (OPAL_ERR_SILENT != ret) {
|
||||
opal_show_help( "help-opal-runtime.txt",
|
||||
"opal_init:startup:internal-failure", true,
|
||||
error, ret );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static mca_base_framework_t *opal_init_util_frameworks[] = {
|
||||
&opal_installdirs_base_framework, &opal_if_base_framework, NULL,
|
||||
};
|
||||
|
||||
int
|
||||
opal_init_util(int* pargc, char*** pargv)
|
||||
@ -363,10 +379,18 @@ opal_init_util(int* pargc, char*** pargv)
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
OBJ_CONSTRUCT(&opal_init_util_domain, opal_finalize_domain_t);
|
||||
(void) opal_finalize_domain_init (&opal_init_util_domain, "opal_init_util");
|
||||
opal_finalize_set_domain (&opal_init_util_domain);
|
||||
|
||||
opal_thread_set_main();
|
||||
|
||||
opal_init_called = true;
|
||||
|
||||
/* register for */
|
||||
opal_finalize_register_cleanup_arg (mca_base_framework_close_list, opal_init_util_frameworks);
|
||||
|
||||
/* set the nodename right away so anyone who needs it has it. Note
|
||||
* that we don't bother with fqdn and prefix issues here - we let
|
||||
* the RTE later replace this with a modified name if the user
|
||||
@ -398,14 +422,12 @@ opal_init_util(int* pargc, char*** pargv)
|
||||
if (OPAL_SUCCESS !=
|
||||
(ret = opal_error_register("OPAL",
|
||||
OPAL_ERR_BASE, OPAL_ERR_MAX, opal_err2str))) {
|
||||
error = "opal_error_register";
|
||||
goto return_error;
|
||||
return opal_init_error ("opal_error_register", ret);
|
||||
}
|
||||
|
||||
/* keyval lex-based parser */
|
||||
if (OPAL_SUCCESS != (ret = opal_util_keyval_parse_init())) {
|
||||
error = "opal_util_keyval_parse_init";
|
||||
goto return_error;
|
||||
return opal_init_error ("opal_util_keyval_parse_init", ret);
|
||||
}
|
||||
|
||||
// Disable PSM signal hijacking (see comment in function for more
|
||||
@ -416,15 +438,13 @@ opal_init_util(int* pargc, char*** pargv)
|
||||
|
||||
/* Setup the parameter system */
|
||||
if (OPAL_SUCCESS != (ret = mca_base_var_init())) {
|
||||
error = "mca_base_var_init";
|
||||
goto return_error;
|
||||
return opal_init_error ("mca_base_var_init", ret);
|
||||
}
|
||||
OPAL_TIMING_ENV_NEXT(otmng, "opal_var_init");
|
||||
|
||||
/* read any param files that were provided */
|
||||
if (OPAL_SUCCESS != (ret = mca_base_var_cache_files(false))) {
|
||||
error = "failed to cache files";
|
||||
goto return_error;
|
||||
return opal_init_error ("failed to cache files", ret);
|
||||
}
|
||||
|
||||
OPAL_TIMING_ENV_NEXT(otmng, "opal_var_cache");
|
||||
@ -432,21 +452,18 @@ opal_init_util(int* pargc, char*** pargv)
|
||||
|
||||
/* register params for opal */
|
||||
if (OPAL_SUCCESS != (ret = opal_register_params())) {
|
||||
error = "opal_register_params";
|
||||
goto return_error;
|
||||
return opal_init_error ("opal_register_params", ret);
|
||||
}
|
||||
|
||||
if (OPAL_SUCCESS != (ret = opal_net_init())) {
|
||||
error = "opal_net_init";
|
||||
goto return_error;
|
||||
return opal_init_error ("opal_net_init", ret);
|
||||
}
|
||||
|
||||
OPAL_TIMING_ENV_NEXT(otmng, "opal_net_init");
|
||||
|
||||
/* pretty-print stack handlers */
|
||||
if (OPAL_SUCCESS != (ret = opal_util_register_stackhandlers())) {
|
||||
error = "opal_util_register_stackhandlers";
|
||||
goto return_error;
|
||||
return opal_init_error ("opal_util_register_stackhandlers", ret);
|
||||
}
|
||||
|
||||
/* set system resource limits - internally protected against
|
||||
@ -461,32 +478,28 @@ opal_init_util(int* pargc, char*** pargv)
|
||||
|
||||
/* initialize the arch string */
|
||||
if (OPAL_SUCCESS != (ret = opal_arch_init ())) {
|
||||
error = "opal_arch_init";
|
||||
goto return_error;
|
||||
return opal_init_error ("opal_arch_init", ret);
|
||||
}
|
||||
|
||||
OPAL_TIMING_ENV_NEXT(otmng, "opal_arch_init");
|
||||
|
||||
/* initialize the datatype engine */
|
||||
if (OPAL_SUCCESS != (ret = opal_datatype_init ())) {
|
||||
error = "opal_datatype_init";
|
||||
goto return_error;
|
||||
return opal_init_error ("opal_datatype_init", ret);
|
||||
}
|
||||
|
||||
OPAL_TIMING_ENV_NEXT(otmng, "opal_datatype_init");
|
||||
|
||||
/* Initialize the data storage service. */
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_open())) {
|
||||
error = "opal_dss_open";
|
||||
goto return_error;
|
||||
return opal_init_error ("opal_dss_open", ret);
|
||||
}
|
||||
|
||||
OPAL_TIMING_ENV_NEXT(otmng, "opal_dss_open");
|
||||
|
||||
/* initialize the mca */
|
||||
if (OPAL_SUCCESS != (ret = mca_base_open())) {
|
||||
error = "mca_base_open";
|
||||
goto return_error;
|
||||
return opal_init_error ("mca_base_open", ret);
|
||||
}
|
||||
|
||||
OPAL_TIMING_ENV_NEXT(otmng, "mca_base_open");
|
||||
@ -501,22 +514,23 @@ opal_init_util(int* pargc, char*** pargv)
|
||||
OPAL_TIMING_ENV_NEXT(otmng, "opal_if_init");
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
|
||||
return_error:
|
||||
if (OPAL_ERR_SILENT != ret) {
|
||||
opal_show_help( "help-opal-runtime.txt",
|
||||
"opal_init:startup:internal-failure", true,
|
||||
error, ret );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* the memcpy component should be one of the first who get
|
||||
* loaded in order to make sure we have all the available
|
||||
* versions of memcpy correctly configured.
|
||||
*/
|
||||
static mca_base_framework_t *opal_init_frameworks[] = {
|
||||
&opal_hwloc_base_framework, &opal_memcpy_base_framework, &opal_memchecker_base_framework,
|
||||
&opal_backtrace_base_framework, &opal_timer_base_framework, &opal_event_base_framework,
|
||||
&opal_shmem_base_framework, &opal_reachable_base_framework, NULL,
|
||||
};
|
||||
|
||||
int
|
||||
opal_init(int* pargc, char*** pargv)
|
||||
{
|
||||
int ret;
|
||||
char *error = NULL;
|
||||
|
||||
if( ++opal_initialized != 1 ) {
|
||||
if( opal_initialized < 1 ) {
|
||||
@ -530,232 +544,46 @@ opal_init(int* pargc, char*** pargv)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* open hwloc - since this is a static framework, no
|
||||
* select is required
|
||||
*/
|
||||
if (OPAL_SUCCESS != (ret = mca_base_framework_open(&opal_hwloc_base_framework, 0))) {
|
||||
error = "opal_hwloc_base_open";
|
||||
goto return_error;
|
||||
}
|
||||
OBJ_CONSTRUCT(&opal_init_domain, opal_finalize_domain_t);
|
||||
(void) opal_finalize_domain_init (&opal_init_domain, "opal_init");
|
||||
opal_finalize_set_domain (&opal_init_domain);
|
||||
|
||||
/* the memcpy component should be one of the first who get
|
||||
* loaded in order to make sure we have all the available
|
||||
* versions of memcpy correctly configured.
|
||||
*/
|
||||
if (OPAL_SUCCESS != (ret = mca_base_framework_open(&opal_memcpy_base_framework, 0))) {
|
||||
error = "opal_memcpy_base_open";
|
||||
goto return_error;
|
||||
opal_finalize_register_cleanup_arg (mca_base_framework_close_list, opal_init_frameworks);
|
||||
opal_finalize_register_cleanup (opal_tsd_keys_destruct);
|
||||
|
||||
ret = mca_base_framework_open_list (opal_init_frameworks, 0);
|
||||
if (OPAL_UNLIKELY(OPAL_SUCCESS != ret)) {
|
||||
return opal_init_error ("opal_init framework open", ret);
|
||||
}
|
||||
|
||||
/* initialize the memory manager / tracker */
|
||||
if (OPAL_SUCCESS != (ret = opal_mem_hooks_init())) {
|
||||
error = "opal_mem_hooks_init";
|
||||
goto return_error;
|
||||
}
|
||||
|
||||
/* initialize the memory checker, to allow early support for annotation */
|
||||
if (OPAL_SUCCESS != (ret = mca_base_framework_open(&opal_memchecker_base_framework, 0))) {
|
||||
error = "opal_memchecker_base_open";
|
||||
goto return_error;
|
||||
return opal_init_error ("opal_mem_hooks_init", ret);
|
||||
}
|
||||
|
||||
/* select the memory checker */
|
||||
if (OPAL_SUCCESS != (ret = opal_memchecker_base_select())) {
|
||||
error = "opal_memchecker_base_select";
|
||||
goto return_error;
|
||||
}
|
||||
|
||||
if (OPAL_SUCCESS != (ret = mca_base_framework_open(&opal_backtrace_base_framework, 0))) {
|
||||
error = "opal_backtrace_base_open";
|
||||
goto return_error;
|
||||
}
|
||||
|
||||
if (OPAL_SUCCESS != (ret = mca_base_framework_open(&opal_timer_base_framework, 0))) {
|
||||
error = "opal_timer_base_open";
|
||||
goto return_error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Need to start the event and progress engines if none 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 = mca_base_framework_open(&opal_event_base_framework, 0))) {
|
||||
error = "opal_event_base_open";
|
||||
goto return_error;
|
||||
return opal_init_error ("opal_memchecker_base_select", ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the general progress engine
|
||||
*/
|
||||
if (OPAL_SUCCESS != (ret = opal_progress_init())) {
|
||||
error = "opal_progress_init";
|
||||
goto return_error;
|
||||
return opal_init_error ("opal_progress_init", ret);
|
||||
}
|
||||
/* we want to tick the event library whenever possible */
|
||||
opal_progress_event_users_increment();
|
||||
|
||||
/* setup the shmem framework */
|
||||
if (OPAL_SUCCESS != (ret = mca_base_framework_open(&opal_shmem_base_framework, 0))) {
|
||||
error = "opal_shmem_base_open";
|
||||
goto return_error;
|
||||
}
|
||||
|
||||
if (OPAL_SUCCESS != (ret = opal_shmem_base_select())) {
|
||||
error = "opal_shmem_base_select";
|
||||
goto return_error;
|
||||
return opal_init_error ("opal_shmem_base_select", ret);
|
||||
}
|
||||
|
||||
/* Load reachable framework */
|
||||
if (OPAL_SUCCESS != (ret = mca_base_framework_open(&opal_reachable_base_framework, 0))){
|
||||
error = "opal_reachable_base_framework";
|
||||
goto return_error;
|
||||
}
|
||||
/* Intitialize reachable framework */
|
||||
if (OPAL_SUCCESS != (ret = opal_reachable_base_select())) {
|
||||
error = "opal_reachable_base_select";
|
||||
goto return_error;
|
||||
}
|
||||
|
||||
#if OPAL_ENABLE_FT_CR == 1
|
||||
/*
|
||||
* Initialize the compression framework
|
||||
* Note: Currently only used in C/R so it has been marked to only
|
||||
* initialize when C/R is enabled. If other places in the code
|
||||
* wish to use this framework, it is safe to remove the protection.
|
||||
*/
|
||||
if( OPAL_SUCCESS != (ret = mca_base_framework_open(&opal_compress_base_framework, 0)) ) {
|
||||
error = "opal_compress_base_open";
|
||||
goto return_error;
|
||||
}
|
||||
if( OPAL_SUCCESS != (ret = opal_compress_base_select()) ) {
|
||||
error = "opal_compress_base_select";
|
||||
goto return_error;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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";
|
||||
goto return_error;
|
||||
return opal_init_error ("opal_reachable_base_select", ret);
|
||||
}
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
|
||||
return_error:
|
||||
opal_show_help( "help-opal-runtime.txt",
|
||||
"opal_init:startup:internal-failure", true,
|
||||
error, ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
int opal_init_test(void)
|
||||
{
|
||||
int ret;
|
||||
char *error;
|
||||
|
||||
/* initialize the memory allocator */
|
||||
opal_malloc_init();
|
||||
|
||||
/* initialize the output system */
|
||||
opal_output_init();
|
||||
|
||||
/* initialize install dirs code */
|
||||
if (OPAL_SUCCESS != (ret = mca_base_framework_open(&opal_installdirs_base_framework, 0))) {
|
||||
fprintf(stderr, "opal_installdirs_base_open() failed -- process will likely abort (%s:%d, returned %d instead of OPAL_SUCCESS)\n",
|
||||
__FILE__, __LINE__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* initialize the help system */
|
||||
opal_show_help_init();
|
||||
|
||||
/* register handler for errnum -> string converstion */
|
||||
if (OPAL_SUCCESS !=
|
||||
(ret = opal_error_register("OPAL",
|
||||
OPAL_ERR_BASE, OPAL_ERR_MAX, opal_err2str))) {
|
||||
error = "opal_error_register";
|
||||
goto return_error;
|
||||
}
|
||||
|
||||
/* keyval lex-based parser */
|
||||
if (OPAL_SUCCESS != (ret = opal_util_keyval_parse_init())) {
|
||||
error = "opal_util_keyval_parse_init";
|
||||
goto return_error;
|
||||
}
|
||||
|
||||
if (OPAL_SUCCESS != (ret = opal_net_init())) {
|
||||
error = "opal_net_init";
|
||||
goto return_error;
|
||||
}
|
||||
|
||||
/* Setup the parameter system */
|
||||
if (OPAL_SUCCESS != (ret = mca_base_var_init())) {
|
||||
error = "mca_base_var_init";
|
||||
goto return_error;
|
||||
}
|
||||
|
||||
/* register params for opal */
|
||||
if (OPAL_SUCCESS != (ret = opal_register_params())) {
|
||||
error = "opal_register_params";
|
||||
goto return_error;
|
||||
}
|
||||
|
||||
/* pretty-print stack handlers */
|
||||
if (OPAL_SUCCESS != (ret = opal_util_register_stackhandlers())) {
|
||||
error = "opal_util_register_stackhandlers";
|
||||
goto return_error;
|
||||
}
|
||||
|
||||
/* Initialize the data storage service. */
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_open())) {
|
||||
error = "opal_dss_open";
|
||||
goto return_error;
|
||||
}
|
||||
|
||||
/* initialize the mca */
|
||||
if (OPAL_SUCCESS != (ret = mca_base_open())) {
|
||||
error = "mca_base_open";
|
||||
goto return_error;
|
||||
}
|
||||
|
||||
if (OPAL_SUCCESS != (ret = mca_base_framework_open(&opal_event_base_framework, 0))) {
|
||||
error = "opal_event_base_open";
|
||||
goto return_error;
|
||||
}
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
|
||||
return_error:
|
||||
opal_show_help( "help-opal-runtime.txt",
|
||||
"opal_init:startup:internal-failure", true,
|
||||
error, ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool fork_warning_issued = false;
|
||||
static bool atfork_called = false;
|
||||
|
||||
static void warn_fork_cb(void)
|
||||
{
|
||||
if (opal_initialized && !fork_warning_issued) {
|
||||
opal_show_help("help-opal-runtime.txt", "opal_init:warn-fork", true,
|
||||
OPAL_NAME_PRINT(OPAL_PROC_MY_NAME), getpid());
|
||||
fork_warning_issued = true;
|
||||
}
|
||||
}
|
||||
|
||||
void opal_warn_fork(void)
|
||||
{
|
||||
if (opal_warn_on_fork && !atfork_called) {
|
||||
pthread_atfork(warn_fork_cb, NULL, NULL);
|
||||
atfork_called = true;
|
||||
}
|
||||
}
|
||||
|
@ -80,6 +80,13 @@ int opal_max_thread_in_progress = 1;
|
||||
|
||||
static bool opal_register_done = false;
|
||||
|
||||
static void opal_deregister_params (void)
|
||||
{
|
||||
/* The MCA variable system will be torn down shortly so reset the registered
|
||||
* flag. */
|
||||
opal_register_done = false;
|
||||
}
|
||||
|
||||
int opal_register_params(void)
|
||||
{
|
||||
int ret;
|
||||
@ -380,12 +387,7 @@ int opal_register_params(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
int opal_deregister_params(void)
|
||||
{
|
||||
opal_register_done = false;
|
||||
opal_finalize_register_cleanup (opal_deregister_params);
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
@ -98,6 +98,25 @@ static int fake_cb(void) { return 0; }
|
||||
static int _opal_progress_unregister (opal_progress_callback_t cb, volatile opal_progress_callback_t *callback_array,
|
||||
size_t *callback_array_len);
|
||||
|
||||
static void opal_progress_finalize (void)
|
||||
{
|
||||
/* free memory associated with the callbacks */
|
||||
opal_atomic_lock(&progress_lock);
|
||||
|
||||
callbacks_len = 0;
|
||||
callbacks_size = 0;
|
||||
free ((void *) callbacks);
|
||||
callbacks = NULL;
|
||||
|
||||
callbacks_lp_len = 0;
|
||||
callbacks_lp_size = 0;
|
||||
free ((void *) callbacks_lp);
|
||||
callbacks_lp = NULL;
|
||||
|
||||
opal_atomic_unlock(&progress_lock);
|
||||
}
|
||||
|
||||
|
||||
/* init the progress engine - called from orte_init */
|
||||
int
|
||||
opal_progress_init(void)
|
||||
@ -144,27 +163,7 @@ opal_progress_init(void)
|
||||
OPAL_OUTPUT((debug_output, "progress: initialized poll rate to: %ld",
|
||||
(long) event_progress_delta));
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
opal_progress_finalize(void)
|
||||
{
|
||||
/* free memory associated with the callbacks */
|
||||
opal_atomic_lock(&progress_lock);
|
||||
|
||||
callbacks_len = 0;
|
||||
callbacks_size = 0;
|
||||
free ((void *) callbacks);
|
||||
callbacks = NULL;
|
||||
|
||||
callbacks_lp_len = 0;
|
||||
callbacks_lp_size = 0;
|
||||
free ((void *) callbacks_lp);
|
||||
callbacks_lp = NULL;
|
||||
|
||||
opal_atomic_unlock(&progress_lock);
|
||||
opal_finalize_register_cleanup (opal_progress_finalize);
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
@ -11,6 +11,8 @@
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2006-2014 Los Alamos National Security, LLC. All rights
|
||||
* reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
*
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
@ -32,6 +34,7 @@ BEGIN_C_DECLS
|
||||
|
||||
#include "opal_config.h"
|
||||
#include "opal/threads/mutex.h"
|
||||
#include "opal/runtime/opal.h"
|
||||
|
||||
/**
|
||||
* Initialize the progress engine
|
||||
@ -43,17 +46,6 @@ BEGIN_C_DECLS
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_progress_init(void);
|
||||
|
||||
|
||||
/**
|
||||
* Shut down the progress engine
|
||||
*
|
||||
* Shut down the progress engine. This includes deregistering all
|
||||
* registered callbacks and freeing all resources. After finalize
|
||||
* returns, no calls into the progress interface are allowed.
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_progress_finalize(void);
|
||||
|
||||
|
||||
/**
|
||||
* Progress all pending events
|
||||
*
|
||||
|
@ -12,6 +12,8 @@
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2015-2016 Los Alamos National Security, LLC. All rights
|
||||
* reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -22,6 +24,7 @@
|
||||
#include "opal_config.h"
|
||||
|
||||
#include "opal/constants.h"
|
||||
#include "opal/runtime/opal.h"
|
||||
#include "opal/util/keyval_parse.h"
|
||||
#include "opal/util/keyval/keyval_lex.h"
|
||||
#include "opal/util/output.h"
|
||||
@ -45,22 +48,20 @@ static void parse_error(int num);
|
||||
static char *env_str = NULL;
|
||||
static int envsize = 1024;
|
||||
|
||||
int opal_util_keyval_parse_init(void)
|
||||
static void opal_util_keyval_parse_finalize (void)
|
||||
{
|
||||
OBJ_CONSTRUCT(&keyval_mutex, opal_mutex_t);
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
opal_util_keyval_parse_finalize(void)
|
||||
{
|
||||
if (NULL != key_buffer) free(key_buffer);
|
||||
free(key_buffer);
|
||||
key_buffer = NULL;
|
||||
key_buffer_len = 0;
|
||||
|
||||
OBJ_DESTRUCT(&keyval_mutex);
|
||||
}
|
||||
|
||||
int opal_util_keyval_parse_init(void)
|
||||
{
|
||||
OBJ_CONSTRUCT(&keyval_mutex, opal_mutex_t);
|
||||
|
||||
opal_finalize_register_cleanup (opal_util_keyval_parse_finalize);
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
||||
* University Research and Technology
|
||||
@ -9,6 +10,8 @@
|
||||
* University of Stuttgart. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -50,8 +53,6 @@ OPAL_DECLSPEC int opal_util_keyval_parse(const char *filename,
|
||||
|
||||
OPAL_DECLSPEC int opal_util_keyval_parse_init(void);
|
||||
|
||||
OPAL_DECLSPEC int opal_util_keyval_parse_finalize(void);
|
||||
|
||||
OPAL_DECLSPEC int opal_util_keyval_save_internal_envars(opal_keyval_parse_fn_t callback);
|
||||
|
||||
END_C_DECLS
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
||||
* University Research and Technology
|
||||
@ -9,6 +10,8 @@
|
||||
* University of Stuttgart. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -22,6 +25,7 @@
|
||||
|
||||
#include "opal/util/malloc.h"
|
||||
#include "opal/util/output.h"
|
||||
#include "opal/runtime/opal.h"
|
||||
|
||||
|
||||
/*
|
||||
@ -54,26 +58,11 @@ int opal_malloc_output = -1;
|
||||
static opal_output_stream_t malloc_stream;
|
||||
|
||||
|
||||
/*
|
||||
* Initialize the malloc debug interface
|
||||
*/
|
||||
void opal_malloc_init(void)
|
||||
{
|
||||
#if OPAL_ENABLE_DEBUG
|
||||
OBJ_CONSTRUCT(&malloc_stream, opal_output_stream_t);
|
||||
malloc_stream.lds_is_debugging = true;
|
||||
malloc_stream.lds_verbose_level = 5;
|
||||
malloc_stream.lds_prefix = "malloc debug: ";
|
||||
malloc_stream.lds_want_stderr = true;
|
||||
opal_malloc_output = opal_output_open(&malloc_stream);
|
||||
#endif /* OPAL_ENABLE_DEBUG */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Finalize the malloc debug interface
|
||||
*/
|
||||
void opal_malloc_finalize(void)
|
||||
static void opal_malloc_finalize(void)
|
||||
{
|
||||
if (-1 != opal_malloc_output) {
|
||||
opal_output_close(opal_malloc_output);
|
||||
@ -82,6 +71,24 @@ void opal_malloc_finalize(void)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the malloc debug interface
|
||||
*/
|
||||
void opal_malloc_init(void)
|
||||
{
|
||||
OBJ_CONSTRUCT(&malloc_stream, opal_output_stream_t);
|
||||
malloc_stream.lds_is_debugging = true;
|
||||
malloc_stream.lds_verbose_level = 5;
|
||||
malloc_stream.lds_prefix = "malloc debug: ";
|
||||
malloc_stream.lds_want_stderr = true;
|
||||
opal_malloc_output = opal_output_open(&malloc_stream);
|
||||
opal_finalize_register_cleanup (opal_malloc_finalize);
|
||||
}
|
||||
#else
|
||||
void opal_malloc_init (void)
|
||||
{
|
||||
}
|
||||
#endif /* OPAL_ENABLE_DEBUG */
|
||||
|
||||
/*
|
||||
* Debug version of malloc
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
|
||||
* University Research and Technology
|
||||
@ -9,6 +10,8 @@
|
||||
* University of Stuttgart. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -60,14 +63,6 @@ BEGIN_C_DECLS
|
||||
*/
|
||||
void opal_malloc_init(void);
|
||||
|
||||
/**
|
||||
* Shut down malloc debug output.
|
||||
*
|
||||
* This function is invoked as part of opal_finalize() to shut down the
|
||||
* output stream for malloc debug messages.
|
||||
*/
|
||||
void opal_malloc_finalize(void);
|
||||
|
||||
/**
|
||||
* \internal
|
||||
*
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
||||
* University Research and Technology
|
||||
@ -17,6 +18,8 @@
|
||||
* and Technology (RIST). All rights reserved.
|
||||
* Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights
|
||||
* reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -60,6 +63,7 @@
|
||||
#include <ifaddrs.h>
|
||||
#endif
|
||||
|
||||
#include "opal/runtime/opal.h"
|
||||
#include "opal/util/net.h"
|
||||
#include "opal/util/output.h"
|
||||
#include "opal/util/argv.h"
|
||||
@ -129,6 +133,21 @@ get_hostname_buffer(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Finalize the network helper subsystem
|
||||
*
|
||||
* Finalize the network helper subsystem. Should be called exactly
|
||||
* once for any process that will use any function in the network
|
||||
* helper subsystem.
|
||||
*
|
||||
* @retval OPAL_SUCCESS Success
|
||||
*/
|
||||
static void opal_net_finalize (void)
|
||||
{
|
||||
free(private_ipv4);
|
||||
private_ipv4 = NULL;
|
||||
}
|
||||
|
||||
int
|
||||
opal_net_init(void)
|
||||
{
|
||||
@ -169,6 +188,8 @@ opal_net_init(void)
|
||||
opal_argv_free(args);
|
||||
}
|
||||
|
||||
opal_finalize_register_cleanup (opal_net_finalize);
|
||||
|
||||
do_local_init:
|
||||
#if OPAL_ENABLE_IPV6
|
||||
return opal_tsd_key_create(&hostname_tsd_key, hostname_cleanup);
|
||||
@ -177,17 +198,6 @@ opal_net_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
opal_net_finalize()
|
||||
{
|
||||
free(private_ipv4);
|
||||
private_ipv4 = NULL;
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* convert a CIDR prefixlen to netmask (in network byte order) */
|
||||
uint32_t
|
||||
opal_net_prefix2netmask(uint32_t prefixlen)
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
||||
* University Research and Technology
|
||||
@ -11,6 +12,8 @@
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2007 Los Alamos National Security, LLC. All rights
|
||||
* reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -50,19 +53,6 @@ BEGIN_C_DECLS
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_net_init(void);
|
||||
|
||||
|
||||
/**
|
||||
* Finalize the network helper subsystem
|
||||
*
|
||||
* Finalize the network helper subsystem. Should be called exactly
|
||||
* once for any process that will use any function in the network
|
||||
* helper subsystem.
|
||||
*
|
||||
* @retval OPAL_SUCCESS Success
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_net_finalize(void);
|
||||
|
||||
|
||||
/**
|
||||
* Calculate netmask in network byte order from CIDR notation
|
||||
*
|
||||
|
@ -18,6 +18,8 @@
|
||||
* Copyright (c) 2017 IBM Corporation. All rights reserved.
|
||||
* Copyright (c) 2017-2018 Intel, Inc. All rights reserved.
|
||||
* Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -99,6 +101,7 @@ static void free_descriptor(int output_id);
|
||||
static int make_string(char **no_newline_string, output_desc_t *ldi,
|
||||
const char *format, va_list arglist);
|
||||
static int output(int output_id, const char *format, va_list arglist);
|
||||
static void opal_output_finalize (void);
|
||||
|
||||
|
||||
#define OPAL_OUTPUT_MAX_STREAMS 64
|
||||
@ -217,6 +220,10 @@ bool opal_output_init(void)
|
||||
|
||||
/* Open the default verbose stream */
|
||||
verbose_stream = opal_output_open(&verbose);
|
||||
|
||||
/* make sure opal output is cleaned up on finalize */
|
||||
opal_finalize_register_cleanup (opal_output_finalize);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -335,7 +342,7 @@ void opal_output_close(int output_id)
|
||||
|
||||
/* Setup */
|
||||
|
||||
if (!initialized) {
|
||||
if (!initialized || output_id < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -343,7 +350,7 @@ void opal_output_close(int output_id)
|
||||
* free the resources associated with the descriptor */
|
||||
|
||||
OPAL_THREAD_LOCK(&mutex);
|
||||
if (output_id >= 0 && output_id < OPAL_OUTPUT_MAX_STREAMS &&
|
||||
if (output_id < OPAL_OUTPUT_MAX_STREAMS &&
|
||||
info[output_id].ldi_used && info[output_id].ldi_enabled) {
|
||||
free_descriptor(output_id);
|
||||
|
||||
@ -492,7 +499,7 @@ void opal_output_set_output_file_info(const char *dir,
|
||||
/*
|
||||
* Shut down the output stream system
|
||||
*/
|
||||
void opal_output_finalize(void)
|
||||
static void opal_output_finalize(void)
|
||||
{
|
||||
if (initialized) {
|
||||
if (verbose_stream != -1) {
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
||||
* University Research and Technology
|
||||
@ -11,6 +12,8 @@
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2007-2011 Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -264,14 +267,6 @@ struct opal_output_stream_t {
|
||||
*/
|
||||
OPAL_DECLSPEC bool opal_output_init(void);
|
||||
|
||||
/**
|
||||
* Shut down the output stream system.
|
||||
*
|
||||
* Shut down the output stream system, including the default verbose
|
||||
* stream.
|
||||
*/
|
||||
OPAL_DECLSPEC void opal_output_finalize(void);
|
||||
|
||||
/**
|
||||
* Opens an output stream.
|
||||
*
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
||||
* University Research and Technology
|
||||
@ -13,6 +14,8 @@
|
||||
* Copyright (c) 2015 Research Organization for Information Science
|
||||
* and Technology (RIST). All rights reserved.
|
||||
* Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -27,6 +30,7 @@
|
||||
#include <locale.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "opal/runtime/opal.h"
|
||||
#include "opal/mca/installdirs/installdirs.h"
|
||||
#include "opal/util/show_help.h"
|
||||
#include "opal/util/show_help_lex.h"
|
||||
@ -52,6 +56,7 @@ static int opal_show_vhelp_internal(const char *filename, const char *topic,
|
||||
int want_error_header, va_list arglist);
|
||||
static int opal_show_help_internal(const char *filename, const char *topic,
|
||||
int want_error_header, ...);
|
||||
static void opal_show_help_finalize (void);
|
||||
|
||||
opal_show_help_fn_t opal_show_help = opal_show_help_internal;
|
||||
opal_show_vhelp_fn_t opal_show_vhelp = opal_show_vhelp_internal;
|
||||
@ -67,10 +72,12 @@ int opal_show_help_init(void)
|
||||
|
||||
opal_argv_append_nosize(&search_dirs, opal_install_dirs.opaldatadir);
|
||||
|
||||
opal_finalize_register_cleanup (opal_show_help_finalize);
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
int opal_show_help_finalize(void)
|
||||
static void opal_show_help_finalize (void)
|
||||
{
|
||||
opal_output_close(output_stream);
|
||||
output_stream = -1;
|
||||
@ -79,9 +86,7 @@ int opal_show_help_finalize(void)
|
||||
if (NULL != search_dirs) {
|
||||
opal_argv_free(search_dirs);
|
||||
search_dirs = NULL;
|
||||
};
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
||||
* University Research and Technology
|
||||
@ -10,6 +11,8 @@
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2008-2018 Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2018 Triad National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -102,15 +105,6 @@ BEGIN_C_DECLS
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_show_help_init(void);
|
||||
|
||||
|
||||
/**
|
||||
* \internal
|
||||
*
|
||||
* Finalization of show_help subsystem
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_show_help_finalize(void);
|
||||
|
||||
|
||||
/**
|
||||
* Look up a text message in a text file and display it to the
|
||||
* stderr using printf()-like substitutions (%d, %s, etc.).
|
||||
|
@ -503,7 +503,7 @@ int main( int argc, char* argv[] )
|
||||
opal_datatype_t *pdt, *pdt1, *pdt2, *pdt3;
|
||||
int rc, length = 500;
|
||||
|
||||
opal_datatype_init();
|
||||
opal_init_util (NULL, NULL);
|
||||
|
||||
/**
|
||||
* By default simulate homogeneous architectures.
|
||||
@ -717,7 +717,7 @@ int main( int argc, char* argv[] )
|
||||
OBJ_RELEASE( pdt2 ); assert( pdt2 == NULL );
|
||||
|
||||
/* clean-ups all data allocations */
|
||||
opal_datatype_finalize();
|
||||
opal_finalize();
|
||||
opal_finalize_util ();
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ uint32_t remote_arch = 0xffffffff;
|
||||
*/
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
opal_datatype_init();
|
||||
opal_init_util (NULL, NULL);
|
||||
|
||||
/**
|
||||
* By default simulate homogeneous architectures.
|
||||
@ -93,7 +93,7 @@ int main( int argc, char* argv[] )
|
||||
OBJ_RELEASE(pConv);
|
||||
|
||||
/* clean-ups all data allocations */
|
||||
opal_datatype_finalize();
|
||||
opal_finalize();
|
||||
opal_finalize_util ();
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user