Commit bacf3537 authored by Robert Schmidt's avatar Robert Schmidt

Merge remote-tracking branch 'origin/fix-seed-physim-script' into integration_2022_wk51

parents 1af5062b 8cacbb88
This diff is collapsed.
...@@ -114,6 +114,7 @@ function test_run() { ...@@ -114,6 +114,7 @@ function test_run() {
for (( run_index=1; run_index <= $nruns; run_index++ )) for (( run_index=1; run_index <= $nruns; run_index++ ))
do do
temp_exec_log="$log_dir/test.$test_case_name.${tags_array[$tags_array_index]}.run_$run_index"
echo "</EXECUTION LOG Test Case = $test_case_name.${tags_array[$tags_array_index]}, Run = $run_index >" >> $temp_exec_log 2>&1 echo "</EXECUTION LOG Test Case = $test_case_name.${tags_array[$tags_array_index]}, Run = $run_index >" >> $temp_exec_log 2>&1
cat "$temp_exec_log" >> "$log_file" 2>&1 cat "$temp_exec_log" >> "$log_file" 2>&1
......
...@@ -70,7 +70,6 @@ COPY --from=lte-ue-build \ ...@@ -70,7 +70,6 @@ COPY --from=lte-ue-build \
/oai-ran/cmake_targets/ran_build/build/liboai_usrpdevif.so \ /oai-ran/cmake_targets/ran_build/build/liboai_usrpdevif.so \
/oai-ran/cmake_targets/ran_build/build/libcoding.so \ /oai-ran/cmake_targets/ran_build/build/libcoding.so \
/oai-ran/cmake_targets/ran_build/build/libparams_libconfig.so \ /oai-ran/cmake_targets/ran_build/build/libparams_libconfig.so \
/oai-ran/cmake_targets/ran_build/build/libSIMU.so \
/oai-ran/cmake_targets/ran_build/build/libdfts.so \ /oai-ran/cmake_targets/ran_build/build/libdfts.so \
/oai-ran/cmake_targets/ran_build/build/libtelnetsrv.so \ /oai-ran/cmake_targets/ran_build/build/libtelnetsrv.so \
/usr/local/lib/ /usr/local/lib/
......
...@@ -76,7 +76,6 @@ COPY --from=lte-ue-build \ ...@@ -76,7 +76,6 @@ COPY --from=lte-ue-build \
/oai-ran/cmake_targets/ran_build/build/liboai_usrpdevif.so \ /oai-ran/cmake_targets/ran_build/build/liboai_usrpdevif.so \
/oai-ran/cmake_targets/ran_build/build/libcoding.so \ /oai-ran/cmake_targets/ran_build/build/libcoding.so \
/oai-ran/cmake_targets/ran_build/build/libparams_libconfig.so \ /oai-ran/cmake_targets/ran_build/build/libparams_libconfig.so \
/oai-ran/cmake_targets/ran_build/build/libSIMU.so \
/oai-ran/cmake_targets/ran_build/build/libdfts.so \ /oai-ran/cmake_targets/ran_build/build/libdfts.so \
/oai-ran/cmake_targets/ran_build/build/libtelnetsrv.so \ /oai-ran/cmake_targets/ran_build/build/libtelnetsrv.so \
/usr/local/lib/ /usr/local/lib/
......
...@@ -89,7 +89,6 @@ COPY --from=phy-sim-build \ ...@@ -89,7 +89,6 @@ COPY --from=phy-sim-build \
/lib64/libxslt.so.1 \ /lib64/libxslt.so.1 \
/usr/lib64/libasan.so.5 \ /usr/lib64/libasan.so.5 \
/oai-ran/cmake_targets/ran_build/build/libdfts.so \ /oai-ran/cmake_targets/ran_build/build/libdfts.so \
/oai-ran/cmake_targets/ran_build/build/libSIMU.so \
/oai-ran/cmake_targets/ran_build/build/libldpc.so \ /oai-ran/cmake_targets/ran_build/build/libldpc.so \
/oai-ran/cmake_targets/ran_build/build/libldpc_orig.so \ /oai-ran/cmake_targets/ran_build/build/libldpc_orig.so \
/usr/local/lib/ /usr/local/lib/
......
...@@ -26,21 +26,7 @@ ...@@ -26,21 +26,7 @@
//#include "PHY/defs.h" //#include "PHY/defs.h"
#include "SIMULATION/TOOLS/sim.h" #include "SIMULATION/TOOLS/sim.h"
#include "rf.h" #include "rf.h"
/*
extern void randominit(void);
extern double gaussdouble(double,double);
//free(input_data);
//extern int LOG_M(const char *,const char *,void *,int,int,char);
//flag change
extern int LOG_M(const char *,const char *,void *,int,int,char);
*/
//double pn[1024];
//#define DEBUG_RF 1
//free(input_data);
void rf_rx(double **r_re, void rf_rx(double **r_re,
double **r_im, double **r_im,
double **r_re_i1, double **r_re_i1,
......
...@@ -26,57 +26,67 @@ ...@@ -26,57 +26,67 @@
#include "sim.h" #include "sim.h"
static unsigned int seed, iy, ir[98]; static unsigned int urseed, iy, ir[98]; /// uniformrandom
/* static bool tableNordDone = false; /// gaussZiggurat
@defgroup _uniformdouble
@ingroup numerical Uniform linear congruential random number generator.
*/
/*!\brief Initialization routine for Uniform/Gaussian random number generators. */
#define a 1664525lu
#define mod 4294967296.0 /* is 2**32 */
#if 1 /*!\brief Generate a random number form `/dev/urandom`. */
void randominit(unsigned seed_init) void fill_random(void *buf, size_t sz)
{ {
int i; const char* fn = "/dev/urandom";
// this need to be integrated with the existing rng, like taus: navid FILE* f = fopen(fn, "rb");
if (f == NULL) {
if (seed_init == 0) { fprintf(stderr, "could not open %s for seed generation: %d %s\n", fn, errno, strerror(errno));
srand((unsigned)time(NULL)); abort();
seed = (unsigned int) rand();
} else {
seed = seed_init;
} }
printf("Initializing random number generator, seed %x\n",seed); int rc = fread(buf, sz, 1, f);
if (rc < 0) {
fprintf(stderr, "could not read %s for seed generation: %d %s\n", fn, errno, strerror(errno));
abort();
}
fclose(f);
}
if (seed % 2 == 0) seed += 1; /* seed and mod are relative prime */ static const unsigned int a = 1664525lu;
for (i=1; i<=97; i++) { /*!\brief Initialization routine for Uniform/Gaussian random number generators. */
seed = a*seed; /* mod 2**32 */ void randominit(unsigned long seed_init)
ir[i]= seed; /* initialize the shuffle table */ {
unsigned long seed = seed_init;
if (seed_init == 0)
fill_random(&seed, sizeof(seed));
printf("Initializing random number generator, seed %ld\n", seed);
// initialize uniformrandom RNG
urseed = (unsigned int) seed;
if (urseed % 2 == 0)
urseed += 1; /* urseed and mod are relative prime */
for (int i = 1; i <= 97; i++) {
urseed = a * urseed; /* mod 2**32 */
ir[i] = urseed; /* initialize the shuffle table */
} }
iy = 1;
iy=1; // initialize gaussZiggurat RNG
tableNor(seed);
tableNordDone = true;
} }
#endif
/*
@defgroup _uniformdouble
@ingroup numerical Uniform linear congruential random number generator.
*/
/*!\brief Uniform linear congruential random number generator on \f$[0,1)\f$. Returns a double-precision floating-point number.*/ /*!\brief Uniform linear congruential random number generator on \f$[0,1)\f$. Returns a double-precision floating-point number.*/
double uniformrandom(void) double uniformrandom(void)
{ {
#define a 1664525lu const double mod = 4294967296.0; /* is 2**32 */
#define mod 4294967296.0 /* is 2**32 */ int j = 1 + 97.0 * iy / mod;
iy = ir[j];
int j; urseed = a * urseed; /* mod 2**32 */
ir[j] = urseed;
j=1 + 97.0*iy/mod; return (double)iy / mod;
iy=ir[j];
seed = a*seed; /* mod 2**32 */
ir[j] = seed;
return( (double) iy/mod );
} }
/* /*
...@@ -109,8 +119,12 @@ double __attribute__ ((no_sanitize_address)) gaussdouble(double mean, double var ...@@ -109,8 +119,12 @@ double __attribute__ ((no_sanitize_address)) gaussdouble(double mean, double var
} }
} }
/*
@defgroup _gaussZiggurat
@ingroup numerical ziggurat random number generator for exponentially distributed numbers
*/
// Ziggurat // Ziggurat
static bool tableNordDone=false;
static double wn[128], fn[128]; static double wn[128], fn[128];
static uint32_t iz, jz, jsr = 123456789, kn[128]; static uint32_t iz, jz, jsr = 123456789, kn[128];
static int32_t hz; static int32_t hz;
...@@ -180,9 +194,9 @@ double __attribute__ ((no_sanitize_address)) gaussZiggurat(double mean, double v ...@@ -180,9 +194,9 @@ double __attribute__ ((no_sanitize_address)) gaussZiggurat(double mean, double v
{ {
if (!tableNordDone) { if (!tableNordDone) {
// let's make reasonnable constant tables // let's make reasonnable constant tables
struct timespec t; unsigned long seed;
clock_gettime(CLOCK_MONOTONIC, &t); fill_random(&seed, sizeof(seed));
tableNor((long)(t.tv_nsec%INT_MAX)); tableNor(seed);
} }
hz = SHR3; hz = SHR3;
iz = hz & 127; iz = hz & 127;
......
...@@ -523,8 +523,9 @@ the value \f$\mathrm{sgn}(u)i\f$. The search requires at most \f$Nbits-1\f$ com ...@@ -523,8 +523,9 @@ the value \f$\mathrm{sgn}(u)i\f$. The search requires at most \f$Nbits-1\f$ com
*/ */
int gauss(unsigned int *gauss_LUT,unsigned char Nbits); int gauss(unsigned int *gauss_LUT,unsigned char Nbits);
void fill_random(void *buf, size_t sz);
double gaussdouble(double,double); double gaussdouble(double,double);
void randominit(unsigned int seed_init); void randominit(unsigned long seed_init);
double uniformrandom(void); double uniformrandom(void);
double gaussZiggurat(double mean, double variance); double gaussZiggurat(double mean, double variance);
void tableNor(unsigned long seed); void tableNor(unsigned long seed);
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
//#include "SIMULATION/TOOLS/sim.h" #include "sim.h"
static unsigned int s0, s1, s2; static unsigned int s0, s1, s2;
...@@ -52,20 +52,9 @@ void set_taus_seed(unsigned int seed_init) ...@@ -52,20 +52,9 @@ void set_taus_seed(unsigned int seed_init)
unsigned long result = 0; unsigned long result = 0;
if (seed_init == 0) { if (seed_init == 0) {
unsigned int data[3]; fill_random(&s0, sizeof(s0));
int fd = open("/dev/urandom", O_RDONLY); fill_random(&s1, sizeof(s1));
if (fd == -1) fill_random(&s2, sizeof(s2));
{
abort();
}
if (read(fd, data, sizeof(data)) != sizeof(data))
{
abort();
}
close(fd);
s0 = data[0];
s1 = data[1];
s2 = data[2];
} else { } else {
/* Use reentrant version of rand48 to ensure that no conflicts with other generators occur */ /* Use reentrant version of rand48 to ensure that no conflicts with other generators occur */
srand48_r((long int)seed_init, &buffer); srand48_r((long int)seed_init, &buffer);
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*
random.c
-------------------
AUTHOR : Lionel GAUTHIER
COMPANY : EURECOM
EMAIL : Lionel.Gauthier@eurecom.fr
***************************************************************************/
#include "rtos_header.h"
#include "platform_types.h"
#include <sys/time.h>
/* Random generators */
#define FACTOR 16807
#define LASTXN 127773
#define UPTOMOD -2836
static int seed;
void
init_uniform (void)
{
struct timeval tv;
struct timezone tz;
gettimeofday (&tv, &tz);
seed = (int) tv.tv_usec;
#ifdef NODE_MT
#warning TO DO seed = mobileId
//seed += mobileId;
#endif
#ifdef NODE_RG
#warning TO DO seed = rgId
//seed += rgId;
#endif
}
int
uniform (void)
{
static int times, rest, prod1, prod2;
times = seed / LASTXN;
rest = seed - times * LASTXN;
prod1 = times * UPTOMOD;
prod2 = rest * FACTOR;
seed = prod1 + prod2;
return seed;
}
...@@ -19,7 +19,7 @@ extern "C" { ...@@ -19,7 +19,7 @@ extern "C" {
#include <openair2/LAYER2/PDCP_v10.1.0/pdcp.h> #include <openair2/LAYER2/PDCP_v10.1.0/pdcp.h>
#include <openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h> #include <openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h>
#include "openair2/SDAP/nr_sdap/nr_sdap.h" #include "openair2/SDAP/nr_sdap/nr_sdap.h"
//#include <openair1/PHY/phy_extern.h> #include "sim.h"
#pragma pack(1) #pragma pack(1)
...@@ -143,6 +143,12 @@ class gtpEndPoints { ...@@ -143,6 +143,12 @@ class gtpEndPoints {
// the instance id will be the Linux socket handler, as this is uniq // the instance id will be the Linux socket handler, as this is uniq
map<uint64_t, gtpEndPoint> instances; map<uint64_t, gtpEndPoint> instances;
gtpEndPoints() {
unsigned int seed;
fill_random(&seed, sizeof(seed));
srandom(seed);
}
~gtpEndPoints() { ~gtpEndPoints() {
// automatically close all sockets on quit // automatically close all sockets on quit
for (const auto &p : instances) for (const auto &p : instances)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment