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