root/opal/mca/pmix/pmix4x/pmix/src/mca/psquash/base/psquash_base_select.c

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

DEFINITIONS

This source file includes following definitions.
  1. pmix_psquash_base_select

   1 /*
   2  * Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2005 The University of Tennessee and The University
   6  *                         of Tennessee Research Foundation.  All rights
   7  *                         reserved.
   8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
   9  *                         University of Stuttgart.  All rights reserved.
  10  * Copyright (c) 2004-2005 The Regents of the University of California.
  11  *                         All rights reserved.
  12  * Copyright (c) 2016-2017 Intel, Inc. All rights reserved.
  13  * Copyright (c) 2019      IBM Corporation.  All rights reserved.
  14  * $COPYRIGHT$
  15  *
  16  * Additional copyrights may follow
  17  *
  18  * $HEADER$
  19  */
  20 
  21 #include <src/include/pmix_config.h>
  22 #include <pmix_common.h>
  23 
  24 #include <string.h>
  25 
  26 #include "src/mca/mca.h"
  27 #include "src/mca/base/base.h"
  28 #include "src/util/error.h"
  29 #include "src/util/show_help.h"
  30 
  31 #include "src/mca/psquash/base/base.h"
  32 
  33 static bool selected = false;
  34 
  35 /* Function for selecting a prioritized list of components
  36  * from all those that are available. */
  37 int pmix_psquash_base_select(void)
  38 {
  39     pmix_mca_base_component_list_item_t *cli;
  40     pmix_mca_base_component_t *component;
  41     pmix_mca_base_module_t *module;
  42     pmix_psquash_base_module_t *nmodule;
  43     int rc, priority, best_pri = -1;
  44     bool inserted = false;
  45 
  46     if (selected) {
  47         /* ensure we don't do this twice */
  48         return PMIX_SUCCESS;
  49     }
  50     selected = true;
  51 
  52     /* Query all available components and ask if they have a module */
  53     PMIX_LIST_FOREACH(cli, &pmix_psquash_base_framework.framework_components, pmix_mca_base_component_list_item_t) {
  54         component = (pmix_mca_base_component_t *) cli->cli_component;
  55 
  56         pmix_output_verbose(5, pmix_psquash_base_framework.framework_output,
  57                             "mca:psquash:select: checking available component %s", component->pmix_mca_component_name);
  58 
  59         /* If there's no query function, skip it */
  60         if (NULL == component->pmix_mca_query_component) {
  61             pmix_output_verbose(5, pmix_psquash_base_framework.framework_output,
  62                                 "mca:psquash:select: Skipping component [%s]. It does not implement a query function",
  63                                 component->pmix_mca_component_name );
  64             continue;
  65         }
  66 
  67         /* Query the component */
  68         pmix_output_verbose(5, pmix_psquash_base_framework.framework_output,
  69                             "mca:psquash:select: Querying component [%s]",
  70                             component->pmix_mca_component_name);
  71         rc = component->pmix_mca_query_component(&module, &priority);
  72 
  73         /* If no module was returned, then skip component */
  74         if (PMIX_SUCCESS != rc || NULL == module) {
  75             pmix_output_verbose(5, pmix_psquash_base_framework.framework_output,
  76                                 "mca:psquash:select: Skipping component [%s]. Query failed to return a module",
  77                                 component->pmix_mca_component_name );
  78             continue;
  79         }
  80 
  81         /* If we got a module, try to initialize it */
  82         nmodule = (pmix_psquash_base_module_t*) module;
  83         if (NULL != nmodule->init && PMIX_SUCCESS != nmodule->init()) {
  84             continue;
  85         }
  86 
  87         /* keep only the highest priority module */
  88         if (best_pri < priority) {
  89             best_pri = priority;
  90             /* give any prior module a chance to finalize */
  91             if (NULL != pmix_psquash.finalize) {
  92                 pmix_psquash.finalize();
  93             }
  94             pmix_psquash = *nmodule;
  95             inserted = true;
  96         }
  97     }
  98 
  99     if (!inserted) {
 100         return PMIX_ERR_NOT_FOUND;
 101     }
 102 
 103     return PMIX_SUCCESS;;
 104 }

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