From 61c9fa941e1ae158d820dc6e28fca11da1148540 Mon Sep 17 00:00:00 2001 From: frtabu Date: Thu, 29 Apr 2021 19:52:51 +0200 Subject: [PATCH] enhance cpu measurments to better support parallelism via using a message queue. --- openair1/PHY/TOOLS/time_meas.c | 39 +++++++++++++++++++++++++++++++++- openair1/PHY/TOOLS/time_meas.h | 15 ++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/TOOLS/time_meas.c b/openair1/PHY/TOOLS/time_meas.c index 8a15edc8f6..e2e0af41a4 100644 --- a/openair1/PHY/TOOLS/time_meas.c +++ b/openair1/PHY/TOOLS/time_meas.c @@ -23,12 +23,20 @@ #include "time_meas.h" #include #include - +#include +#include "assertions.h" +#ifndef PHYSIM + #include "common/config/config_userapi.h" +#endif // global var for openair performance profiler int opp_enabled = 0; double cpu_freq_GHz __attribute__ ((aligned(32))); double cpu_freq_GHz __attribute__ ((aligned(32)))=0.0; +#ifndef PHYSIM +static uint32_t max_cpumeasur; +time_stats_t **measur_table; +#endif double get_cpu_freq_GHz(void) { if (cpu_freq_GHz <1 ) { @@ -133,3 +141,32 @@ double get_time_meas_us(time_stats_t *ts) return 0; } + +#ifndef PHYSIM + + +int register_meas(char *name, time_stats_t *dst_ts) +{ + for (int i=0; imeas_name = strdup(name); + measur_table[i]->meas_index = i; + return i; + } + } + return -1; +} + +void init_meas(void) +{ + paramdef_t cpumeasur_params[] = CPUMEASUR_PARAMS_DESC; + int numparams=sizeof(cpumeasur_params)/sizeof(paramdef_t); + int ret = config_get( cpumeasur_params,numparams,CPUMEASUR_SECTION); + AssertFatal(ret >= 0, "cpumeasur configuration couldn't be performed"); + measur_table=calloc(max_cpumeasur,sizeof( time_stats_t *)); + AssertFatal(measur_table!=NULL, "couldn't allocate %u cpu measurements entries\n",max_cpumeasur); + +} +#endif diff --git a/openair1/PHY/TOOLS/time_meas.h b/openair1/PHY/TOOLS/time_meas.h index e2ceef8405..d3151284bd 100644 --- a/openair1/PHY/TOOLS/time_meas.h +++ b/openair1/PHY/TOOLS/time_meas.h @@ -34,7 +34,7 @@ // global var to enable openair performance profiler extern int opp_enabled; extern double cpu_freq_GHz __attribute__ ((aligned(32)));; - +// structure to store data to compute cpu measurment #if defined(__x86_64__) || defined(__i386__) typedef struct { long long in; @@ -44,6 +44,8 @@ typedef struct { long long max; int trials; int meas_flag; + char *meas_name; /*!< \brief name to use when printing the measure (not used for PHY simulators)*/ + int meas_index; /*!< \brief index of this measure in the measure array (not used for PHY simulators)*/ } time_stats_t; #elif defined(__arm__) typedef struct { @@ -137,4 +139,15 @@ static inline void copy_meas(time_stats_t *dst_ts,time_stats_t *src_ts) { dst_ts->max=src_ts->max; } } + +#ifndef PHYSIM +#define CPUMEASUR_SECTION "cpumeasur" + +#define CPUMEASUR_PARAMS_DESC { \ + {"max_cpumeasur", "Max number of cpu measur entries", 0, uptr:&max_cpumeasur, defintval:100, TYPE_UINT, 0},\ + } + + void init_meas(void); + int register_meas(char *name, time_stats_t *ts); +#endif //ifndef PHYSIM #endif