root/opal/mca/pmix/pmix4x/pmix/src/mca/base/pmix_mca_base_components_register.c

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

DEFINITIONS

This source file includes following definitions.
  1. pmix_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 (c) 2016      Intel, Inc. All rights reserved.
  17  * $COPYRIGHT$
  18  *
  19  * Additional copyrights may follow
  20  *
  21  * $HEADER$
  22  */
  23 
  24 #include <src/include/pmix_config.h>
  25 
  26 #include <stdio.h>
  27 #include <string.h>
  28 #include <stdlib.h>
  29 
  30 #include "src/class/pmix_list.h"
  31 #include "src/util/argv.h"
  32 #include "src/util/error.h"
  33 #include "src/util/output.h"
  34 #include "src/util/show_help.h"
  35 #include "src/mca/mca.h"
  36 #include "src/mca/base/base.h"
  37 #include "src/mca/base/pmix_mca_base_framework.h"
  38 #include "src/mca/base/pmix_mca_base_component_repository.h"
  39 #include "pmix_common.h"
  40 
  41 /*
  42  * Local functions
  43  */
  44 static int register_components(pmix_mca_base_framework_t *framework);
  45 /**
  46  * Function for finding and opening either all MCA components, or the
  47  * one that was specifically requested via a MCA parameter.
  48  */
  49 int pmix_mca_base_framework_components_register (pmix_mca_base_framework_t *framework,
  50                                             pmix_mca_base_register_flag_t flags)
  51 {
  52     bool open_dso_components = !(flags & PMIX_MCA_BASE_REGISTER_STATIC_ONLY);
  53     bool ignore_requested = !!(flags & PMIX_MCA_BASE_REGISTER_ALL);
  54     int ret;
  55 
  56     /* Find and load requested components */
  57     ret = pmix_mca_base_component_find(NULL, framework, ignore_requested, open_dso_components);
  58     if (PMIX_SUCCESS != ret) {
  59         return ret;
  60     }
  61 
  62     /* Register all remaining components */
  63     return register_components(framework);
  64 }
  65 
  66 /*
  67  * Traverse the entire list of found components (a list of
  68  * pmix_mca_base_component_t instances).  If the requested_component_names
  69  * array is empty, or the name of each component in the list of found
  70  * components is in the requested_components_array, try to open it.
  71  * If it opens, add it to the components_available list.
  72  */
  73 static int register_components(pmix_mca_base_framework_t *framework)
  74 {
  75     int ret;
  76     pmix_mca_base_component_t *component;
  77     pmix_mca_base_component_list_item_t *cli, *next;
  78     int output_id = framework->framework_output;
  79 
  80     /* Announce */
  81     pmix_output_verbose (PMIX_MCA_BASE_VERBOSE_COMPONENT, output_id,
  82                          "pmix:mca: base: components_register: registering framework %s components",
  83                          framework->framework_name);
  84 
  85     /* Traverse the list of found components */
  86 
  87     PMIX_LIST_FOREACH_SAFE(cli, next, &framework->framework_components, pmix_mca_base_component_list_item_t) {
  88         component = (pmix_mca_base_component_t *)cli->cli_component;
  89 
  90         pmix_output_verbose(PMIX_MCA_BASE_VERBOSE_COMPONENT, output_id,
  91                             "pmix:mca: base: components_register: found loaded component %s",
  92                             component->pmix_mca_component_name);
  93 
  94         /* Call the component's MCA parameter registration function (or open if register doesn't exist) */
  95         if (NULL == component->pmix_mca_register_component_params) {
  96             pmix_output_verbose (PMIX_MCA_BASE_VERBOSE_COMPONENT, output_id,
  97                                  "pmix:mca: base: components_register: "
  98                                  "component %s has no register or open function",
  99                                  component->pmix_mca_component_name);
 100             ret = PMIX_SUCCESS;
 101         } else {
 102             ret = component->pmix_mca_register_component_params();
 103         }
 104 
 105         if (PMIX_SUCCESS != ret) {
 106             if (PMIX_ERR_NOT_AVAILABLE != ret) {
 107                 /* If the component returns PMIX_ERR_NOT_AVAILABLE,
 108                    it's a cue to "silently ignore me" -- it's not a
 109                    failure, it's just a way for the component to say
 110                    "nope!".
 111 
 112                    Otherwise, however, display an error.  We may end
 113                    up displaying this twice, but it may go to separate
 114                    streams.  So better to be redundant than to not
 115                    display the error in the stream where it was
 116                    expected. */
 117 
 118                 if (pmix_mca_base_component_show_load_errors) {
 119                     pmix_output_verbose (PMIX_MCA_BASE_VERBOSE_ERROR, output_id,
 120                                          "pmix:mca: base: components_register: component %s "
 121                                          "/ %s register function failed",
 122                                          component->pmix_mca_type_name,
 123                                          component->pmix_mca_component_name);
 124                 }
 125 
 126                 pmix_output_verbose (PMIX_MCA_BASE_VERBOSE_COMPONENT, output_id,
 127                                      "pmix:mca: base: components_register: "
 128                                      "component %s register function failed",
 129                                      component->pmix_mca_component_name);
 130             }
 131 
 132             pmix_list_remove_item (&framework->framework_components, &cli->super);
 133 
 134             /* Release this list item */
 135             PMIX_RELEASE(cli);
 136             continue;
 137         }
 138 
 139         if (NULL != component->pmix_mca_register_component_params) {
 140             pmix_output_verbose (PMIX_MCA_BASE_VERBOSE_COMPONENT, output_id, "pmix:mca: base: components_register: "
 141                                  "component %s register function successful",
 142                                  component->pmix_mca_component_name);
 143         }
 144 
 145         /* Register this component's version */
 146         pmix_mca_base_component_var_register (component, "major_version", NULL, PMIX_MCA_BASE_VAR_TYPE_INT, NULL,
 147                                          0, PMIX_MCA_BASE_VAR_FLAG_DEFAULT_ONLY | PMIX_MCA_BASE_VAR_FLAG_INTERNAL,
 148                                          PMIX_INFO_LVL_9, PMIX_MCA_BASE_VAR_SCOPE_CONSTANT,
 149                                          &component->pmix_mca_component_major_version);
 150         pmix_mca_base_component_var_register (component, "minor_version", NULL, PMIX_MCA_BASE_VAR_TYPE_INT, NULL,
 151                                          0, PMIX_MCA_BASE_VAR_FLAG_DEFAULT_ONLY | PMIX_MCA_BASE_VAR_FLAG_INTERNAL,
 152                                          PMIX_INFO_LVL_9, PMIX_MCA_BASE_VAR_SCOPE_CONSTANT,
 153                                          &component->pmix_mca_component_minor_version);
 154         pmix_mca_base_component_var_register (component, "release_version", NULL, PMIX_MCA_BASE_VAR_TYPE_INT, NULL,
 155                                          0, PMIX_MCA_BASE_VAR_FLAG_DEFAULT_ONLY | PMIX_MCA_BASE_VAR_FLAG_INTERNAL,
 156                                          PMIX_INFO_LVL_9, PMIX_MCA_BASE_VAR_SCOPE_CONSTANT,
 157                                          &component->pmix_mca_component_release_version);
 158     }
 159 
 160     /* All done */
 161 
 162     return PMIX_SUCCESS;
 163 }

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