RNG Implementation module. More...
#include <ross.h>
Go to the source code of this file.
Macros | |
#define | H 32768 |
#define | S0_MAX 2147483646 |
#define | S1_MAX 2147483542 |
#define | S2_MAX 2147483422 |
#define | S3_MAX 2147483322 |
Functions | |
long long | FindB (long long a, long long k, long long m) |
Find B to run CLCG4 backwards. | |
int32_t | MultModM (int32_t s, int32_t t, int32_t M) |
Returns(s*t) MOD M. | |
void | clamp_seed (uint32_t s[4]) |
void | rng_set_seed (tw_rng_stream *g, uint32_t s[4], tw_rng *the_rng) |
void | rng_write_state (tw_rng_stream *g, FILE *f) |
void | rng_get_state (tw_rng_stream *g, uint32_t s[4]) |
void | rng_put_state (tw_rng_stream *g, uint32_t s[4]) |
void | rng_init_generator (tw_rng_stream *g, SeedType Where, tw_rng *the_rng) |
void | tw_rand_initial_seed (tw_rng_stream *g, tw_lpid id, tw_rng *the_rng) |
void | tw_rand_init_streams (tw_lp *lp, unsigned int nstreams, unsigned int n_core_streams) |
tw_rng * | rng_init (int v, int w) |
tw_rng * | rng_core_init (int v, int w) |
double | rng_gen_val (tw_rng_stream *g) |
double | rng_gen_reverse_val (tw_rng_stream *g) |
Variables | |
static tw_rng * | rng = NULL |
static tw_rng * | core_rng = NULL |
int32_t | seed [4] = { 11111111, 22222222, 33333333, 44444444 } |
Random number generator, provides all of the features GTW requires by default. Chris hacked this pretty well, he would know the features better.
Definition in file rand-clcg4.c.
#define H 32768 |
Definition at line 20 of file rand-clcg4.c.
Referenced by MultModM().
#define S0_MAX 2147483646 |
Definition at line 146 of file rand-clcg4.c.
Referenced by clamp_seed().
#define S1_MAX 2147483542 |
Definition at line 147 of file rand-clcg4.c.
Referenced by clamp_seed().
#define S2_MAX 2147483422 |
Definition at line 148 of file rand-clcg4.c.
Referenced by clamp_seed().
#define S3_MAX 2147483322 |
Definition at line 149 of file rand-clcg4.c.
Referenced by clamp_seed().
void clamp_seed | ( | uint32_t | s[4] | ) |
These seeds MUST adhere to these requirements. This is explicitly stated in L'Ecuyer and Andres (1997)
Definition at line 155 of file rand-clcg4.c.
References S0_MAX, S1_MAX, S2_MAX, and S3_MAX.
Referenced by rng_core_init(), rng_init(), rng_set_seed(), and tw_rand_initial_seed().
long long FindB | ( | long long | a, |
long long | k, | ||
long long | m ) |
FindB
B is
which is used in running the CLCG4 backwards
Added by Chris Carothers, 5/15/98
Definition at line 39 of file rand-clcg4.c.
Referenced by rng_init().
int32_t MultModM | ( | int32_t | s, |
int32_t | t, | ||
int32_t | M ) |
MultiModM
See L'Ecuyer and Cote(1991).
Returns(s*t) MOD M. Assumes that -M < s < M and -M < t < M.
Definition at line 79 of file rand-clcg4.c.
References H.
Referenced by rng_init(), rng_init_generator(), and tw_rand_initial_seed().
tw_rng * rng_core_init | ( | int | v, |
int | w ) |
Definition at line 416 of file rand-clcg4.c.
References clamp_seed(), core_rng, g_tw_core_rng_seed, g_tw_mynode, rng, tw_calloc(), and TW_LOC.
Referenced by tw_rand_core_init().
double rng_gen_reverse_val | ( | tw_rng_stream * | g | ) |
Definition at line 515 of file rand-clcg4.c.
References tw_rng_stream::Cg, tw_rng_stream::count, rng, tw_error(), and TW_LOC.
double rng_gen_val | ( | tw_rng_stream * | g | ) |
Definition at line 451 of file rand-clcg4.c.
References tw_rng_stream::Cg, and tw_rng_stream::count.
void rng_get_state | ( | tw_rng_stream * | g, |
uint32_t | s[4] ) |
Definition at line 214 of file rand-clcg4.c.
References tw_rng_stream::Cg.
tw_rng * rng_init | ( | int | v, |
int | w ) |
Definition at line 359 of file rand-clcg4.c.
References clamp_seed(), FindB(), g_tw_mynode, g_tw_rng_seed, MultModM(), rng, tw_calloc(), and TW_LOC.
Referenced by tw_rand_init().
void rng_init_generator | ( | tw_rng_stream * | g, |
SeedType | Where, | ||
tw_rng * | the_rng ) |
Definition at line 241 of file rand-clcg4.c.
References tw_rng::aw, tw_rng_stream::Cg, tw_rng_stream::Ig, InitialSeed, LastSeed, tw_rng_stream::Lg, tw_rng::m, MultModM(), and NewSeed.
Referenced by rng_set_seed(), and tw_rand_initial_seed().
void rng_put_state | ( | tw_rng_stream * | g, |
uint32_t | s[4] ) |
Definition at line 228 of file rand-clcg4.c.
References tw_rng_stream::Cg.
void rng_set_seed | ( | tw_rng_stream * | g, |
uint32_t | s[4], | ||
tw_rng * | the_rng ) |
Definition at line 183 of file rand-clcg4.c.
References clamp_seed(), tw_rng_stream::Ig, InitialSeed, and rng_init_generator().
void rng_write_state | ( | tw_rng_stream * | g, |
FILE * | f ) |
Definition at line 200 of file rand-clcg4.c.
References tw_rng_stream::Cg.
void tw_rand_init_streams | ( | tw_lp * | lp, |
unsigned int | nstreams, | ||
unsigned int | n_core_streams ) |
Definition at line 329 of file rand-clcg4.c.
References core_rng, tw_lp::core_rng, g_tw_nRNG_core_per_lp, g_tw_nRNG_per_lp, g_tw_total_lps, tw_lp::gid, rng, tw_lp::rng, tw_calloc(), tw_error(), TW_LOC, and tw_rand_initial_seed().
Referenced by tw_define_lps().
void tw_rand_initial_seed | ( | tw_rng_stream * | g, |
tw_lpid | id, | ||
tw_rng * | the_rng ) |
Definition at line 268 of file rand-clcg4.c.
References tw_rng::avw, clamp_seed(), tw_rng_stream::count, tw_rng_stream::Ig, InitialSeed, tw_rng::m, MultModM(), rng, rng_init_generator(), and tw_rng::seed.
Referenced by tw_rand_init_streams().
|
static |
Definition at line 25 of file rand-clcg4.c.
Referenced by rng_core_init(), and tw_rand_init_streams().
|
static |
Definition at line 23 of file rand-clcg4.c.
Referenced by rng_core_init(), rng_gen_reverse_val(), rng_init(), tw_rand_init_streams(), and tw_rand_initial_seed().
int32_t seed[4] = { 11111111, 22222222, 33333333, 44444444 } |
Definition at line 28 of file rand-clcg4.c.