2004-06-15 01:05:53 +04:00
|
|
|
/*
|
2005-11-05 22:57:48 +03: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 23:09:25 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-06-15 01:05:53 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2004-10-22 20:06:05 +04:00
|
|
|
#include "ompi_config.h"
|
2004-06-15 01:05:53 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "opal/mca/mca.h"
|
|
|
|
#include "opal/mca/base/base.h"
|
|
|
|
#include "ompi/mca/mpool/mpool.h"
|
|
|
|
#include "ompi/mca/mpool/base/base.h"
|
|
|
|
#include "ompi/constants.h"
|
2005-12-11 08:49:29 +03:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2005-09-27 06:01:21 +04:00
|
|
|
#include <unistd.h>
|
2005-12-11 08:49:29 +03:00
|
|
|
#endif /* HAVE_UNISTD_H */
|
2004-06-15 01:05:53 +04: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 04:24:22 +04:00
|
|
|
* component's public mca_base_component_t struct.
|
2004-06-15 01:05:53 +04:00
|
|
|
*/
|
2005-07-04 22:24:58 +04:00
|
|
|
#include "ompi/mca/mpool/base/static-components.h"
|
2004-06-15 01:05:53 +04:00
|
|
|
|
2006-06-08 08:29:27 +04:00
|
|
|
#include "mpool_base_tree.h"
|
2004-06-15 01:05:53 +04:00
|
|
|
/*
|
|
|
|
* Global variables
|
|
|
|
*/
|
2004-06-15 23:07:45 +04:00
|
|
|
int mca_mpool_base_output = -1;
|
2005-09-17 02:22:03 +04:00
|
|
|
int mca_mpool_base_use_mem_hooks = 0;
|
2006-01-24 01:51:50 +03:00
|
|
|
|
2006-02-23 07:30:24 +03:00
|
|
|
#if defined(HAVE_MALLOPT)
|
2006-01-24 01:51:50 +03:00
|
|
|
int mca_mpool_base_disable_sbrk = 0;
|
|
|
|
#endif
|
|
|
|
|
2005-09-27 06:01:21 +04:00
|
|
|
uint32_t mca_mpool_base_page_size;
|
|
|
|
uint32_t mca_mpool_base_page_size_log;
|
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_t mca_mpool_base_components;
|
|
|
|
opal_list_t mca_mpool_base_modules;
|
2004-06-15 01:05:53 +04:00
|
|
|
|
|
|
|
/**
|
2004-08-02 04:24:22 +04:00
|
|
|
* Function for finding and opening either all MCA components, or the one
|
2004-06-15 01:05:53 +04:00
|
|
|
* that was specifically requested via a MCA parameter.
|
|
|
|
*/
|
2004-06-15 23:07:45 +04:00
|
|
|
int mca_mpool_base_open(void)
|
2004-06-15 01:05:53 +04:00
|
|
|
{
|
2005-09-22 21:27:56 +04:00
|
|
|
/* Open up all available components - and populate the
|
|
|
|
mca_mpool_base_components list */
|
2006-03-23 19:15:50 +03:00
|
|
|
|
|
|
|
int use_mem_hooks;
|
2006-03-24 07:43:53 +03:00
|
|
|
#if defined(HAVE_MALLOPT)
|
2006-03-23 19:15:50 +03:00
|
|
|
int disable_sbrk;
|
2006-03-24 07:43:53 +03:00
|
|
|
#endif /* defined(HAVE_MALLOPT) */
|
2006-03-23 19:15:50 +03:00
|
|
|
|
2005-09-22 21:27:56 +04:00
|
|
|
if (OMPI_SUCCESS !=
|
|
|
|
mca_base_components_open("mpool", 0, mca_mpool_base_static_components,
|
2005-04-13 07:19:48 +04:00
|
|
|
&mca_mpool_base_components, true)) {
|
2005-09-22 21:27:56 +04:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
2005-09-17 02:22:03 +04:00
|
|
|
|
2005-09-22 21:27:56 +04: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-15 01:05:53 +04:00
|
|
|
|
2005-09-22 21:27:56 +04:00
|
|
|
OBJ_CONSTRUCT(&mca_mpool_base_modules, opal_list_t);
|
2005-09-17 02:22:03 +04:00
|
|
|
|
2005-09-22 21:27:56 +04:00
|
|
|
/*
|
|
|
|
* check for use_mem_hooks (for diagnostics/testing)
|
|
|
|
* however if leave_pinned is set we force this to be enabled
|
|
|
|
*/
|
2006-01-24 01:51:50 +03:00
|
|
|
mca_base_param_reg_int_name("mpool",
|
2006-03-23 19:15:50 +03:00
|
|
|
"base_use_mem_hooks",
|
|
|
|
"use memory hooks for deregistering freed memory",
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
0,
|
|
|
|
&mca_mpool_base_use_mem_hooks);
|
|
|
|
|
|
|
|
mca_base_param_reg_int_name("mpool",
|
|
|
|
"use_mem_hooks",
|
|
|
|
"(deprecated, use mpool_base_use_mem_hooks)",
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
0,
|
|
|
|
&use_mem_hooks);
|
|
|
|
|
|
|
|
mca_mpool_base_use_mem_hooks = use_mem_hooks || mca_mpool_base_use_mem_hooks;
|
|
|
|
|
|
|
|
|
2006-02-23 07:30:24 +03:00
|
|
|
#if defined(HAVE_MALLOPT)
|
2006-01-24 01:51:50 +03:00
|
|
|
mca_base_param_reg_int_name("mpool",
|
2006-03-23 19:15:50 +03:00
|
|
|
"base_disable_sbrk",
|
2006-01-24 01:51:50 +03:00
|
|
|
"use mallopt to override calling sbrk (doesn't return memory to OS!)",
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
0,
|
2006-03-23 19:15:50 +03:00
|
|
|
&mca_mpool_base_disable_sbrk);
|
|
|
|
|
|
|
|
mca_base_param_reg_int_name("mpool",
|
|
|
|
"disable_sbrk",
|
|
|
|
"(deprecated, use mca_mpool_base_disable_sbrk)",
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
0,
|
|
|
|
&disable_sbrk);
|
|
|
|
|
|
|
|
mca_mpool_base_disable_sbrk = disable_sbrk || mca_mpool_base_disable_sbrk;
|
|
|
|
|
2006-01-24 01:51:50 +03:00
|
|
|
#endif
|
2006-02-07 00:22:20 +03:00
|
|
|
|
2006-02-14 01:34:45 +03:00
|
|
|
/* force mem hooks if leave_pinned or leave_pinned_pipeline is enabled */
|
2006-02-23 07:30:24 +03:00
|
|
|
#if defined(HAVE_MALLOPT)
|
2006-02-07 00:22:20 +03:00
|
|
|
if(0 == mca_mpool_base_use_mem_hooks && 0 == mca_mpool_base_disable_sbrk) {
|
|
|
|
#else
|
2006-02-14 01:34:45 +03:00
|
|
|
if(0 == mca_mpool_base_use_mem_hooks ) {
|
2006-02-07 00:22:20 +03:00
|
|
|
#endif
|
2006-02-06 22:44:21 +03:00
|
|
|
int param;
|
|
|
|
mca_base_param_register_int("mpi", NULL, "leave_pinned", "leave_pinned", 0);
|
|
|
|
param = mca_base_param_find("mpi", NULL, "leave_pinned");
|
|
|
|
mca_base_param_lookup_int(param, &mca_mpool_base_use_mem_hooks);
|
2006-02-14 01:34:45 +03:00
|
|
|
|
|
|
|
if(0 == mca_mpool_base_use_mem_hooks) {
|
|
|
|
/* and now check leave_pinned_pipeline if necessary */
|
2006-03-23 18:57:34 +03:00
|
|
|
mca_base_param_register_int("mpi", NULL,
|
2006-02-14 01:34:45 +03:00
|
|
|
"leave_pinned_pipeline",
|
|
|
|
"leave_pinned_pipeline", 0);
|
2006-03-23 18:57:34 +03:00
|
|
|
param = mca_base_param_find("mpi", NULL, "leave_pinned_pipeline");
|
2006-02-14 01:34:45 +03:00
|
|
|
mca_base_param_lookup_int(param, &mca_mpool_base_use_mem_hooks);
|
|
|
|
}
|
|
|
|
}
|
2005-09-27 06:01:21 +04: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 08:29:27 +04:00
|
|
|
|
|
|
|
/* setup tree for tracking MPI_Alloc_mem */
|
|
|
|
mca_mpool_base_tree_init();
|
|
|
|
|
2005-09-22 21:27:56 +04:00
|
|
|
return OMPI_SUCCESS;
|
2004-06-15 01:05:53 +04:00
|
|
|
}
|
2005-09-14 06:17:04 +04:00
|
|
|
|