root/ompi/mca/coll/hcoll/coll_hcoll_component.c

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

DEFINITIONS

This source file includes following definitions.
  1. mca_coll_hcoll_get_lib
  2. reg_int
  3. hcoll_register
  4. hcoll_open
  5. hcoll_close

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2011 Mellanox Technologies. All rights reserved.
   4  * Copyright (c) 2015      Los Alamos National Security, LLC. All rights
   5  *                         reserved.
   6  * $COPYRIGHT$
   7  *
   8  * Additional copyrights may follow
   9  *
  10  * $HEADER$
  11  */
  12 #include "ompi_config.h"
  13 #include <stdio.h>
  14 
  15 #include <dlfcn.h>
  16 #include <libgen.h>
  17 
  18 #include "coll_hcoll.h"
  19 #include "opal/mca/installdirs/installdirs.h"
  20 #include "coll_hcoll_dtypes.h"
  21 
  22 /*
  23  * Public string showing the coll ompi_hcol component version number
  24  */
  25 const char *mca_coll_hcoll_component_version_string =
  26   "Open MPI HCOL collective MCA component version " OMPI_VERSION;
  27 
  28 
  29 static int hcoll_open(void);
  30 static int hcoll_close(void);
  31 static int hcoll_register(void);
  32 int mca_coll_hcoll_output = -1;
  33 mca_coll_hcoll_component_t mca_coll_hcoll_component = {
  34 
  35     /* First, the mca_component_t struct containing meta information
  36        about the component itfca */
  37     {
  38         .collm_version = {
  39             MCA_COLL_BASE_VERSION_2_0_0,
  40 
  41             /* Component name and version */
  42             .mca_component_name = "hcoll",
  43             MCA_BASE_MAKE_VERSION(component, OMPI_MAJOR_VERSION, OMPI_MINOR_VERSION,
  44                                   OMPI_RELEASE_VERSION),
  45 
  46             /* Component open and close functions */
  47             .mca_open_component = hcoll_open,
  48             .mca_close_component = hcoll_close,
  49             .mca_register_component_params = hcoll_register,
  50         },
  51         .collm_data = {
  52             /* The component is not checkpoint ready */
  53             MCA_BASE_METADATA_PARAM_NONE
  54         },
  55 
  56         /* Initialization / querying functions */
  57 
  58         .collm_init_query = mca_coll_hcoll_init_query,
  59         .collm_comm_query = mca_coll_hcoll_comm_query,
  60     },
  61     90, /* priority */
  62     0,  /* verbose level */
  63     0,   /* hcoll_enable */
  64     NULL /*hcoll version */
  65 };
  66 
  67 
  68 
  69 
  70 int mca_coll_hcoll_get_lib(void)
  71 {
  72 
  73     memset(&mca_coll_hcoll_component.hcoll_ops,
  74             0, sizeof(mca_coll_hcoll_component.hcoll_ops));
  75 
  76     return OMPI_SUCCESS;
  77 }
  78 
  79 /*
  80  *  * Local flags
  81  *   */
  82 enum {
  83     REGINT_NEG_ONE_OK = 0x01,
  84     REGINT_GE_ZERO = 0x02,
  85     REGINT_GE_ONE = 0x04,
  86     REGINT_NONZERO = 0x08,
  87     REGINT_MAX = 0x88
  88 };
  89 
  90 enum {
  91     REGSTR_EMPTY_OK = 0x01,
  92     REGSTR_MAX = 0x88
  93 };
  94 
  95 
  96 /*
  97  * Utility routine for integer parameter registration
  98  */
  99 static int reg_int(const char* param_name,
 100         const char* deprecated_param_name,
 101         const char* param_desc,
 102         int default_value, int *storage, int flags)
 103 {
 104     int index;
 105 
 106     *storage = default_value;
 107     index = mca_base_component_var_register(
 108             &mca_coll_hcoll_component.super.collm_version,
 109             param_name, param_desc, MCA_BASE_VAR_TYPE_INT,
 110             NULL, 0, 0,OPAL_INFO_LVL_9,
 111             MCA_BASE_VAR_SCOPE_READONLY, storage);
 112     if (NULL != deprecated_param_name) {
 113         (void) mca_base_var_register_synonym(index,
 114                 "ompi", "coll", "hcoll", deprecated_param_name,
 115                 MCA_BASE_VAR_SYN_FLAG_DEPRECATED);
 116     }
 117 
 118     if (0 != (flags & REGINT_NEG_ONE_OK) && -1 == *storage) {
 119         return OMPI_SUCCESS;
 120     }
 121 
 122     if ((0 != (flags & REGINT_GE_ZERO) && *storage < 0) ||
 123             (0 != (flags & REGINT_GE_ONE) && *storage < 1) ||
 124             (0 != (flags & REGINT_NONZERO) && 0 == *storage)) {
 125         opal_output(0, "Bad parameter value for parameter \"%s\"",
 126                 param_name);
 127         return OMPI_ERR_BAD_PARAM;
 128     }
 129 
 130     return OMPI_SUCCESS;
 131 }
 132 
 133 
 134 static int hcoll_register(void)
 135 {
 136 
 137     int ret, tmp;
 138 
 139     ret = OMPI_SUCCESS;
 140 
 141 #define CHECK(expr) do {                        \
 142         tmp = (expr);                           \
 143         if (OMPI_SUCCESS != tmp) ret = tmp;     \
 144     } while (0)
 145 
 146 
 147     CHECK(reg_int("priority",NULL,
 148                   "Priority of the hcol coll component",
 149                   90,
 150                   &mca_coll_hcoll_component.hcoll_priority,
 151                   0));
 152 
 153     CHECK(reg_int("verbose", NULL,
 154                   "Verbose level of the hcol coll component",
 155                   0,
 156                   &mca_coll_hcoll_component.hcoll_verbose,
 157                   0));
 158 
 159     CHECK(reg_int("enable",NULL,
 160                   "[1|0|] Enable/Disable HCOL",
 161                   1,
 162                   &mca_coll_hcoll_component.hcoll_enable,
 163                   0));
 164 
 165     CHECK(reg_int("np",NULL,
 166                   "Minimal number of processes in the communicator"
 167                   " for the corresponding hcoll context to be created (default: 32)",
 168                   2,
 169                   &mca_coll_hcoll_component.hcoll_np,
 170                   0));
 171 
 172     CHECK(reg_int("datatype_fallback",NULL,
 173                   "[1|0|] Enable/Disable user defined dattypes fallback",
 174                   1,
 175                   &mca_coll_hcoll_component.hcoll_datatype_fallback,
 176                   0));
 177 #if HCOLL_API >= HCOLL_VERSION(3,6)
 178     CHECK(reg_int("dts",NULL,
 179                   "[1|0|] Enable/Disable derived types support",
 180                   1,
 181                   &mca_coll_hcoll_component.derived_types_support_enabled,
 182                   0));
 183 #else
 184     mca_coll_hcoll_component.derived_types_support_enabled = 0;
 185 #endif
 186     mca_coll_hcoll_component.compiletime_version = HCOLL_VERNO_STRING;
 187     mca_base_component_var_register(&mca_coll_hcoll_component.super.collm_version,
 188             MCA_COMPILETIME_VER,
 189             "Version of the libhcoll library with which Open MPI was compiled",
 190             MCA_BASE_VAR_TYPE_VERSION_STRING,
 191             NULL, 0, 0,
 192             OPAL_INFO_LVL_3,
 193             MCA_BASE_VAR_SCOPE_READONLY,
 194             &mca_coll_hcoll_component.compiletime_version);
 195     mca_coll_hcoll_component.runtime_version = hcoll_get_version();
 196     mca_base_component_var_register(&mca_coll_hcoll_component.super.collm_version,
 197             MCA_RUNTIME_VER,
 198             "Version of the libhcoll library with which Open MPI is running",
 199             MCA_BASE_VAR_TYPE_VERSION_STRING,
 200             NULL, 0, 0,
 201             OPAL_INFO_LVL_3,
 202             MCA_BASE_VAR_SCOPE_READONLY,
 203             &mca_coll_hcoll_component.runtime_version);
 204 
 205     return ret;
 206 }
 207 
 208 static int hcoll_open(void)
 209 {
 210     mca_coll_hcoll_component_t *cm;
 211     cm  = &mca_coll_hcoll_component;
 212     mca_coll_hcoll_output = opal_output_open(NULL);
 213     opal_output_set_verbosity(mca_coll_hcoll_output, cm->hcoll_verbose);
 214     hcoll_rte_fns_setup();
 215     cm->libhcoll_initialized = false;
 216     return OMPI_SUCCESS;
 217 }
 218 
 219 static int hcoll_close(void)
 220 {
 221     int rc;
 222     mca_coll_hcoll_component_t *cm;
 223     cm = &mca_coll_hcoll_component;
 224 
 225     if (false == cm->libhcoll_initialized) {
 226         return OMPI_SUCCESS;
 227     }
 228 
 229     if (cm->using_mem_hooks) {
 230         opal_mem_hooks_unregister_release(mca_coll_hcoll_mem_release_cb);
 231     }
 232 
 233 #if HCOLL_API >= HCOLL_VERSION(3,2)
 234     hcoll_free_init_opts(cm->init_opts);
 235 #endif
 236 
 237     HCOL_VERBOSE(5,"HCOLL FINALIZE");
 238     rc = hcoll_finalize();
 239     OBJ_DESTRUCT(&cm->dtypes);
 240     opal_progress_unregister(hcoll_progress_fn);
 241     if (HCOLL_SUCCESS != rc){
 242         HCOL_VERBOSE(1,"Hcol library finalize failed");
 243         return OMPI_ERROR;
 244     }
 245 
 246     mca_base_framework_close(&opal_memory_base_framework);
 247 
 248     return OMPI_SUCCESS;
 249 }

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