OpenMPI  0.1.1
allocator.h
Go to the documentation of this file.
1 /**
2  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3  * University Research and Technology
4  * Corporation. All rights reserved.
5  * Copyright (c) 2004-2006 The University of Tennessee and The University
6  * of Tennessee Research Foundation. All rights
7  * reserved.
8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9  * University of Stuttgart. All rights reserved.
10  * Copyright (c) 2004-2005 The Regents of the University of California.
11  * All rights reserved.
12  * $COPYRIGHT$
13  *
14  * Additional copyrights may follow
15  *
16  * $HEADER$
17  */
18 /**
19  * @file
20  * The public definition of the MCA Allocator framework.
21  */
22 #ifndef MCA_ALLOCATOR_H
23 #define MCA_ALLOCATOR_H
24 
25 #include "ompi_config.h"
26 #include "opal/mca/mca.h"
27 #include "ompi/mca/mpool/mpool.h"
28 
29 BEGIN_C_DECLS
30 
31 /* Here so that we can use mca_allocator_base_module_t in the function typedefs */
33 
34 /**
35  * The allocate function typedef for the function to be provided by the component.
36  */
37 typedef void* (*mca_allocator_base_module_alloc_fn_t)(
39  size_t size,
40  size_t align,
41  mca_mpool_base_registration_t** registration);
42 
43 /**
44  * The realloc function typedef
45  */
46 typedef void* (*mca_allocator_base_module_realloc_fn_t)(
48  void*, size_t,
49  mca_mpool_base_registration_t** registration);
50 
51 /**
52  * Free function typedef
53  */
55  struct mca_allocator_base_module_t*, void *);
56 
57 
58 /**
59  * compact/return memory to higher level allocator
60  */
61 
63  struct mca_allocator_base_module_t* allocator
64 );
65 
66 
67 /**
68  * cleanup (free) any resources held by allocator
69  */
70 
72  struct mca_allocator_base_module_t* allocator
73 );
74 
75 /**
76  * The data structure for each component.
77  */
80  /**< Allocate memory */
82  /**< Reallocate memory */
84  /**< Free memory */
86  /**< Return memory */
88  /**< Finalize and free everything */
89  /* memory pool and resources */
90  struct mca_mpool_base_module_t* alc_mpool;
91 };
92 /**
93  * Convenience typedef.
94  */
96 
97 
98 /**
99  * A function to get more memory from the system. This function is to be
100  * provided by the module to the allocator framework.
101  */
102 
103 typedef void* (*mca_allocator_base_component_segment_alloc_fn_t)(
104  struct mca_mpool_base_module_t* module,
105  size_t* size,
106  mca_mpool_base_registration_t** registration);
107 
108 /**
109  * A function to free memory from the control of the allocator framework
110  * back to the system. This function is to be provided by the module to the
111  * allocator framework.
112  */
114  struct mca_mpool_base_module_t* module,
115  void* segment);
116 
117 
118 /**
119  * The function used to initialize the component.
120  */
121 typedef struct mca_allocator_base_module_t*
122  (*mca_allocator_base_component_init_fn_t)(
123  bool enable_mpi_threads,
126  struct mca_mpool_base_module_t* mpool
127 );
128 
129 /**
130  * The data structure provided by each component to the framework which
131  * describes the component.
132  */
135  /**< The version of the component */
137  /**< The component metadata */
139  /**< The component initialization function. */
140 };
141 
142 /**
143  * Convenience typedef.
144  */
146 
147 /**
148  * Macro for use in components that are of type allocator
149  */
150 #define MCA_ALLOCATOR_BASE_VERSION_2_0_0 \
151  MCA_BASE_VERSION_2_0_0, \
152  "allocator", 2, 0, 0
153 
154 /**
155  * The output integer used for the mca base
156  */
157 OMPI_DECLSPEC extern int mca_allocator_base_output;
158 
159 END_C_DECLS
160 
161 #endif /* MCA_ALLOCATOR_H */
162 
Common type for all MCA components.
Definition: mca.h:250
mca_allocator_base_module_alloc_fn_t alc_alloc
Allocate memory.
Definition: allocator.h:79
OMPI_DECLSPEC int mca_allocator_base_output
The output integer used for the mca base.
Definition: allocator_base_open.c:43
int(* mca_allocator_base_module_finalize_fn_t)(struct mca_allocator_base_module_t *allocator)
cleanup (free) any resources held by allocator
Definition: allocator.h:71
mca_allocator_base_module_free_fn_t alc_free
Free memory.
Definition: allocator.h:83
Definition: mpool.h:44
mca_base_component_t allocator_version
The version of the component.
Definition: allocator.h:134
void(* mca_allocator_base_module_free_fn_t)(struct mca_allocator_base_module_t *, void *)
Free function typedef.
Definition: allocator.h:54
struct mca_allocator_base_module_t *(* mca_allocator_base_component_init_fn_t)(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)
The function used to initialize the component.
Definition: allocator.h:122
void(* mca_allocator_base_component_segment_free_fn_t)(struct mca_mpool_base_module_t *module, void *segment)
A function to free memory from the control of the allocator framework back to the system...
Definition: allocator.h:113
Top-level interface for all MCA components.
void *(* mca_allocator_base_module_realloc_fn_t)(struct mca_allocator_base_module_t *, void *, size_t, mca_mpool_base_registration_t **registration)
The realloc function typedef.
Definition: allocator.h:46
void *(* mca_allocator_base_component_segment_alloc_fn_t)(struct mca_mpool_base_module_t *module, size_t *size, mca_mpool_base_registration_t **registration)
A function to get more memory from the system.
Definition: allocator.h:103
mca_allocator_base_component_init_fn_t allocator_init
The component initialization function.
Definition: allocator.h:138
int(* mca_allocator_base_module_compact_fn_t)(struct mca_allocator_base_module_t *allocator)
compact/return memory to higher level allocator
Definition: allocator.h:62
The data structure provided by each component to the framework which describes the component...
Definition: allocator.h:133
Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana University Research and Techno...
Meta data for MCA v2.0.0 components.
Definition: mca.h:309
mca_allocator_base_module_finalize_fn_t alc_finalize
Finalize and free everything.
Definition: allocator.h:87
mca_allocator_base_module_realloc_fn_t alc_realloc
Reallocate memory.
Definition: allocator.h:81
mca_allocator_base_module_compact_fn_t alc_compact
Return memory.
Definition: allocator.h:85
mca_base_component_data_t allocator_data
The component metadata.
Definition: allocator.h:136
void *(* mca_allocator_base_module_alloc_fn_t)(struct mca_allocator_base_module_t *, size_t size, size_t align, mca_mpool_base_registration_t **registration)
The allocate function typedef for the function to be provided by the component.
Definition: allocator.h:37
The data structure for each component.
Definition: allocator.h:78
mpool module descriptor.
Definition: mpool.h:174