}
public void run() {
- int eventcount=0;
int index, val;
Random rand = new Random();
rand.random_alloc();
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);
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
}
//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<l2; j++) {
count+=val*j*j;
}
//Time at Point7
- lt[eventcount].event = 7;
- lt[eventcount++].time = System.getticks();
+ System.logevent(7);
// Write values
mainobj[index] = count;
}
//Time at Point8
- lt[eventcount].event = 8;
- lt[eventcount++].time = System.getticks();
+ System.logevent(8);
}
+ //System.out.println("id= " + threadid + " End= " + System.getticks());
+
//Time at Point9
- lt[eventcount].event = 9;
- lt[eventcount++].time = System.getticks();
+ System.logevent(9);
//Output to file
- FileOutputStream fo = new FileOutputStream("test_"+threadid);
- //test output to files test_threadid
- for(int i = 0; i<(7*(stop-start))+3; i++) {
- fo.write(fillBytes(lt[i].event));
- fo.write(longToByteArray(lt[i].time));
- }
- fo.close();
+ System.flushToFile(threadid);
}
/*
System.exit(0);
}
}
-
-public class LogTime {
- public int event;
- public long time;
- public LogTime() {
- event = 0;
- time = 0;
- }
-}
../KMeans/Random.java \
../../../ClassLibrary/intwrapper.java
-FLAGSSTATS=-stmstats -mainclass ${MAINCLASS} -singleTM -optimize -debug -joptimize -64bit -abcclose -dcopts -transstats -arraypad
-FLAGS=-mainclass ${MAINCLASS} -singleTM -nooptimize -debug -joptimize -64bit -abcclose -dcopts -transstats -arraypad
+FLAGSSTATS=-stmlog -stmstats -mainclass ${MAINCLASS} -singleTM -optimize -debug -joptimize -64bit -abcclose -dcopts -transstats -arraypad
+FLAGS=-stmlog -mainclass ${MAINCLASS} -singleTM -optimize -debug -joptimize -64bit -abcclose -dcopts -transstats -arraypad
+
+#-stmlog creates log files on each core that records the time logging of events in the microbenchmark
base:
../../../buildscript ${FLAGS} ${SRC} -o STATS${MAINCLASS}NoLockBase
return b;
}
+ public int byteArrayToInt(byte [] b) {
+ int value = 0;
+ for (int i = 0; i < 4; i++) {
+ int shift = (4 - 1 - i) * 8;
+ value += (b[i] & 0x000000FF) << shift;
+ }
+ return value;
+ }
+
+ /*
public int byteArrayToInt(byte [] b) {
int val;
val = b[0] << 24 + ((b[1] & 0xFF) << 16) + ((b[2] & 0xFF) << 8) + (b[3] & 0xFF);
return val;
}
+ */
public static int parseInt(String str) {
return Integer.parseInt(str, 10);
public static native void deepArrayCopy(Object dst, Object src);
+ /* Only used for microbenchmark testing of SingleTM version */
+ public static native void logevent(int event);
+
+ /* Only used for microbenchmark testing of SingleTM version */
+ public static native void initLog();
+
+ public static native void flushToFile(int threadid);
+ /* Only used for microbenchmark testing of SingleTM version */
+
}
#include "tm.h"
#include <pthread.h>
#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 */
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___;
elif [[ $1 = '-stmstats' ]]
then
EXTRAOPTIONS="$EXTRAOPTIONS -DSTMSTATS"
+elif [[ $1 = '-stmlog' ]]
+then
+EXTRAOPTIONS="$EXTRAOPTIONS -DSTMLOG"
elif [[ $1 = '-prefetch' ]]
then
JAVAOPTS="$JAVAOPTS -prefetch"