Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to minimize the external dependencies for OMPI wrappers. #9893

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 37 additions & 8 deletions opal/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2009 The University of Tennessee and The University
# Copyright (c) 2004-2022 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2009 High Performance Computing Center Stuttgart,
Expand Down Expand Up @@ -70,30 +70,59 @@ DIST_SUBDIRS = \
$(MCA_opal_FRAMEWORK_COMPONENT_ALL_SUBDIRS)
endif

noinst_LTLIBRARIES = lib@OPAL_LIB_NAME@_core.la lib@OPAL_LIB_NAME@_util.la

# The first convenience library for the core functionality, everything that is shared
# between the base and the util libraries. We need this in order to avoid duplicate
# symbols when lib@OPAL_LIB_NAME@.la depends directly of lib@OPAL_LIB_NAME@_util.la
# (because $MCA_opal_FRAMEWORK_LIBS already contains the _STATIC_LTLIBS added to the
# lib@OPAL_LIB_NAME@_util.la library).
lib@OPAL_LIB_NAME@_core_la_SOURCES =
lib@OPAL_LIB_NAME@_core_la_LIBADD = \
datatype/libdatatype.la \
mca/base/libmca_base.la \
util/libopalutil.la

lib@OPAL_LIB_NAME@_util_la_SOURCES =
lib@OPAL_LIB_NAME@_util_la_LIBADD = \
lib@OPAL_LIB_NAME@_core.la \
mca/backtrace/libmca_backtrace.la \
$(MCA_opal_backtrace_STATIC_LTLIBS) \
mca/threads/libmca_threads.la \
$(MCA_opal_threads_STATIC_LTLIBS) \
mca/timer/libmca_timer.la \
$(MCA_opal_timer_STATIC_LTLIBS) \
mca/installdirs/libmca_installdirs.la \
$(MCA_opal_installdirs_STATIC_LTLIBS) \
mca/if/libmca_if.la \
$(MCA_opal_if_STATIC_LTLIBS) \
mca/dl/libmca_dl.la \
$(MCA_opal_dl_STATIC_LTLIBS) \
$(opal_libevent_LIBS)
lib@OPAL_LIB_NAME@_util_la_DEPENDENCIES = \
lib@OPAL_LIB_NAME@_core.la

# Build the main OPAL library
lib_LTLIBRARIES = lib@OPAL_LIB_NAME@.la
lib@OPAL_LIB_NAME@_la_SOURCES =
lib@OPAL_LIB_NAME@_la_LIBADD = \
datatype/libdatatype.la \
mca/base/libmca_base.la \
util/libopalutil.la \
lib@OPAL_LIB_NAME@_core.la \
$(MCA_opal_FRAMEWORK_LIBS) \
$(opal_libevent_LIBS) \
$(opal_hwloc_LIBS) \
$(opal_pmix_LIBS)
lib@OPAL_LIB_NAME@_la_DEPENDENCIES = \
datatype/libdatatype.la \
mca/base/libmca_base.la \
util/libopalutil.la \
lib@OPAL_LIB_NAME@_core.la \
$(MCA_opal_FRAMEWORK_LIBS)

lib@OPAL_LIB_NAME@_la_LDFLAGS = -version-info @libopen_pal_so_version@ \
lib@OPAL_LIB_NAME@_core_LDFLAGS \
$(opal_libevent_LDFLAGS) \
$(opal_hwloc_LDFLAGS) \
$(opal_pmix_LDFLAGS)

# included subdirectory Makefile.am's and appended-to variables
headers =
noinst_LTLIBRARIES =
dist_opaldata_DATA =
lib@OPAL_LIB_NAME@_la_SOURCES += $(headers)

Expand Down
4 changes: 2 additions & 2 deletions opal/class/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2007 The University of Tennessee and The University
# Copyright (c) 2004-2022 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
Expand Down Expand Up @@ -42,7 +42,7 @@ headers += \
class/opal_rb_tree.h \
class/opal_interval_tree.h

lib@OPAL_LIB_NAME@_la_SOURCES += \
lib@OPAL_LIB_NAME@_core_la_SOURCES += \
class/opal_bitmap.c \
class/opal_cstring.c \
class/opal_free_list.c \
Expand Down
32 changes: 32 additions & 0 deletions opal/mca/pmix/base/pmix_base_frame.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/*
* Copyright (c) 2014-2019 Intel, Inc. All rights reserved.
* Copyright (c) 2015-2016 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2022 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand All @@ -16,6 +19,7 @@
#include "opal/mca/threads/thread_usage.h"
#include "opal/util/argv.h"
#include "opal/util/output.h"
#include "opal/util/proc.h"

#include "opal/mca/pmix/base/base.h"
#include "opal/mca/pmix/pmix-internal.h"
Expand Down Expand Up @@ -59,6 +63,32 @@ static int opal_pmix_base_frame_register(mca_base_register_flag_t flags)
return OPAL_SUCCESS;
}

static char*
opal_get_proc_hostname_using_pmix(const opal_proc_t *proc)
{
int ret;
char *hostname;

/* if the proc is NULL, then we can't know */
if (NULL == proc) {
return strdup("unknown");
}

/* if it is my own hostname we are after, then just hand back
* the value in opal_process_info */
if (proc == opal_proc_local_get()) {
return strdup(opal_process_info.nodename);
}
/* if we don't already have it, then try to get it */
OPAL_MODEX_RECV_VALUE_OPTIONAL(ret, PMIX_HOSTNAME, &proc->proc_name, (char **) &hostname,
PMIX_STRING);
if (OPAL_SUCCESS != ret) {
return strdup("unknown"); // return something so the caller doesn't segfault
}
/* user is not allowed to release the data */
return hostname;
}

static int opal_pmix_base_frame_close(void)
{
int rc;
Expand All @@ -77,6 +107,8 @@ static int opal_pmix_base_frame_open(mca_base_open_flag_t flags)
opal_pmix_base.evbase = opal_sync_event_base;
/* pass across the verbosity */
opal_pmix_verbose_output = opal_pmix_base_framework.framework_output;
/* Set the distributed name service via PMIx */
opal_get_proc_hostname = opal_get_proc_hostname_using_pmix;
return rc;
}

Expand Down
2 changes: 1 addition & 1 deletion opal/mca/shmem/posix/shmem_posix_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ static int segment_create(opal_shmem_ds_t *ds_buf, const char *file_name, size_t
* already set for us :-)
*/

/* set "valid" bit because setment creation was successful */
/* set "valid" bit because segment creation was successful */
OPAL_SHMEM_DS_SET_VALID(ds_buf);

OPAL_OUTPUT_VERBOSE((70, opal_shmem_base_framework.framework_output,
Expand Down
12 changes: 8 additions & 4 deletions opal/runtime/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2020 The University of Tennessee and The University
# Copyright (c) 2004-2022 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
Expand Down Expand Up @@ -37,10 +37,14 @@ headers += \
runtime/opal_params.h \
runtime/opal_progress_threads.h

lib@OPAL_LIB_NAME@_la_SOURCES += \
lib@OPAL_LIB_NAME@_core_la_SOURCES += \
runtime/opal_progress.c \
runtime/opal_finalize.c \
runtime/opal_init.c \
runtime/opal_params.c \
runtime/opal_util_finalize.c \
runtime/opal_util_init.c \
runtime/opal_info_support.c \
runtime/opal_progress_threads.c

lib@OPAL_LIB_NAME@_la_SOURCES += \
runtime/opal_finalize.c \
runtime/opal_init.c
117 changes: 1 addition & 116 deletions opal/runtime/opal_finalize.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* Copyright (c) 2004-2022 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
Expand Down Expand Up @@ -43,121 +43,6 @@
#include "opal/util/show_help.h"

extern int opal_initialized;
extern int opal_util_initialized;
extern bool opal_init_called;

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_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 = {{{0}}};
opal_finalize_domain_t opal_init_domain = {{{0}}};

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(&current_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;
}

opal_finalize_cleanup_domain(&opal_init_util_domain);
OBJ_DESTRUCT(&opal_init_util_domain);

/* finalize the class/object system */
opal_class_finalize();

free(opal_process_info.nodename);
opal_process_info.nodename = NULL;

return OPAL_SUCCESS;
}

int opal_finalize(void)
{
Expand Down
Loading