1
1

* updates to make Darwin malloc intercept code work properly in Open MPI

This commit was SVN r6873.
Этот коммит содержится в:
Brian Barrett 2005-08-14 17:24:57 +00:00
родитель 18bed00b9d
Коммит 3b9cc73d08
7 изменённых файлов: 161 добавлений и 37 удалений

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

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

@ -1,42 +1,36 @@
# -*- makefile -*-
#
# Copyright (c) 2001-2004 The Trustees of Indiana University.
# Copyright (c) 2004-2005 The Trustees of Indiana University.
# All rights reserved.
# Copyright (c) 1998-2001 University of Notre Dame.
# Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
# All rights reserved.
# Copyright (c) 1994-1998 The Ohio State University.
# 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$
#
# This file is part of the LAM/MPI software package. For license
# information, see the LICENSE file in the top level directory of the
# LAM/MPI source distribution.
#
# See APPLE_LICENSE file included in this directory for additional notices
# about the original ptmalloc package.
# Additional copyrights may follow
#
# $HEADER$
#
include $(top_srcdir)/config/Makefile.options
AM_CPPFLAGS = \
-I$(top_srcdir)/src \
-I$(top_lam_builddir)/share/include \
-I$(top_lam_srcdir)/share/include
# Apple requires us to include the copyright notice in the software.
# So install it in the same place that we install ROMIO's copyright
# notices.
docdir = $(datadir)/lam/doc
docdir = $(datadir)/openmpi/doc
doc_DATA = APPLE_LICENSE
if LAM_WANT_DARWIN7MALLOC
noinst_LTLIBRARIES = libdarwin7malloc.la
endif
noinst_LTLIBRARIES = libmca_memory_darwin7.la
libdarwin7malloc_la_SOURCES = \
libmca_memory_darwin7_la_SOURCES = \
pthread_machdep.h \
pthread_spinlock.h \
scalable_malloc.c \
scalable_malloc.h
scalable_malloc.h \
darwin7_component.c \
darwin7_munmap.c
EXTRA_DIST = \
$(doc_DATA)

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

@ -31,5 +31,33 @@ AC_DEFUN([MCA_memory_darwin7_CONFIG],[
[Use TYPE for intercepting memory management
calls to control memory pinning.])])
$2
# First, a mistaken user test
AS_IF([test "$with_memory_manager" = "darwin7"],
[AS_IF([test "`echo $host | grep apple-darwin`" == ""],
[AC_MSG_WARN([*** Using Dawrin malloc while not on Darwin system will not work.])
AC_MSG_ERROR([*** Aborting to save you the effort])])])
AS_IF([test "$with_memory_manager" = "darwin7"],
[memory_darwin7_happy="yes"
memory_darwin7_should_use=1],
[memory_darwin7_should_use=0
AS_IF([test "$with_memory_manager" = ""],
[ # make this "yes" if we ever want to be default
memory_darwin7_happy="no"],
[memory_darwin7_happy="no"])])
# disable if we aren't on Darwin
AS_IF([test "$memory_darwin7_happy" = "yes"],
[AS_IF([test "`echo $host | grep apple-darwin`" == ""],
[memory_darwin7_happy="no"])])
AS_IF([test "$memory_darwin7_happy" = "no" -a \
"$memory_darwin7_should_use" = "1"],
[AC_MSG_ERROR([Darwin7 memory management requested but not available. Aborting.])])
AS_IF([test "$memory_darwin7_happy" = "yes"],
[memory_darwin7_WRAPPER_ALWAYS_EXTRA_LDFLAGS="-Wl,-u,_opal_darwin_malloc_linker_hack -Wl,-multiply_defined,suppress -Wl,-force_flat_namespace -Wl,-flat_namespace"
memory_darwin7_LIBMPI_ALWAYS_EXTRA_LDFLAGS="-Wl,-multiply_defined,suppress"
$1],
[$2])
])

61
opal/mca/memory/darwin7/darwin7_component.c Обычный файл
Просмотреть файл

@ -0,0 +1,61 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* 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$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include "opal/memory/memory_internal.h"
#include "opal/mca/memory/memory.h"
#include "opal/include/opal_constants.h"
static int
darwin7_open(void)
{
/* there isn't a good "init hook" exposed in the way we did the
Darwin 7 intercept code. This should provde "good enough" - if
we got this far, the linker hasn't killed anyone yet (Darwin
has a mean, vengeful linker), so the rest of the code is most
likely also along for the ride */
opal_mem_free_set_free_support(1);
return OPAL_SUCCESS;
}
const opal_memory_base_component_1_0_0_t mca_memory_darwin7_component = {
/* First, the mca_component_t struct containing meta information
about the component itself */
{
/* Indicate that we are a memory v1.0.0 component (which also
implies a specific MCA version) */
OPAL_MEMORY_BASE_VERSION_1_0_0,
/* Component name and version */
"darwin7",
OPAL_MAJOR_VERSION,
OPAL_MINOR_VERSION,
OPAL_RELEASE_VERSION,
/* Component open and close functions */
darwin7_open,
NULL
},
/* Next the MCA v1.0.0 component meta data */
{
/* Whether the component is checkpointable or not */
true
},
};

41
opal/mca/memory/darwin7/darwin7_munmap.c Обычный файл
Просмотреть файл

@ -0,0 +1,41 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* 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$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include <sys/types.h>
#include "opal/memory/memory_internal.h"
#include <stdlib.h>
#include <sys/mman.h>
#include <dlfcn.h>
/* munmap is a weak symbol on any platform that I know of that
supports malloc hooks, so we can just intercept it like this... */
int
munmap(void* addr, size_t len)
{
static int (*realmunmap)(void*, size_t);
/* dispatch about the pending release */
opal_mem_free_release_hook(addr, len);
if (NULL == realmunmap) {
realmunmap = (int (*)(void*, size_t)) dlsym(RTLD_NEXT, "munmap");
}
return realmunmap(addr, len);
}

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

@ -51,12 +51,12 @@
/*
* Changes from original file:
* LAM/MPI team, June 2004
* Open MPI team, August 2005
*
* - changed include files to allow building without Darwin internal
* source files
*
* Changes marked with LAM/MPI comment in source code
* Changes marked with Open MPI comment in source code
*/
#ifndef _POSIX_PTHREAD_SPINLOCK_H
@ -64,9 +64,9 @@
#include <mach/mach.h>
#define __APPLE_API_PRIVATE
#if 0 /* LAM/MPI Change */
#if 0 /* Open MPI Change */
#include <machine/cpu_capabilities.h>
#endif /* LAM/MPI Change */
#endif /* Open MPI Change */
#ifndef __POSIX_LIB__
#define __POSIX_LIB__

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

@ -25,19 +25,19 @@
/*
* Changes from original file:
* LAM/MPI team, June 2004
* Open MPI team, August 2005
*
* - changed include files to allow building without Darwin internal
* source files
* - Added hook into deallocation algorithm to call LAM/MPI
* - Added hook into deallocation algorithm to call Open MPI
* deregistration function
*
* Changes marked with LAM/MPI comment in source code
* Changes marked with Open MPI comment in source code
*/
#import "scalable_malloc.h"
#if 0 /* LAM/MPI */
#if 0 /* Open MPI */
#import <pthread_internals.h>
#endif /* #if 0 */
@ -45,13 +45,11 @@
#import <libc.h>
#include <mach/vm_statistics.h>
/* LAM/MPI - begin changes */
/* Open MPI - begin changes */
#include <mach/mach_init.h>
#include <machine/byte_order.h>
#include "pthread_spinlock.h"
#include "lam_config.h"
#include "malloc_wrapper.h"
#include "opal/memory/memory_internal.h"
/*
* Need to convince the linker that we need this version of this file,
@ -59,7 +57,7 @@
* we instruct the linker to pull in first (and is in the call stack from
* MPI_Init().
*/
void lam_darwin_malloc_linker_hack()
void opal_darwin_malloc_linker_hack()
{
/* need to do some work to keep us from getting optimized away */
}
@ -68,7 +66,7 @@ void lam_darwin_malloc_linker_hack()
#define __PRETTY_FUNCTION__ ""
#endif
/* LAM/MPI - end changes */
/* Open MPI - end changes */
/********************* DEFINITIONS ************************/
@ -397,7 +395,9 @@ deallocate_pages(szone_t *szone, vm_address_t addr, size_t size, unsigned debug_
addr -= 1 << vm_page_shift;
size += 2 * (1 << vm_page_shift);
}
lam_handle_free((void*) addr, size);
/* Open MPI change */
opal_mem_free_release_hook((void*) addr, size);
/* Open MPI change */
err = vm_deallocate(mach_task_self(), addr, size);
if (err) {
szone_error(szone, "Can't deallocate_pages region", (void *)addr);