2004-11-22 03:37:56 +03: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-11-22 03:37:56 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-10-20 05:03:09 +04:00
|
|
|
#include "ompi_config.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "ompi/mca/allocator/allocator.h"
|
|
|
|
#include "ompi/constants.h"
|
|
|
|
#include "opal/mca/base/mca_base_param.h"
|
|
|
|
#include "ompi/mca/allocator/bucket/allocator_bucket_alloc.h"
|
|
|
|
#include "ompi/mca/mpool/mpool.h"
|
2004-06-16 19:53:55 +04:00
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
struct mca_allocator_base_module_t* mca_allocator_bucket_module_init(
|
2005-03-27 17:05:23 +04:00
|
|
|
bool enable_mpi_threads,
|
2004-08-02 04:24:22 +04:00
|
|
|
mca_allocator_base_component_segment_alloc_fn_t segment_alloc,
|
2005-05-31 21:06:55 +04:00
|
|
|
mca_allocator_base_component_segment_free_fn_t segment_free,
|
2005-06-21 21:10:28 +04:00
|
|
|
struct mca_mpool_base_module_t* mpool
|
2005-05-31 21:06:55 +04:00
|
|
|
);
|
2004-06-16 19:53:55 +04:00
|
|
|
|
|
|
|
int mca_allocator_bucket_module_open(void);
|
|
|
|
|
|
|
|
int mca_allocator_bucket_module_close(void);
|
|
|
|
|
2005-06-21 21:10:28 +04:00
|
|
|
void * mca_allocator_bucket_alloc_wrapper(
|
|
|
|
struct mca_allocator_base_module_t* allocator,
|
|
|
|
size_t size, size_t align,
|
2005-06-25 01:12:38 +04:00
|
|
|
mca_mpool_base_registration_t** registration);
|
2005-06-21 21:10:28 +04:00
|
|
|
|
2004-06-17 00:59:06 +04:00
|
|
|
static int mca_allocator_num_buckets;
|
|
|
|
|
|
|
|
|
2004-06-16 19:53:55 +04:00
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
int mca_allocator_bucket_finalize(struct mca_allocator_base_module_t* allocator)
|
2004-06-24 20:47:00 +04:00
|
|
|
{
|
|
|
|
mca_allocator_bucket_cleanup(allocator);
|
|
|
|
free(allocator);
|
|
|
|
return(OMPI_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
struct mca_allocator_base_module_t* mca_allocator_bucket_module_init(
|
2005-03-27 17:05:23 +04:00
|
|
|
bool enable_mpi_threads,
|
2004-08-02 04:24:22 +04:00
|
|
|
mca_allocator_base_component_segment_alloc_fn_t segment_alloc,
|
2005-05-31 21:06:55 +04:00
|
|
|
mca_allocator_base_component_segment_free_fn_t segment_free,
|
2005-06-21 21:10:28 +04:00
|
|
|
struct mca_mpool_base_module_t* mpool)
|
2004-06-16 19:53:55 +04:00
|
|
|
{
|
|
|
|
size_t alloc_size = sizeof(mca_allocator_bucket_t);
|
|
|
|
mca_allocator_bucket_t * retval;
|
2005-05-09 20:23:00 +04:00
|
|
|
mca_allocator_bucket_t * allocator = (mca_allocator_bucket_t *) malloc(alloc_size);
|
2004-06-16 19:53:55 +04:00
|
|
|
if(NULL == allocator) {
|
|
|
|
return(NULL);
|
|
|
|
}
|
2005-06-21 21:10:28 +04:00
|
|
|
retval = mca_allocator_bucket_init((mca_allocator_base_module_t *) allocator,
|
|
|
|
mca_allocator_num_buckets,
|
|
|
|
segment_alloc,
|
|
|
|
segment_free);
|
2004-06-16 19:53:55 +04:00
|
|
|
if(NULL == retval) {
|
2004-06-18 00:33:52 +04:00
|
|
|
free(allocator);
|
2004-06-16 19:53:55 +04:00
|
|
|
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;
|
2004-10-20 02:00:19 +04:00
|
|
|
allocator->super.alc_compact = mca_allocator_bucket_cleanup;
|
2004-06-24 20:47:00 +04:00
|
|
|
allocator->super.alc_finalize = mca_allocator_bucket_finalize;
|
2005-06-21 21:10:28 +04:00
|
|
|
allocator->super.alc_mpool = mpool;
|
2004-08-02 04:24:22 +04:00
|
|
|
return((mca_allocator_base_module_t *) allocator);
|
2004-06-16 19:53:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int mca_allocator_bucket_module_open(void) {
|
|
|
|
|
2004-06-17 00:59:06 +04:00
|
|
|
int id = mca_base_param_register_int("allocator","bucket","num_buckets", NULL,30);
|
|
|
|
mca_base_param_lookup_int(id,&mca_allocator_num_buckets);
|
2004-06-16 19:53:55 +04:00
|
|
|
return(OMPI_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
int mca_allocator_bucket_module_close(void) {
|
|
|
|
return(OMPI_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2005-06-21 21:10:28 +04:00
|
|
|
void * mca_allocator_bucket_alloc_wrapper(
|
|
|
|
struct mca_allocator_base_module_t* allocator,
|
|
|
|
size_t size,
|
|
|
|
size_t align,
|
2005-06-25 01:12:38 +04:00
|
|
|
mca_mpool_base_registration_t** registration)
|
2004-06-16 19:53:55 +04:00
|
|
|
{
|
|
|
|
if(0 == align){
|
2005-06-21 21:10:28 +04:00
|
|
|
return(mca_allocator_bucket_alloc(allocator, size, registration));
|
2004-06-16 19:53:55 +04:00
|
|
|
}
|
2005-06-21 21:10:28 +04:00
|
|
|
return(mca_allocator_bucket_alloc_align(allocator, size, align, registration));
|
2004-06-16 19:53:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
mca_allocator_base_component_t mca_allocator_bucket_component = {
|
|
|
|
|
|
|
|
/* First, the mca_base_module_t struct containing meta information
|
|
|
|
about the module itself */
|
|
|
|
|
|
|
|
{
|
2004-06-16 19:53:55 +04:00
|
|
|
/* Indicate that we are a allocator v1.0.0 module (which also implies a
|
|
|
|
specific MCA version) */
|
|
|
|
|
|
|
|
MCA_ALLOCATOR_BASE_VERSION_1_0_0,
|
|
|
|
|
|
|
|
"bucket", /* MCA module name */
|
|
|
|
1, /* MCA module major version */
|
|
|
|
0, /* MCA module minor version */
|
|
|
|
0, /* MCA module release version */
|
|
|
|
mca_allocator_bucket_module_open, /* module open */
|
|
|
|
mca_allocator_bucket_module_close /* module close */
|
2004-08-02 04:24:22 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
/* Next the MCA v1.0.0 module meta data */
|
2004-06-16 19:53:55 +04:00
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
{
|
2004-06-16 19:53:55 +04:00
|
|
|
/* Whether the module is checkpointable or not */
|
|
|
|
false
|
2004-08-02 04:24:22 +04:00
|
|
|
},
|
|
|
|
mca_allocator_bucket_module_init
|
2004-06-16 19:53:55 +04:00
|
|
|
};
|
|
|
|
|