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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user