File: mca_base_framework.h

package info (click to toggle)
openmpi 5.0.8-4
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 201,684 kB
  • sloc: ansic: 613,078; makefile: 42,353; sh: 11,194; javascript: 9,244; f90: 7,052; java: 6,404; perl: 5,179; python: 1,859; lex: 740; fortran: 61; cpp: 20; tcl: 12
file content (283 lines) | stat: -rw-r--r-- 10,181 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights
 *                         reserved.
 * Copyright (c) 2017 IBM Corporation.  All rights reserved.
 * Copyright (c) 2018      Triad National Security, LLC. All rights
 *                         reserved.
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */

#if !defined(OPAL_MCA_BASE_FRAMEWORK_H)
#    define OPAL_MCA_BASE_FRAMEWORK_H

#    include "opal/class/opal_list.h"
#    include "opal/mca/mca.h"

/*
 * Register and open flags
 */
enum mca_base_register_flag_t {
    MCA_BASE_REGISTER_DEFAULT = 0,
    /** Register all components (ignore selection MCA variables) */
    MCA_BASE_REGISTER_ALL = 1,
    /** Do not register DSO components */
    MCA_BASE_REGISTER_STATIC_ONLY = 2
};

typedef enum mca_base_register_flag_t mca_base_register_flag_t;

enum mca_base_open_flag_t {
    MCA_BASE_OPEN_DEFAULT = 0,
    /** Find components in mca_base_components_find. Used by
     mca_base_framework_open() when NOREGISTER is specified
     by the framework */
    MCA_BASE_OPEN_FIND_COMPONENTS = 1,
    /** Do not open DSO components */
    MCA_BASE_OPEN_STATIC_ONLY = 2,
};

typedef enum mca_base_open_flag_t mca_base_open_flag_t;

/**
 * Register the MCA framework parameters
 *
 * @param[in] flags Registration flags (see mca/base/base.h)
 *
 * @retval OPAL_SUCCESS on success
 * @retval opal error code on failure
 *
 * This function registers all framework MCA parameters. This
 * function should not call mca_base_framework_components_register().
 *
 * Frameworks are NOT required to provide this function. It
 * may be NULL.
 */
typedef int (*mca_base_framework_register_params_fn_t)(mca_base_register_flag_t flags);

/**
 * Initialize the MCA framework
 *
 * @retval OPAL_SUCCESS Upon success
 * @retval OPAL_ERROR Upon failure
 *
 * This must be the first function invoked in the MCA framework.
 * It initializes the MCA framework, finds and opens components,
 * populates the components list, etc.
 *
 * This function is invoked during opal_init() and during the
 * initialization of the special case of the ompi_info command.
 *
 * This function fills in the components framework value, which
 * is a list of all components that were successfully opened.
 * This variable should \em only be used by other framework base
 * functions or by ompi_info -- it is not considered a public
 * interface member -- and is only mentioned here for completeness.
 *
 * Any resources allocated by this function must be freed
 * in the framework close function.
 *
 * Frameworks are NOT required to provide this function. It may
 * be NULL. If a framework does not provide an open function the
 * default behavior of mca_base_framework_open() is to call
 * mca_base_framework_components_open(). If a framework provides
 * an open function it will need to call mca_base_framework_components_open()
 * if it needs to open any components.
 */
typedef int (*mca_base_framework_open_fn_t)(mca_base_open_flag_t flags);

/**
 * Shut down the MCA framework.
 *
 * @retval OPAL_SUCCESS Always
 *
 * This function should shut downs everything in the MCA
 * framework, and is called during opal_finalize() and the
 * special case of the ompi_info command.
 *
 * It must be the last function invoked on the MCA framework.
 *
 * Frameworks are NOT required to provide this function. It may
 * be NULL. If a framework does not provide a close function the
 * default behavior of mca_base_framework_close() is to call
 * mca_base_framework_components_close(). If a framework provide
 * a close function it will need to call mca_base_framework_components_close()
 * if any components were opened.
 */
typedef int (*mca_base_framework_close_fn_t)(void);

typedef enum {
    MCA_BASE_FRAMEWORK_FLAG_DEFAULT = 0,
    /** Don't register any variables for this framework */
    MCA_BASE_FRAMEWORK_FLAG_NOREGISTER = 1,
    /** Internal. Don't set outside mca_base_framework.h */
    MCA_BASE_FRAMEWORK_FLAG_REGISTERED = 2,
    /** Framework does not have any DSO components */
    MCA_BASE_FRAMEWORK_FLAG_NO_DSO = 4,
    /** Internal. Don't set outside mca_base_framework.h */
    MCA_BASE_FRAMEWORK_FLAG_OPEN = 8,
    /**
     * The upper 16 bits are reserved for project specific flags.
     */
} mca_base_framework_flags_t;

typedef struct mca_base_framework_t {
    /** Project name for this component (ex "opal") */
    char *framework_project;
    /** Framework name */
    char *framework_name;
    /** Description of this framework or NULL */
    const char *framework_description;
    /** Framework register function or NULL if the framework
        and all its components have nothing to register */
    mca_base_framework_register_params_fn_t framework_register;
    /** Framework open function or NULL */
    mca_base_framework_open_fn_t framework_open;
    /** Framework close function or NULL */
    mca_base_framework_close_fn_t framework_close;
    /** Framework flags (future use) set to 0 */
    mca_base_framework_flags_t framework_flags;
    /** Framework open count */
    int framework_refcnt;
    /** List of static components */
    const mca_base_component_t **framework_static_components;
    /** Component selection. This will be registered with the MCA
        variable system and should be either NULL (all components) or
        a heap allocated, comma-delimited list of components. */
    char *framework_selection;
    /** Verbosity level (0-100) */
    int framework_verbose;
    /** Opal output for this framework (or -1) */
    int framework_output;
    /** List of selected components (filled in by mca_base_framework_register()
        or mca_base_framework_open() */
    opal_list_t framework_components;
    /** List of components that failed to load */
    opal_list_t framework_failed_components;
} mca_base_framework_t;

/**
 * Register a framework with MCA.
 *
 * @param[in] framework framework to register
 *
 * @retval OPAL_SUCCESS Upon success
 * @retval OPAL_ERROR Upon failure
 *
 * Call a framework's register function.
 */
OPAL_DECLSPEC int mca_base_framework_register(mca_base_framework_t *framework,
                                              mca_base_register_flag_t flags);

/**
 * Register frameworks with MCA.
 *
 * @param[in] framework NULL-terminated list of frameworks to register
 *
 * @retval OPAL_SUCCESS Upon success
 * @retval OPAL_ERROR Upon failure
 *
 * Call the MCA variable registration functions of each framework in the
 * frameworks array.
 */
OPAL_DECLSPEC int mca_base_framework_register_list(mca_base_framework_t **frameworks,
                                                   mca_base_register_flag_t flags);

/**
 * Open a framework
 *
 * @param[in] framework framework to open
 *
 * @retval OPAL_SUCCESS Upon success
 * @retval OPAL_ERROR Upon failure
 *
 * Call a framework's open function.
 */
OPAL_DECLSPEC int mca_base_framework_open(mca_base_framework_t *framework,
                                          mca_base_open_flag_t flags);

/**
 * Open frameworks
 *
 * @param[in] frameworks NULL-terminated array of framework to open
 *
 * @retval OPAL_SUCCESS Upon success
 * @retval OPAL_ERROR Upon failure
 *
 * Call the open function on multiple frameworks
 */
OPAL_DECLSPEC int mca_base_framework_open_list(mca_base_framework_t **frameworks,
                                               mca_base_open_flag_t flags);

/**
 * Close a framework
 *
 * @param[in] framework framework to close
 *
 * @retval OPAL_SUCCESS Upon success
 * @retval OPAL_ERROR Upon failure
 *
 * Call a framework's close function.
 */
OPAL_DECLSPEC int mca_base_framework_close(mca_base_framework_t *framework);

/**
 * Close frameworks
 *
 * @param[in] frameworks NULL-terminated array of framework to close
 *
 * @retval OPAL_SUCCESS Upon success
 * @retval OPAL_ERROR Upon failure
 *
 * Call the close function on multiple frameworks
 */
OPAL_DECLSPEC int mca_base_framework_close_list(mca_base_framework_t **frameworks);

/**
 * Check if a framework is already registered
 *
 * @param[in] framework framework to query
 *
 * @retval true if the framework's mca variables are registered
 * @retval false if not
 */
OPAL_DECLSPEC bool mca_base_framework_is_registered(struct mca_base_framework_t *framework);

/**
 * Check if a framework is already open
 *
 * @param[in] framework framework to query
 *
 * @retval true if the framework is open
 * @retval false if not
 */
OPAL_DECLSPEC bool mca_base_framework_is_open(struct mca_base_framework_t *framework);

/**
 * Macro to declare an MCA framework
 *
 * Example:
 *  MCA_BASE_FRAMEWORK_DECLARE(opal, foo, NULL, opal_foo_open, opal_foo_close,
 * MCA_BASE_FRAMEWORK_FLAG_LAZY)
 */
#    define MCA_BASE_FRAMEWORK_DECLARE(project, name, description, registerfn, openfn, closefn, \
                                       static_components, flags)                                \
        mca_base_framework_t project##_##name##_base_framework                                  \
            = {.framework_project = #project,                                                   \
               .framework_name = #name,                                                         \
               .framework_description = description,                                            \
               .framework_register = registerfn,                                                \
               .framework_open = openfn,                                                        \
               .framework_close = closefn,                                                      \
               .framework_flags = flags,                                                        \
               .framework_refcnt = 0,                                                           \
               .framework_static_components = static_components,                                \
               .framework_selection = NULL,                                                     \
               .framework_verbose = 0,                                                          \
               .framework_output = -1}

#endif /* OPAL_MCA_BASE_FRAMEWORK_H */