1
1
openmpi/ompi/mca/allocator/bucket/allocator_bucket.c
Nathan Hjelm cf377db823 MCA/base: Add new MCA variable system
Features:
 - Support for an override parameter file (openmpi-mca-param-override.conf).
   Variable values in this file can not be overridden by any file or environment
   value.
 - Support for boolean, unsigned, and unsigned long long variables.
 - Support for true/false values.
 - Support for enumerations on integer variables.
 - Support for MPIT scope, verbosity, and binding.
 - Support for command line source.
 - Support for setting variable source via the environment using
   OMPI_MCA_SOURCE_<var name>=source (either command or file:filename)
 - Cleaner API.
 - Support for variable groups (equivalent to MPIT categories).

Notes:
 - Variables must be created with a backing store (char **, int *, or bool *)
   that must live at least as long as the variable.
 - Creating a variable with the MCA_BASE_VAR_FLAG_SETTABLE enables the use of
   mca_base_var_set_value() to change the value.
 - String values are duplicated when the variable is registered. It is up to
   the caller to free the original value if necessary. The new value will be
   freed by the mca_base_var system and must not be freed by the user.
 - Variables with constant scope may not be settable.
 - Variable groups (and all associated variables) are deregistered when the
   component is closed or the component repository item is freed. This
   prevents a segmentation fault from accessing a variable after its component
   is unloaded.
 - After some discussion we decided we should remove the automatic registration
   of component priority variables. Few component actually made use of this
   feature.
 - The enumerator interface was updated to be general enough to handle
   future uses of the interface.
 - The code to generate ompi_info output has been moved into the MCA variable
   system. See mca_base_var_dump().

opal: update core and components to mca_base_var system
orte: update core and components to mca_base_var system
ompi: update core and components to mca_base_var system

This commit also modifies the rmaps framework. The following variables were
moved from ppr and lama: rmaps_base_pernode, rmaps_base_n_pernode,
rmaps_base_n_persocket. Both lama and ppr create synonyms for these variables.

This commit was SVN r28236.
2013-03-27 21:09:41 +00:00

136 строки
4.5 KiB
C

/*
* 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) 2008 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include "ompi/mca/allocator/allocator.h"
#include "ompi/constants.h"
#include "ompi/mca/allocator/bucket/allocator_bucket_alloc.h"
#include "ompi/mca/mpool/mpool.h"
struct mca_allocator_base_module_t* mca_allocator_bucket_module_init(
bool enable_mpi_threads,
mca_allocator_base_component_segment_alloc_fn_t segment_alloc,
mca_allocator_base_component_segment_free_fn_t segment_free,
struct mca_mpool_base_module_t* mpool
);
int mca_allocator_bucket_module_open(void);
int mca_allocator_bucket_module_close(void);
void * mca_allocator_bucket_alloc_wrapper(
struct mca_allocator_base_module_t* allocator,
size_t size, size_t align,
mca_mpool_base_registration_t** registration);
static int mca_allocator_num_buckets;
int mca_allocator_bucket_finalize(struct mca_allocator_base_module_t* allocator)
{
mca_allocator_bucket_cleanup(allocator);
free(allocator);
return(OMPI_SUCCESS);
}
struct mca_allocator_base_module_t* mca_allocator_bucket_module_init(
bool enable_mpi_threads,
mca_allocator_base_component_segment_alloc_fn_t segment_alloc,
mca_allocator_base_component_segment_free_fn_t segment_free,
struct mca_mpool_base_module_t* mpool)
{
size_t alloc_size = sizeof(mca_allocator_bucket_t);
mca_allocator_bucket_t * retval;
mca_allocator_bucket_t * allocator = (mca_allocator_bucket_t *) malloc(alloc_size);
if(NULL == allocator) {
return(NULL);
}
retval = mca_allocator_bucket_init((mca_allocator_base_module_t *) allocator,
mca_allocator_num_buckets,
segment_alloc,
segment_free);
if(NULL == retval) {
free(allocator);
return(NULL);
}
allocator->super.alc_alloc = mca_allocator_bucket_alloc_wrapper;
allocator->super.alc_realloc = mca_allocator_bucket_realloc;
allocator->super.alc_free = mca_allocator_bucket_free;
allocator->super.alc_compact = mca_allocator_bucket_cleanup;
allocator->super.alc_finalize = mca_allocator_bucket_finalize;
allocator->super.alc_mpool = mpool;
return((mca_allocator_base_module_t *) allocator);
}
static int mca_allocator_bucket_module_register(void) {
mca_allocator_num_buckets = 30;
(void) mca_base_component_var_register(&mca_allocator_bucket_component.allocator_version,
"num_buckets", NULL, MCA_BASE_VAR_TYPE_INT, NULL, 0,
MCA_BASE_VAR_FLAG_SETTABLE, OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_LOCAL, &mca_allocator_num_buckets);
return(OMPI_SUCCESS);
}
int mca_allocator_bucket_module_open(void) {
return(OMPI_SUCCESS);
}
int mca_allocator_bucket_module_close(void) {
return(OMPI_SUCCESS);
}
void * mca_allocator_bucket_alloc_wrapper(
struct mca_allocator_base_module_t* allocator,
size_t size,
size_t align,
mca_mpool_base_registration_t** registration)
{
if(0 == align){
return(mca_allocator_bucket_alloc(allocator, size, registration));
}
return(mca_allocator_bucket_alloc_align(allocator, size, align, registration));
}
mca_allocator_base_component_t mca_allocator_bucket_component = {
/* First, the mca_base_module_t struct containing meta information
about the module itself */
{
MCA_ALLOCATOR_BASE_VERSION_2_0_0,
"bucket", /* MCA module name */
OMPI_MAJOR_VERSION,
OMPI_MINOR_VERSION,
OMPI_RELEASE_VERSION,
mca_allocator_bucket_module_open, /* module open */
mca_allocator_bucket_module_close, /* module close */
NULL,
mca_allocator_bucket_module_register
},
{
/* The component is checkpoint ready */
MCA_BASE_METADATA_PARAM_CHECKPOINT
},
mca_allocator_bucket_module_init
};