Compiling and Running
----------------------
+ Note: For this benchmark the fudgefactor used in the "~/research/Robust/src/Runtime/DSTM/interface/dstm.h" file is 3
+
To build:
make stmlock
e.g. ~/research/Robust/src/Benchmarks/SingleTM/MicroBenchmarks$ make clean && make stmlock
+ To build the base version with no locks:
+ make base
+
+ e.g. ~/research/Robust/src/Benchmarks/SingleTM/MicroBenchmarks$ make clean && make base
+
To run:
- ./STATSSingleObjectMod.bin -t <num threads>
+ ./STATSSingleObjectModX.bin -t <num threads>
-size <array size>
-l <loopsize>
-l1 <loopsize1>
-l2 <loopsize2>
+ -p <probability of distribution>
+
+ where X = target probability desired
+
+ To run the base version:
+ ./STATSSingleObjectModNoLockBase.bin -t 8 -size 1 -l 100000 -l1 10000 -l2 10000 -p 90
- low contention: -t 8 -size 5000 -l 100
- high contention: -t 8 -size 5 -l 500000
+ low contention: -t 8 -size 5000 -l 100 -p 50
+ high contention: -t 8 -size 5 -l 500000 -p 50
}
public void run() {
+ int eventcount=0;
int index, val;
Random rand = new Random();
rand.random_alloc();
else
stop = start + partitionSize;
LogTime[] lt = new LogTime[8*(stop-start)];
- for(int i = 0; i<8*(stop-start); i++) {
+ for(int i = 0; i<(7*(stop-start))+3; i++) {
lt[i] = new LogTime();
}
- int eventcount=0;
//System.out.println("Start = " + start+ " stop= " + stop + " partitionSize= " + partitionSize+ " loopsize= " + loopsize + " lsize1= " + lsize1 + " lsize2= " + lsize2);
rand.random_seed(0);
int l1, l2;
l1=l2=lsize2;
}
- /*
- //50% distribution
- int l3= (int)(rand.random_generate() % 2);
- if(l3==0) {
- l1=l2=lsize2;
- }
- if(l3==1) {
- l1=l2=lsize1;
- }
- */
-
int count;
//Time at point3
//Output to file
FileOutputStream fo = new FileOutputStream("test_"+threadid);
- //test output to file
- char a = 'a';
- fo.write(a);
+ //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();
}
/*
* Convert int to a byte array
**/
- public byte[] fillBytes(int key) {
+ static byte[] fillBytes(int key) {
byte[] b = new byte[4];
for(int i = 0; i < 4; i++){
int offset = (3-i) * 8;
return b;
}
+ static byte[] longToByteArray(long a) {
+ byte[] b = new byte[8];
+ int i, shift;
+ for (i = 0, shift = 56; i < 8; i++, shift -= 8)
+ {
+ b[i] = (byte) (0xFF & (a >> shift));
+ }
+
+ return b;
+ }
public static void main(String[] args) {
SingleObjectMod som = new SingleObjectMod();
public class LogTime {
public int event;
public long time;
-
public LogTime() {
event = 0;
time = 0;
--- /dev/null
+/** readFromFile
+ ** This file is associated with the output generated from file SingleObjectMod.java
+ ** This file reads the contents of the output files such as test_0, test_1 ...test_N
+ ** generated by running the SingleObjectMod.java file
+ **
+ ** First execute SingleObjectMod.java in the following manner
+ **./STATSSingleObjectModNoLockBase.bin -t 8 -size 1 -l 100000 -l1 10000 -l2 10000 -p 90
+ **
+ ** build:
+ ** javac readFromFile.java
+ **
+ **
+ ** run :
+ ** java readFromFile <filename> > log_filename
+ ** for e.g. java readFromFile test_0 > log_test_0
+ **
+ **/
+
+import java.io.*;
+
+
+public class readFromFile {
+ public static void main(String[] args) {
+ for (int i = 0; i < args.length; i++)
+ System.out.println(args[i]);
+ File file = new File(args[0]);
+ try {
+ FileInputStream fin = new FileInputStream(file);
+ byte[] b1 = new byte[4];
+ byte[] b2 = new byte[8];
+ int start = 0;
+ int stop = 12500; // Note: l/NUMTHREADS (number of iterations (-l) / num of threads)
+ for(int i = 0;i<(7*(stop-start))+3; i++) {
+ fin.read(b1);
+ int event = convertToInt(b1);
+ System.out.print("Event= " + event + " ");
+ fin.read(b2);
+ long time = convertToLong(b2);
+ System.out.println("Time= " + time);
+ }
+ fin.close();
+ } catch(FileNotFoundException e) {
+ System.out.println("File " + file.getAbsolutePath() +
+ " could not be found on filesystem");
+ } catch(IOException ioe)
+ {
+ System.out.println("Exception while reading the file" + ioe);
+ }
+ }
+
+ static int convertToInt(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;
+ }
+
+ static long convertToLong (byte[] buf)
+ {
+ return (((long)(buf [0] & 0xff) << 56) |
+ ((long)(buf [1] & 0xff) << 48) |
+ ((long)(buf [2] & 0xff) << 40) |
+ ((long)(buf [3] & 0xff) << 32) |
+ ((long)(buf [4] & 0xff) << 24) |
+ ((long)(buf [5] & 0xff) << 16) |
+ ((long)(buf [6] & 0xff) << 8) |
+ ((long)(buf [7] & 0xff)));
+ }
+}