Skip to content

Topic/opal memory linux abstraction #1376

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

Merged
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
4 changes: 2 additions & 2 deletions ompi/runtime/ompi_mpi_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@
#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
hook in the memory component doesn't work. So we have to do it
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.
Expand Down
22 changes: 3 additions & 19 deletions opal/mca/btl/openib/btl_openib_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Copyright (c) 2011-2015 NVIDIA Corporation. All rights reserved.
* Copyright (c) 2012 Oak Ridge National Laboratory. All rights reserved
* Copyright (c) 2013-2015 Intel, Inc. All rights reserved
* Copyright (c) 2014-2015 Research Organization for Information Science
* Copyright (c) 2014-2016 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2014 Bull SAS. All rights reserved.
* $COPYRIGHT$
Expand All @@ -42,22 +42,8 @@
#include <fcntl.h>
#include <stdlib.h>
#include <stddef.h>
#if MEMORY_LINUX_MALLOC_ALIGN_ENABLED
/*
* The include of malloc.h below breaks abstractions in OMPI (by
* directly including a header file from another component), but has
* been ruled "ok" because the openib component is only supported on
* Linux.
*
* The malloc hooks in newer glibc were deprecated, including stock
* malloc.h causes compilation warnings. Instead, we use the internal
* linux component malloc.h which does not cause these warnings.
* Internally, OMPI uses the built-in ptmalloc from the linux memory
* component anyway.
*/
#include "opal/mca/memory/linux/memory_linux.h"
#endif

#include "opal/mca/memory/memory.h"
#include "opal/mca/event/event.h"
#include "opal/align.h"
#include "opal/util/output.h"
Expand Down Expand Up @@ -2512,14 +2498,12 @@ btl_openib_component_init(int *num_btl_modules,
*num_btl_modules = 0;
num_devs = 0;

#if MEMORY_LINUX_MALLOC_ALIGN_ENABLED
/* If we got this far, then setup the memory alloc hook (because
we're most likely going to be using this component). The hook
is to be set up as early as possible in this function since we
want most of the allocated resources be aligned.
*/
opal_memory_linux_malloc_set_alignment(32, mca_btl_openib_module.super.btl_eager_limit);
#endif /* MEMORY_LINUX_MALLOC_ALIGN_ENABLED */
opal_memory->memoryc_set_alignment(32, mca_btl_openib_module.super.btl_eager_limit);

/* Per https://svn.open-mpi.org/trac/ompi/ticket/1305, check to
see if $sysfsdir/class/infiniband exists. If it does not,
Expand Down
13 changes: 12 additions & 1 deletion opal/mca/memory/base/empty.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
8 changes: 8 additions & 0 deletions opal/mca/memory/base/memory_base_empty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
{
}

3 changes: 3 additions & 0 deletions opal/mca/memory/base/memory_base_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
};


Expand Down
7 changes: 7 additions & 0 deletions opal/mca/memory/linux/memory_linux_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
};

/*
Expand Down
12 changes: 11 additions & 1 deletion opal/mca/memory/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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.
*/
Expand All @@ -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;
Expand Down