1
1

Create new memory component for default solaris allocator.

This commit was SVN r19217.
Этот коммит содержится в:
Donald Kerr 2008-08-07 15:38:37 +00:00
родитель f09dc4be31
Коммит 7654e8fdf4
4 изменённых файлов: 270 добавлений и 0 удалений

26
opal/mca/memory/malloc_solaris/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,26 @@
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2007-2008 Sun Microsystems, Inc. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
noinst_LTLIBRARIES = libmca_memory_malloc_solaris.la
# Source code files
libmca_memory_malloc_solaris_la_SOURCES = \
memory_malloc_solaris_component.c
libmca_memory_malloc_solaris_la_LIBADD = \
$(memory_malloc_solaris_LIBS)

100
opal/mca/memory/malloc_solaris/configure.m4 Обычный файл
Просмотреть файл

@ -0,0 +1,100 @@
# -*- shell-script -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2007-2008 Sun Microsystems, Inc. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
AC_DEFUN([MCA_memory_malloc_solaris_COMPILE_MODE], [
AC_MSG_CHECKING([for MCA component $2:$3 compile mode])
$4="static"
AC_MSG_RESULT([$$4])
])
# MCA_memory_malloc_solaris_CONFIG(action-if-can-compile,
# [action-if-cant-compile])
# ------------------------------------------------
AC_DEFUN([MCA_memory_malloc_solaris_CONFIG],[
OMPI_VAR_SCOPE_PUSH([memory_malloc_solaris_happy],
[memory_malloc_solaris_should_use],
[memory_malloc_solaris_munmap])
AC_MSG_CHECKING([for Solaris])
case "$host" in
*solaris*)
AC_MSG_RESULT([yes])
AS_IF([test "$with_memory_manager" = "malloc_solaris"],
[memory_malloc_solaris_happy="yes"
memory_malloc_solaris_should_use=1],
[memory_malloc_solaris_should_use=0
AS_IF([test "$with_memory_manager" = ""],
[memory_malloc_solaris_happy="yes"],
[memory_malloc_solaris_happy="no"])])
AS_IF([test "$memory_malloc_solaris_happy" = "yes"],
[AC_CHECK_HEADER([malloc.h], [],
[memory_malloc_solaris_happy="no"])])
AS_IF([test "$memory_malloc_solaris_happy" = "yes"],
[memory_malloc_solaris_munmap=0
AC_CHECK_HEADER([sys/syscall.h],
[AC_CHECK_FUNCS([syscall],
[memory_malloc_solaris_munmap=1])])
AC_CHECK_FUNCS([__munmap], [memory_malloc_solaris_munmap=1])
# only allow dlsym (and therefore add -ldl) if we
# really need to
AS_IF([test "$memory_malloc_solaris_munmap" = "0"],
[memory_malloc_solaris_LIBS_SAVE="$LIBS"
AC_CHECK_LIB([dl],
[dlsym],
[memory_malloc_solaris_LIBS="-ldl"
memory_malloc_solaris_munmap=1])
AC_CHECK_FUNCS([dlsym])
LIBS="$memory_malloc_solaris_LIBS_SAVE"])
AS_IF([test "$memory_malloc_solaris_munmap" = "0"],
[memory_malloc_solaris_happy="no"])])
AS_IF([test "$memory_malloc_solaris_happy" = "yes"],
[memory_malloc_solaris_WRAPPER_EXTRA_LIBS="$memory_malloc_solaris_LIBS"])
AS_IF([test "$memory_malloc_solaris_happy" = "no" -a \
"$memory_malloc_solaris_should_use" = "1"],
[AC_MSG_ERROR([malloc_solaris memory management requested but not available. Aborting.])])
AC_SUBST(memory_malloc_solaris_LIBS)
AS_IF([test "$memory_malloc_solaris_happy" = "yes"],
[memory_base_found=1
$1], [$2])
;;
*)
AC_MSG_RESULT([no])
AS_IF([test "$with_memory_manager" = "malloc_solaris"],
[memory_malloc_solaris_happy="no"
memory_malloc_solaris_should_use=0])
;;
esac
OMPI_VAR_SCOPE_POP
])

Просмотреть файл

@ -0,0 +1,24 @@
# -*- shell-script -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2007-2008 Sun Microsystems, Inc. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
# Specific to this module
PARAM_CONFIG_PRIORITY=0
PARAM_CONFIG_FILES="Makefile"

Просмотреть файл

@ -0,0 +1,120 @@
/*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007-2008 Sun Microsystems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "opal_config.h"
#include "opal/mca/memory/memory.h"
#include "opal/memoryhooks/memory_internal.h"
#include "opal/constants.h"
#include <sys/types.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <dlfcn.h>
#if defined(HAVE___MUNMAP)
/* here so we only include others if we absolutely have to */
#elif defined(HAVE_SYSCALL)
#include <sys/syscall.h>
#include <unistd.h>
#endif
#if defined(HAVE___MUNMAP)
int __munmap(caddr_t addr, size_t len);
#endif
static int opal_memory_malloc_open(void);
const opal_memory_base_component_2_0_0_t mca_memory_malloc_solaris_component = {
/* First, the mca_component_t struct containing meta information
about the component itself */
{
OPAL_MEMORY_BASE_VERSION_2_0_0,
/* Component name and version */
"malloc_solaris",
OPAL_MAJOR_VERSION,
OPAL_MINOR_VERSION,
OPAL_RELEASE_VERSION,
/* Component open and close functions */
opal_memory_malloc_open,
NULL
},
{
/* The component is checkpoint ready */
MCA_BASE_METADATA_PARAM_CHECKPOINT
},
};
/*
* This component exists to establish the memory hook support
* level available on Solaris. By default Solaris does not
* return memory to the system, i.e. does not unmap memory
* from the process space, when a user calls free(). This allows
* us to declare OPAL_MEMORY_FREE_SUPPORT. Additionally, by
* intercepting munmap we can declare OPAL_MEMORY_MUNMAP_SUPPORT.
*
* NOTE: Not releasing memory back to the system when calling
* free() may be unique to Solaris which is why this component
* was created.
*/
static int
opal_memory_malloc_open(void)
{
opal_mem_hooks_set_support(
(OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_MUNMAP_SUPPORT));
return OPAL_SUCCESS;
}
/*
* Three ways to call munmap. Prefered is to call __munmap, which
* will exist if munmap is a weak symbol. If not available next try
* the syscall, and if that doesn't work, try looking in the dynamic
* libc.
*/
int
munmap(caddr_t addr, size_t len)
{
#if !defined(HAVE___MUNMAP) && \
!defined(HAVE_SYSCALL) && defined(HAVE_DLSYM)
static int (*realmunmap)(void*, size_t);
#endif
opal_mem_hooks_release_hook(addr, len, 0);
#if defined(HAVE___MUNMAP)
return __munmap(addr, len);
#elif defined(HAVE_SYSCALL)
return syscall(SYS_munmap, addr, len);
#elif defined(HAVE_DLSYM)
if (NULL == realmunmap) {
union {
int (*munmap_fp)(void*, size_t);
void *munmap_p;
} tmp;
tmp.munmap_p = dlsym(RTLD_NEXT, "munmap");
realmunmap = tmp.munmap_fp;
}
return realmunmap(addr, len);
#else
#error "Can not determine how to call munmap"
#endif
}