enhance cpu measurments to better support parallelism via using a message queue.
This commit is contained in:
@@ -23,12 +23,20 @@
|
|||||||
#include "time_meas.h"
|
#include "time_meas.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "assertions.h"
|
||||||
|
#ifndef PHYSIM
|
||||||
|
#include "common/config/config_userapi.h"
|
||||||
|
#endif
|
||||||
// global var for openair performance profiler
|
// global var for openair performance profiler
|
||||||
int opp_enabled = 0;
|
int opp_enabled = 0;
|
||||||
double cpu_freq_GHz __attribute__ ((aligned(32)));
|
double cpu_freq_GHz __attribute__ ((aligned(32)));
|
||||||
|
|
||||||
double cpu_freq_GHz __attribute__ ((aligned(32)))=0.0;
|
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)
|
double get_cpu_freq_GHz(void)
|
||||||
{
|
{
|
||||||
if (cpu_freq_GHz <1 ) {
|
if (cpu_freq_GHz <1 ) {
|
||||||
@@ -133,3 +141,32 @@ double get_time_meas_us(time_stats_t *ts)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef PHYSIM
|
||||||
|
|
||||||
|
|
||||||
|
int register_meas(char *name, time_stats_t *dst_ts)
|
||||||
|
{
|
||||||
|
for (int i=0; i<max_cpumeasur; i++) {
|
||||||
|
if (measur_table[i] == NULL) {
|
||||||
|
measur_table[i] = (time_stats_t *)malloc(sizeof(time_stats_t));
|
||||||
|
memset(measur_table[i] ,0,sizeof(time_stats_t));
|
||||||
|
measur_table[i]->meas_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
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
// global var to enable openair performance profiler
|
// global var to enable openair performance profiler
|
||||||
extern int opp_enabled;
|
extern int opp_enabled;
|
||||||
extern double cpu_freq_GHz __attribute__ ((aligned(32)));;
|
extern double cpu_freq_GHz __attribute__ ((aligned(32)));;
|
||||||
|
// structure to store data to compute cpu measurment
|
||||||
#if defined(__x86_64__) || defined(__i386__)
|
#if defined(__x86_64__) || defined(__i386__)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
long long in;
|
long long in;
|
||||||
@@ -44,6 +44,8 @@ typedef struct {
|
|||||||
long long max;
|
long long max;
|
||||||
int trials;
|
int trials;
|
||||||
int meas_flag;
|
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;
|
} time_stats_t;
|
||||||
#elif defined(__arm__)
|
#elif defined(__arm__)
|
||||||
typedef struct {
|
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;
|
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
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user