root/opal/mca/base/mca_base_components_register.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. mca_base_framework_components_register
  2. register_components

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2012 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
  10  *                         University of Stuttgart.  All rights reserved.
  11  * Copyright (c) 2004-2005 The Regents of the University of California.
  12  *                         All rights reserved.
  13  * Copyright (c) 2008-2012 Cisco Systems, Inc.  All rights reserved.
  14  * Copyright (c) 2011-2015 Los Alamos National Security, LLC.
  15  *                         All rights reserved.
  16  * $COPYRIGHT$
  17  *
  18  * Additional copyrights may follow
  19  *
  20  * $HEADER$
  21  */
  22 
  23 #include "opal_config.h"
  24 
  25 #include <stdio.h>
  26 #include <string.h>
  27 #include <stdlib.h>
  28 
  29 #include "opal/class/opal_list.h"
  30 #include "opal/util/argv.h"
  31 #include "opal/util/output.h"
  32 #include "opal/util/show_help.h"
  33 #include "opal/mca/mca.h"
  34 #include "opal/mca/base/base.h"
  35 #include "opal/mca/base/mca_base_framework.h"
  36 #include "opal/mca/base/mca_base_component_repository.h"
  37 #include "opal/constants.h"
  38 
  39 /*
  40  * Local functions
  41  */
  42 static int register_components(mca_base_framework_t *framework);
  43 /**
  44  * Function for finding and opening either all MCA components, or the
  45  * one that was specifically requested via a MCA parameter.
  46  */
  47 int mca_base_framework_components_register (mca_base_framework_t *framework,
  48                                             mca_base_register_flag_t flags)
  49 {
  50     bool open_dso_components = !(flags & MCA_BASE_REGISTER_STATIC_ONLY);
  51     bool ignore_requested = !!(flags & MCA_BASE_REGISTER_ALL);
  52     int ret;
  53 
  54     /* Find and load requested components */
  55     ret = mca_base_component_find(NULL, framework, ignore_requested, open_dso_components);
  56     if (OPAL_SUCCESS != ret) {
  57         return ret;
  58     }
  59 
  60     /* Register all remaining components */
  61     return register_components(framework);
  62 }
  63 
  64 /*
  65  * Traverse the entire list of found components (a list of
  66  * mca_base_component_t instances).  If the requested_component_names
  67  * array is empty, or the name of each component in the list of found
  68  * components is in the requested_components_array, try to open it.
  69  * If it opens, add it to the components_available list.
  70  */
  71 static int register_components(mca_base_framework_t *framework)
  72 {
  73     int ret;
  74     mca_base_component_t *component;
  75     mca_base_component_list_item_t *cli, *next;
  76     int output_id = framework->framework_output;
  77 
  78     /* Announce */
  79     opal_output_verbose (MCA_BASE_VERBOSE_COMPONENT, output_id,
  80                          "mca: base: components_register: registering framework %s components",
  81                          framework->framework_name);
  82 
  83     /* Traverse the list of found components */
  84 
  85     OPAL_LIST_FOREACH_SAFE(cli, next, &framework->framework_components, mca_base_component_list_item_t) {
  86         component = (mca_base_component_t *)cli->cli_component;
  87 
  88         opal_output_verbose(MCA_BASE_VERBOSE_COMPONENT, output_id,
  89                             "mca: base: components_register: found loaded component %s",
  90                             component->mca_component_name);
  91 
  92         /* Call the component's MCA parameter registration function (or open if register doesn't exist) */
  93         if (NULL == component->mca_register_component_params) {
  94             opal_output_verbose (MCA_BASE_VERBOSE_COMPONENT, output_id,
  95                                  "mca: base: components_register: "
  96                                  "component %s has no register or open function",
  97                                  component->mca_component_name);
  98             ret = OPAL_SUCCESS;
  99         } else {
 100             ret = component->mca_register_component_params();
 101         }
 102 
 103         if (OPAL_SUCCESS != ret) {
 104             if (OPAL_ERR_NOT_AVAILABLE != ret) {
 105                 /* If the component returns OPAL_ERR_NOT_AVAILABLE,
 106                    it's a cue to "silently ignore me" -- it's not a
 107                    failure, it's just a way for the component to say
 108                    "nope!".
 109 
 110                    Otherwise, however, display an error.  We may end
 111                    up displaying this twice, but it may go to separate
 112                    streams.  So better to be redundant than to not
 113                    display the error in the stream where it was
 114                    expected. */
 115 
 116                 if (mca_base_component_show_load_errors) {
 117                     opal_output_verbose (MCA_BASE_VERBOSE_ERROR, output_id,
 118                                          "mca: base: components_register: component %s "
 119                                          "/ %s register function failed",
 120                                          component->mca_type_name,
 121                                          component->mca_component_name);
 122                 }
 123 
 124                 opal_output_verbose (MCA_BASE_VERBOSE_COMPONENT, output_id,
 125                                      "mca: base: components_register: "
 126                                      "component %s register function failed",
 127                                      component->mca_component_name);
 128             }
 129 
 130             opal_list_remove_item (&framework->framework_components, &cli->super);
 131 
 132             /* Release this list item */
 133             OBJ_RELEASE(cli);
 134             continue;
 135         }
 136 
 137         if (NULL != component->mca_register_component_params) {
 138             opal_output_verbose (MCA_BASE_VERBOSE_COMPONENT, output_id, "mca: base: components_register: "
 139                                  "component %s register function successful",
 140                                  component->mca_component_name);
 141         }
 142 
 143         /* Register this component's version */
 144         mca_base_component_var_register (component, "major_version", NULL, MCA_BASE_VAR_TYPE_INT, NULL,
 145                                          0, MCA_BASE_VAR_FLAG_DEFAULT_ONLY | MCA_BASE_VAR_FLAG_INTERNAL,
 146                                          OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_CONSTANT,
 147                                          &component->mca_component_major_version);
 148         mca_base_component_var_register (component, "minor_version", NULL, MCA_BASE_VAR_TYPE_INT, NULL,
 149                                          0, MCA_BASE_VAR_FLAG_DEFAULT_ONLY | MCA_BASE_VAR_FLAG_INTERNAL,
 150                                          OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_CONSTANT,
 151                                          &component->mca_component_minor_version);
 152         mca_base_component_var_register (component, "release_version", NULL, MCA_BASE_VAR_TYPE_INT, NULL,
 153                                          0, MCA_BASE_VAR_FLAG_DEFAULT_ONLY | MCA_BASE_VAR_FLAG_INTERNAL,
 154                                          OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_CONSTANT,
 155                                          &component->mca_component_release_version);
 156     }
 157 
 158     /* All done */
 159 
 160     return OPAL_SUCCESS;
 161 }

/* [<][>][^][v][top][bottom][index][help] */