Source

mpi3-fortran / orte / runtime / orte_info_support.c

  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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
/*
 * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana
 *                         University Research and Technology
 *                         Corporation.  All rights reserved.
 * Copyright (c) 2004-2011 The University of Tennessee and The University
 *                         of Tennessee Research Foundation.  All rights
 *                         reserved.
 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 
 *                         University of Stuttgart.  All rights reserved.
 * Copyright (c) 2004-2005 The Regents of the University of California.
 *                         All rights reserved.
 * Copyright (c) 2006-2012 Cisco Systems, Inc.  All rights reserved.
 * Copyright (c) 2010-2012 Los Alamos National Security, LLC.
 *                         All rights reserved.
 * Copyright (c) 2011-2012 University of Houston. All rights reserved.
 * $COPYRIGHT$
 * 
 * Additional copyrights may follow
 * 
 * $HEADER$
 */

#include "orte_config.h"
#include "orte/constants.h"
#include "orte/types.h"

#include "opal/class/opal_pointer_array.h"
#include "opal/runtime/opal_info_support.h"

#include "orte/mca/db/base/base.h"
#include "orte/mca/errmgr/base/base.h"
#include "orte/mca/ess/base/base.h"
#include "orte/mca/grpcomm/base/base.h"
#include "orte/mca/iof/base/base.h"
#include "orte/mca/odls/base/base.h"
#include "orte/mca/oob/base/base.h"
#include "orte/mca/plm/base/base.h"
#include "orte/mca/ras/base/ras_private.h"
#include "orte/mca/rmaps/base/base.h"
#include "orte/mca/rml/base/base.h"
#include "orte/mca/routed/base/base.h"
#if OPAL_ENABLE_FT_CR == 1
#include "orte/mca/snapc/base/base.h"
#include "orte/mca/sstore/base/base.h"
#endif
#if ORTE_ENABLE_SENSORS
#include "orte/mca/sensor/base/base.h"
#endif
#include "orte/mca/filem/base/base.h"
#include "orte/mca/state/base/base.h"
#include "orte/util/proc_info.h"
#include "orte/runtime/runtime.h"

#include "orte/runtime/orte_info_support.h"

const char *orte_info_type_orte = "orte";

void orte_info_register_types(opal_pointer_array_t *mca_types)
{
    /* frameworks */
    opal_pointer_array_add(mca_types, "db");
    opal_pointer_array_add(mca_types, "errmgr");
    opal_pointer_array_add(mca_types, "ess");
    opal_pointer_array_add(mca_types, "filem");
    opal_pointer_array_add(mca_types, "grpcomm");
    opal_pointer_array_add(mca_types, "iof");
    opal_pointer_array_add(mca_types, "odls");
    opal_pointer_array_add(mca_types, "oob");
    opal_pointer_array_add(mca_types, "orte");
    opal_pointer_array_add(mca_types, "plm");
    opal_pointer_array_add(mca_types, "ras");
    opal_pointer_array_add(mca_types, "rmaps");
    opal_pointer_array_add(mca_types, "rml");
    opal_pointer_array_add(mca_types, "routed");
#if ORTE_ENABLE_SENSORS
    opal_pointer_array_add(mca_types, "sensor");
#endif
#if OPAL_ENABLE_FT_CR == 1
    opal_pointer_array_add(mca_types, "snapc");
    opal_pointer_array_add(mca_types, "sstore");
#endif
    opal_pointer_array_add(mca_types, "state");
}

int orte_info_register_components(opal_pointer_array_t *mca_types,
                                  opal_pointer_array_t *component_map)
{
    opal_info_component_map_t *map;
    char *env, *str;
    int i, rc;
    char *target, *save, *type;
    char **env_save=NULL;

    /* Clear out the environment.  Use strdup() to orphan the resulting
     * strings because items are placed in the environment by reference,
     * not by value.
     */
    for (i = 0; i < mca_types->size; ++i) {
        if (NULL == (type = (char*)opal_pointer_array_get_item(mca_types, i))) {
            continue;
        }
        asprintf(&env, "OMPI_MCA_%s", type);
        if (NULL != (save = getenv(env))) {
            /* save this param so it can later be restored */
            asprintf(&str, "%s=%s", env, save);
            opal_argv_append_nosize(&env_save, str);
            free(str);
            /* can't manipulate it directly, so make a copy first */
            asprintf(&target, "%s=", env);
            putenv(target);
            free(target);
        }
        free(env);
    }

    /* Set orte_process_info.proc_type to HNP to force all frameworks to
     * open components
     */
    orte_process_info.proc_type = ORTE_PROC_HNP;
    /* set the event base to be the opal event base as we
     * aren't attempting to do anything with progress threads here
     */
    orte_event_base = opal_event_base;

    /* Register the ORTE layer's MCA parameters */
    
    if (ORTE_SUCCESS != (rc = orte_register_params()) &&
        ORTE_ERR_BAD_PARAM != rc) {
        str = "orte_register_params";
        goto error;
    }
    
    if (ORTE_SUCCESS != (rc = orte_db_base_open()) &&
        ORTE_ERR_BAD_PARAM != rc) {
        str = "db_base_open";
        goto error;
    }
    map = OBJ_NEW(opal_info_component_map_t);
    map->type = strdup("db");
    map->components = &orte_db_base.available_components;
    opal_pointer_array_add(component_map, map);
    if (ORTE_ERR_BAD_PARAM == rc)  {
        str = "db";
        goto breakout;
    }

    if (ORTE_SUCCESS != (rc = orte_errmgr_base_open()) &&
        ORTE_ERR_BAD_PARAM != rc) {
        str = "errmgr_base_open";
        goto error;
    }
    map = OBJ_NEW(opal_info_component_map_t);
    map->type = strdup("errmgr");
    map->components = &orte_errmgr_base_components_available;
    opal_pointer_array_add(component_map, map);
    if (ORTE_ERR_BAD_PARAM == rc)  {
        str = "errmgr";
        goto breakout;
    }

    if (ORTE_SUCCESS != (rc = orte_ess_base_open()) &&
        ORTE_ERR_BAD_PARAM != rc) {
        str = "ess_base_open";
        goto error;
    }
    map = OBJ_NEW(opal_info_component_map_t);
    map->type = strdup("ess");
    map->components = &orte_ess_base_components_available;
    opal_pointer_array_add(component_map, map);
    if (ORTE_ERR_BAD_PARAM == rc)  {
        str = "ess";
        goto breakout;
    }

    if (ORTE_SUCCESS != (rc = orte_filem_base_open()) &&
        ORTE_ERR_BAD_PARAM != rc) {
        str = "filem_base_open";
        goto error;
    }
    map = OBJ_NEW(opal_info_component_map_t);
    map->type = strdup("filem");
    map->components = &orte_filem_base_components_available;
    opal_pointer_array_add(component_map, map);
    if (ORTE_ERR_BAD_PARAM == rc)  {
        str = "filem";
        goto breakout;
    }

    if (ORTE_SUCCESS != (rc = orte_grpcomm_base_open()) &&
        ORTE_ERR_BAD_PARAM != rc) {
        str = "grpcomm_base_open";
        goto error;
    }
    map = OBJ_NEW(opal_info_component_map_t);
    map->type = strdup("grpcomm");
    map->components = &orte_grpcomm_base.components_available;
    opal_pointer_array_add(component_map, map);
    if (ORTE_ERR_BAD_PARAM == rc)  {
        str = "grpcomm";
        goto breakout;
    }

    if (ORTE_SUCCESS != (rc = orte_iof_base_open()) &&
        ORTE_ERR_BAD_PARAM != rc) {
        str = "iof_base_open";
        goto error;
    }
    map = OBJ_NEW(opal_info_component_map_t);
    map->type = strdup("iof");
    map->components = &orte_iof_base.iof_components_opened;
    opal_pointer_array_add(component_map, map);
    if (ORTE_ERR_BAD_PARAM == rc)  {
        str = "iof";
        goto breakout;
    }

    if (ORTE_SUCCESS != (rc = orte_odls_base_open()) &&
        ORTE_ERR_BAD_PARAM != rc) {
        str = "odls_base_open";
        goto error;
    }
    map = OBJ_NEW(opal_info_component_map_t);
    map->type = strdup("odls");
    map->components = &orte_odls_base.available_components;
    opal_pointer_array_add(component_map, map);
    if (ORTE_ERR_BAD_PARAM == rc)  {
        str = "odls";
        goto breakout;
    }

    if (ORTE_SUCCESS != (rc = mca_oob_base_open()) &&
        ORTE_ERR_BAD_PARAM != rc) {
        str = "oob_base_open";
        goto error;
    }
    map = OBJ_NEW(opal_info_component_map_t);
    map->type = strdup("oob");
    map->components = &mca_oob_base_components;
    opal_pointer_array_add(component_map, map);
    if (ORTE_ERR_BAD_PARAM == rc)  {
        str = "oob";
        goto breakout;
    }

    if (ORTE_SUCCESS != (rc = orte_plm_base_open()) &&
        ORTE_ERR_BAD_PARAM != rc) {
        str = "plm_base_open";
        goto error;
    }
    map = OBJ_NEW(opal_info_component_map_t);
    map->type = strdup("plm");
    map->components = &orte_plm_base.available_components;
    opal_pointer_array_add(component_map, map);
    if (ORTE_ERR_BAD_PARAM == rc)  {
        str = "plm";
        goto breakout;
    }

    if (ORTE_SUCCESS != (rc = orte_ras_base_open()) &&
        ORTE_ERR_BAD_PARAM != rc) {
        str = "ras_base_open";
        goto error;
    }
    map = OBJ_NEW(opal_info_component_map_t);
    map->type = strdup("ras");
    map->components = &orte_ras_base.ras_opened;
    opal_pointer_array_add(component_map, map);
    if (ORTE_ERR_BAD_PARAM == rc)  {
        str = "ras";
        goto breakout;
    }

    if (ORTE_SUCCESS != (rc = orte_rmaps_base_open()) &&
        ORTE_ERR_BAD_PARAM != rc) {
        str = "rmaps_base_open";
        goto error;
    }
    map = OBJ_NEW(opal_info_component_map_t);
    map->type = strdup("rmaps");
    map->components = &orte_rmaps_base.available_components;
    opal_pointer_array_add(component_map, map);
    if (ORTE_ERR_BAD_PARAM == rc)  {
        str = "rmaps";
        goto breakout;
    }

    if (ORTE_SUCCESS != (rc = orte_routed_base_open()) &&
        ORTE_ERR_BAD_PARAM != rc) {
        str = "routed_base_open";
        goto error;
    }
    map = OBJ_NEW(opal_info_component_map_t);
    map->type = strdup("routed");
    map->components = &orte_routed_base_components;
    opal_pointer_array_add(component_map, map);
    if (ORTE_ERR_BAD_PARAM == rc)  {
        str = "routed";
        goto breakout;
    }

    if (ORTE_SUCCESS != (rc = orte_rml_base_open()) &&
        ORTE_ERR_BAD_PARAM != rc) {
        str = "rml_base_open";
        goto error;
    }
    map = OBJ_NEW(opal_info_component_map_t);
    map->type = strdup("rml");
    map->components = &orte_rml_base_components;
    opal_pointer_array_add(component_map, map);
    if (ORTE_ERR_BAD_PARAM == rc)  {
        str = "rml";
        goto breakout;
    }

#if ORTE_ENABLE_SENSORS
    if (ORTE_SUCCESS != (rc = orte_sensor_base_open()) &&
        ORTE_ERR_BAD_PARAM != rc) {
        str = "sensor_base_open";
        goto error;
    }
    map = OBJ_NEW(opal_info_component_map_t);
    map->type = strdup("sensor");
    map->components = &mca_sensor_base_components_available;
    opal_pointer_array_add(component_map, map);
    if (ORTE_ERR_BAD_PARAM == rc)  {
        str = "sensor";
        goto breakout;
    }
#endif
    
#if OPAL_ENABLE_FT_CR == 1
    if (ORTE_SUCCESS != (rc = orte_snapc_base_open()) &&
        ORTE_ERR_BAD_PARAM != rc) {
        str = "snapc_base_open";
        goto error;
    }
    map = OBJ_NEW(opal_info_component_map_t);
    map->type = strdup("snapc");
    map->components = &orte_snapc_base_components_available;
    opal_pointer_array_add(component_map, map);
    if (ORTE_ERR_BAD_PARAM == rc)  {
        str = "snapc";
        goto breakout;
    }

    if (ORTE_SUCCESS != (rc = orte_sstore_base_open()) &&
        ORTE_ERR_BAD_PARAM != rc) {
        str = "sstore_base_open";
        goto error;
    }
    map = OBJ_NEW(opal_info_component_map_t);
    map->type = strdup("sstore");
    map->components = &orte_sstore_base_components_available;
    opal_pointer_array_add(component_map, map);
    if (ORTE_ERR_BAD_PARAM == rc)  {
        str = "sstore";
        goto breakout;
    }
#endif
    
    if (ORTE_SUCCESS != (rc = orte_state_base_open()) &&
        ORTE_ERR_BAD_PARAM != rc) {
        str = "state_base_open";
        goto error;
    }
    map = OBJ_NEW(opal_info_component_map_t);
    map->type = strdup("state");
    map->components = &orte_state_base_components_available;
    opal_pointer_array_add(component_map, map);
    if (ORTE_ERR_BAD_PARAM == rc)  {
        str = "state";
        goto breakout;
    }

 breakout:
    /* Restore the environment to what it was before we started so that
     * if users setenv OMPI_MCA_<framework name> to some value, they'll
     * see that value when it is shown via --param output.
     */
    
    if (NULL != env_save) {
        for (i = 0; i < opal_argv_count(env_save); ++i) {
            putenv(env_save[i]);
        }
    }

    if (ORTE_ERR_BAD_PARAM == rc) {
        fprintf(stderr, "\nA \"bad parameter\" error was encountered when opening the ORTE %s framework\n", str);
        fprintf(stderr, "The output received from that framework includes the following parameters:\n\n");
    }

    return rc;

 error:
    fprintf(stderr, "orte_info_register: %s failed\n", str);
    return ORTE_ERROR;
}

void orte_info_close_components(void)
{
    (void) orte_db_base_close();
    (void) orte_errmgr_base_close();
    (void) orte_ess_base_close();
    (void) orte_filem_base_close();
    (void) orte_grpcomm_base_close();
    (void) orte_iof_base_close();
    (void) orte_odls_base_close();
    (void) mca_oob_base_close();
    (void) orte_plm_base_close();
    (void) orte_ras_base_close();
    (void) orte_rmaps_base_close();
    (void) orte_rml_base_close();
    (void) orte_routed_base_close();
#if OPAL_ENABLE_FT_CR == 1
    (void) orte_snapc_base_close();
    (void) orte_sstore_base_close();
#endif
    (void) orte_state_base_close();
}

void orte_info_show_orte_version(const char *scope)
{
    char *tmp, *tmp2;

    asprintf(&tmp, "%s:version:full", orte_info_type_orte);
    tmp2 = opal_info_make_version_str(scope, 
                                      ORTE_MAJOR_VERSION, ORTE_MINOR_VERSION, 
                                      ORTE_RELEASE_VERSION, 
                                      ORTE_GREEK_VERSION,
                                      ORTE_WANT_REPO_REV, ORTE_REPO_REV);
    opal_info_out("Open RTE", tmp, tmp2);
    free(tmp);
    free(tmp2);
    asprintf(&tmp, "%s:version:repo", orte_info_type_orte);
    opal_info_out("Open RTE repo revision", tmp, ORTE_REPO_REV);
    free(tmp);
    asprintf(&tmp, "%s:version:release_date", orte_info_type_orte);
    opal_info_out("Open RTE release date", tmp, ORTE_RELEASE_DATE);
    free(tmp);
}