예제 #1
0
파일: bml_base_frame.c 프로젝트: IanYXXL/A1
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(&ompi_btl_base_framework, 0);
}
예제 #2
0
/* the file name is only guaranteed to be unique on the local host.  if there
 * was a failure that left backing files behind, then no such guarantees can be
 * made.  we use the pid + file_name hash + random number to help avoid issues.
 *
 * caller is responsible for freeing returned resources. the returned string
 * will be OPAL_PATH_MAX long.
 */
static char *
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;
    opal_rng_buff_t rand_buff;
    uint32_t rand_num;

    /* invalid argument */
    if (NULL == hash_key) {
        return NULL;
    }
    if (NULL == (uniq_name_buf = calloc(OPAL_PATH_MAX, sizeof(char)))) {
        /* out of resources */
        return NULL;
    }

    my_pid = getpid();
    opal_srand(&rand_buff,((uint32_t)(time(NULL) + my_pid)));
    rand_num = opal_rand(&rand_buff) % 1024;
    str_hash = sdbm_hash((unsigned char *)hash_key);
    /* build the name */
    snprintf(uniq_name_buf, OPAL_PATH_MAX, "%s/open_mpi_shmem_mmap.%d_%lu_%d",
             base_path, (int)my_pid, str_hash, rand_num);

    return uniq_name_buf;
}
예제 #3
0
static int orcm_sensor_evinj_query(mca_base_module_t **module, int *priority)
{
    if (0.0 < mca_sensor_evinj_component.prob) {
        *priority = 1;  /* at the bottom */
        *module = (mca_base_module_t *)&orcm_sensor_evinj_module;
        /* seed the random number generator */
        opal_srand(&mca_sensor_evinj_component.rng_buff, (uint32_t)getpid());
        return ORCM_SUCCESS;
    }
    *priority = 0;
    *module = NULL;
    return ORTE_ERROR;

}
예제 #4
0
static int orte_sensor_ft_tester_query(mca_base_module_t **module, int *priority)
{
    if (0.0 < mca_sensor_ft_tester_component.fail_prob ||
        0.0 < mca_sensor_ft_tester_component.daemon_fail_prob) {
        *priority = 1;  /* at the bottom */
        *module = (mca_base_module_t *)&orte_sensor_ft_tester_module;
        /* seed the RNG --- Not sure if we should assume all procs use 
         * the same seed? 
         */
        opal_srand(&orte_sensor_ft_rng_buff, (uint32_t) getpid());
        return ORTE_SUCCESS;
    }
    *priority = 0;
    *module = NULL;
    return ORTE_ERROR;

}
예제 #5
0
static inline void orte_pre_condition_transports_use_rand(uint64_t* unique_key) { 
    opal_rng_buff_t rng;
    opal_srand(&rng,(unsigned int)time(NULL));
    unique_key[0] = opal_rand(&rng);
    unique_key[1] = opal_rand(&rng);
}