Skip to content

Commit b5adaf6

Browse files
vvenkates27hjelmn
authored andcommitted
Adding memkind component to use MPI_Alloc_mem through memkind
1 parent fba91c3 commit b5adaf6

File tree

5 files changed

+525
-0
lines changed

5 files changed

+525
-0
lines changed

opal/mca/mpool/memkind/Makefile.am

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# -*- indent-tabs-mode:nil -*-
2+
#
3+
# Copyright (c) 2011-2013 Los Alamos National Security, LLC. All rights
4+
# reserved.
5+
#
6+
# Additional copyrights may follow
7+
#
8+
# $HEADER$
9+
#
10+
11+
# Make the output library in this directory, and name it either
12+
# mca_<type>_<name>.la (for DSO builds) or libmca_<type>_<name>.la
13+
# (for static builds).
14+
15+
AM_CPPFLAGS = $(mpool_memkind_CPPFLAGS)
16+
17+
if MCA_BUILD_opal_mpool_memkind_DSO
18+
component_noinst =
19+
component_install = mca_mpool_memkind.la
20+
else
21+
component_noinst = libmca_mpool_memkind.la
22+
component_install =
23+
endif
24+
25+
memkind_SOURCES = \
26+
mpool_memkind_component.c \
27+
mpool_memkind_module.c \
28+
mpool_memkind.h
29+
30+
mcacomponentdir = $(opallibdir)
31+
mcacomponent_LTLIBRARIES = $(component_install)
32+
mca_mpool_memkind_la_SOURCES = $(memkind_SOURCES)
33+
nodist_mca_mpool_memkind_la_SOURCES = $(memkind_nodist_SOURCES)
34+
mca_mpool_memkind_la_LIBADD = $(mpool_memkind_LIBS)
35+
mca_mpool_memkind_la_LDFLAGS = -module -avoid-version $(mpool_memkind_LDFLAGS)
36+
37+
noinst_LTLIBRARIES = $(component_noinst)
38+
libmca_mpool_memkind_la_SOURCES = $(memkind_SOURCES)
39+
nodist_libmca_mpool_memkind_la_SOURCES = $(memkind_nodist_SOURCES)
40+
libmca_mpool_memkind_la_LIBADD = $(mpool_memkind_LIBS)
41+
libmca_mpool_memkind_la_LDFLAGS = -module -avoid-version $(mpool_memkind_LDFLAGS)

opal/mca/mpool/memkind/configure.m4

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# -*- shell-script -*-
2+
#
3+
# Copyright (c) 2013-2014 Los Alamos National Security, LLC. All rights
4+
# reserved.
5+
# $COPYRIGHT$
6+
#
7+
# Additional copyrights may follow
8+
#
9+
# $HEADER$
10+
#
11+
12+
AC_DEFUN([MCA_opal_mpool_memkind_CONFIG],[
13+
OPAL_VAR_SCOPE_PUSH([opal_mpool_memkind_happy])
14+
AC_CONFIG_FILES([opal/mca/mpool/memkind/Makefile])
15+
16+
AC_ARG_WITH([memkind], [AC_HELP_STRING([--with-memkind(=DIR)]),
17+
[Build with MEMKIND, searching for headers in DIR])])
18+
OPAL_CHECK_WITHDIR([memkind], [$with_memkind], [include/memkind.h])
19+
20+
opal_mpool_memkind_happy="no"
21+
22+
if test "$with_memkind" != "no" ; then
23+
if test -n "$with_memkind" -a "$with_memkind" != "yes" ; then
24+
opal_check_memkind_dir=$with_memkind
25+
fi
26+
27+
OPAL_CHECK_PACKAGE([mpool_memkind], [memkind.h], [memkind], [memkind_malloc], [-ljemalloc, -lnuma],
28+
[$opal_check_memkind_dir], [], [opal_mpool_memkind_happy="yes"], [])
29+
30+
if test "$opal_mpool_memkind_happy" != "yes" -a -n "$with_memkind" ; then
31+
AC_MSG_ERROR([MEMKIND support requested but not found. Aborting])
32+
fi
33+
fi
34+
35+
AS_IF([test "$opal_mpool_memkind_happy" = "yes"], [$1], [$2])
36+
37+
# substitute in the things needed to build memkind
38+
AC_SUBST([mpool_memkind_CPPFLAGS])
39+
AC_SUBST([mpool_memkind_LDFLAGS])
40+
AC_SUBST([mpool_memkind_LIBS])
41+
OPAL_VAR_SCOPE_POP
42+
])dnl
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/*
2+
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
3+
* University Research and Technology
4+
* Corporation. All rights reserved.
5+
* Copyright (c) 2004-2006 The University of Tennessee and The University
6+
* of Tennessee Research Foundation. All rights
7+
* reserved.
8+
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9+
* University of Stuttgart. All rights reserved.
10+
* Copyright (c) 2004-2005 The Regents of the University of California.
11+
* All rights reserved.
12+
* Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
13+
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
14+
* Copyright (c) 2010-2012 Los Alamos National Security, LLC.
15+
* All rights reserved.
16+
* $COPYRIGHT$
17+
*
18+
* Additional copyrights may follow
19+
*
20+
* $HEADER$
21+
*/
22+
/**
23+
* @file
24+
*/
25+
#ifndef MCA_MPOOL_MEMKIND_H
26+
#define MCA_MPOOL_MEMKIND_H
27+
28+
#include "opal_config.h"
29+
30+
#include "opal/mca/event/event.h"
31+
#include "opal/mca/mpool/mpool.h"
32+
33+
#include "opal/mca/allocator/allocator.h"
34+
#include "memkind.h"
35+
36+
BEGIN_C_DECLS
37+
38+
struct mca_mpool_base_resources_t {
39+
char *pool_name;
40+
void *reg_data;
41+
size_t size;
42+
};
43+
static const int mca_mpool_memkind_default_pagesize = 4096;
44+
45+
46+
typedef struct mca_mpool_base_resources_t mca_mpool_base_resources_t;
47+
48+
struct mca_mpool_memkind_module_t {
49+
mca_mpool_base_module_t super;
50+
size_t alloc_size;
51+
struct mca_mpool_base_resources_t resources;
52+
};
53+
typedef struct mca_mpool_memkind_module_t mca_mpool_memkind_module_t;
54+
55+
struct mca_mpool_memkind_component_t {
56+
mca_mpool_base_component_t super;
57+
int hbw;
58+
int pagesize;
59+
int bind;
60+
memkind_t kind;
61+
char *memkind_name;
62+
char *memkind_file;
63+
int verbose;
64+
};
65+
typedef struct mca_mpool_memkind_component_t mca_mpool_memkind_component_t;
66+
OPAL_MODULE_DECLSPEC extern mca_mpool_memkind_component_t mca_mpool_memkind_component;
67+
68+
/*
69+
* Initializes the mpool module.
70+
*/
71+
72+
void mca_mpool_memkind_module_init(mca_mpool_memkind_module_t *mpool);
73+
74+
/**
75+
* Allocate block of high bandwidth memory.
76+
*/
77+
void* mca_mpool_memkind_alloc(
78+
mca_mpool_base_module_t* mpool,
79+
size_t size,
80+
size_t align,
81+
uint32_t flags,
82+
mca_mpool_base_registration_t** registration);
83+
84+
/**
85+
* realloc function typedef
86+
*/
87+
void* mca_mpool_memkind_realloc(
88+
mca_mpool_base_module_t* mpool,
89+
void* addr,
90+
size_t size,
91+
mca_mpool_base_registration_t** registration);
92+
93+
/**
94+
* free function typedef
95+
*/
96+
void mca_mpool_memkind_free(
97+
mca_mpool_base_module_t* mpool,
98+
void * addr,
99+
mca_mpool_base_registration_t* registration);
100+
101+
END_C_DECLS
102+
103+
#endif

0 commit comments

Comments
 (0)