Merge remote-tracking branch 'origin/develop' into ul-phr
This commit is contained in:
@@ -48,6 +48,10 @@
|
||||
|
||||
// main log variables
|
||||
|
||||
// Fixme: a better place to be shure it is called
|
||||
void read_cpu_hardware (void) __attribute__ ((constructor));
|
||||
void read_cpu_hardware (void) {__builtin_cpu_init(); }
|
||||
|
||||
log_mem_cnt_t log_mem_d[2];
|
||||
int log_mem_flag=0;
|
||||
int log_mem_multi=1;
|
||||
|
||||
@@ -366,6 +366,7 @@ typedef struct {
|
||||
#define MATLAB_CSHORT_BRACKET3 15
|
||||
|
||||
int32_t write_file_matlab(const char *fname, const char *vname, void *data, int length, int dec, unsigned int format, int multiVec);
|
||||
#define write_output(a, b, c, d, e, f) write_file_matlab(a, b, c, d, e, f, 0)
|
||||
|
||||
/*----------------macro definitions for reading log configuration from the config module */
|
||||
#define CONFIG_STRING_LOG_PREFIX "log_config"
|
||||
|
||||
@@ -45,9 +45,7 @@ extern "C" {
|
||||
std::vector<MessageDef *> message_queue;
|
||||
std::map<long,timer_elm_t> timer_map;
|
||||
uint64_t next_timer=UINT64_MAX;
|
||||
struct epoll_event *events =NULL;
|
||||
int nb_fd_epoll=0;
|
||||
int nb_events=0;
|
||||
int epoll_fd=-1;
|
||||
int sem_fd=-1;
|
||||
} task_list_t;
|
||||
@@ -167,8 +165,6 @@ extern "C" {
|
||||
struct epoll_event event;
|
||||
task_list_t *t=tasks[task_id];
|
||||
t->nb_fd_epoll++;
|
||||
t->events = (struct epoll_event *)realloc((void *)t->events,
|
||||
t->nb_fd_epoll * sizeof(struct epoll_event));
|
||||
event.events = EPOLLIN | EPOLLERR;
|
||||
event.data.u64 = 0;
|
||||
event.data.fd = fd;
|
||||
@@ -185,10 +181,10 @@ extern "C" {
|
||||
t->nb_fd_epoll--;
|
||||
}
|
||||
|
||||
static inline int itti_get_events_locked(task_id_t task_id, struct epoll_event **events) {
|
||||
static inline int itti_get_events_locked(task_id_t task_id, struct epoll_event *events, int max_events) {
|
||||
task_list_t *t=tasks[task_id];
|
||||
uint64_t current_time=0;
|
||||
|
||||
int nb_events;
|
||||
do {
|
||||
if ( t->next_timer != UINT64_MAX ) {
|
||||
struct timespec tp;
|
||||
@@ -234,40 +230,41 @@ extern "C" {
|
||||
|
||||
pthread_mutex_unlock(&t->queue_cond_lock);
|
||||
LOG_D(ITTI,"enter blocking wait for %s, timeout: %d ms\n", itti_get_task_name(task_id), epoll_timeout);
|
||||
t->nb_events = epoll_wait(t->epoll_fd,t->events,t->nb_fd_epoll, epoll_timeout);
|
||||
nb_events = epoll_wait(t->epoll_fd, events, max_events, epoll_timeout);
|
||||
|
||||
if ( t->nb_events < 0 && (errno == EINTR || errno == EAGAIN ) )
|
||||
if ( nb_events < 0 && (errno == EINTR || errno == EAGAIN ) )
|
||||
pthread_mutex_lock(&t->queue_cond_lock);
|
||||
} while (t->nb_events < 0 && (errno == EINTR || errno == EAGAIN ) );
|
||||
} while (nb_events < 0 && (errno == EINTR || errno == EAGAIN ) );
|
||||
|
||||
AssertFatal (t->nb_events >=0,
|
||||
AssertFatal (nb_events >=0,
|
||||
"epoll_wait failed for task %s, nb fds %d, timeout %lu: %s!\n",
|
||||
itti_get_task_name(task_id), t->nb_fd_epoll, t->next_timer != UINT64_MAX ? t->next_timer-current_time : -1, strerror(errno));
|
||||
LOG_D(ITTI,"receive on %d descriptors for %s\n", t->nb_events, itti_get_task_name(task_id));
|
||||
itti_get_task_name(task_id), t->nb_fd_epoll,
|
||||
t->next_timer != UINT64_MAX ? t->next_timer-current_time : -1,
|
||||
strerror(errno));
|
||||
LOG_D(ITTI,"receive on %d descriptors for %s\n", nb_events, itti_get_task_name(task_id));
|
||||
|
||||
if (t->nb_events == 0)
|
||||
if (nb_events == 0)
|
||||
/* No data to read -> return */
|
||||
return 0;
|
||||
|
||||
for (int i = 0; i < t->nb_events; i++) {
|
||||
for (int i = 0; i < nb_events; i++) {
|
||||
/* Check if there is an event for ITTI for the event fd */
|
||||
if ((t->events[i].events & EPOLLIN) &&
|
||||
(t->events[i].data.fd == t->sem_fd)) {
|
||||
if ((events[i].events & EPOLLIN) &&
|
||||
(events[i].data.fd == t->sem_fd)) {
|
||||
eventfd_t sem_counter;
|
||||
/* Read will always return 1 */
|
||||
AssertFatal( sizeof(sem_counter) == read (t->sem_fd, &sem_counter, sizeof(sem_counter)), "");
|
||||
/* Mark that the event has been processed */
|
||||
t->events[i].events &= ~EPOLLIN;
|
||||
events[i].events &= ~EPOLLIN;
|
||||
}
|
||||
}
|
||||
|
||||
*events = t->events;
|
||||
return t->nb_events;
|
||||
return nb_events;
|
||||
}
|
||||
|
||||
int itti_get_events(task_id_t task_id, struct epoll_event **events) {
|
||||
int itti_get_events(task_id_t task_id, struct epoll_event *events, int nb_evts) {
|
||||
pthread_mutex_lock(&tasks[task_id]->queue_cond_lock);
|
||||
return itti_get_events_locked(task_id, events);
|
||||
return itti_get_events_locked(task_id, events, nb_evts);
|
||||
}
|
||||
|
||||
void itti_receive_msg(task_id_t task_id, MessageDef **received_msg) {
|
||||
@@ -275,15 +272,16 @@ extern "C" {
|
||||
task_list_t *t=tasks[task_id];
|
||||
pthread_mutex_lock(&t->queue_cond_lock);
|
||||
|
||||
struct epoll_event events[t->nb_fd_epoll];
|
||||
// Weird condition to deal with crap legacy itti interface
|
||||
if ( t->nb_fd_epoll == 1 ) {
|
||||
while (t->message_queue.empty()) {
|
||||
itti_get_events_locked(task_id, &t->events);
|
||||
itti_get_events_locked(task_id, events, t->nb_fd_epoll);
|
||||
pthread_mutex_lock(&t->queue_cond_lock);
|
||||
}
|
||||
} else {
|
||||
if (t->message_queue.empty()) {
|
||||
itti_get_events_locked(task_id, &t->events);
|
||||
itti_get_events_locked(task_id, events, t->nb_fd_epoll);
|
||||
pthread_mutex_lock(&t->queue_cond_lock);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -479,7 +479,7 @@ void itti_unsubscribe_event_fd(task_id_t task_id, int fd);
|
||||
\param events events list
|
||||
@returns number of events to handle
|
||||
**/
|
||||
int itti_get_events(task_id_t task_id, struct epoll_event **events);
|
||||
int itti_get_events(task_id_t task_id, struct epoll_event *events, int nb_max_evts);
|
||||
|
||||
/** \brief Retrieves a message in the queue associated to task_id.
|
||||
If the queue is empty, the thread is blocked till a new message arrives.
|
||||
|
||||
@@ -111,7 +111,7 @@ void initNamedTpool(char *params,tpool_t *pool, bool performanceMeas, char *name
|
||||
|
||||
if (measr) {
|
||||
mkfifo(measr,0666);
|
||||
AssertFatal(-1 != (pool->dummyTraceFd=
|
||||
AssertFatal(-1 != (pool->dummyKeepReadingTraceFd=
|
||||
open(measr, O_RDONLY| O_NONBLOCK)),"");
|
||||
AssertFatal(-1 != (pool->traceFd=
|
||||
open(measr, O_WRONLY|O_APPEND|O_NOATIME|O_NONBLOCK)),"");
|
||||
@@ -130,6 +130,7 @@ void initNamedTpool(char *params,tpool_t *pool, bool performanceMeas, char *name
|
||||
int c=toupper(curptr[0]);
|
||||
|
||||
switch (c) {
|
||||
|
||||
case 'N':
|
||||
pool->activated=false;
|
||||
break;
|
||||
@@ -161,6 +162,17 @@ void initNamedTpool(char *params,tpool_t *pool, bool performanceMeas, char *name
|
||||
}
|
||||
}
|
||||
|
||||
void initFloatingCoresTpool(int nbThreads,tpool_t *pool, bool performanceMeas, char *name) {
|
||||
char threads[1024] = "n";
|
||||
if (nbThreads) {
|
||||
strcpy(threads,"-1");
|
||||
for (int i=1; i < nbThreads; i++)
|
||||
strncat(threads,",-1", sizeof(threads-1));
|
||||
}
|
||||
threads[sizeof(threads-1)]=0;
|
||||
initNamedTpool(threads, pool, performanceMeas, name);
|
||||
}
|
||||
|
||||
#ifdef TEST_THREAD_POOL
|
||||
volatile int oai_exit=0;
|
||||
|
||||
|
||||
@@ -256,9 +256,8 @@ typedef struct thread_pool {
|
||||
bool activated;
|
||||
bool measurePerf;
|
||||
int traceFd;
|
||||
int dummyTraceFd;
|
||||
int dummyKeepReadingTraceFd;
|
||||
uint64_t cpuCyclesMicroSec;
|
||||
uint64_t startProcessingUE;
|
||||
int nbThreads;
|
||||
notifiedFIFO_t incomingFifo;
|
||||
struct one_thread *allthreads;
|
||||
@@ -389,5 +388,6 @@ static inline int abortTpool(tpool_t *t) {
|
||||
return nbRemoved;
|
||||
}
|
||||
void initNamedTpool(char *params,tpool_t *pool, bool performanceMeas, char *name);
|
||||
void initFloatingCoresTpool(int nbThreads,tpool_t *pool, bool performanceMeas, char *name);
|
||||
#define initTpool(PARAMPTR,TPOOLPTR, MEASURFLAG) initNamedTpool(PARAMPTR,TPOOLPTR, MEASURFLAG, NULL)
|
||||
#endif
|
||||
|
||||
@@ -39,14 +39,14 @@ notifiedFIFO_t measur_fifo;
|
||||
double get_cpu_freq_GHz(void)
|
||||
{
|
||||
if (cpu_freq_GHz <1 ) {
|
||||
time_stats_t ts = {0};
|
||||
reset_meas(&ts);
|
||||
ts.trials++;
|
||||
ts.in = rdtsc_oai();
|
||||
sleep(1);
|
||||
ts.diff = (rdtsc_oai()-ts.in);
|
||||
cpu_freq_GHz = (double)ts.diff/1000000000;
|
||||
printf("CPU Freq is %f \n", cpu_freq_GHz);
|
||||
time_stats_t ts = {0};
|
||||
reset_meas(&ts);
|
||||
ts.trials++;
|
||||
ts.in = rdtsc_oai();
|
||||
sleep(1);
|
||||
ts.diff = (rdtsc_oai()-ts.in);
|
||||
cpu_freq_GHz = (double)ts.diff/1000000000;
|
||||
printf("CPU Freq is %f \n", cpu_freq_GHz);
|
||||
}
|
||||
return cpu_freq_GHz;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user