Addressing Jeff's comments:
1. Changed rng_buff_t --> opal_rng_buff_t 2. All global variables obey the prefix rule 3. Old code has been removed 4. Found a couple of unnecessary includes Refs trac:4298 This commit was SVN r30807. The following Trac tickets were found above: Ticket 4298 --> https://svn.open-mpi.org/trac/ompi/ticket/4298
Этот коммит содержится в:
родитель
90625573ff
Коммит
9ea9bec4ad
@ -21,7 +21,6 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "ompi/mca/bml/bml.h"
|
||||
#include "ompi/mca/bml/base/bml_base_btl.h"
|
||||
#include "bml_base_btl.h"
|
||||
#include "opal/util/crc.h"
|
||||
#if OPAL_ENABLE_DEBUG_RELIABILITY
|
||||
@ -75,7 +74,7 @@ int mca_bml_base_btl_array_reserve(mca_bml_base_btl_array_t* array, size_t size)
|
||||
extern int mca_bml_base_error_rate_floor;
|
||||
extern int mca_bml_base_error_rate_ceiling;
|
||||
extern int mca_bml_base_error_count;
|
||||
extern rng_buff_t rand_buff;
|
||||
extern opal_rng_buff_t mca_bml_base_rand_buff;
|
||||
|
||||
struct mca_bml_base_context_t {
|
||||
size_t index;
|
||||
@ -107,7 +106,7 @@ int mca_bml_base_send( mca_bml_base_btl_t* bml_btl,
|
||||
des->des_context = (void*)bml_btl;
|
||||
if(mca_bml_base_error_count <= 0 && mca_bml_base_error_rate_ceiling > 0) {
|
||||
mca_bml_base_error_count = (int) (((double) mca_bml_base_error_rate_ceiling *
|
||||
opal_rand(&rand_buff))/(UINT32_MAX+1.0));
|
||||
opal_rand(&mca_bml_base_rand_buff))/(UINT32_MAX+1.0));
|
||||
if(mca_bml_base_error_count < (double) mca_bml_base_error_rate_floor) {
|
||||
mca_bml_base_error_count = (double) mca_bml_base_error_rate_floor;
|
||||
}
|
||||
@ -123,7 +122,7 @@ int mca_bml_base_send( mca_bml_base_btl_t* bml_btl,
|
||||
if(NULL != ctx) {
|
||||
opal_output(0, "%s:%d: corrupting data\n", __FILE__, __LINE__);
|
||||
ctx->index = (size_t) ((des->des_src[0].seg_len *
|
||||
opal_rand(&rand_buff) * 1.0) / (UINT32_MAX + 1.0));
|
||||
opal_rand(&mca_bml_base_rand_buff) * 1.0) / (UINT32_MAX + 1.0));
|
||||
ctx->cbfunc = des->des_cbfunc;
|
||||
ctx->cbdata = des->des_cbdata;
|
||||
((unsigned char*)des->des_src[0].seg_addr.pval)[ctx->index] ^= ~0;
|
||||
@ -136,8 +135,6 @@ int mca_bml_base_send( mca_bml_base_btl_t* bml_btl,
|
||||
return bml_btl->btl_send( bml_btl->btl,
|
||||
bml_btl->btl_endpoint,
|
||||
des, tag );
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
#include "ompi/mca/bml/base/base.h"
|
||||
#include "ompi/mca/bml/base/bml_base_btl.h"
|
||||
#include "ompi/mca/bml/base/static-components.h"
|
||||
#include "ompi/mca/btl/base/base.h"
|
||||
#include "opal/mca/base/base.h"
|
||||
@ -45,7 +44,7 @@ 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;
|
||||
rng_buff_t rand_buff;
|
||||
opal_rng_buff_t mca_bml_base_rand_buff;
|
||||
#endif
|
||||
|
||||
static int mca_bml_base_register(mca_base_register_flag_t flags)
|
||||
@ -100,13 +99,13 @@ static int mca_bml_base_open(mca_base_open_flag_t flags)
|
||||
/* seed random number generator */
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
opal_srand(&rand_buff,(uint32_t)(getpid() * tv.tv_usec));
|
||||
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(&rand_buff))/(UINT32_MAX+1.0));
|
||||
opal_rand(&mca_bml_base_rand_buff))/(UINT32_MAX+1.0));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -230,8 +230,6 @@ static int btl_openib_component_open(void)
|
||||
OBJ_CONSTRUCT(&mca_btl_openib_component.ib_procs, opal_list_t);
|
||||
mca_btl_openib_component.memory_registration_verbose = -1;
|
||||
|
||||
/* JSL */
|
||||
/*srand48(getpid() * time(NULL)); */
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -359,7 +359,7 @@ static int udcm_timeout;
|
||||
/* seed for rand_r. remove me when opal gets a random number generator */
|
||||
/* Uses the OPAL ALFG RNG */
|
||||
static uint32_t udcm_random_seed = 0;
|
||||
static rng_buff_t udcm_rand_buff;
|
||||
static opal_rng_buff_t udcm_rand_buff;
|
||||
|
||||
static struct timeval udcm_timeout_tv;
|
||||
|
||||
@ -1036,7 +1036,7 @@ static uint32_t max_inline_size(int qp, mca_btl_openib_device_t *device)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Using OPAL's Additive Lagged Fibbonacci RNG */
|
||||
/* Using OPAL's Additive Lagged Fibonacci RNG */
|
||||
static inline uint32_t udcm_random (void)
|
||||
{
|
||||
return opal_rand(&udcm_rand_buff);
|
||||
|
@ -58,7 +58,7 @@ get_nsec(void)
|
||||
}
|
||||
|
||||
/* RNG buffer declaration */
|
||||
extern rng_buff_t ompi_btl_usnic_rand_buff;
|
||||
extern opal_rng_buff_t ompi_btl_usnic_rand_buff;
|
||||
|
||||
#ifndef container_of
|
||||
#define container_of(ptr, type, member) ( \
|
||||
@ -100,7 +100,6 @@ extern rng_buff_t ompi_btl_usnic_rand_buff;
|
||||
#define WANT_FAIL_TO_RESEND_FRAG 0
|
||||
|
||||
#if WANT_RECV_FRAG_DROPS > 0
|
||||
//#define FAKE_RECV_FRAG_DROP (rand() < WANT_RECV_FRAG_DROPS)
|
||||
#define FAKE_RECV_FRAG_DROP (opal_rand(&ompi_btl_usnic_rand_buff) < WANT_RECV_FRAG_DROPS)
|
||||
#else
|
||||
#define FAKE_RECV_FRAG_DROP 0
|
||||
|
@ -48,7 +48,6 @@
|
||||
#include "opal_stdint.h"
|
||||
#include "opal/prefetch.h"
|
||||
#include "opal/mca/timer/base/base.h"
|
||||
//#include "opal/util/alfg.h"
|
||||
#include "opal/util/argv.h"
|
||||
#include "opal/util/net.h"
|
||||
#include "opal/util/if.h"
|
||||
@ -80,7 +79,7 @@
|
||||
#define max(a,b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
/* RNG buffer definition */
|
||||
rng_buff_t ompi_btl_usnic_rand_buff;
|
||||
opal_rng_buff_t ompi_btl_usnic_rand_buff;
|
||||
|
||||
/* simulated clock */
|
||||
uint64_t ompi_btl_usnic_ticks = 0;
|
||||
|
@ -28,7 +28,6 @@
|
||||
|
||||
#include "opal/class/opal_bitmap.h"
|
||||
#include "opal/prefetch.h"
|
||||
//#include "opal/util/alfg.h"
|
||||
#include "opal/util/output.h"
|
||||
#include "opal/datatype/opal_convertor.h"
|
||||
#include "opal/include/opal_stdint.h"
|
||||
|
@ -64,7 +64,7 @@ typedef struct switch_to_switch_sl{
|
||||
|
||||
static int oob_priority = 50;
|
||||
static bool rml_recv_posted = false;
|
||||
static rng_buff_t rand_buff;
|
||||
static opal_rng_buff_t rand_buff;
|
||||
|
||||
static void oob_component_register(void);
|
||||
static int oob_component_query(ompi_common_ofacm_base_dev_desc_t *dev,
|
||||
@ -610,7 +610,6 @@ static int qp_create_one(ompi_common_ofacm_base_local_connection_context_t *cont
|
||||
}
|
||||
|
||||
/* Setup meta data on the endpoint */
|
||||
//context->qps[qp].lcl_psn = lrand48() & 0xffffff;
|
||||
context->qps[qp].lcl_psn = opal_rand(&rand_buff) & 0xffffff;
|
||||
|
||||
return OMPI_SUCCESS;
|
||||
|
@ -73,7 +73,7 @@ typedef enum {
|
||||
|
||||
static int xoob_priority = 60;
|
||||
static bool rml_recv_posted = false;
|
||||
static rng_buff_t rand_buff;
|
||||
static opal_rng_buff_t rand_buff;
|
||||
|
||||
#define XOOB_SET_REMOTE_INFO(EP, INFO) \
|
||||
do { \
|
||||
@ -857,7 +857,6 @@ static int xoob_send_qp_create
|
||||
}
|
||||
|
||||
/* Setup meta data on the context */
|
||||
//context->qps[0].lcl_psn = lrand48() & 0xffffff;
|
||||
context->qps[0].lcl_psn = opal_rand(&rand_buff) & 0xffffff;
|
||||
|
||||
/* Now that all the qp's are created locally, post some receive
|
||||
|
@ -271,8 +271,7 @@ get_uniq_file_name(const char *base_path, const char *hash_key)
|
||||
char *uniq_name_buf = NULL;
|
||||
unsigned long str_hash = 0;
|
||||
pid_t my_pid;
|
||||
// JSL int rand_num;
|
||||
rng_buff_t rand_buff;
|
||||
opal_rng_buff_t rand_buff;
|
||||
uint32_t rand_num;
|
||||
|
||||
/* invalid argument */
|
||||
@ -286,7 +285,6 @@ get_uniq_file_name(const char *base_path, const char *hash_key)
|
||||
|
||||
my_pid = getpid();
|
||||
opal_srand(&rand_buff,((uint32_t)(time(NULL) + my_pid)));
|
||||
// JSL srand((unsigned int)(time(NULL) + my_pid));
|
||||
rand_num = opal_rand(&rand_buff) % 1024;
|
||||
str_hash = sdbm_hash((unsigned char *)hash_key);
|
||||
/* build the name */
|
||||
|
@ -56,9 +56,9 @@ static uint32_t galois(unsigned int *seed){
|
||||
* @brief Routine to seed the ALFG register
|
||||
*
|
||||
* @param[in] uint32_t seed
|
||||
* @param[out] rng_buff_t *buff: handle to ALFG buffer state
|
||||
* @param[out] opal_rng_buff_t *buff: handle to ALFG buffer state
|
||||
*/
|
||||
int opal_srand(rng_buff_t *buff, uint32_t seed) {
|
||||
int opal_srand(opal_rng_buff_t *buff, uint32_t seed) {
|
||||
|
||||
int i, j;
|
||||
uint32_t seed_cpy = seed;
|
||||
@ -88,11 +88,11 @@ int opal_srand(rng_buff_t *buff, uint32_t seed) {
|
||||
/**
|
||||
* @brief The additive lagged Fibonnaci PRNG
|
||||
*
|
||||
* @param[in] rng_buff_t *buff: handle to ALFG buffer state
|
||||
* @param[in] opal_rng_buff_t *buff: handle to ALFG buffer state
|
||||
* @param[out] 32-bit unsigned random integer
|
||||
*/
|
||||
|
||||
uint32_t opal_rand(rng_buff_t *buff){
|
||||
uint32_t opal_rand(opal_rng_buff_t *buff){
|
||||
|
||||
int *tap1 = &(buff->tap1);
|
||||
int *tap2 = &(buff->tap2);
|
||||
|
@ -14,16 +14,16 @@
|
||||
|
||||
#include "opal_config.h"
|
||||
|
||||
struct rng_buff_t {
|
||||
unsigned int alfg[127];
|
||||
struct opal_rng_buff_t {
|
||||
uint32_t alfg[127];
|
||||
int tap1;
|
||||
int tap2;
|
||||
};
|
||||
typedef struct rng_buff_t rng_buff_t;
|
||||
typedef struct opal_rng_buff_t opal_rng_buff_t;
|
||||
|
||||
|
||||
int opal_srand(rng_buff_t *buff, uint32_t seed);
|
||||
int opal_srand(opal_rng_buff_t *buff, uint32_t seed);
|
||||
|
||||
uint32_t opal_rand(rng_buff_t *buff);
|
||||
uint32_t opal_rand(opal_rng_buff_t *buff);
|
||||
|
||||
#endif /* ALFG_H */
|
||||
|
@ -70,8 +70,7 @@ static void sample(void)
|
||||
"%s sample:ft_tester considering killing me!",
|
||||
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)));
|
||||
/* roll the dice */
|
||||
//prob = (double)random() / (double)INT32_MAX;
|
||||
prob = (double)opal_rand(&sensor_rng_buff) / (double)UINT32_MAX;
|
||||
prob = (double)opal_rand(&orte_sensor_ft_rng_buff) / (double)UINT32_MAX;
|
||||
if (prob < mca_sensor_ft_tester_component.daemon_fail_prob) {
|
||||
/* commit suicide */
|
||||
OPAL_OUTPUT_VERBOSE((1, orte_sensor_base_framework.framework_output,
|
||||
@ -99,8 +98,7 @@ static void sample(void)
|
||||
continue;
|
||||
}
|
||||
/* roll the dice */
|
||||
//prob = (double)random() / (double)INT32_MAX;
|
||||
prob = (double)opal_rand(&sensor_rng_buff) / (double)UINT32_MAX;
|
||||
prob = (double)opal_rand(&orte_sensor_ft_rng_buff) / (double)UINT32_MAX;
|
||||
OPAL_OUTPUT_VERBOSE((1, orte_sensor_base_framework.framework_output,
|
||||
"%s sample:ft_tester child: %s dice: %f prob %f",
|
||||
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
||||
|
@ -33,7 +33,7 @@ typedef struct orte_sensor_ft_tester_component_t orte_sensor_ft_tester_component
|
||||
ORTE_MODULE_DECLSPEC extern orte_sensor_ft_tester_component_t mca_sensor_ft_tester_component;
|
||||
extern orte_sensor_base_module_t orte_sensor_ft_tester_module;
|
||||
|
||||
extern rng_buff_t sensor_rng_buff;
|
||||
extern opal_rng_buff_t orte_sensor_ft_rng_buff;
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
|
@ -52,7 +52,7 @@ orte_sensor_ft_tester_component_t mca_sensor_ft_tester_component = {
|
||||
|
||||
static char *daemon_fail_prob = NULL;
|
||||
static char *fail_prob = NULL;
|
||||
rng_buff_t sensor_rng_buff;
|
||||
opal_rng_buff_t orte_sensor_ft_sensor_rng_buff;
|
||||
|
||||
/**
|
||||
* component register/open/close/init function
|
||||
@ -121,7 +121,7 @@ static int orte_sensor_ft_tester_query(mca_base_module_t **module, int *priority
|
||||
/* seed the RNG --- Not sure if we should assume all procs use
|
||||
* the same seed?
|
||||
*/
|
||||
opal_srand(&sensor_rng_buff, (uint32_t) getpid());
|
||||
opal_srand(&orte_sensor_ft_rng_buff, (uint32_t) getpid());
|
||||
return ORTE_SUCCESS;
|
||||
}
|
||||
*priority = 0;
|
||||
|
@ -57,7 +57,7 @@
|
||||
*/
|
||||
|
||||
static inline void orte_pre_condition_transports_use_rand(uint64_t* unique_key) {
|
||||
rng_buff_t rng;
|
||||
opal_rng_buff_t rng;
|
||||
opal_srand(&rng,(unsigned int)time(NULL));
|
||||
unique_key[0] = opal_rand(&rng);
|
||||
unique_key[1] = opal_rand(&rng);
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user