Exclusively use OAI_RNGSEED env variable everywhere
Hide normal table initialization of Ziggurat generator from outside to
force the usage of randominit() for RNG initialization. In this step,
remove the randominit() seed parameter and only rely on OAI_RNGSEED for
a consistent RNG initialization, as this parameter was used differently
("0" as fixed number or to force a random seed).
Now, only use OAI_RNGSEED env variable to force the usage of a fixed
seed.
This commit is contained in:
committed by
Robert Schmidt
parent
0e4ade9472
commit
a1b4220a91
@@ -9,7 +9,8 @@ OAI uses/supports a number of environment variables, documented in the following
|
||||
- `NVRAM_DIR`: directory to read/write NVRAM data in (5G) `nvram` tool; if not defined, will use `PWD` (working directory)
|
||||
- `OAI_CONFIGMODULE`: can be used to pass the configuration file instead of `-O`
|
||||
- `OAI_GDBSTACKS`: if defined when hitting an assertion (`DevAssert()`, `AssertFatal()`, ...), OAI will load `gdb` and provide a backtrace for every thread
|
||||
- `OAI_RNGSEED`: overwrites any seed for random number generators (RNG) in simulators
|
||||
- `OAI_RNGSEED`: provide a fixed seed for random number generators (RNG). If
|
||||
this variable is absent, a random seed will be read (from `/dev/urandom`).
|
||||
- `USIM_DIR`: directory to read/write USIM data in (4G) `usim` tool; if not defined, will use `PWD` (working directory)
|
||||
|
||||
Furthermore, these variables appear in code that is not maintained and maybe not even compiled anywhere:
|
||||
|
||||
@@ -405,7 +405,6 @@ int main ( int argc, char **argv )
|
||||
#if T_TRACER
|
||||
T_Config_Init();
|
||||
#endif
|
||||
//randominit (0);
|
||||
set_taus_seed (0);
|
||||
printf("configuring for RAU/RRU\n");
|
||||
|
||||
|
||||
@@ -492,7 +492,6 @@ int main( int argc, char **argv ) {
|
||||
#if T_TRACER
|
||||
T_Config_Init();
|
||||
#endif
|
||||
//randominit (0);
|
||||
set_taus_seed (0);
|
||||
cpuf=get_cpu_freq_GHz();
|
||||
pthread_cond_init(&sync_cond,NULL);
|
||||
|
||||
@@ -546,7 +546,6 @@ int main( int argc, char **argv ) {
|
||||
#if T_TRACER
|
||||
T_Config_Init();
|
||||
#endif
|
||||
//randominit (0);
|
||||
set_taus_seed (0);
|
||||
|
||||
cpuf=get_cpu_freq_GHz();
|
||||
|
||||
@@ -340,7 +340,6 @@ int main(int argc, char **argv)
|
||||
T_Config_Init();
|
||||
#endif
|
||||
initTpool(get_softmodem_params()->threadPoolConfig, &(nrUE_params.Tpool), cpumeas(CPUMEAS_GETSTATE));
|
||||
//randominit (0);
|
||||
set_taus_seed (0);
|
||||
|
||||
if (!has_cap_sys_nice())
|
||||
|
||||
@@ -438,7 +438,7 @@ int main(int argc, char *argv[])
|
||||
int n_trials = 1;
|
||||
double SNR_step = 0.1;
|
||||
|
||||
randominit(0);
|
||||
randominit();
|
||||
int test_uncoded = 0;
|
||||
n_iter_stats_t dec_iter[400] = {0};
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ void lte_param_init(unsigned char N_tx, unsigned char N_rx,unsigned char transmi
|
||||
PHY_vars_UE = malloc(sizeof(PHY_VARS_UE));
|
||||
mac_xface = malloc(sizeof(MAC_xface));
|
||||
|
||||
randominit(0);
|
||||
randominit();
|
||||
set_taus_seed(0);
|
||||
|
||||
lte_frame_parms = &(PHY_vars_eNB->lte_frame_parms);
|
||||
@@ -367,7 +367,7 @@ int main(int argc, char *argv[])
|
||||
int num_pdcch_symbols = 1;
|
||||
int subframe = 6;
|
||||
|
||||
randominit(0);
|
||||
randominit();
|
||||
logInit();
|
||||
lte_param_init(1,1,1,0,0,3);
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ void lte_param_init(unsigned char N_tx, unsigned char N_rx)
|
||||
PHY_config = malloc(sizeof(PHY_CONFIG));
|
||||
mac_xface = malloc(sizeof(MAC_xface));
|
||||
|
||||
randominit(0);
|
||||
randominit();
|
||||
set_taus_seed(0);
|
||||
|
||||
lte_frame_parms = &(PHY_config->lte_frame_parms);
|
||||
@@ -241,8 +241,7 @@ int main(int argc, char *argv[])
|
||||
PHY_vars = malloc(sizeof(PHY_VARS));
|
||||
mac_xface = malloc(sizeof(MAC_xface));
|
||||
|
||||
|
||||
randominit(0);
|
||||
randominit();
|
||||
set_taus_seed(0);
|
||||
|
||||
ccodelte_init();
|
||||
|
||||
@@ -125,7 +125,7 @@ int main(int argc, char *argv[])
|
||||
cpu_meas_enabled = 1;
|
||||
reset_meas(&timeEncoder);
|
||||
reset_meas(&timeDecoder);
|
||||
randominit(0);
|
||||
randominit();
|
||||
crcTableInit();
|
||||
|
||||
if (polarMessageType == 0) { // PBCH
|
||||
|
||||
@@ -13,7 +13,7 @@ int main(int argc, char *argv[])
|
||||
cpu_meas_enabled = 1;
|
||||
reset_meas(&timeEncoder);
|
||||
reset_meas(&timeDecoder);
|
||||
randominit(0);
|
||||
randominit();
|
||||
|
||||
int ret = 1;
|
||||
int arguments, iterations = 1000, messageLength = 11;
|
||||
|
||||
@@ -77,7 +77,7 @@ void lte_param_init(PHY_VARS_eNB **eNBp,
|
||||
eNB->RU_list[0] = ru;
|
||||
ru->num_eNB=1;
|
||||
srand(0);
|
||||
randominit(0);
|
||||
randominit();
|
||||
set_taus_seed(0);
|
||||
frame_parms = &(eNB->frame_parms);
|
||||
frame_parms->N_RB_DL = N_RB_DL; //50 for 10MHz and 25 for 5 MHz
|
||||
|
||||
@@ -70,6 +70,7 @@ void math_dft(cd_t *in, cd_t *out, int len)
|
||||
int main(void)
|
||||
{
|
||||
int ret = 0;
|
||||
randominit();
|
||||
load_dftslib();
|
||||
c16_t *d16 = malloc16(12 * dftFtab[sizeofArray(dftFtab) - 1].size * sizeof(*d16));
|
||||
c16_t *o16 = malloc16(12 * dftFtab[sizeofArray(dftFtab) - 1].size * sizeof(*d16));
|
||||
|
||||
@@ -378,7 +378,7 @@ void lte_param_init( unsigned char transmission_mode,
|
||||
mac_xface->get_dci_sdu = get_dci;
|
||||
mac_xface->get_dlsch_sdu = get_DLSCH_pdu;
|
||||
|
||||
randominit(0);
|
||||
randominit();
|
||||
set_taus_seed(0);
|
||||
|
||||
lte_frame_parms = &(PHY_vars_eNB_g[0]->lte_frame_parms);
|
||||
|
||||
@@ -249,7 +249,7 @@ void lte_param_init(unsigned char N_tx, unsigned char N_rx,unsigned char transmi
|
||||
PHY_vars_UE[1] = malloc(sizeof(PHY_VARS_UE));
|
||||
//PHY_config = malloc(sizeof(PHY_CONFIG));
|
||||
mac_xface = malloc(sizeof(MAC_xface));
|
||||
randominit(0);
|
||||
randominit();
|
||||
set_taus_seed(0);
|
||||
lte_frame_parms = &(PHY_vars_eNB->lte_frame_parms);
|
||||
lte_frame_parms->N_RB_DL = N_RB_DL; //50 for 10MHz and 25 for 5 MHz
|
||||
|
||||
@@ -174,7 +174,7 @@ int main(int argc, char **argv)
|
||||
for (i = 0; i<4; i++)
|
||||
ch[i] = (struct complexd*) malloc(channel_length * sizeof(struct complexd));
|
||||
|
||||
randominit(0);
|
||||
randominit();
|
||||
set_taus_seed(0);
|
||||
|
||||
#ifdef RF
|
||||
|
||||
@@ -839,8 +839,7 @@ int main(int argc, char **argv) {
|
||||
ack_errors=0;
|
||||
cqi_crc_falsepositives=0;
|
||||
cqi_crc_falsenegatives=0;
|
||||
round=0;
|
||||
//randominit(0);
|
||||
round = 0;
|
||||
harq_pid = subframe2harq_pid(&UE->frame_parms,proc_rxtx_ue->frame_tx,subframe);
|
||||
input_buffer_length = UE->ulsch[0]->harq_processes[harq_pid]->TBS/8;
|
||||
|
||||
|
||||
@@ -232,7 +232,7 @@ int main(int argc, char **argv)
|
||||
//LOG_M("txsig1.m","txs1", txdata[1],FRAME_LENGTH_COMPLEX_SAMPLES,1,1);
|
||||
|
||||
// multipath channel
|
||||
randominit(0);
|
||||
randominit();
|
||||
|
||||
for (i=0; i<FRAME_LENGTH_COMPLEX_SAMPLES; i++) {
|
||||
for (aa=0; aa<lte_frame_parms->nb_antennas_tx; aa++) {
|
||||
|
||||
@@ -141,7 +141,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
// logInit();
|
||||
randominit(0);
|
||||
randominit();
|
||||
|
||||
int c;
|
||||
while ((c = getopt(argc, argv, "--:O:df:hpVg:i:j:n:l:m:r:s:S:y:z:M:N:F:R:P:L:X:")) != -1) {
|
||||
|
||||
@@ -393,7 +393,7 @@ int main(int argc, char **argv)
|
||||
exit_fun("[NR_DLSIM] Error, configuration module init failed\n");
|
||||
}
|
||||
|
||||
randominit(0);
|
||||
randominit();
|
||||
|
||||
int print_perf = 0;
|
||||
|
||||
|
||||
@@ -176,8 +176,6 @@ int main(int argc, char **argv)
|
||||
|
||||
float target_error_rate = 0.01;
|
||||
|
||||
int seed = 0;
|
||||
|
||||
cpuf = get_cpu_freq_GHz();
|
||||
|
||||
if ((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) == 0) {
|
||||
@@ -185,8 +183,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
int c;
|
||||
while ((c = getopt (argc, argv, "--:O:c:F:g:hIL:m:M:n:N:o:P:r:R:s:S:x:y:z:")) != -1) {
|
||||
|
||||
while ((c = getopt(argc, argv, "--:O:c:F:g:hIL:m:M:n:N:o:P:R:s:S:x:y:z:")) != -1) {
|
||||
/* ignore long options starting with '--', option '-O' and their arguments that are handled by configmodule */
|
||||
/* with this opstring getopt returns 1 for non-option arguments, refer to 'man 3 getopt' */
|
||||
if (c == 1 || c == '-' || c == 'O')
|
||||
@@ -312,20 +309,6 @@ int main(int argc, char **argv)
|
||||
printf("Illegal PBCH phase (0-3) got %d\n",pbch_phase);
|
||||
break;
|
||||
|
||||
/*
|
||||
case 'r':
|
||||
ricean_factor = pow(10,-.1*atof(optarg));
|
||||
if (ricean_factor>1) {
|
||||
printf("Ricean factor must be between 0 and 1\n");
|
||||
exit(-1);
|
||||
}
|
||||
break;
|
||||
*/
|
||||
|
||||
case 'r':
|
||||
seed = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
N_RB_DL = atoi(optarg);
|
||||
break;
|
||||
@@ -379,8 +362,10 @@ int main(int argc, char **argv)
|
||||
|
||||
default:
|
||||
case 'h':
|
||||
printf("%s -F input_filename -g channel_mod -h(elp) -I(nitial sync) -L log_lvl -n n_frames -M SSBs -n frames -N cell_id -o FO -P phase -r seed -R RBs -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant\n",
|
||||
argv[0]);
|
||||
printf(
|
||||
"OAI_RNGSEED=xxx ./%s -F input_filename -g channel_mod -h(elp) -I(nitial sync) -L log_lvl -n n_frames -M SSBs -n frames "
|
||||
"-N cell_id -o FO -P phase -R RBs -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant\n",
|
||||
argv[0]);
|
||||
//printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n");
|
||||
printf("-c SSB subcarrier offset\n");
|
||||
//printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n");
|
||||
@@ -401,7 +386,6 @@ int main(int argc, char **argv)
|
||||
//printf("-O oversampling factor (1,2,4,8,16)\n");
|
||||
//printf("-p Use extended prefix mode\n");
|
||||
printf("-P PBCH phase, allowed values 0-3\n");
|
||||
printf("-r set the random number generator seed (default: 0 = current time)\n");
|
||||
printf("-R N_RB_DL\n");
|
||||
printf("-s Starting SNR, runs from SNR0 to SNR0 + 10 dB if not -S given. If -n 1, then just SNR is simulated\n");
|
||||
printf("-S Ending SNR, runs from SNR0 to SNR1\n");
|
||||
@@ -414,7 +398,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
randominit(seed);
|
||||
randominit();
|
||||
|
||||
logInit();
|
||||
set_glog(loglvl);
|
||||
|
||||
@@ -162,7 +162,7 @@ int main(int argc, char **argv){
|
||||
exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
|
||||
}
|
||||
|
||||
randominit(0);
|
||||
randominit();
|
||||
|
||||
int c;
|
||||
while ((c = getopt (argc, argv, "--:O:hHaA:Cc:l:r:p:g:m:n:s:S:t:x:y:v:V:z:N:F:d:Z:L:R:E")) != -1) {
|
||||
|
||||
@@ -325,15 +325,13 @@ int main(int argc, char **argv)
|
||||
// int frame_length_complex_samples_no_prefix;
|
||||
NR_DL_FRAME_PARMS *frame_parms;
|
||||
|
||||
int seed = 0;
|
||||
|
||||
cpuf = get_cpu_freq_GHz();
|
||||
|
||||
if ((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) == 0) {
|
||||
exit_fun("[NR_PSBCHSIM] Error, configuration module init failed\n");
|
||||
}
|
||||
|
||||
randominit(0);
|
||||
randominit();
|
||||
|
||||
int c;
|
||||
while ((c = getopt(argc, argv, "--:O:c:hn:o:s:FIL:N:R:S:T:")) != -1) {
|
||||
@@ -456,7 +454,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
randominit(seed);
|
||||
randominit();
|
||||
|
||||
logInit();
|
||||
set_glog(loglvl);
|
||||
|
||||
@@ -151,7 +151,7 @@ int main(int argc, char **argv)
|
||||
exit_fun("[NR_PUCCHSIM] Error, configuration module init failed\n");
|
||||
}
|
||||
|
||||
randominit(0);
|
||||
randominit();
|
||||
logInit();
|
||||
|
||||
int c;
|
||||
|
||||
@@ -139,7 +139,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
//logInit();
|
||||
randominit(0);
|
||||
randominit();
|
||||
|
||||
int c;
|
||||
while ((c = getopt(argc, argv, "--:O:hg:n:s:S:py:z:M:N:R:F:m:l:q:r:W:")) != -1) {
|
||||
|
||||
@@ -348,7 +348,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
int ul_proc_error = 0; // uplink processing checking status flag
|
||||
//logInit();
|
||||
randominit(0);
|
||||
randominit();
|
||||
|
||||
/* initialize the sin-cos table */
|
||||
InitSinLUT();
|
||||
|
||||
@@ -248,7 +248,7 @@ int main(int argc, char* argv[])
|
||||
channel_desc_t *channel;
|
||||
|
||||
srand(0);
|
||||
randominit(0);
|
||||
randominit();
|
||||
set_taus_seed(0);
|
||||
|
||||
channel = new_channel_desc_scm(nb_antennas,
|
||||
|
||||
@@ -93,7 +93,7 @@ int main() {
|
||||
{3420,2820},{1580,3940},{660,2100},{2740,1180},{2500,2500},
|
||||
{3580,3580},{3740,3140},{3020,3020},{4340,4140},{980,4300}
|
||||
};
|
||||
randominit(0);
|
||||
randominit();
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
int tabl_len=0;
|
||||
double local_table[MCS_COUNT][9][9];
|
||||
|
||||
@@ -572,11 +572,6 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
|
||||
double path_loss_dB,
|
||||
float noise_power_dB)
|
||||
{
|
||||
// To create tables for normal distribution
|
||||
struct timespec t;
|
||||
clock_gettime(CLOCK_MONOTONIC, &t);
|
||||
tableNor((long) (t.tv_nsec % INT_MAX));
|
||||
|
||||
channel_desc_t *chan_desc = (channel_desc_t *)calloc(1,sizeof(channel_desc_t));
|
||||
|
||||
for(int i=0; i<max_chan; i++) {
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "sim.h"
|
||||
|
||||
static inline void tableNor(unsigned long seed);
|
||||
static unsigned int urseed, iy, ir[98]; /// uniformrandom
|
||||
static bool tableNordDone = false; /// gaussZiggurat
|
||||
|
||||
@@ -49,14 +50,16 @@ void fill_random(void *buf, size_t sz)
|
||||
static const unsigned int a = 1664525lu;
|
||||
|
||||
/*!\brief Initialization routine for Uniform/Gaussian random number generators. */
|
||||
void randominit(unsigned long seed_init)
|
||||
// fix seed number by env variable OAI_RNGSEED
|
||||
void randominit()
|
||||
{
|
||||
unsigned long seed = seed_init;
|
||||
if (seed_init == 0)
|
||||
fill_random(&seed, sizeof(seed));
|
||||
unsigned long seed;
|
||||
const char* str_oai_rngseed = getenv("OAI_RNGSEED");
|
||||
if (str_oai_rngseed != NULL)
|
||||
if (str_oai_rngseed != NULL) {
|
||||
seed = atoi(str_oai_rngseed);
|
||||
} else {
|
||||
fill_random(&seed, sizeof(seed));
|
||||
}
|
||||
printf("Initializing random number generator, seed %lu\n", seed);
|
||||
|
||||
// initialize uniformrandom RNG
|
||||
@@ -71,7 +74,6 @@ void randominit(unsigned long seed_init)
|
||||
|
||||
// initialize gaussZiggurat RNG
|
||||
tableNor(seed);
|
||||
tableNordDone = true;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -164,7 +166,7 @@ double nfix(void)
|
||||
}
|
||||
|
||||
/*!Procedure to create tables for normal distribution kn,wn and fn. */
|
||||
void tableNor(unsigned long seed)
|
||||
static inline void tableNor(unsigned long seed)
|
||||
{
|
||||
jsr = seed;
|
||||
double dn = 3.442619855899;
|
||||
@@ -194,12 +196,11 @@ void tableNor(unsigned long seed)
|
||||
|
||||
double __attribute__ ((no_sanitize("address", "undefined"))) gaussZiggurat(double mean, double variance)
|
||||
{
|
||||
if (!tableNordDone) {
|
||||
// let's make reasonnable constant tables
|
||||
unsigned long seed;
|
||||
fill_random(&seed, sizeof(seed));
|
||||
tableNor(seed);
|
||||
if (!__builtin_expect(tableNordDone, 1)) {
|
||||
fprintf(stderr, "%s(): RNG not initialized, run randominit() first\n", __func__);
|
||||
abort();
|
||||
}
|
||||
|
||||
hz = SHR3;
|
||||
iz = hz & 127;
|
||||
return hz != INT32_MIN && abs(hz) < kn[iz] ? hz * wn[iz] : nfix();
|
||||
|
||||
@@ -528,10 +528,9 @@ int gauss(unsigned int *gauss_LUT,unsigned char Nbits);
|
||||
|
||||
void fill_random(void *buf, size_t sz);
|
||||
double gaussdouble(double,double);
|
||||
void randominit(unsigned long seed_init);
|
||||
void randominit(); // fix seed number by env variable OAI_RNGSEED
|
||||
double uniformrandom(void);
|
||||
double gaussZiggurat(double mean, double variance);
|
||||
void tableNor(unsigned long seed);
|
||||
int freq_channel(channel_desc_t *desc,uint16_t nb_rb, int16_t n_samples,int scs);
|
||||
int init_freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples,int scs);
|
||||
void term_freq_channel(void);
|
||||
|
||||
@@ -199,20 +199,6 @@ static buffer_t *allocCirBuf(rfsimulator_state_t *bridge, int sock)
|
||||
|
||||
if (bridge->channelmod > 0) {
|
||||
// create channel simulation model for this mode reception
|
||||
static bool init_done = false;
|
||||
|
||||
if (!init_done) {
|
||||
uint64_t rand;
|
||||
FILE *h = fopen("/dev/random", "r");
|
||||
|
||||
if (1 != fread(&rand, sizeof(rand), 1, h))
|
||||
LOG_W(HW, "Can't read /dev/random\n");
|
||||
|
||||
fclose(h);
|
||||
randominit(rand);
|
||||
tableNor(rand);
|
||||
init_done = true;
|
||||
}
|
||||
char modelname[30];
|
||||
snprintf(modelname,
|
||||
sizeofArray(modelname),
|
||||
@@ -1170,7 +1156,7 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
|
||||
|
||||
AssertFatal((rfsimulator->epollfd = epoll_create1(0)) != -1, "epoll_create1() failed, errno(%d)", errno);
|
||||
// we need to call randominit() for telnet server (use gaussdouble=>uniformrand)
|
||||
randominit(0);
|
||||
randominit();
|
||||
set_taus_seed(0);
|
||||
/* look for telnet server, if it is loaded, add the channel modeling commands to it */
|
||||
add_telnetcmd_func_t addcmd = (add_telnetcmd_func_t)get_shlibmodule_fptr("telnetsrv", TELNET_ADDCMD_FNAME);
|
||||
|
||||
Reference in New Issue
Block a user