Skip to content

Commit 1e6b4f2

Browse files
committed
Merge pull request #1495 from hjelmn/new_hooks
Add new patcher memory hooks
2 parents e500ea2 + c2b6fbb commit 1e6b4f2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+2347
-11340
lines changed

config/opal_configure_options.m4

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ else
283283
OPAL_ENABLE_DLOPEN_SUPPORT=1
284284
AC_MSG_RESULT([yes])
285285
fi
286-
286+
AC_DEFINE_UNQUOTED(OPAL_ENABLE_DLOPEN_SUPPORT, $OPAL_ENABLE_DLOPEN_SUPPORT,
287+
[Whether we want to enable dlopen support])
287288

288289
#
289290
# Heterogeneous support

contrib/platform/lanl/cray_xe6/debug-common

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
enable_dlopen=no
21
enable_mem_profile=no
32
enable_binaries=yes
43
enable_heterogeneous=no
@@ -33,8 +32,5 @@ enable_mca_direct=pml-ob1
3332
# enable development headers
3433
with_devel_headers=yes
3534

36-
# enable ptmalloc (enables lazy deregistration)
37-
with_memory_manager=linux
38-
3935
# disable valgrind
4036
with_valgrind=no

contrib/platform/lanl/cray_xe6/optimized-common

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
enable_dlopen=no
2-
31
enable_mem_profile=no
42
enable_binaries=yes
53

@@ -40,8 +38,5 @@ enable_mca_direct=pml-ob1
4038
# enable development headers
4139
with_devel_headers=yes
4240

43-
# enable ptmalloc (enables lazy deregistration)
44-
with_memory_manager=linux
45-
4641
# disable valgrind
4742
with_valgrind=no

contrib/platform/lanl/toss/toss-common

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# (c) 2013 Los Alamos National Security, LLC. All rights reserved.
22
# Open MPI common configuration for TOSS/TOSS2 v1.7.x/1.8.x
33

4-
enable_dlopen=no
54
enable_binaries=yes
65
enable_heterogeneous=no
76
enable_shared=yes

ompi/runtime/ompi_mpi_init.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,13 @@
9898
#endif
9999
#include "ompi/runtime/ompi_cr.h"
100100

101-
#if defined(MEMORY_LINUX_PTMALLOC2) && MEMORY_LINUX_PTMALLOC2
102-
#include "opal/mca/memory/linux/memory_linux.h"
101+
#include "opal/mca/memory/base/base.h"
103102
/* So this sucks, but with OPAL in its own library that is brought in
104103
implicity from libmpi, there are times when the malloc initialize
105104
hook in the memory component doesn't work. So we have to do it
106105
from here, since any MPI code is going to call MPI_Init... */
107106
OPAL_DECLSPEC void (*__malloc_initialize_hook) (void) =
108-
opal_memory_linux_malloc_init_hook;
109-
#endif /* defined(MEMORY_LINUX_PTMALLOC2) && MEMORY_LINUX_PTMALLOC2 */
107+
opal_memory_base_malloc_init_hook;
110108

111109
/* This is required for the boundaries of the hash tables used to store
112110
* the F90 types returned by the MPI_Type_create_f90_XXX functions.

opal/common_sym_whitelist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ opal_show_help_yyleng
44
opal_show_help_yytext
55
opal_util_keyval_yyleng
66
opal_util_keyval_yytext
7+
__curbrk

opal/mca/btl/openib/btl_openib_component.c

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,39 +2562,6 @@ btl_openib_component_init(int *num_btl_modules,
25622562
goto no_btls;
25632563
}
25642564

2565-
/* If we are using ptmalloc2 and there are no posix threads
2566-
available, this will cause memory corruption. Refuse to run.
2567-
Right now, ptmalloc2 is the only memory manager that we have on
2568-
OS's that support OpenFabrics that provide both FREE and MUNMAP
2569-
support, so the following test is [currently] good enough... */
2570-
value = opal_mem_hooks_support_level();
2571-
2572-
/* If we have a memory manager available, and
2573-
opal_leave_pinned==-1, then unless the user explicitly set
2574-
opal_leave_pinned_pipeline==0, then set opal_leave_pinned to 1.
2575-
2576-
We have a memory manager if we have both FREE and MUNMAP
2577-
support */
2578-
if ((OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_MUNMAP_SUPPORT) ==
2579-
((OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_MUNMAP_SUPPORT) & value)) {
2580-
if (0 == opal_leave_pinned_pipeline &&
2581-
-1 == opal_leave_pinned) {
2582-
opal_leave_pinned = 1;
2583-
}
2584-
} else {
2585-
opal_leave_pinned = 0;
2586-
opal_leave_pinned_pipeline = 0;
2587-
}
2588-
2589-
#if OPAL_CUDA_SUPPORT
2590-
if (mca_btl_openib_component.cuda_want_gdr && (0 == opal_leave_pinned)) {
2591-
opal_show_help("help-mpi-btl-openib.txt",
2592-
"CUDA_gdr_and_nopinned", true,
2593-
opal_process_info.nodename);
2594-
goto no_btls;
2595-
}
2596-
#endif /* OPAL_CUDA_SUPPORT */
2597-
25982565
index = mca_base_var_find("ompi", "btl", "openib", "max_inline_data");
25992566
if (index >= 0) {
26002567
if (OPAL_SUCCESS == mca_base_var_get_value(index, NULL, &source, NULL)) {
@@ -2931,6 +2898,22 @@ btl_openib_component_init(int *num_btl_modules,
29312898
mca_btl_openib_component.if_exclude_list = NULL;
29322899
}
29332900

2901+
/* If we are using ptmalloc2 and there are no posix threads
2902+
available, this will cause memory corruption. Refuse to run.
2903+
Right now, ptmalloc2 is the only memory manager that we have on
2904+
OS's that support OpenFabrics that provide both FREE and MUNMAP
2905+
support, so the following test is [currently] good enough... */
2906+
value = opal_mem_hooks_support_level();
2907+
2908+
#if OPAL_CUDA_SUPPORT
2909+
if (mca_btl_openib_component.cuda_want_gdr && (0 == opal_leave_pinned)) {
2910+
opal_show_help("help-mpi-btl-openib.txt",
2911+
"CUDA_gdr_and_nopinned", true,
2912+
opal_process_info.nodename);
2913+
goto no_btls;
2914+
}
2915+
#endif /* OPAL_CUDA_SUPPORT */
2916+
29342917
mca_btl_openib_component.memory_registration_verbose = opal_output_open(NULL);
29352918
opal_output_set_verbosity (mca_btl_openib_component.memory_registration_verbose,
29362919
mca_btl_openib_component.memory_registration_verbose_level);

opal/mca/btl/ugni/btl_ugni_component.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -331,26 +331,6 @@ btl_ugni_component_close(void)
331331
return OPAL_SUCCESS;
332332
}
333333

334-
static void mca_btl_ugni_autoset_leave_pinned (void) {
335-
if (MCA_BTL_UGNI_RCACHE_UDREG != mca_btl_ugni_component.rcache_type) {
336-
int value = opal_mem_hooks_support_level();
337-
if ((OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_MUNMAP_SUPPORT) ==
338-
((OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_MUNMAP_SUPPORT) & value)) {
339-
/* Set leave pinned to 1 if leave pinned pipeline is not set */
340-
if (-1 == opal_leave_pinned) {
341-
opal_leave_pinned = !opal_leave_pinned_pipeline;
342-
}
343-
} else {
344-
opal_leave_pinned = 0;
345-
opal_leave_pinned_pipeline = 0;
346-
}
347-
} else if (-1 == opal_leave_pinned) {
348-
/* if udreg is in use we can set leave pinned without checking for the
349-
* memory hooks. */
350-
opal_leave_pinned = !opal_leave_pinned_pipeline;
351-
}
352-
}
353-
354334
static mca_btl_base_module_t **
355335
mca_btl_ugni_component_init (int *num_btl_modules,
356336
bool enable_progress_threads,
@@ -409,8 +389,6 @@ mca_btl_ugni_component_init (int *num_btl_modules,
409389
}
410390
}
411391

412-
mca_btl_ugni_autoset_leave_pinned ();
413-
414392
mca_btl_ugni_module.super.btl_rdma_pipeline_send_length = mca_btl_ugni_module.super.btl_eager_limit;
415393

416394
for (i = 0 ; i < mca_btl_ugni_component.ugni_num_btls ; ++i) {

opal/mca/memory/base/base.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,7 @@ BEGIN_C_DECLS
3232
*/
3333
OPAL_DECLSPEC extern mca_base_framework_t opal_memory_base_framework;
3434

35+
OPAL_DECLSPEC void opal_memory_base_malloc_init_hook (void);
36+
3537
END_C_DECLS
3638
#endif /* OPAL_BASE_MEMORY_H */

opal/mca/memory/base/memory_base_open.c

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2016 Research Organization for Information Science
1515
* and Technology (RIST). All rights reserved.
16+
* Copyright (c) 2016 Los Alamos National Security, LLC. All rights
17+
* reserved.
1618
* $COPYRIGHT$
1719
*
1820
* Additional copyrights may follow
@@ -43,20 +45,22 @@ static int empty_process(void)
4345
return OPAL_SUCCESS;
4446
}
4547

48+
static int empty_query (int *priority)
49+
{
50+
*priority = 0;
51+
return OPAL_SUCCESS;
52+
}
4653

4754
/*
4855
* Local variables
4956
*/
5057
static opal_memory_base_component_2_0_0_t empty_component = {
51-
/* Don't care about the version info */
52-
{ 0, },
53-
/* Don't care about the data */
54-
{ 0, },
5558
/* Empty / safe functions to call if no memory componet is selected */
56-
empty_process,
57-
opal_memory_base_component_register_empty,
58-
opal_memory_base_component_deregister_empty,
59-
opal_memory_base_component_set_alignment_empty,
59+
.memoryc_query = empty_query,
60+
.memoryc_process = empty_process,
61+
.memoryc_register = opal_memory_base_component_register_empty,
62+
.memoryc_deregister = opal_memory_base_component_deregister_empty,
63+
.memoryc_set_alignment = opal_memory_base_component_set_alignment_empty,
6064
};
6165

6266

@@ -66,30 +70,49 @@ static opal_memory_base_component_2_0_0_t empty_component = {
6670
opal_memory_base_component_2_0_0_t *opal_memory = &empty_component;
6771

6872

73+
void opal_memory_base_malloc_init_hook (void)
74+
{
75+
if (opal_memory->memoryc_init_hook) {
76+
opal_memory->memoryc_init_hook ();
77+
}
78+
}
6979

7080
/*
7181
* Function for finding and opening either all MCA components, or the one
7282
* that was specifically requested via a MCA parameter.
7383
*/
7484
static int opal_memory_base_open(mca_base_open_flag_t flags)
7585
{
86+
mca_base_component_list_item_t *item, *next;
87+
opal_memory_base_component_2_0_0_t *tmp;
88+
int priority, highest_priority = 0;
7689
int ret;
7790

78-
/* Open up all available components */
91+
/* can only be zero or one */
92+
OPAL_LIST_FOREACH(item, &opal_memory_base_framework.framework_components, mca_base_component_list_item_t) {
93+
tmp = (opal_memory_base_component_2_0_0_t *) item->cli_component;
94+
ret = tmp->memoryc_query (&priority);
95+
if (OPAL_SUCCESS != ret || priority < highest_priority) {
96+
continue;
97+
}
98+
99+
highest_priority = priority;
100+
opal_memory = tmp;
101+
}
102+
103+
OPAL_LIST_FOREACH_SAFE(item, next, &opal_memory_base_framework.framework_components, mca_base_component_list_item_t) {
104+
if ((void *) opal_memory != (void *) item->cli_component) {
105+
mca_base_component_unload (item->cli_component, opal_memory_base_framework.framework_output);
106+
opal_list_remove_item (&opal_memory_base_framework.framework_components, &item->super);
107+
}
108+
}
109+
110+
/* open remaining component */
79111
ret = mca_base_framework_components_open (&opal_memory_base_framework, flags);
80112
if (ret != OPAL_SUCCESS) {
81113
return ret;
82114
}
83115

84-
/* can only be zero or one */
85-
if (opal_list_get_size(&opal_memory_base_framework.framework_components) == 1) {
86-
mca_base_component_list_item_t *item;
87-
item = (mca_base_component_list_item_t*)
88-
opal_list_get_first(&opal_memory_base_framework.framework_components);
89-
opal_memory = (opal_memory_base_component_2_0_0_t*)
90-
item->cli_component;
91-
}
92-
93116
/* All done */
94117
return OPAL_SUCCESS;
95118
}

0 commit comments

Comments
 (0)