2004-06-15 20:56:35 +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.
|
2006-08-24 20:38:08 +04:00
|
|
|
* Copyright (c) 2004-2006 The University of Tennessee and The University
|
2005-11-05 22:57:48 +03:00
|
|
|
* 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 20:56:35 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
/**
|
2004-07-13 00:05:29 +04:00
|
|
|
* @file
|
|
|
|
* The public definition of the MCA Allocator framework.
|
2004-06-15 20:56:35 +04:00
|
|
|
*/
|
|
|
|
#ifndef MCA_ALLOCATOR_H
|
|
|
|
#define MCA_ALLOCATOR_H
|
2009-03-12 23:27:16 +03:00
|
|
|
|
2009-03-04 18:35:54 +03:00
|
|
|
#include "ompi_config.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "opal/mca/mca.h"
|
|
|
|
#include "ompi/mca/mpool/mpool.h"
|
2004-06-15 20:56:35 +04:00
|
|
|
|
2009-01-27 22:19:04 +03:00
|
|
|
BEGIN_C_DECLS
|
2005-06-21 21:10:28 +04:00
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
/* Here so that we can use mca_allocator_base_module_t in the function typedefs */
|
|
|
|
struct mca_allocator_base_module_t;
|
2004-06-15 20:56:35 +04:00
|
|
|
|
|
|
|
/**
|
2005-05-31 23:07:27 +04:00
|
|
|
* The allocate function typedef for the function to be provided by the component.
|
2004-06-15 20:56:35 +04:00
|
|
|
*/
|
2005-06-21 21:10:28 +04:00
|
|
|
typedef void* (*mca_allocator_base_module_alloc_fn_t)(
|
|
|
|
struct mca_allocator_base_module_t*,
|
|
|
|
size_t size,
|
|
|
|
size_t align,
|
2005-06-25 01:12:38 +04:00
|
|
|
mca_mpool_base_registration_t** registration);
|
2004-06-15 20:56:35 +04:00
|
|
|
|
|
|
|
/**
|
2004-07-13 00:05:29 +04:00
|
|
|
* The realloc function typedef
|
2004-06-15 20:56:35 +04:00
|
|
|
*/
|
2005-06-21 21:10:28 +04:00
|
|
|
typedef void* (*mca_allocator_base_module_realloc_fn_t)(
|
|
|
|
struct mca_allocator_base_module_t*,
|
|
|
|
void*, size_t,
|
2005-06-25 01:12:38 +04:00
|
|
|
mca_mpool_base_registration_t** registration);
|
2004-06-15 20:56:35 +04:00
|
|
|
|
|
|
|
/**
|
2004-07-13 00:05:29 +04:00
|
|
|
* Free function typedef
|
2004-06-15 20:56:35 +04:00
|
|
|
*/
|
2005-06-21 21:10:28 +04:00
|
|
|
typedef void(*mca_allocator_base_module_free_fn_t)(
|
|
|
|
struct mca_allocator_base_module_t*, void *);
|
2004-06-15 20:56:35 +04:00
|
|
|
|
|
|
|
|
2004-07-13 00:05:29 +04:00
|
|
|
/**
|
2004-06-17 00:59:06 +04:00
|
|
|
* compact/return memory to higher level allocator
|
|
|
|
*/
|
|
|
|
|
2004-10-20 02:00:19 +04:00
|
|
|
typedef int (*mca_allocator_base_module_compact_fn_t)(
|
2004-08-02 04:24:22 +04:00
|
|
|
struct mca_allocator_base_module_t* allocator
|
2004-06-17 00:59:06 +04:00
|
|
|
);
|
|
|
|
|
|
|
|
|
2004-07-13 00:05:29 +04:00
|
|
|
/**
|
2004-06-17 00:59:06 +04:00
|
|
|
* cleanup (free) any resources held by allocator
|
|
|
|
*/
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
typedef int (*mca_allocator_base_module_finalize_fn_t)(
|
|
|
|
struct mca_allocator_base_module_t* allocator
|
2004-06-15 20:56:35 +04:00
|
|
|
);
|
|
|
|
|
2004-07-13 00:05:29 +04:00
|
|
|
/**
|
|
|
|
* The data structure for each component.
|
|
|
|
*/
|
2004-08-02 04:24:22 +04:00
|
|
|
struct mca_allocator_base_module_t {
|
|
|
|
mca_allocator_base_module_alloc_fn_t alc_alloc;
|
|
|
|
/**< Allocate memory */
|
|
|
|
mca_allocator_base_module_realloc_fn_t alc_realloc;
|
|
|
|
/**< Reallocate memory */
|
|
|
|
mca_allocator_base_module_free_fn_t alc_free;
|
|
|
|
/**< Free memory */
|
2004-10-20 02:00:19 +04:00
|
|
|
mca_allocator_base_module_compact_fn_t alc_compact;
|
2004-08-02 04:24:22 +04:00
|
|
|
/**< Return memory */
|
2005-06-21 21:10:28 +04:00
|
|
|
mca_allocator_base_module_finalize_fn_t alc_finalize;
|
2004-08-02 04:24:22 +04:00
|
|
|
/**< Finalize and free everything */
|
2005-06-21 21:10:28 +04:00
|
|
|
/* memory pool and resources */
|
|
|
|
struct mca_mpool_base_module_t* alc_mpool;
|
2004-06-15 20:56:35 +04:00
|
|
|
};
|
2004-07-13 00:05:29 +04:00
|
|
|
/**
|
|
|
|
* Convenience typedef.
|
|
|
|
*/
|
2004-08-02 04:24:22 +04:00
|
|
|
typedef struct mca_allocator_base_module_t mca_allocator_base_module_t;
|
2004-06-15 20:56:35 +04:00
|
|
|
|
|
|
|
|
2004-06-15 21:19:11 +04:00
|
|
|
/**
|
2004-07-13 00:05:29 +04:00
|
|
|
* A function to get more memory from the system. This function is to be
|
|
|
|
* provided by the module to the allocator framework.
|
2004-06-15 21:19:11 +04:00
|
|
|
*/
|
|
|
|
|
2005-06-21 21:10:28 +04:00
|
|
|
typedef void* (*mca_allocator_base_component_segment_alloc_fn_t)(
|
|
|
|
struct mca_mpool_base_module_t* module,
|
|
|
|
size_t* size,
|
2005-06-25 01:12:38 +04:00
|
|
|
mca_mpool_base_registration_t** registration);
|
2004-06-15 21:19:11 +04:00
|
|
|
|
|
|
|
/**
|
2004-07-13 00:05:29 +04:00
|
|
|
* A function to free memory from the control of the allocator framework
|
|
|
|
* back to the system. This function is to be provided by the module to the
|
2009-01-27 22:19:04 +03:00
|
|
|
* allocator framework.
|
2004-06-15 21:19:11 +04:00
|
|
|
*/
|
2007-03-22 04:00:34 +03:00
|
|
|
typedef void (*mca_allocator_base_component_segment_free_fn_t)(
|
2005-06-21 21:10:28 +04:00
|
|
|
struct mca_mpool_base_module_t* module,
|
|
|
|
void* segment);
|
2004-06-15 21:19:11 +04:00
|
|
|
|
|
|
|
|
2004-06-15 20:56:35 +04:00
|
|
|
/**
|
2004-08-02 04:24:22 +04:00
|
|
|
* The function used to initialize the component.
|
2004-06-15 20:56:35 +04:00
|
|
|
*/
|
2005-03-27 17:05:23 +04:00
|
|
|
typedef struct mca_allocator_base_module_t*
|
|
|
|
(*mca_allocator_base_component_init_fn_t)(
|
|
|
|
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-15 20:56:35 +04:00
|
|
|
);
|
|
|
|
|
2004-07-13 00:05:29 +04:00
|
|
|
/**
|
|
|
|
* The data structure provided by each component to the framework which
|
|
|
|
* describes the component.
|
|
|
|
*/
|
2008-07-29 02:40:57 +04:00
|
|
|
struct mca_allocator_base_component_2_0_0_t {
|
2004-08-02 04:24:22 +04:00
|
|
|
mca_base_component_t allocator_version;
|
|
|
|
/**< The version of the component */
|
2008-07-29 02:40:57 +04:00
|
|
|
mca_base_component_data_t allocator_data;
|
2004-08-02 04:24:22 +04:00
|
|
|
/**< The component metadata */
|
|
|
|
mca_allocator_base_component_init_fn_t allocator_init;
|
|
|
|
/**< The component initialization function. */
|
2004-06-15 20:56:35 +04:00
|
|
|
};
|
2004-08-02 04:24:22 +04:00
|
|
|
|
2004-07-13 00:05:29 +04:00
|
|
|
/**
|
|
|
|
* Convenience typedef.
|
|
|
|
*/
|
2008-07-29 02:40:57 +04:00
|
|
|
typedef struct mca_allocator_base_component_2_0_0_t mca_allocator_base_component_t;
|
2004-06-15 20:56:35 +04:00
|
|
|
|
2004-07-13 00:05:29 +04:00
|
|
|
/**
|
2008-07-29 02:40:57 +04:00
|
|
|
* Macro for use in components that are of type allocator
|
2004-06-16 02:03:54 +04:00
|
|
|
*/
|
2008-07-29 02:40:57 +04:00
|
|
|
#define MCA_ALLOCATOR_BASE_VERSION_2_0_0 \
|
|
|
|
MCA_BASE_VERSION_2_0_0, \
|
|
|
|
"allocator", 2, 0, 0
|
2004-06-16 02:03:54 +04:00
|
|
|
|
2009-01-27 22:19:04 +03:00
|
|
|
END_C_DECLS
|
|
|
|
|
2004-06-15 20:56:35 +04:00
|
|
|
#endif /* MCA_ALLOCATOR_H */
|
|
|
|
|