root/opal/mca/pmix/pmix4x/pmix/src/mca/psensor/base/psensor_base_select.c

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

DEFINITIONS

This source file includes following definitions.
  1. pmix_psensor_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$
  14  *
  15  * Additional copyrights may follow
  16  *
  17  * $HEADER$
  18  */
  19 
  20 #include <src/include/pmix_config.h>
  21 #include <pmix_common.h>
  22 
  23 #include <string.h>
  24 
  25 #include "src/mca/mca.h"
  26 #include "src/mca/base/base.h"
  27 
  28 #include "src/mca/psensor/base/base.h"
  29 
  30 static bool selected = false;
  31 
  32 /* Function for selecting a prioritized list of components
  33  * from all those that are available. */
  34 int pmix_psensor_base_select(void)
  35 {
  36     pmix_mca_base_component_list_item_t *cli = NULL;
  37     pmix_psensor_base_component_t *component = NULL;
  38     pmix_psensor_active_module_t *newactive, *active;
  39     pmix_mca_base_module_t *mod;
  40     int pri;
  41     bool inserted;
  42 
  43     if (selected) {
  44         /* ensure we don't do this twice */
  45         return PMIX_SUCCESS;
  46     }
  47     selected = true;
  48 
  49     /* Query all available components and ask if they have a module */
  50     PMIX_LIST_FOREACH(cli, &pmix_psensor_base_framework.framework_components, pmix_mca_base_component_list_item_t) {
  51         component = (pmix_psensor_base_component_t *) cli->cli_component;
  52 
  53         pmix_output_verbose(5, pmix_psensor_base_framework.framework_output,
  54                             "mca:psensor:select: checking available component %s",
  55                             component->base.pmix_mca_component_name);
  56 
  57         /* get the module for this component */
  58         if (PMIX_SUCCESS != component->base.pmix_mca_query_component(&mod, &pri)) {
  59             continue;
  60         }
  61 
  62         /* add to our prioritized list of available actives */
  63         newactive = PMIX_NEW(pmix_psensor_active_module_t);
  64         newactive->priority = pri;
  65         newactive->component = component;
  66         newactive->module = (pmix_psensor_base_module_t*)mod;
  67 
  68         /* maintain priority order */
  69         inserted = false;
  70         PMIX_LIST_FOREACH(active, &pmix_psensor_base.actives, pmix_psensor_active_module_t) {
  71             if (newactive->priority > active->priority) {
  72                 pmix_list_insert_pos(&pmix_psensor_base.actives,
  73                                      (pmix_list_item_t*)active, &newactive->super);
  74                 inserted = true;
  75                 break;
  76             }
  77         }
  78         if (!inserted) {
  79             /* must be lowest priority - add to end */
  80             pmix_list_append(&pmix_psensor_base.actives, &newactive->super);
  81         }
  82     }
  83 
  84     if (4 < pmix_output_get_verbosity(pmix_psensor_base_framework.framework_output)) {
  85         pmix_output(0, "Final PSENSOR priorities");
  86         /* show the prioritized list */
  87         PMIX_LIST_FOREACH(active, &pmix_psensor_base.actives, pmix_psensor_active_module_t) {
  88             pmix_output(0, "\tPSENSOR: %s Priority: %d",
  89                         active->component->base.pmix_mca_component_name, active->priority);
  90         }
  91     }
  92 
  93     return PMIX_SUCCESS;;
  94 }

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