root/oshmem/mca/atomic/base/atomic_base_available.c

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

DEFINITIONS

This source file includes following definitions.
  1. mca_atomic_base_find_available
  2. init_query

   1 /*
   2  * Copyright (c) 2013      Mellanox Technologies, Inc.
   3  *                         All rights reserved.
   4  * $COPYRIGHT$
   5  *
   6  * Additional copyrights may follow
   7  *
   8  * $HEADER$
   9  */
  10 
  11 #include <stdio.h>
  12 #include <stdlib.h>
  13 #include <string.h>
  14 
  15 #include "oshmem_config.h"
  16 
  17 #include "opal/class/opal_list.h"
  18 #include "oshmem/mca/mca.h"
  19 #include "opal/mca/base/base.h"
  20 #include "opal/mca/base/mca_base_component_repository.h"
  21 
  22 #include "oshmem/constants.h"
  23 #include "oshmem/util/oshmem_util.h"
  24 #include "oshmem/mca/atomic/atomic.h"
  25 #include "oshmem/mca/atomic/base/base.h"
  26 
  27 /*
  28  * Private functions
  29  */
  30 static int init_query(const mca_base_component_t * ls,
  31                       bool enable_progress_threads,
  32                       bool enable_threads);
  33 
  34 /*
  35  * Scan down the list of successfully opened components and query each of
  36  * them (the opened list will be one or more components.  If the user
  37  * requested a specific component, it will be the only component in the
  38  * opened list).  Create and populate the available list of all
  39  * components who indicate that they want to be considered for selection.
  40  * Close all components who do not want to be considered for selection,
  41  * and destroy the opened list.
  42  *
  43  * Also find the basic component while we're doing all of this, and save
  44  * it in a global variable so that we can find it easily later (e.g.,
  45  * during scope selection).
  46  */
  47 int mca_atomic_base_find_available(bool enable_progress_threads,
  48                                    bool enable_threads)
  49 {
  50     mca_base_component_list_item_t *cli, *next;
  51     const mca_base_component_t *component;
  52 
  53     OPAL_LIST_FOREACH_SAFE(cli, next, &oshmem_atomic_base_framework.framework_components, mca_base_component_list_item_t) {
  54         component = cli->cli_component;
  55 
  56         /* Call a subroutine to do the work, because the component may
  57            represent different versions of the coll MCA. */
  58 
  59         if (OSHMEM_SUCCESS != init_query(component, enable_progress_threads,
  60                                        enable_threads)) {
  61             /* If the component doesn't want to run, then close it.
  62                Now close it out and release it from the DSO repository (if it's there). */
  63             opal_list_remove_item(&oshmem_atomic_base_framework.framework_components, &cli->super);
  64             mca_base_component_close(component, oshmem_atomic_base_framework.framework_output);
  65             OBJ_RELEASE(cli);
  66         }
  67     }
  68 
  69     /* If we have no collective components available, it's an error.
  70        Thanks for playing! */
  71 
  72     if (opal_list_get_size(&oshmem_atomic_base_framework.framework_components) == 0) {
  73         ATOMIC_VERBOSE(10,
  74                       "atomic:find_available: no components available!");
  75         return OSHMEM_ERROR;
  76     }
  77 
  78     /* All done */
  79 
  80     return mca_atomic_base_select();
  81 }
  82 
  83 /*
  84  * Query a component, see if it wants to run at all.  If it does, save
  85  * some information.  If it doesn't, close it.
  86  */
  87 static int init_query(const mca_base_component_t * component,
  88                       bool enable_progress_threads,
  89                       bool enable_threads)
  90 {
  91     int ret;
  92 
  93     ATOMIC_VERBOSE(10,
  94                    "atomic:find_available: querying atomic component %s",
  95                    component->mca_component_name);
  96 
  97     /* This component has already been successfully opened.  So now
  98      query it. */
  99 
 100     if (1 == component->mca_type_major_version
 101             && 0 == component->mca_type_minor_version
 102             && 0 == component->mca_type_release_version) {
 103 
 104         mca_atomic_base_component_t *atomic =
 105                 (mca_atomic_base_component_t *) component;
 106 
 107         ret = atomic->atomic_startup(enable_progress_threads, enable_threads);
 108     } else {
 109         /* Unrecognized coll API version */
 110 
 111         ATOMIC_VERBOSE(10,
 112                        "atomic:find_available: unrecognized atomic API version (%d.%d.%d, ignored)",
 113                       component->mca_type_major_version,
 114                       component->mca_type_minor_version,
 115                       component->mca_type_release_version);
 116         return OSHMEM_ERROR;
 117     }
 118 
 119     /* Query done -- look at the return value to see what happened */
 120 
 121     if (OSHMEM_SUCCESS != ret) {
 122         ATOMIC_VERBOSE(10,
 123                        "atomic:find_available: atomic component %s is not available",
 124                        component->mca_component_name);
 125         if (NULL != component->mca_close_component) {
 126             component->mca_close_component();
 127         }
 128     } else {
 129         ATOMIC_VERBOSE(10,
 130                        "atomic:find_available: atomic component %s is available",
 131                        component->mca_component_name);
 132     }
 133 
 134     /* All done */
 135 
 136     return ret;
 137 }

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