Skip to content

Commit d8482ce

Browse files
committed
opal/mca/memory: add a memoryc_set_alignment subroutine to the OPAL memory MCA
this commit also (partially) reverts : - 7de01b3 - 8b05f30
1 parent 2c4b93f commit d8482ce

File tree

7 files changed

+46
-4
lines changed

7 files changed

+46
-4
lines changed

ompi/runtime/ompi_mpi_init.c

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

101-
#if defined(MEMORY_LINUX_PTMALLOC2) && MEMORY_LINUX_PTMALLOC2 && MEMORY_LINUX_HAVE_MALLOC_HOOK_SUPPORT
101+
#if defined(MEMORY_LINUX_PTMALLOC2) && MEMORY_LINUX_PTMALLOC2
102102
#include "opal/mca/memory/linux/memory_linux.h"
103103
/* So this sucks, but with OPAL in its own library that is brought in
104104
implicity from libmpi, there are times when the malloc initialize
105105
hook in the memory component doesn't work. So we have to do it
106106
from here, since any MPI code is going to call MPI_Init... */
107107
OPAL_DECLSPEC void (*__malloc_initialize_hook) (void) =
108108
opal_memory_linux_malloc_init_hook;
109-
#endif /* defined(MEMORY_LINUX_PTMALLOC2) && MEMORY_LINUX_PTMALLOC2 && MEMORY_LINUX_HAVE_MALLOC_HOOK_SUPPORT */
109+
#endif /* defined(MEMORY_LINUX_PTMALLOC2) && MEMORY_LINUX_PTMALLOC2 */
110110

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

opal/mca/memory/base/empty.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/*
2-
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
2+
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
3+
* Copyright (c) 2016 Research Organization for Information Science
4+
* and Technology (RIST). All rights reserved.
35
* $COPYRIGHT$
46
*
57
* Additional copyrights may follow
@@ -51,6 +53,15 @@ OPAL_DECLSPEC int opal_memory_base_component_deregister_empty(void *start,
5153
size_t len,
5254
uint64_t cookie);
5355

56+
/**
57+
* Default (empty) implementation of the memoryc_set_alignment function
58+
*
59+
* See opal/mca/memory/memory.h for a description of the parameters.
60+
*/
61+
OPAL_DECLSPEC void opal_memory_base_component_set_alignment_empty(int use_memalign,
62+
size_t memalign_threshold);
63+
64+
5465
END_C_DECLS
5566

5667
#endif

opal/mca/memory/base/memory_base_empty.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12+
* Copyright (c) 2016 Research Organization for Information Science
13+
* and Technology (RIST). All rights reserved.
1214
* $COPYRIGHT$
1315
*
1416
* Additional copyrights may follow
@@ -34,3 +36,9 @@ int opal_memory_base_component_deregister_empty(void *base, size_t len,
3436
{
3537
return OPAL_SUCCESS;
3638
}
39+
40+
void opal_memory_base_component_set_alignment_empty(int use_memalign,
41+
size_t memalign_threshold)
42+
{
43+
}
44+

opal/mca/memory/base/memory_base_open.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
1313
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
14+
* Copyright (c) 2016 Research Organization for Information Science
15+
* and Technology (RIST). All rights reserved.
1416
* $COPYRIGHT$
1517
*
1618
* Additional copyrights may follow
@@ -54,6 +56,7 @@ static opal_memory_base_component_2_0_0_t empty_component = {
5456
empty_process,
5557
opal_memory_base_component_register_empty,
5658
opal_memory_base_component_deregister_empty,
59+
opal_memory_base_component_set_alignment_empty,
5760
};
5861

5962

opal/mca/memory/linux/memory_linux_component.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* Copyright (c) 2009-2014 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
1515
* reserved.
16+
* Copyright (c) 2016 Research Organization for Information Science
17+
* and Technology (RIST). All rights reserved.
1618
* $COPYRIGHT$
1719
*
1820
* Additional copyrights may follow
@@ -96,6 +98,11 @@ opal_memory_linux_component_t mca_memory_linux_component = {
9698
end up using ummunotify support. */
9799
.memoryc_register = opal_memory_base_component_register_empty,
98100
.memoryc_deregister = opal_memory_base_component_deregister_empty,
101+
#if MEMORY_LINUX_MALLOC_ALIGN_ENABLED
102+
.memoryc_set_alignment = opal_memory_linux_malloc_set_alignment,
103+
#else
104+
.memoryc_set_alignment = opal_memory_base_component_set_alignment_empty,
105+
#endif
99106
},
100107

101108
/* Component-specific data, filled in later (compiler will 0/NULL

opal/mca/memory/malloc_solaris/memory_malloc_solaris_component.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* Copyright (c) 2009-2011 Cisco Systems, Inc. All rights reserved.
1515
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
1616
* reserved.
17+
* Copyright (c) 2016 Research Organization for Information Science
18+
* and Technology (RIST). All rights reserved.
1719
* $COPYRIGHT$
1820
*
1921
* Additional copyrights may follow
@@ -68,6 +70,7 @@ const opal_memory_base_component_2_0_0_t mca_memory_malloc_solaris_component = {
6870
provide safe/empty register/deregister functions to call */
6971
.memoryc_register = opal_memory_base_component_register_empty,
7072
.memoryc_deregister = opal_memory_base_component_deregister_empty,
73+
.memoryc_set_alignment = opal_memory_base_component_set_alignment_empty,
7174
};
7275

7376
/*

opal/mca/memory/memory.h

Lines changed: 11 additions & 1 deletion
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) 2015 Los Alamos National Security, LLC. All rights
1515
* reserved.
16+
* Copyright (c) 2016 Research Organization for Information Science
17+
* and Technology (RIST). All rights reserved.
1618
* $COPYRIGHT$
1719
*
1820
* Additional copyrights may follow
@@ -92,7 +94,7 @@ typedef int (*opal_memory_base_component_register_fn_t)(void *base,
9294

9395

9496
/**
95-
* Prototype for a function that is the opposite of
97+
* Prototype for a function that is the opposite of
9698
* opal_memory_base_component_register_fn_t: this function is invoked
9799
* when Open MPI stops to "caring" about a specific memory region.
98100
* That is, Open MPI declares that it no longer wants to be notified
@@ -111,6 +113,12 @@ typedef int (*opal_memory_base_component_deregister_fn_t)(void *base,
111113
uint64_t cookie);
112114

113115

116+
/**
117+
* Prototype for a function that set the memory alignment
118+
*/
119+
typedef void (*opal_memory_base_component_set_alignment_fn_t)(int use_memalign,
120+
size_t memalign_threshold);
121+
114122
/**
115123
* Structure for memory components.
116124
*/
@@ -132,6 +140,8 @@ typedef struct opal_memory_base_component_2_0_0_t {
132140
/** Function invoked when Open MPI stops "caring" about a
133141
specific memory region */
134142
opal_memory_base_component_deregister_fn_t memoryc_deregister;
143+
/** Function invoked in order to set malloc'ed memory alignment */
144+
opal_memory_base_component_set_alignment_fn_t memoryc_set_alignment;
135145
} opal_memory_base_component_2_0_0_t;
136146

137147
OPAL_DECLSPEC extern opal_memory_base_component_2_0_0_t *opal_memory;

0 commit comments

Comments
 (0)