From d8482ce6f423cc9104b511e378e02255888e6943 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Thu, 18 Feb 2016 10:24:57 +0900 Subject: [PATCH] opal/mca/memory: add a memoryc_set_alignment subroutine to the OPAL memory MCA this commit also (partially) reverts : - open-mpi/ompi@7de01b347cd13544439b4eae86607a535c32489c - open-mpi/ompi@8b05f308f9d38bac1b43741f93a1766d4e15b135 --- ompi/runtime/ompi_mpi_init.c | 4 ++-- opal/mca/memory/base/empty.h | 13 ++++++++++++- opal/mca/memory/base/memory_base_empty.c | 8 ++++++++ opal/mca/memory/base/memory_base_open.c | 3 +++ opal/mca/memory/linux/memory_linux_component.c | 7 +++++++ .../memory_malloc_solaris_component.c | 3 +++ opal/mca/memory/memory.h | 12 +++++++++++- 7 files changed, 46 insertions(+), 4 deletions(-) diff --git a/ompi/runtime/ompi_mpi_init.c b/ompi/runtime/ompi_mpi_init.c index 7b4444576c..b5c61cba84 100644 --- a/ompi/runtime/ompi_mpi_init.c +++ b/ompi/runtime/ompi_mpi_init.c @@ -98,7 +98,7 @@ #endif #include "ompi/runtime/ompi_cr.h" -#if defined(MEMORY_LINUX_PTMALLOC2) && MEMORY_LINUX_PTMALLOC2 && MEMORY_LINUX_HAVE_MALLOC_HOOK_SUPPORT +#if defined(MEMORY_LINUX_PTMALLOC2) && MEMORY_LINUX_PTMALLOC2 #include "opal/mca/memory/linux/memory_linux.h" /* So this sucks, but with OPAL in its own library that is brought in implicity from libmpi, there are times when the malloc initialize @@ -106,7 +106,7 @@ from here, since any MPI code is going to call MPI_Init... */ OPAL_DECLSPEC void (*__malloc_initialize_hook) (void) = opal_memory_linux_malloc_init_hook; -#endif /* defined(MEMORY_LINUX_PTMALLOC2) && MEMORY_LINUX_PTMALLOC2 && MEMORY_LINUX_HAVE_MALLOC_HOOK_SUPPORT */ +#endif /* defined(MEMORY_LINUX_PTMALLOC2) && MEMORY_LINUX_PTMALLOC2 */ /* This is required for the boundaries of the hash tables used to store * the F90 types returned by the MPI_Type_create_f90_XXX functions. diff --git a/opal/mca/memory/base/empty.h b/opal/mca/memory/base/empty.h index 564f29648f..46cacc56e3 100644 --- a/opal/mca/memory/base/empty.h +++ b/opal/mca/memory/base/empty.h @@ -1,5 +1,7 @@ /* - * Copyright (c) 2009 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2009 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2016 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -51,6 +53,15 @@ OPAL_DECLSPEC int opal_memory_base_component_deregister_empty(void *start, size_t len, uint64_t cookie); +/** + * Default (empty) implementation of the memoryc_set_alignment function + * + * See opal/mca/memory/memory.h for a description of the parameters. + */ +OPAL_DECLSPEC void opal_memory_base_component_set_alignment_empty(int use_memalign, + size_t memalign_threshold); + + END_C_DECLS #endif diff --git a/opal/mca/memory/base/memory_base_empty.c b/opal/mca/memory/base/memory_base_empty.c index d9833374a9..c31db23487 100644 --- a/opal/mca/memory/base/memory_base_empty.c +++ b/opal/mca/memory/base/memory_base_empty.c @@ -9,6 +9,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2016 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -34,3 +36,9 @@ int opal_memory_base_component_deregister_empty(void *base, size_t len, { return OPAL_SUCCESS; } + +void opal_memory_base_component_set_alignment_empty(int use_memalign, + size_t memalign_threshold) +{ +} + diff --git a/opal/mca/memory/base/memory_base_open.c b/opal/mca/memory/base/memory_base_open.c index 1cf1400ec3..b27b1ae61d 100644 --- a/opal/mca/memory/base/memory_base_open.c +++ b/opal/mca/memory/base/memory_base_open.c @@ -11,6 +11,8 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2009 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2016 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -54,6 +56,7 @@ static opal_memory_base_component_2_0_0_t empty_component = { empty_process, opal_memory_base_component_register_empty, opal_memory_base_component_deregister_empty, + opal_memory_base_component_set_alignment_empty, }; diff --git a/opal/mca/memory/linux/memory_linux_component.c b/opal/mca/memory/linux/memory_linux_component.c index d5590e4b8b..3319066bbb 100644 --- a/opal/mca/memory/linux/memory_linux_component.c +++ b/opal/mca/memory/linux/memory_linux_component.c @@ -13,6 +13,8 @@ * Copyright (c) 2009-2014 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights * reserved. + * Copyright (c) 2016 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -96,6 +98,11 @@ opal_memory_linux_component_t mca_memory_linux_component = { end up using ummunotify support. */ .memoryc_register = opal_memory_base_component_register_empty, .memoryc_deregister = opal_memory_base_component_deregister_empty, +#if MEMORY_LINUX_MALLOC_ALIGN_ENABLED + .memoryc_set_alignment = opal_memory_linux_malloc_set_alignment, +#else + .memoryc_set_alignment = opal_memory_base_component_set_alignment_empty, +#endif }, /* Component-specific data, filled in later (compiler will 0/NULL diff --git a/opal/mca/memory/malloc_solaris/memory_malloc_solaris_component.c b/opal/mca/memory/malloc_solaris/memory_malloc_solaris_component.c index dd35feb081..15fa63468d 100644 --- a/opal/mca/memory/malloc_solaris/memory_malloc_solaris_component.c +++ b/opal/mca/memory/malloc_solaris/memory_malloc_solaris_component.c @@ -14,6 +14,8 @@ * Copyright (c) 2009-2011 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Los Alamos National Security, LLC. All rights * reserved. + * Copyright (c) 2016 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -68,6 +70,7 @@ const opal_memory_base_component_2_0_0_t mca_memory_malloc_solaris_component = { provide safe/empty register/deregister functions to call */ .memoryc_register = opal_memory_base_component_register_empty, .memoryc_deregister = opal_memory_base_component_deregister_empty, + .memoryc_set_alignment = opal_memory_base_component_set_alignment_empty, }; /* diff --git a/opal/mca/memory/memory.h b/opal/mca/memory/memory.h index 2b5c62f1f3..ab9ac49d78 100644 --- a/opal/mca/memory/memory.h +++ b/opal/mca/memory/memory.h @@ -13,6 +13,8 @@ * Copyright (c) 2009 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Los Alamos National Security, LLC. All rights * reserved. + * Copyright (c) 2016 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -92,7 +94,7 @@ typedef int (*opal_memory_base_component_register_fn_t)(void *base, /** - * Prototype for a function that is the opposite of + * Prototype for a function that is the opposite of * opal_memory_base_component_register_fn_t: this function is invoked * when Open MPI stops to "caring" about a specific memory region. * 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, uint64_t cookie); +/** + * Prototype for a function that set the memory alignment + */ +typedef void (*opal_memory_base_component_set_alignment_fn_t)(int use_memalign, + size_t memalign_threshold); + /** * Structure for memory components. */ @@ -132,6 +140,8 @@ typedef struct opal_memory_base_component_2_0_0_t { /** Function invoked when Open MPI stops "caring" about a specific memory region */ opal_memory_base_component_deregister_fn_t memoryc_deregister; + /** Function invoked in order to set malloc'ed memory alignment */ + opal_memory_base_component_set_alignment_fn_t memoryc_set_alignment; } opal_memory_base_component_2_0_0_t; OPAL_DECLSPEC extern opal_memory_base_component_2_0_0_t *opal_memory;