root/opal/mca/pmix/pmix4x/pmix/src/mca/pshmem/base/pshmem_base_select.c

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

DEFINITIONS

This source file includes following definitions.
  1. pmix_pshmem_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/pshmem/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_pshmem_base_select(void)
  35 {
  36     pmix_mca_base_component_list_item_t *cli;
  37     pmix_mca_base_component_t *component;
  38     pmix_mca_base_module_t *module;
  39     pmix_pshmem_base_module_t *nmodule;
  40     int rc, priority, best_pri = -1;
  41     bool inserted = false;
  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_pshmem_base_framework.framework_components, pmix_mca_base_component_list_item_t) {
  51         component = (pmix_mca_base_component_t *) cli->cli_component;
  52 
  53         pmix_output_verbose(5, pmix_pshmem_base_framework.framework_output,
  54                             "mca:pshmem:select: checking available component %s", component->pmix_mca_component_name);
  55 
  56         /* If there's no query function, skip it */
  57         if (NULL == component->pmix_mca_query_component) {
  58             pmix_output_verbose(5, pmix_pshmem_base_framework.framework_output,
  59                                 "mca:pshmem:select: Skipping component [%s]. It does not implement a query function",
  60                                 component->pmix_mca_component_name );
  61             continue;
  62         }
  63 
  64         /* Query the component */
  65         pmix_output_verbose(5, pmix_pshmem_base_framework.framework_output,
  66                             "mca:pshmem:select: Querying component [%s]",
  67                             component->pmix_mca_component_name);
  68         rc = component->pmix_mca_query_component(&module, &priority);
  69 
  70         /* If no module was returned, then skip component */
  71         if (PMIX_SUCCESS != rc || NULL == module) {
  72             pmix_output_verbose(5, pmix_pshmem_base_framework.framework_output,
  73                                 "mca:pshmem:select: Skipping component [%s]. Query failed to return a module",
  74                                 component->pmix_mca_component_name );
  75             continue;
  76         }
  77 
  78         /* If we got a module, try to initialize it */
  79         nmodule = (pmix_pshmem_base_module_t*) module;
  80         if (NULL != nmodule->init && PMIX_SUCCESS != nmodule->init()) {
  81             continue;
  82         }
  83 
  84         /* keep only the highest priority module */
  85         if (best_pri < priority) {
  86             best_pri = priority;
  87             /* give any prior module a chance to finalize */
  88             if (NULL != pmix_pshmem.finalize) {
  89                 pmix_pshmem.finalize();
  90             }
  91             pmix_pshmem = *nmodule;
  92             inserted = true;
  93         }
  94     }
  95 
  96     if (!inserted) {
  97         return PMIX_ERR_NOT_FOUND;
  98     }
  99     return PMIX_SUCCESS;
 100 }

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