root/ompi/mca/topo/base/topo_base_find_available.c

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

DEFINITIONS

This source file includes following definitions.
  1. mca_topo_base_find_available
  2. init_query
  3. init_query_2_2_0

   1 /*
   2  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2013 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) 2012-2013 Inria.  All rights reserved.
  13  * Copyright (c) 2014      Research Organization for Information Science
  14  *                         and Technology (RIST). All rights reserved.
  15  * $COPYRIGHT$
  16  *
  17  * Additional copyrights may follow
  18  *
  19  * $HEADER$
  20  */
  21 
  22 #include "ompi_config.h"
  23 
  24 #include <stdio.h>
  25 #include <stdlib.h>
  26 
  27 #include "opal/class/opal_list.h"
  28 #include "opal/util/output.h"
  29 #include "ompi/mca/mca.h"
  30 #include "opal/mca/base/base.h"
  31 #include "opal/mca/base/mca_base_component_repository.h"
  32 #include "ompi/mca/topo/topo.h"
  33 #include "ompi/mca/topo/base/base.h"
  34 #include "ompi/constants.h"
  35 
  36 static int init_query(const mca_base_component_t *m,
  37                       mca_base_component_list_item_t *entry,
  38                       bool enable_progress_threads,
  39                       bool enable_mpi_threads);
  40 static int init_query_2_2_0(const mca_base_component_t *component,
  41                             mca_base_component_list_item_t *entry,
  42                             bool enable_progress_threads,
  43                             bool enable_mpi_threads);
  44 
  45 int mca_topo_base_find_available(bool enable_progress_threads,
  46                                  bool enable_mpi_threads)
  47 {
  48     opal_list_item_t *item, *next;
  49     mca_base_component_list_item_t *cli;
  50 
  51     /* The list of components which we should check is already present
  52        in ompi_topo_base_framework.framework_components, which was established in
  53        mca_topo_base_open */
  54 
  55     item = opal_list_get_first(&ompi_topo_base_framework.framework_components);
  56     while (item != opal_list_get_end(&ompi_topo_base_framework.framework_components)) {
  57         next = opal_list_get_next(item);
  58          cli = (mca_base_component_list_item_t*)item;
  59 
  60          /* Now for this entry, we have to determine the thread level. Call
  61             a subroutine to do the job for us */
  62 
  63          if (OMPI_SUCCESS != init_query(cli->cli_component, cli,
  64                                         enable_progress_threads,
  65                                         enable_mpi_threads)) {
  66              /* The component does not want to run, so close it. Its close()
  67                 has already been invoked. Close it out of the DSO repository
  68                 (if it is there in the repository) */
  69              mca_base_component_repository_release(cli->cli_component);
  70              opal_list_remove_item(&ompi_topo_base_framework.framework_components, item);
  71              OBJ_RELEASE(item);
  72          }
  73          item = next;
  74      }
  75 
  76      /* There should at least be one topo component available */
  77     if (0 == opal_list_get_size(&ompi_topo_base_framework.framework_components)) {
  78          opal_output_verbose (10, ompi_topo_base_framework.framework_output,
  79                               "topo:find_available: no topo components available!");
  80          return OMPI_ERROR;
  81      }
  82 
  83     /* All done */
  84     return OMPI_SUCCESS;
  85 }
  86 
  87 
  88 static int init_query(const mca_base_component_t *m,
  89                       mca_base_component_list_item_t *entry,
  90                       bool enable_progress_threads,
  91                       bool enable_mpi_threads)
  92 {
  93     int ret;
  94 
  95     opal_output_verbose(10, ompi_topo_base_framework.framework_output,
  96                         "topo:find_available: querying topo component %s",
  97                         m->mca_component_name);
  98 
  99     /* This component has been successfully opened, now try to query
 100        it and see if it wants to run in this job.  Nothing interesting
 101        happened in the topo framework before v2.2.0, so don't bother
 102        supporting anything before then. */
 103     if (2 == m->mca_type_major_version &&
 104         2 == m->mca_type_minor_version &&
 105         0 == m->mca_type_release_version) {
 106         ret = init_query_2_2_0(m, entry, enable_progress_threads,
 107                                enable_mpi_threads);
 108     } else {
 109         /* unrecognised API version */
 110         opal_output_verbose(10, ompi_topo_base_framework.framework_output,
 111                             "topo:find_available:unrecognised topo API version (%d.%d.%d)",
 112                             m->mca_type_major_version,
 113                             m->mca_type_minor_version,
 114                             m->mca_type_release_version);
 115         return OMPI_ERROR;
 116     }
 117 
 118     /* Query done -- look at return value to see what happened */
 119     if (OMPI_SUCCESS != ret) {
 120         opal_output_verbose(10, ompi_topo_base_framework.framework_output,
 121                             "topo:find_available topo component %s is not available",
 122                             m->mca_component_name);
 123         if (NULL != m->mca_close_component) {
 124             m->mca_close_component();
 125         }
 126     } else {
 127         opal_output_verbose(10, ompi_topo_base_framework.framework_output,
 128                             "topo:find_avalable: topo component %s is available",
 129                             m->mca_component_name);
 130 
 131     }
 132 
 133     /* All done */
 134     return ret;
 135 }
 136 
 137 
 138 static int init_query_2_2_0(const mca_base_component_t *component,
 139                             mca_base_component_list_item_t *entry,
 140                             bool enable_progress_threads,
 141                             bool enable_mpi_threads)
 142 {
 143     mca_topo_base_component_2_2_0_t *topo =
 144         (mca_topo_base_component_2_2_0_t *) component;
 145 
 146     return topo->topoc_init_query(enable_progress_threads,
 147                                   enable_mpi_threads);
 148 }

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