From: adash Date: Tue, 1 Sep 2009 01:43:50 +0000 (+0000) Subject: changes to read clockticks from file X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=4a93ffbfd3a9e550965a35dc8b9fad0140c2f69e;p=IRC.git changes to read clockticks from file --- diff --git a/Robust/src/Benchmarks/SingleTM/MicroBenchmarks/README b/Robust/src/Benchmarks/SingleTM/MicroBenchmarks/README index 33ed312c..a475657f 100644 --- a/Robust/src/Benchmarks/SingleTM/MicroBenchmarks/README +++ b/Robust/src/Benchmarks/SingleTM/MicroBenchmarks/README @@ -10,17 +10,30 @@ SingleObjectMod.java: 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 + ./STATSSingleObjectModX.bin -t -size -l -l1 -l2 + -p + + 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 diff --git a/Robust/src/Benchmarks/SingleTM/MicroBenchmarks/SingleObjectMod.java b/Robust/src/Benchmarks/SingleTM/MicroBenchmarks/SingleObjectMod.java index 9b279a25..a0cc90f2 100644 --- a/Robust/src/Benchmarks/SingleTM/MicroBenchmarks/SingleObjectMod.java +++ b/Robust/src/Benchmarks/SingleTM/MicroBenchmarks/SingleObjectMod.java @@ -62,6 +62,7 @@ public class SingleObjectMod extends Thread { } public void run() { + int eventcount=0; int index, val; Random rand = new Random(); rand.random_alloc(); @@ -74,11 +75,10 @@ public class SingleObjectMod extends Thread { 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; @@ -101,17 +101,6 @@ public class SingleObjectMod extends Thread { 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 @@ -161,15 +150,18 @@ public class SingleObjectMod extends Thread { //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; @@ -182,6 +174,16 @@ public class SingleObjectMod extends Thread { 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(); @@ -220,7 +222,6 @@ public class SingleObjectMod extends Thread { public class LogTime { public int event; public long time; - public LogTime() { event = 0; time = 0; diff --git a/Robust/src/Benchmarks/SingleTM/MicroBenchmarks/readFromFile.java b/Robust/src/Benchmarks/SingleTM/MicroBenchmarks/readFromFile.java new file mode 100644 index 00000000..0926e8a1 --- /dev/null +++ b/Robust/src/Benchmarks/SingleTM/MicroBenchmarks/readFromFile.java @@ -0,0 +1,71 @@ +/** 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 > 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))); + } +}