Skip to content

Commit 8636d39

Browse files
committed
Try to minimize the external dependencies for OMPI wrappers.
The solution put forward here consist of creating a convenience library, opal-tiny, that holds all the basic things we need to have a working app with minimal external dependencies. More detailed discussion in #9869. Signed-off-by: George Bosilca <[email protected]>
1 parent 60e82dd commit 8636d39

File tree

12 files changed

+845
-654
lines changed

12 files changed

+845
-654
lines changed

opal/Makefile.am

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
33
# University Research and Technology
44
# Corporation. All rights reserved.
5-
# Copyright (c) 2004-2009 The University of Tennessee and The University
5+
# Copyright (c) 2004-2021 The University of Tennessee and The University
66
# of Tennessee Research Foundation. All rights
77
# reserved.
88
# Copyright (c) 2004-2009 High Performance Computing Center Stuttgart,
@@ -70,30 +70,59 @@ DIST_SUBDIRS = \
7070
$(MCA_opal_FRAMEWORK_COMPONENT_ALL_SUBDIRS)
7171
endif
7272

73+
noinst_LTLIBRARIES = lib@OPAL_LIB_NAME@_core.la lib@OPAL_LIB_NAME@_util.la
74+
75+
# First convenience library for the core functionality, everything that is shared
76+
# between the base and the util libraries. We need this in order to avoid duplicate
77+
# symbols when lib@[email protected] depends directly of lib@OPAL_LIB_NAME@_util.la
78+
# (because $MCA_opal_FRAMEWORK_LIBS already contains the _STATIC_LTLIBS added to the
79+
# lib@OPAL_LIB_NAME@_util.la library).
80+
lib@OPAL_LIB_NAME@_core_la_SOURCES =
81+
lib@OPAL_LIB_NAME@_core_la_LIBADD = \
82+
datatype/libdatatype.la \
83+
mca/base/libmca_base.la \
84+
util/libopalutil.la
85+
86+
lib@OPAL_LIB_NAME@_util_la_SOURCES =
87+
lib@OPAL_LIB_NAME@_util_la_LIBADD = \
88+
lib@OPAL_LIB_NAME@_core.la \
89+
mca/backtrace/libmca_backtrace.la \
90+
$(MCA_opal_backtrace_STATIC_LTLIBS) \
91+
mca/threads/libmca_threads.la \
92+
$(MCA_opal_threads_STATIC_LTLIBS) \
93+
mca/timer/libmca_timer.la \
94+
$(MCA_opal_timer_STATIC_LTLIBS) \
95+
mca/installdirs/libmca_installdirs.la \
96+
$(MCA_opal_installdirs_STATIC_LTLIBS) \
97+
mca/if/libmca_if.la \
98+
$(MCA_opal_if_STATIC_LTLIBS) \
99+
mca/dl/libmca_dl.la \
100+
$(MCA_opal_dl_STATIC_LTLIBS) \
101+
$(opal_libevent_LIBS)
102+
lib@OPAL_LIB_NAME@_util_la_DEPENDENCIES = \
103+
lib@OPAL_LIB_NAME@_core.la
104+
73105
# Build the main OPAL library
74106
lib_LTLIBRARIES = lib@[email protected]
75107
lib@OPAL_LIB_NAME@_la_SOURCES =
76108
lib@OPAL_LIB_NAME@_la_LIBADD = \
77-
datatype/libdatatype.la \
78-
mca/base/libmca_base.la \
79-
util/libopalutil.la \
109+
lib@OPAL_LIB_NAME@_core.la \
80110
$(MCA_opal_FRAMEWORK_LIBS) \
81111
$(opal_libevent_LIBS) \
82112
$(opal_hwloc_LIBS) \
83113
$(opal_pmix_LIBS)
84114
lib@OPAL_LIB_NAME@_la_DEPENDENCIES = \
85-
datatype/libdatatype.la \
86-
mca/base/libmca_base.la \
87-
util/libopalutil.la \
115+
lib@OPAL_LIB_NAME@_core.la \
88116
$(MCA_opal_FRAMEWORK_LIBS)
117+
89118
lib@OPAL_LIB_NAME@_la_LDFLAGS = -version-info @libopen_pal_so_version@ \
119+
lib@OPAL_LIB_NAME@_core_LDFLAGS \
90120
$(opal_libevent_LDFLAGS) \
91121
$(opal_hwloc_LDFLAGS) \
92122
$(opal_pmix_LDFLAGS)
93123

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

@@ -109,3 +138,4 @@ include memoryhooks/Makefile.am
109138
include runtime/Makefile.am
110139
include mca/Makefile.am
111140
include tools/Makefile.am
141+

opal/class/Makefile.am

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
44
# University Research and Technology
55
# Corporation. All rights reserved.
6-
# Copyright (c) 2004-2007 The University of Tennessee and The University
6+
# Copyright (c) 2004-2021 The University of Tennessee and The University
77
# of Tennessee Research Foundation. All rights
88
# reserved.
99
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@@ -42,7 +42,7 @@ headers += \
4242
class/opal_rb_tree.h \
4343
class/opal_interval_tree.h
4444

45-
lib@OPAL_LIB_NAME@_la_SOURCES += \
45+
lib@OPAL_LIB_NAME@_core_la_SOURCES += \
4646
class/opal_bitmap.c \
4747
class/opal_cstring.c \
4848
class/opal_free_list.c \

opal/mca/pmix/base/pmix_base_frame.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "opal/mca/threads/thread_usage.h"
1717
#include "opal/util/argv.h"
1818
#include "opal/util/output.h"
19+
#include "opal/util/proc.h"
1920

2021
#include "opal/mca/pmix/base/base.h"
2122
#include "opal/mca/pmix/pmix-internal.h"
@@ -59,6 +60,32 @@ static int opal_pmix_base_frame_register(mca_base_register_flag_t flags)
5960
return OPAL_SUCCESS;
6061
}
6162

63+
static char*
64+
opal_get_proc_hostname_using_pmix(const opal_proc_t *proc)
65+
{
66+
int ret;
67+
char *hostname;
68+
69+
/* if the proc is NULL, then we can't know */
70+
if (NULL == proc) {
71+
return strdup("unknown");
72+
}
73+
74+
/* if it is my own hostname we are after, then just hand back
75+
* the value in opal_process_info */
76+
if (proc == opal_proc_local_get()) {
77+
return strdup(opal_process_info.nodename);
78+
}
79+
/* if we don't already have it, then try to get it */
80+
OPAL_MODEX_RECV_VALUE_OPTIONAL(ret, PMIX_HOSTNAME, &proc->proc_name, (char **) &hostname,
81+
PMIX_STRING);
82+
if (OPAL_SUCCESS != ret) {
83+
return strdup("unknown"); // return something so the caller doesn't segfault
84+
}
85+
/* user is not allowed to release the data */
86+
return hostname;
87+
}
88+
6289
static int opal_pmix_base_frame_close(void)
6390
{
6491
int rc;
@@ -77,6 +104,8 @@ static int opal_pmix_base_frame_open(mca_base_open_flag_t flags)
77104
opal_pmix_base.evbase = opal_sync_event_base;
78105
/* pass across the verbosity */
79106
opal_pmix_verbose_output = opal_pmix_base_framework.framework_output;
107+
/* Set the distributed name service via PMIx */
108+
opal_get_proc_hostname = opal_get_proc_hostname_using_pmix;
80109
return rc;
81110
}
82111

opal/runtime/Makefile.am

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
44
# University Research and Technology
55
# Corporation. All rights reserved.
6-
# Copyright (c) 2004-2020 The University of Tennessee and The University
6+
# Copyright (c) 2004-2021 The University of Tennessee and The University
77
# of Tennessee Research Foundation. All rights
88
# reserved.
99
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@@ -37,10 +37,14 @@ headers += \
3737
runtime/opal_params.h \
3838
runtime/opal_progress_threads.h
3939

40-
lib@OPAL_LIB_NAME@_la_SOURCES += \
40+
lib@OPAL_LIB_NAME@_core_la_SOURCES += \
4141
runtime/opal_progress.c \
42-
runtime/opal_finalize.c \
43-
runtime/opal_init.c \
4442
runtime/opal_params.c \
43+
runtime/opal_util_finalize.c \
44+
runtime/opal_util_init.c \
4545
runtime/opal_info_support.c \
4646
runtime/opal_progress_threads.c
47+
48+
lib@OPAL_LIB_NAME@_la_SOURCES += \
49+
runtime/opal_finalize.c \
50+
runtime/opal_init.c

opal/runtime/opal_finalize.c

Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -43,121 +43,6 @@
4343
#include "opal/util/show_help.h"
4444

4545
extern int opal_initialized;
46-
extern int opal_util_initialized;
47-
extern bool opal_init_called;
48-
49-
static opal_mutex_t opal_finalize_cleanup_fns_lock = OPAL_MUTEX_STATIC_INIT;
50-
opal_list_t opal_finalize_cleanup_fns = {{0}};
51-
52-
struct opal_cleanup_fn_item_t {
53-
opal_list_item_t super;
54-
opal_cleanup_fn_t cleanup_fn;
55-
void *user_data;
56-
#if OPAL_ENABLE_DEBUG
57-
char *cleanup_fn_name;
58-
#endif
59-
};
60-
61-
typedef struct opal_cleanup_fn_item_t opal_cleanup_fn_item_t;
62-
OBJ_CLASS_DECLARATION(opal_cleanup_fn_item_t);
63-
64-
static void opal_cleanup_fn_item_construct(opal_cleanup_fn_item_t *item)
65-
{
66-
#if OPAL_ENABLE_DEBUG
67-
item->cleanup_fn_name = NULL;
68-
#endif
69-
}
70-
71-
static void opal_cleanup_fn_item_destruct(opal_cleanup_fn_item_t *item)
72-
{
73-
#if OPAL_ENABLE_DEBUG
74-
free(item->cleanup_fn_name);
75-
item->cleanup_fn_name = NULL;
76-
#endif
77-
}
78-
79-
OBJ_CLASS_INSTANCE(opal_cleanup_fn_item_t, opal_list_item_t, opal_cleanup_fn_item_construct,
80-
opal_cleanup_fn_item_destruct);
81-
82-
static void opal_finalize_domain_construct(opal_finalize_domain_t *domain)
83-
{
84-
domain->domain_name = NULL;
85-
}
86-
87-
static void opal_finalize_domain_destruct(opal_finalize_domain_t *domain)
88-
{
89-
free(domain->domain_name);
90-
domain->domain_name = NULL;
91-
}
92-
93-
OBJ_CLASS_INSTANCE(opal_finalize_domain_t, opal_list_t, opal_finalize_domain_construct,
94-
opal_finalize_domain_destruct);
95-
96-
static opal_finalize_domain_t *current_finalize_domain;
97-
opal_finalize_domain_t opal_init_util_domain = {{{0}}};
98-
opal_finalize_domain_t opal_init_domain = {{{0}}};
99-
100-
void opal_finalize_append_cleanup(opal_cleanup_fn_t cleanup_fn, const char *fn_name,
101-
void *user_data)
102-
{
103-
opal_cleanup_fn_item_t *cleanup_item = OBJ_NEW(opal_cleanup_fn_item_t);
104-
assert(NULL != cleanup_item);
105-
cleanup_item->cleanup_fn = cleanup_fn;
106-
cleanup_item->user_data = user_data;
107-
#if OPAL_ENABLE_DEBUG
108-
cleanup_item->cleanup_fn_name = strdup(fn_name);
109-
assert(NULL != cleanup_item->cleanup_fn_name);
110-
#else
111-
(void) fn_name;
112-
#endif
113-
114-
opal_mutex_lock(&opal_finalize_cleanup_fns_lock);
115-
opal_list_append(&current_finalize_domain->super, &cleanup_item->super);
116-
opal_mutex_unlock(&opal_finalize_cleanup_fns_lock);
117-
}
118-
119-
void opal_finalize_domain_init(opal_finalize_domain_t *domain, const char *domain_name)
120-
{
121-
free(domain->domain_name);
122-
domain->domain_name = domain_name ? strdup(domain_name) : NULL;
123-
}
124-
125-
void opal_finalize_set_domain(opal_finalize_domain_t *domain)
126-
{
127-
current_finalize_domain = domain;
128-
}
129-
130-
void opal_finalize_cleanup_domain(opal_finalize_domain_t *domain)
131-
{
132-
opal_cleanup_fn_item_t *cleanup_item, *next;
133-
/* call any registered cleanup functions before tearing down OPAL */
134-
OPAL_LIST_FOREACH_SAFE_REV (cleanup_item, next, &domain->super, opal_cleanup_fn_item_t) {
135-
cleanup_item->cleanup_fn(cleanup_item->user_data);
136-
opal_list_remove_item(&domain->super, &cleanup_item->super);
137-
OBJ_RELEASE(cleanup_item);
138-
}
139-
}
140-
141-
int opal_finalize_util(void)
142-
{
143-
if (--opal_util_initialized != 0) {
144-
if (opal_util_initialized < 0) {
145-
return OPAL_ERROR;
146-
}
147-
return OPAL_SUCCESS;
148-
}
149-
150-
opal_finalize_cleanup_domain(&opal_init_util_domain);
151-
OBJ_DESTRUCT(&opal_init_util_domain);
152-
153-
/* finalize the class/object system */
154-
opal_class_finalize();
155-
156-
free(opal_process_info.nodename);
157-
opal_process_info.nodename = NULL;
158-
159-
return OPAL_SUCCESS;
160-
}
16146

16247
int opal_finalize(void)
16348
{

0 commit comments

Comments
 (0)