From 02b1e15fdf5097fa376be2ba8150bad4363d9ad9 Mon Sep 17 00:00:00 2001 From: adash Date: Fri, 11 Sep 2009 22:27:44 +0000 Subject: [PATCH] changes to get clocks ticks, add stmlog option to log results in file --- .../MicroBenchmarks/SingleObjectMod.java | 57 ++++-------- .../SingleTM/MicroBenchmarks/makefile | 6 +- Robust/src/ClassLibrary/Integer.java | 11 +++ Robust/src/ClassLibrary/System.java | 9 ++ Robust/src/Runtime/runtime.c | 86 +++++++++++++++++++ Robust/src/buildscript | 3 + 6 files changed, 129 insertions(+), 43 deletions(-) diff --git a/Robust/src/Benchmarks/SingleTM/MicroBenchmarks/SingleObjectMod.java b/Robust/src/Benchmarks/SingleTM/MicroBenchmarks/SingleObjectMod.java index a0cc90f2..0f6ed69b 100644 --- a/Robust/src/Benchmarks/SingleTM/MicroBenchmarks/SingleObjectMod.java +++ b/Robust/src/Benchmarks/SingleTM/MicroBenchmarks/SingleObjectMod.java @@ -62,7 +62,6 @@ public class SingleObjectMod extends Thread { } public void run() { - int eventcount=0; int index, val; Random rand = new Random(); rand.random_alloc(); @@ -74,22 +73,18 @@ public class SingleObjectMod extends Thread { stop = loopsize; else stop = start + partitionSize; - LogTime[] lt = new LogTime[8*(stop-start)]; - for(int i = 0; i<(7*(stop-start))+3; i++) { - lt[i] = new LogTime(); - } - //System.out.println("Start = " + start+ " stop= " + stop + " partitionSize= " + partitionSize+ " loopsize= " + loopsize + " lsize1= " + lsize1 + " lsize2= " + lsize2); - rand.random_seed(0); + System.initLog(); + + //rand.random_seed(0); int l1, l2; //Time at Point1 - lt[eventcount].event = 1; - lt[eventcount++].time = System.getticks(); + System.logevent(1); + //System.out.println("id= " + threadid + " Start= " + System.getticks()); for(int i = start; i < stop; i++) { //Time at Point2 - lt[eventcount].event = 2; - lt[eventcount++].time = System.getticks(); + System.logevent(2); int distribution = (int)(rand.random_generate() % 100); @@ -104,13 +99,11 @@ public class SingleObjectMod extends Thread { int count; //Time at point3 - lt[eventcount].event = 3; - lt[eventcount++].time = System.getticks(); + System.logevent(3); atomic { //Time at Point4 - lt[eventcount].event = 4; - lt[eventcount++].time = System.getticks(); + System.logevent(4); index = (int)(rand.random_generate() % arrysize); // Do computation 1 @@ -119,43 +112,34 @@ public class SingleObjectMod extends Thread { } //Time at Point5 - lt[eventcount].event = 5; - lt[eventcount++].time = System.getticks(); + System.logevent(5); // Only read values from an object val = mainobj[index]; //Time at Point6 - lt[eventcount].event = 6; - lt[eventcount++].time = System.getticks(); + System.logevent(6); // Do computation 2 for(int j = 0; j #endif +#ifdef STMLOG +__thread int counter; +__thread int event[100000*7+3]; +__thread unsigned long long clkticks[100000*7+3]; +#define FILENAME "log" +#endif #if defined(THREADS)||defined(STM) /* Global barrier for STM */ @@ -200,6 +206,86 @@ void CALL11(___System______exit____I,int ___status___, int ___status___) { exit(___status___); } +#if defined(__i386__) + +static __inline__ unsigned long long rdtsc(void) +{ + unsigned long long int x; + __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x)); + return x; +} +#elif defined(__x86_64__) + +static __inline__ unsigned long long rdtsc(void) +{ + unsigned hi, lo; + __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi)); + return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 ); +} + +#elif defined(__powerpc__) + +typedef unsigned long long int unsigned long long; + +static __inline__ unsigned long long rdtsc(void) +{ + unsigned long long int result=0; + unsigned long int upper, lower,tmp; + __asm__ volatile( + "0: \n" + "\tmftbu %0 \n" + "\tmftb %1 \n" + "\tmftbu %2 \n" + "\tcmpw %2,%0 \n" + "\tbne 0b \n" + : "=r"(upper),"=r"(lower),"=r"(tmp) + ); + result = upper; + result = result<<32; + result = result|lower; + + return(result); +} +#endif + +void CALL11(___System______logevent____I,int ___event___, int ___event___) { +#ifdef STMLOG + event[counter] = ___event___; + clkticks[counter] = rdtsc(); + counter++; +#endif + return; +} + +void CALL11(___System______flushToFile____I, int ___threadid___, int ___threadid___) { +#ifdef STMLOG + FILE *fp; + /* Flush to file */ + char filename[20]; + memset(filename, 0, 20); + sprintf(filename, "%s_%d", FILENAME, ___threadid___); + if ((fp = fopen(filename, "w+")) == NULL) { + perror("fopen"); + return; + } + int i; + for (i = 0; i < counter-1; i++) { + fprintf(fp, "%d %lld %lld\n", event[i], clkticks[i], clkticks[i+1]); + } + fprintf(fp, "%d %lld\n", event[i], clkticks[i]); + + fclose(fp); +#endif + return; +} + +void CALL00(___System______initLog____) { +#ifdef STMLOG + counter=0; +#endif + return; +} + #ifdef D___Vector______removeElement_____AR_L___Object____I_I void CALL23(___Vector______removeElement_____AR_L___Object____I_I, int ___index___, int ___size___, struct ArrayObject * ___array___, int ___index___, int ___size___) { char* offset=((char *)(&VAR(___array___)->___length___))+sizeof(unsigned int)+sizeof(void *)*___index___; diff --git a/Robust/src/buildscript b/Robust/src/buildscript index a8565e72..8d5bb769 100755 --- a/Robust/src/buildscript +++ b/Robust/src/buildscript @@ -199,6 +199,9 @@ EXTRAOPTIONS="$EXTRAOPTIONS -DSTATDEBUG" elif [[ $1 = '-stmstats' ]] then EXTRAOPTIONS="$EXTRAOPTIONS -DSTMSTATS" +elif [[ $1 = '-stmlog' ]] +then +EXTRAOPTIONS="$EXTRAOPTIONS -DSTMLOG" elif [[ $1 = '-prefetch' ]] then JAVAOPTS="$JAVAOPTS -prefetch" -- 2.34.1