2004-06-14 21:05:53 +00:00
|
|
|
/*
|
2005-11-05 19:57:48 +00:00
|
|
|
* 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.
|
2004-11-28 20:09:25 +00:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 12:43:37 +00:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2008-07-24 22:51:26 +00:00
|
|
|
* Copyright (c) 2007-2008 Cisco Systems, Inc. All rights reserved.
|
2004-11-22 01:38:40 +00:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-06-14 21:05:53 +00:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2007-05-27 03:55:21 +00:00
|
|
|
#define OMPI_DISABLE_ENABLE_MEM_DEBUG 1
|
2004-10-22 16:06:05 +00:00
|
|
|
#include "ompi_config.h"
|
2007-05-27 03:55:21 +00:00
|
|
|
|
2004-06-14 21:05:53 +00:00
|
|
|
#include <stdio.h>
|
2007-05-27 03:55:21 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif /* HAVE_UNISTD_H */
|
|
|
|
#ifdef HAVE_MALLOC_H
|
|
|
|
#include <malloc.h>
|
|
|
|
#endif
|
2004-06-14 21:05:53 +00:00
|
|
|
|
2006-02-12 01:33:29 +00:00
|
|
|
#include "opal/mca/mca.h"
|
|
|
|
#include "opal/mca/base/base.h"
|
2008-06-13 22:32:49 +00:00
|
|
|
#include "opal/memoryhooks/memory.h"
|
2006-02-12 01:33:29 +00:00
|
|
|
#include "ompi/mca/mpool/mpool.h"
|
|
|
|
#include "ompi/mca/mpool/base/base.h"
|
|
|
|
#include "ompi/constants.h"
|
2004-06-14 21:05:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The following file was created by configure. It contains extern
|
|
|
|
* statements and the definition of an array of pointers to each
|
2004-08-02 00:24:22 +00:00
|
|
|
* component's public mca_base_component_t struct.
|
2004-06-14 21:05:53 +00:00
|
|
|
*/
|
2005-07-04 18:24:58 +00:00
|
|
|
#include "ompi/mca/mpool/base/static-components.h"
|
2004-06-14 21:05:53 +00:00
|
|
|
|
2006-06-08 04:29:27 +00:00
|
|
|
#include "mpool_base_tree.h"
|
2004-06-14 21:05:53 +00:00
|
|
|
/*
|
|
|
|
* Global variables
|
|
|
|
*/
|
2004-06-15 19:07:45 +00:00
|
|
|
int mca_mpool_base_output = -1;
|
2006-01-23 22:51:50 +00:00
|
|
|
|
2008-07-24 22:51:26 +00:00
|
|
|
/* whether we actually used the mem hooks or not */
|
|
|
|
int mca_mpool_base_used_mem_hooks = 0;
|
2008-06-13 22:32:49 +00:00
|
|
|
/* should we attempt to use the available memory hooks */
|
2008-07-24 22:51:26 +00:00
|
|
|
int mca_mpool_base_use_mem_hooks_index;
|
2008-06-13 22:32:49 +00:00
|
|
|
/* should we attempt to use mallopt to disable free() returning memory
|
|
|
|
to OS? */
|
2008-07-24 22:51:26 +00:00
|
|
|
int mca_mpool_base_disable_mallopt_index;
|
2006-01-23 22:51:50 +00:00
|
|
|
|
2005-09-27 02:01:21 +00:00
|
|
|
uint32_t mca_mpool_base_page_size;
|
|
|
|
uint32_t mca_mpool_base_page_size_log;
|
|
|
|
|
2005-07-03 16:22:16 +00:00
|
|
|
opal_list_t mca_mpool_base_components;
|
|
|
|
opal_list_t mca_mpool_base_modules;
|
2004-06-14 21:05:53 +00:00
|
|
|
|
|
|
|
/**
|
2004-08-02 00:24:22 +00:00
|
|
|
* Function for finding and opening either all MCA components, or the one
|
2004-06-14 21:05:53 +00:00
|
|
|
* that was specifically requested via a MCA parameter.
|
|
|
|
*/
|
2004-06-15 19:07:45 +00:00
|
|
|
int mca_mpool_base_open(void)
|
2004-06-14 21:05:53 +00:00
|
|
|
{
|
2005-09-22 17:27:56 +00:00
|
|
|
/* Open up all available components - and populate the
|
|
|
|
mca_mpool_base_components list */
|
2006-03-23 16:15:50 +00:00
|
|
|
|
2005-09-22 17:27:56 +00:00
|
|
|
if (OMPI_SUCCESS !=
|
|
|
|
mca_base_components_open("mpool", 0, mca_mpool_base_static_components,
|
2005-04-13 03:19:48 +00:00
|
|
|
&mca_mpool_base_components, true)) {
|
2005-09-22 17:27:56 +00:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
2005-09-16 22:22:03 +00:00
|
|
|
|
2005-09-22 17:27:56 +00:00
|
|
|
/* Initialize the list so that in mca_mpool_base_close(), we can
|
|
|
|
iterate over it (even if it's empty, as in the case of ompi_info) */
|
2004-06-14 21:05:53 +00:00
|
|
|
|
2005-09-22 17:27:56 +00:00
|
|
|
OBJ_CONSTRUCT(&mca_mpool_base_modules, opal_list_t);
|
2005-09-16 22:22:03 +00:00
|
|
|
|
2005-09-22 17:27:56 +00:00
|
|
|
/*
|
|
|
|
* check for use_mem_hooks (for diagnostics/testing)
|
|
|
|
* however if leave_pinned is set we force this to be enabled
|
|
|
|
*/
|
2008-07-24 22:51:26 +00:00
|
|
|
mca_mpool_base_use_mem_hooks_index =
|
|
|
|
mca_base_param_reg_int_name("mpool",
|
|
|
|
"base_use_mem_hooks",
|
|
|
|
"Use memory hooks for deregistering freed memory",
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
0,
|
|
|
|
NULL);
|
2008-07-29 13:05:39 +00:00
|
|
|
mca_base_param_reg_syn_name(mca_mpool_base_use_mem_hooks_index,
|
|
|
|
"mpool", "use_mem_hooks", true);
|
2006-03-23 16:15:50 +00:00
|
|
|
|
2008-07-24 22:51:26 +00:00
|
|
|
mca_mpool_base_disable_mallopt_index =
|
|
|
|
mca_base_param_reg_int_name("mpool",
|
|
|
|
"base_disable_mallopt",
|
|
|
|
"Do not use mallopt to disable returning memory to "
|
|
|
|
"the OS when leave_pinned is active and no memory "
|
|
|
|
"components are found (this value is only changable on Linux systems that support mallopt()).",
|
|
|
|
false,
|
2008-06-13 22:32:49 +00:00
|
|
|
#if OMPI_MPOOL_BASE_HAVE_LINUX_MALLOPT
|
2008-07-24 22:51:26 +00:00
|
|
|
false,
|
|
|
|
0,
|
2008-06-13 22:32:49 +00:00
|
|
|
#else
|
2008-07-24 22:51:26 +00:00
|
|
|
true,
|
|
|
|
1,
|
2006-01-23 22:51:50 +00:00
|
|
|
#endif
|
2008-07-24 22:51:26 +00:00
|
|
|
NULL);
|
2006-02-06 21:22:20 +00:00
|
|
|
|
2005-09-27 02:01:21 +00:00
|
|
|
/* get the page size for this architecture*/
|
|
|
|
mca_mpool_base_page_size = sysconf(_SC_PAGESIZE);
|
|
|
|
mca_mpool_base_page_size_log = my_log2(mca_mpool_base_page_size);
|
2006-06-08 04:29:27 +00:00
|
|
|
|
|
|
|
/* setup tree for tracking MPI_Alloc_mem */
|
|
|
|
mca_mpool_base_tree_init();
|
|
|
|
|
2005-09-22 17:27:56 +00:00
|
|
|
return OMPI_SUCCESS;
|
2004-06-14 21:05:53 +00:00
|
|
|
}
|
2005-09-14 02:17:04 +00:00
|
|
|
|