File: mca_base_components_register.c

package info (click to toggle)
openmpi 5.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 202,312 kB
  • sloc: ansic: 612,441; makefile: 42,495; sh: 11,230; javascript: 9,244; f90: 7,052; java: 6,404; perl: 5,154; python: 1,856; lex: 740; fortran: 61; cpp: 20; tcl: 12
file content (167 lines) | stat: -rw-r--r-- 7,337 bytes parent folder | download | duplicates (3)
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
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
 *                         University Research and Technology
 *                         Corporation.  All rights reserved.
 * Copyright (c) 2004-2012 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) 2008-2022 Cisco Systems, Inc.  All rights reserved
 * Copyright (c) 2011-2015 Los Alamos National Security, LLC.
 *                         All rights reserved.
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */

#include "opal_config.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "opal/class/opal_list.h"
#include "opal/constants.h"
#include "opal/mca/base/base.h"
#include "opal/mca/base/mca_base_component_repository.h"
#include "opal/mca/base/mca_base_framework.h"
#include "opal/mca/mca.h"
#include "opal/util/argv.h"
#include "opal/util/output.h"
#include "opal/util/show_help.h"

/*
 * Local functions
 */
static int register_components(mca_base_framework_t *framework);
/**
 * Function for finding and opening either all MCA components, or the
 * one that was specifically requested via a MCA parameter.
 */
int mca_base_framework_components_register(mca_base_framework_t *framework,
                                           mca_base_register_flag_t flags)
{
    bool open_dso_components = !(flags & MCA_BASE_REGISTER_STATIC_ONLY);
    bool ignore_requested = !!(flags & MCA_BASE_REGISTER_ALL);
    int ret;

    /* Find and load requested components */
    ret = mca_base_component_find(NULL, framework, ignore_requested, open_dso_components);
    if (OPAL_SUCCESS != ret) {
        return ret;
    }

    /* Register all remaining components */
    return register_components(framework);
}

/*
 * Traverse the entire list of found components (a list of
 * mca_base_component_t instances).  If the requested_component_names
 * array is empty, or the name of each component in the list of found
 * components is in the requested_components_array, try to open it.
 * If it opens, add it to the components_available list.
 */
static int register_components(mca_base_framework_t *framework)
{
    int ret;
    mca_base_component_t *component;
    mca_base_component_list_item_t *cli, *next;
    int output_id = framework->framework_output;

    /* Announce */
    opal_output_verbose(MCA_BASE_VERBOSE_COMPONENT, output_id,
                        "mca: base: components_register: registering framework %s components",
                        framework->framework_name);

    /* Traverse the list of found components */

    OPAL_LIST_FOREACH_SAFE (cli, next, &framework->framework_components,
                            mca_base_component_list_item_t) {
        component = (mca_base_component_t *) cli->cli_component;

        opal_output_verbose(MCA_BASE_VERBOSE_COMPONENT, output_id,
                            "mca: base: components_register: found loaded component %s",
                            component->mca_component_name);

        /* Call the component's MCA parameter registration function (or open if register doesn't
         * exist) */
        if (NULL == component->mca_register_component_params) {
            opal_output_verbose(MCA_BASE_VERBOSE_COMPONENT, output_id,
                                "mca: base: components_register: "
                                "component %s has no register or open function",
                                component->mca_component_name);
            ret = OPAL_SUCCESS;
        } else {
            ret = component->mca_register_component_params();
        }

        if (OPAL_SUCCESS != ret) {
            if (OPAL_ERR_NOT_AVAILABLE != ret) {
                /* If the component returns OPAL_ERR_NOT_AVAILABLE,
                   it's a cue to "silently ignore me" -- it's not a
                   failure, it's just a way for the component to say
                   "nope!".

                   Otherwise, however, display an error.  We may end
                   up displaying this twice, but it may go to separate
                   streams.  So better to be redundant than to not
                   display the error in the stream where it was
                   expected. */

                if (mca_base_show_load_errors(component->mca_type_name,
                                              component->mca_component_name)) {
                    opal_output_verbose(MCA_BASE_VERBOSE_ERROR, output_id,
                                        "mca: base: components_register: component %s "
                                        "/ %s register function failed",
                                        component->mca_type_name, component->mca_component_name);
                }

                opal_output_verbose(MCA_BASE_VERBOSE_COMPONENT, output_id,
                                    "mca: base: components_register: "
                                    "component %s register function failed",
                                    component->mca_component_name);
            }

            opal_list_remove_item(&framework->framework_components, &cli->super);

            /* Release this list item */
            OBJ_RELEASE(cli);
            continue;
        }

        if (NULL != component->mca_register_component_params) {
            opal_output_verbose(MCA_BASE_VERBOSE_COMPONENT, output_id,
                                "mca: base: components_register: "
                                "component %s register function successful",
                                component->mca_component_name);
        }

        /* Register this component's version */
        mca_base_component_var_register(component, "major_version", NULL, MCA_BASE_VAR_TYPE_INT,
                                        NULL, 0,
                                        MCA_BASE_VAR_FLAG_DEFAULT_ONLY | MCA_BASE_VAR_FLAG_INTERNAL,
                                        OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_CONSTANT,
                                        &component->mca_component_major_version);
        mca_base_component_var_register(component, "minor_version", NULL, MCA_BASE_VAR_TYPE_INT,
                                        NULL, 0,
                                        MCA_BASE_VAR_FLAG_DEFAULT_ONLY | MCA_BASE_VAR_FLAG_INTERNAL,
                                        OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_CONSTANT,
                                        &component->mca_component_minor_version);
        mca_base_component_var_register(component, "release_version", NULL, MCA_BASE_VAR_TYPE_INT,
                                        NULL, 0,
                                        MCA_BASE_VAR_FLAG_DEFAULT_ONLY | MCA_BASE_VAR_FLAG_INTERNAL,
                                        OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_CONSTANT,
                                        &component->mca_component_release_version);
    }

    /* All done */

    return OPAL_SUCCESS;
}