root/ompi/mca/bml/base/bml_base_frame.c

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

DEFINITIONS

This source file includes following definitions.
  1. mca_bml_base_register
  2. mca_bml_base_open
  3. mca_bml_base_close

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2005 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
  10  *                         University of Stuttgart.  All rights reserved.
  11  * Copyright (c) 2004-2006 The Regents of the University of California.
  12  *                         All rights reserved.
  13  * Copyright (c) 2009      Cisco Systems, Inc.  All rights reserved.
  14  * Copyright (c) 2014      Los Alamos National Security, LLC. All rights
  15  *                         reserved.
  16  * $COPYRIGHT$
  17  *
  18  * Additional copyrights may follow
  19  *
  20  * $HEADER$
  21  */
  22 
  23 
  24 #include "ompi_config.h"
  25 #include <stdio.h>
  26 #ifdef HAVE_UNISTD_H
  27 #include <unistd.h>
  28 #endif  /* HAVE_UNISTD_H */
  29 #include "ompi/mca/bml/base/base.h"
  30 #include "ompi/mca/bml/base/static-components.h"
  31 #include "opal/mca/btl/base/base.h"
  32 #include "opal/mca/base/base.h"
  33 #if OPAL_ENABLE_DEBUG_RELIABILITY
  34 #include "opal/util/alfg.h"
  35 #endif /* OPAL_ENABLE_DEBUG_RELIABILITY */
  36 
  37 static int mca_bml_base_register(mca_base_register_flag_t flags);
  38 static int mca_bml_base_open(mca_base_open_flag_t flags);
  39 static int mca_bml_base_close(void);
  40 
  41 MCA_BASE_FRAMEWORK_DECLARE(ompi, bml, "BTL Multiplexing Layer", mca_bml_base_register,
  42                            mca_bml_base_open, mca_bml_base_close, mca_bml_base_static_components,
  43                            0);
  44 
  45 #if OPAL_ENABLE_DEBUG_RELIABILITY
  46 int mca_bml_base_error_rate_floor;
  47 int mca_bml_base_error_rate_ceiling;
  48 int mca_bml_base_error_count;
  49 static bool mca_bml_base_srand;
  50 opal_rng_buff_t mca_bml_base_rand_buff;
  51 #endif
  52 
  53 opal_mutex_t mca_bml_lock = OPAL_MUTEX_STATIC_INIT;
  54 
  55 static int mca_bml_base_register(mca_base_register_flag_t flags)
  56 {
  57 #if OPAL_ENABLE_DEBUG_RELIABILITY
  58     do {
  59         int var_id;
  60 
  61         mca_bml_base_error_rate_floor = 0;
  62         var_id = mca_base_var_register("ompi", "bml", "base", "error_rate_floor", NULL,
  63                                        MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
  64                                        OPAL_INFO_LVL_9,
  65                                        MCA_BASE_VAR_SCOPE_READONLY,
  66                                        &mca_bml_base_error_rate_floor);
  67         (void) mca_base_var_register_synonym(var_id, "ompi", "bml", NULL, "error_rate_floor",
  68                                              MCA_BASE_VAR_SYN_FLAG_DEPRECATED);
  69 
  70         mca_bml_base_error_rate_ceiling = 0;
  71         var_id = mca_base_var_register("ompi", "bml", "base", "error_rate_ceiling", NULL,
  72                                        MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
  73                                        OPAL_INFO_LVL_9,
  74                                        MCA_BASE_VAR_SCOPE_READONLY,
  75                                        &mca_bml_base_error_rate_ceiling);
  76         (void) mca_base_var_register_synonym(var_id, "ompi", "bml", NULL, "error_rate_ceiling",
  77                                              MCA_BASE_VAR_SYN_FLAG_DEPRECATED);
  78 
  79 
  80         mca_bml_base_srand = true;
  81         var_id = mca_base_var_register("ompi", "bml", "base", "srand", NULL,
  82                                        MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
  83                                        OPAL_INFO_LVL_9,
  84                                        MCA_BASE_VAR_SCOPE_READONLY,
  85                                        &mca_bml_base_srand);
  86         (void) mca_base_var_register_synonym(var_id, "ompi", "bml", NULL, "srand",
  87                                              MCA_BASE_VAR_SYN_FLAG_DEPRECATED);
  88     } while (0);
  89 #endif
  90 
  91     return OMPI_SUCCESS;
  92 }
  93 
  94 static int mca_bml_base_open(mca_base_open_flag_t flags)
  95 {
  96     int ret;
  97 
  98     if(OMPI_SUCCESS !=
  99        (ret = mca_base_framework_components_open(&ompi_bml_base_framework, flags))) {
 100         return ret;
 101     }
 102 
 103 #if OPAL_ENABLE_DEBUG_RELIABILITY
 104     /* seed random number generator */
 105         struct timeval tv;
 106         gettimeofday(&tv, NULL);
 107         opal_srand(&mca_bml_base_rand_buff,(uint32_t)(getpid() * tv.tv_usec));
 108 
 109     /* initialize count */
 110     if(mca_bml_base_error_rate_ceiling > 0
 111        && mca_bml_base_error_rate_floor <= mca_bml_base_error_rate_ceiling) {
 112         mca_bml_base_error_count = (int) (((double) mca_bml_base_error_rate_ceiling *
 113                     opal_rand(&mca_bml_base_rand_buff))/(UINT32_MAX+1.0));
 114     }
 115 #endif
 116 
 117     return mca_base_framework_open(&opal_btl_base_framework, 0);
 118 }
 119 
 120 static int mca_bml_base_close( void )
 121 {
 122     int ret;
 123 
 124     /* close any open components (including the selected one) */
 125     ret = mca_base_framework_components_close(&ompi_bml_base_framework, NULL);
 126     if (OMPI_SUCCESS != ret) {
 127         return ret;
 128     }
 129 
 130     return mca_base_framework_close(&opal_btl_base_framework);
 131 }

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