Use (portable) rdtsc_oai() in tpool
This commit is contained in:
@@ -43,9 +43,9 @@ int main(int argc, char *argv[]) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
uint64_t deb=rdtsc();
|
||||
uint64_t deb=rdtsc_oai();
|
||||
usleep(100000);
|
||||
cpuCyclesMicroSec=(rdtsc()-deb)/100000;
|
||||
cpuCyclesMicroSec=(rdtsc_oai()-deb)/100000;
|
||||
printf("Cycles per µs: %lu\n",cpuCyclesMicroSec);
|
||||
printf("Key" SEP "delay to process" SEP "processing time" SEP "delay to be read answer\n");
|
||||
notifiedFIFO_elt_t doneRequest;
|
||||
|
||||
@@ -72,11 +72,11 @@ void *one_thread(void *arg) {
|
||||
do {
|
||||
notifiedFIFO_elt_t *elt=pullNotifiedFifoRemember(&tp->incomingFifo, myThread);
|
||||
|
||||
if (tp->measurePerf) elt->startProcessingTime=rdtsc();
|
||||
if (tp->measurePerf) elt->startProcessingTime=rdtsc_oai();
|
||||
|
||||
elt->processingFunc(NotifiedFifoData(elt));
|
||||
|
||||
if (tp->measurePerf) elt->endProcessingTime=rdtsc();
|
||||
if (tp->measurePerf) elt->endProcessingTime=rdtsc_oai();
|
||||
|
||||
if (elt->reponseFifo) {
|
||||
// Check if the job is still alive, else it has been aborted
|
||||
|
||||
@@ -29,15 +29,9 @@
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <assertions.h>
|
||||
#include <common/utils/system.h>
|
||||
//#include <stdatomic.h>
|
||||
|
||||
static __inline__ uint64_t rdtsc(void) {
|
||||
uint32_t a, d;
|
||||
__asm__ volatile ("rdtsc" : "=a" (a), "=d" (d));
|
||||
return (((uint64_t)d)<<32) | ((uint64_t)a);
|
||||
}
|
||||
#include "assertions.h"
|
||||
#include "common/utils/time_meas.h"
|
||||
#include "common/utils/system.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#define THREADINIT PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
|
||||
@@ -66,10 +60,10 @@ typedef struct notifiedFIFO_elt_s {
|
||||
struct notifiedFIFO_s *reponseFifo;
|
||||
void (*processingFunc)(void *);
|
||||
bool malloced;
|
||||
uint64_t creationTime;
|
||||
uint64_t startProcessingTime;
|
||||
uint64_t endProcessingTime;
|
||||
uint64_t returnTime;
|
||||
OAI_CPUTIME_TYPE creationTime;
|
||||
OAI_CPUTIME_TYPE startProcessingTime;
|
||||
OAI_CPUTIME_TYPE endProcessingTime;
|
||||
OAI_CPUTIME_TYPE returnTime;
|
||||
void *msgData;
|
||||
} notifiedFIFO_elt_t;
|
||||
|
||||
@@ -225,18 +219,18 @@ typedef struct thread_pool {
|
||||
} tpool_t;
|
||||
|
||||
static inline void pushTpool(tpool_t *t, notifiedFIFO_elt_t *msg) {
|
||||
if (t->measurePerf) msg->creationTime=rdtsc();
|
||||
if (t->measurePerf) msg->creationTime=rdtsc_oai();
|
||||
|
||||
if ( t->activated)
|
||||
pushNotifiedFIFO(&t->incomingFifo, msg);
|
||||
else {
|
||||
if (t->measurePerf)
|
||||
msg->startProcessingTime=rdtsc();
|
||||
msg->startProcessingTime=rdtsc_oai();
|
||||
|
||||
msg->processingFunc(NotifiedFifoData(msg));
|
||||
|
||||
if (t->measurePerf)
|
||||
msg->endProcessingTime=rdtsc();
|
||||
msg->endProcessingTime=rdtsc_oai();
|
||||
|
||||
if (msg->reponseFifo)
|
||||
pushNotifiedFIFO(msg->reponseFifo, msg);
|
||||
@@ -247,7 +241,7 @@ static inline notifiedFIFO_elt_t *pullTpool(notifiedFIFO_t *responseFifo, tpool_
|
||||
notifiedFIFO_elt_t *msg= pullNotifiedFIFO(responseFifo);
|
||||
AssertFatal(t->traceFd, "Thread pool used while not initialized");
|
||||
if (t->measurePerf)
|
||||
msg->returnTime=rdtsc();
|
||||
msg->returnTime=rdtsc_oai();
|
||||
|
||||
if (t->traceFd > 0)
|
||||
if(write(t->traceFd, msg, sizeof(*msg)));
|
||||
@@ -262,7 +256,7 @@ static inline notifiedFIFO_elt_t *tryPullTpool(notifiedFIFO_t *responseFifo, tpo
|
||||
return NULL;
|
||||
|
||||
if (t->measurePerf)
|
||||
msg->returnTime=rdtsc();
|
||||
msg->returnTime=rdtsc_oai();
|
||||
|
||||
if (t->traceFd)
|
||||
if(write(t->traceFd, msg, sizeof(*msg)));
|
||||
|
||||
Reference in New Issue
Block a user