OpenMPI  0.1.1
base.h
1 /*
2  * Copyright (c) 2004-2006 High Performance Computing Center Stuttgart,
3  * University of Stuttgart. All rights reserved.
4  * $COPYRIGHT$
5  *
6  * Additional copyrights may follow
7  *
8  * $HEADER$
9  *
10  */
11 
12 #ifndef OPAL_MEMCHECKER_BASE_H
13 #define OPAL_MEMCHECKER_BASE_H
14 
15 #include "opal_config.h"
16 
18 
19 /*
20  * Global functions for MCA overall memchecker open and close
21  */
22 
23 BEGIN_C_DECLS
24 
25 /**
26  * Initialize the memchecker MCA framework
27  *
28  * @retval OPAL_SUCCESS Upon success
29  * @retval OPAL_ERROR Upon failure
30  *
31  * This must be the first function invoked in the memchecker MCA
32  * framework. It initializes the memchecker MCA framework, finds
33  * and opens memchecker components, etc.
34  *
35  * This function is invoked during opal_init() and during the
36  * initialization of the special case of the laminfo command.
37  *
38  * This function fills in the internal global variable
39  * opal_memchecker_base_components_opened, which is a list of all
40  * memchecker components that were successfully opened. This
41  * variable should \em only be used by other memchecker base
42  * functions -- it is not considered a public interface member --
43  * and is only mentioned here for completeness.
44  */
45 OPAL_DECLSPEC int opal_memchecker_base_open(void);
46 
47 /**
48  * Select one available component.
49  *
50  * @return OPAL_SUCCESS Upon success.
51  *
52  * This function invokes the selection process for memchecker
53  * components
54  */
55 OPAL_DECLSPEC int opal_memchecker_base_select(void);
56 
57 /**
58  * Shut down the memchecker MCA framework.
59  *
60  * @retval OPAL_SUCCESS Always
61  *
62  * This function shuts down everything in the memchecker MCA
63  * framework, and is called during opal_finalize() and the
64  * special case of the laminfo command.
65  *
66  * It must be the last function invoked on the memchecker MCA framework.
67  */
68 OPAL_DECLSPEC int opal_memchecker_base_close(void);
69 
70 /**
71  * List of all opened components; created when the memchecker
72  * framework is initialized and destroyed, when we reduce the list
73  * to all available memchecker components (actually one).
74  */
75 OPAL_DECLSPEC extern opal_list_t opal_memchecker_base_components_opened;
76 
77 /**
78  * Indication of whether one component was successfully selected
79  */
80 OPAL_DECLSPEC extern bool opal_memchecker_base_selected;
81 
82 /**
83  * Global component struct for the selected component
84  */
85 OPAL_DECLSPEC extern const opal_memchecker_base_component_2_0_0_t
86  *opal_memchecker_base_component;
87 
88 /**
89  * Global module struct for the selected module
90  */
91 OPAL_DECLSPEC extern const opal_memchecker_base_module_1_0_0_t
92  *opal_memchecker_base_module;
93 
94 /**
95  * Debugging output stream
96  */
97 extern int opal_memchecker_base_output;
98 
99 /**
100  * Check if we are running under the memory debugger.
101  *
102  * @retval 0 if not running under memory debugger
103  * !=0 if running under memory debugger
104  *
105  */
106 OPAL_DECLSPEC int opal_memchecker_base_runindebugger(void);
107 #if OMPI_WANT_MEMCHECKER == 0
108 #define opal_memchecker_base_runindebugger() 0
109 #endif
110 
111 
112 /**
113  * Check if a memory region is valid to address
114  *
115  * @param p Pointer to the memory region
116  * @param len Length of the memory region
117  *
118  * @retval OPAL_SUCCESS upon success.
119  *
120  * This function calls the selected memchecker, whether
121  * every Byte of this memory region is addressable
122  */
123 OPAL_DECLSPEC int opal_memchecker_base_isaddressable(void * p, size_t len);
124 #if OMPI_WANT_MEMCHECKER == 0
125 #define opal_memchecker_base_isaddressable(p, len) 0
126 #endif
127 
128 
129 /**
130  * Check if a memory region is defined
131  *
132  * @param p Pointer to the memory region
133  * @param len Length of the memory region
134  *
135  * @retval OPAL_SUCCESS upon success.
136  *
137  * This function calls the selected memchecker, whether
138  * every Byte of this memory region is correctly initialized.
139  */
140 OPAL_DECLSPEC int opal_memchecker_base_isdefined(void * p, size_t len);
141 #if OMPI_WANT_MEMCHECKER == 0
142 #define opal_memchecker_base_isdefined(p, len) 0
143 #endif
144 
145 /**
146  * Set a memory region to not accessible
147  *
148  * @param p Pointer to the memory region
149  * @param len Length of the memory region
150  *
151  * @retval OPAL_SUCCESS upon success.
152  *
153  * This function calls the selected memchecker, to set
154  * every Byte of this memory region to not accessible.
155  */
156 OPAL_DECLSPEC int opal_memchecker_base_mem_noaccess(void * p, size_t len);
157 #if OMPI_WANT_MEMCHECKER == 0
158 #define opal_memchecker_base_mem_noaccess(p, len)
159 #endif
160 
161 /**
162  * Set a memory region to undefined
163  *
164  * @param p Pointer to the memory region
165  * @param len Length of the memory region
166  *
167  * @retval OPAL_SUCCESS upon success.
168  *
169  * This function calls the selected memchecker, to set
170  * every Byte of this memory region to not contain initialized data.
171  */
172 OPAL_DECLSPEC int opal_memchecker_base_mem_undefined(void * p, size_t len);
173 #if OMPI_WANT_MEMCHECKER == 0
174 #define opal_memchecker_base_mem_undefined(p, len)
175 #endif
176 
177 /**
178  * Set a memory region to defined
179  *
180  * @param p Pointer to the memory region
181  * @param len Length of the memory region
182  *
183  * @retval OPAL_SUCCESS upon success.
184  *
185  * This function calls the selected memchecker, to set
186  * every Byte of this memory region to contain valid, initialized data.
187  */
188 OPAL_DECLSPEC int opal_memchecker_base_mem_defined(void * p, size_t len);
189 #if OMPI_WANT_MEMCHECKER == 0
190 #define opal_memchecker_base_mem_defined(p, len)
191 #endif
192 
193 /**
194  * Set a memory region to defined only if the region is addressable
195  *
196  * @param p Pointer to the memory region
197  * @param len Length of the memory region
198  *
199  * @retval OPAL_SUCCESS upon success.
200  *
201  * This function calls the selected memchecker, to set
202  * every Byte of this memory region to contain valid, initialized data,
203  * but only, if the memory region is addressable.
204  */
205 OPAL_DECLSPEC int opal_memchecker_base_mem_defined_if_addressable(void * p, size_t len);
206 #if OMPI_WANT_MEMCHECKER == 0
207 #define opal_memchecker_base_mem_defined_if_addressable(p, len)
208 #endif
209 
210 /**
211  * Create a named memory region
212  *
213  * @param p Pointer to the memory region
214  * @param len Length of the memory region
215  * @param description Name of the memory region
216  *
217  * @retval OPAL_SUCCESS upon success.
218  *
219  * This function calls the selected memchecker, to name
220  * this memory region.
221  */
222 OPAL_DECLSPEC int opal_memchecker_base_create_block(void * p, size_t len, char * description);
223 #if OMPI_WANT_MEMCHECKER == 0
224 #define opal_memchecker_base_create_block(p, len, description)
225 #endif
226 
227 /**
228  * Discard a named memory region
229  *
230  * @param p Pointer to the memory region
231  *
232  * @retval OPAL_SUCCESS upon success.
233  *
234  * This function calls the selected memchecker, to discard
235  * the name information of the memory region.
236  */
237 OPAL_DECLSPEC int opal_memchecker_base_discard_block(void * p);
238 #if OMPI_WANT_MEMCHECKER == 0
239 #define opal_memchecker_base_discard_block(p)
240 #endif
241 
242 /**
243  * Perform leak check on lost allocated memory.
244  *
245  * @param len Length of the memory region
246  *
247  * @retval OPAL_SUCCESS upon success.
248  *
249  * This function calls the selected memchecker, to output
250  * information regarding lost allocated memory.
251  */
252 OPAL_DECLSPEC int opal_memchecker_base_leakcheck(void);
253 #if OMPI_WANT_MEMCHECKER == 0
254 #define opal_memchecker_base_leakcheck
255 #endif
256 
257 /**
258  * Get vbits of the memory
259  *
260  * @param p Pointer to the memory region
261  * @param vbits Pointer to the vbit table
262  * @param len Length of the memory region
263  *
264  * @retval OPAL_SUCCESS upon success.
265  *
266  * This function calls the selected memchecker, to get
267  * every vbit of this memory region.
268  */
269 OPAL_DECLSPEC int opal_memchecker_base_get_vbits(void * p, char * vbits, size_t len);
270 #if OMPI_WANT_MEMCHECKER == 0
271 #define opal_memchecker_base_get_vbits(p, vbits, len)
272 #endif
273 
274 /**
275  * Set vbits of the memory
276  *
277  * @param p Pointer to the memory region
278  * @param vbits Pointer to the vbit table
279  * @param len Length of the memory region
280  *
281  * @retval OPAL_SUCCESS upon success.
282  *
283  * This function calls the selected memchecker, to get
284  * every vbit of this memory region.
285  */
286 OPAL_DECLSPEC int opal_memchecker_base_set_vbits(void * p, char * vbits, size_t len);
287 #if OMPI_WANT_MEMCHECKER == 0
288 #define opal_memchecker_base_set_vbits(p, vbits, len)
289 #endif
290 
291 END_C_DECLS
292 
293 #endif /* OPAL_MEMCHECKER_BASE_H */
memchecker (memory checker) framework component interface.
Definition: opal_list.h:147
Structure for memchecker components.
Definition: memchecker.h:113
Structure for memchecker modules.
Definition: memchecker.h:129