From 44681ed1080fed0814e313ff767e8a7ccdca31b6 Mon Sep 17 00:00:00 2001 From: jihoonl Date: Mon, 21 Sep 2009 23:18:38 +0000 Subject: [PATCH] simple benchmark for recovery --- .../Prefetch/MicroBenchmarks/dsm/Drinker.java | 123 +++++++++++++ .../Prefetch/MicroBenchmarks/dsm/Simple.java | 166 ++++++++++++++++++ .../Prefetch/MicroBenchmarks/dsm/dstm.conf | 11 ++ .../Prefetch/MicroBenchmarks/dsm/makefile | 17 ++ 4 files changed, 317 insertions(+) create mode 100644 Robust/src/Benchmarks/Prefetch/MicroBenchmarks/dsm/Drinker.java create mode 100644 Robust/src/Benchmarks/Prefetch/MicroBenchmarks/dsm/Simple.java create mode 100644 Robust/src/Benchmarks/Prefetch/MicroBenchmarks/dsm/dstm.conf create mode 100644 Robust/src/Benchmarks/Prefetch/MicroBenchmarks/dsm/makefile diff --git a/Robust/src/Benchmarks/Prefetch/MicroBenchmarks/dsm/Drinker.java b/Robust/src/Benchmarks/Prefetch/MicroBenchmarks/dsm/Drinker.java new file mode 100644 index 00000000..2d900caf --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/MicroBenchmarks/dsm/Drinker.java @@ -0,0 +1,123 @@ +public class Drinker extends Task { + int ownTotal; + + public Drinker(int num_threads,Queue todo,Queue done) { + ownTotal = 0; + todoList = todo; + doneList = done; + } + + // fill up the Work Pool + public void fillTodoList(Queue todoList, int size) { + Segment seg; + int i; + + for(i = 0; i < size; i += 10) { + seg = global new Segment(10); + todoList.push(seg); + } + + System.out.println("TodoSIZE = " + todoList.size()); + } + + public Object grabTask() { + atomic { + if (todoList.size() != 0) { + return (Segment)todoList.pop(); + } + } + return null; + } + + public void execute(Object myWork) { + Segment work = (Segment)myWork; + + int numApple = work.x; + + ownTotal += numApple; + + } + + public void done(Object work) { + atomic { + doneList.push(work); + } + } + + public static void main(String[] args) { + int NUM_THREADS; + int i,j; + int size = Integer.parseInt(args[1]); + Work[] work; + Drinker[] drinkers; + Segment[] currentWorkList; + Queue todoList; + Queue doneList; + + if (args.length > 0) { + NUM_THREADS = Integer.parseInt(args[0]); + } + + int[] mid = new int[NUM_THREADS]; +// mid[0] = (128<<24)|(195<<16)|(136<<8)|162; //dc1 +// mid[1] = (128<<24)|(195<<16)|(136<<8)|163; //dc2 + mid[0] = (128<<24)|(195<<16)|(136<<8)|164; //dc3 + mid[1] = (128<<24)|(195<<16)|(136<<8)|165; //dc4 + mid[2] = (128<<24)|(195<<16)|(136<<8)|166; //dc5 + mid[3] = (128<<24)|(195<<16)|(136<<8)|167; //dc6 + mid[4] = (128<<24)|(195<<16)|(136<<8)|168; //dc7 + mid[5] = (128<<24)|(195<<16)|(136<<8)|169; //dc8 + + atomic { + drinkers = global new Drinker[NUM_THREADS]; + todoList = global new Queue(500); + doneList = global new Queue(500); + + work = global new Work[NUM_THREADS]; + currentWorkList = global new Segment[NUM_THREADS]; + + drinkers[0] = global new Drinker(NUM_THREADS,todoList,doneList); + drinkers[0].fillTodoList(todoList,size); + work[0] = global new Work(drinkers[0], NUM_THREADS, 0 , currentWorkList); + + for(i = 1; i < NUM_THREADS; i++) { + drinkers[i] = global new Drinker(NUM_THREADS,todoList,doneList); + work[i] = global new Work(drinkers[i], NUM_THREADS, i,currentWorkList); + } + } + + System.out.println("Finished initialization"); + Work tmp; + for (i = 0; i < NUM_THREADS; i++) { + atomic { + tmp = work[i]; + } + Thread.myStart(tmp,mid[i]); + } + + System.out.println("Finished Starting Threads"); + for (i = 0; i < NUM_THREADS; i++) { + atomic { + tmp = work[i]; + } + System.out.println("Thread id " + i + " is joining"); + tmp.join(); + } + + System.printString("Finished\n"); + } +} + +public class Segment { + int x; + + Segment (int x) { + this.x = x; + } + + public String toString() + { + return "lol"; + } +} + diff --git a/Robust/src/Benchmarks/Prefetch/MicroBenchmarks/dsm/Simple.java b/Robust/src/Benchmarks/Prefetch/MicroBenchmarks/dsm/Simple.java new file mode 100644 index 00000000..1e0d50e6 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/MicroBenchmarks/dsm/Simple.java @@ -0,0 +1,166 @@ +public class Simple extends Thread { + Counting mycount; + int id; + public Simple(Counting mycount, int i) { + this.mycount = mycount; + this.id = i; + } + + public void run() { + + int threadid; + + atomic { + threadid = id; +// System.println("\n##threadid: " + threadid + "\n"); + } +// if(threadid == ((128<<24)|(195<<16)|(180<<8)|24)) + // System.exit(0); + + for(int i = 0; i < 1000; i++) { + atomic { +// System.println("##threadid: " + threadid); + mycount.increment(); + } + +// if(threadid == ((128<<24)|(195<<16)|(180<<8)|21)) { + for(int j =0;j< 4;j++) { + atomic { + // System.out.println("##Threadid " + j + " : " + getStatus(j)); + } + } + // } + } + + FileOutputStream output = new FileOutputStream("output"+threadid); + int cc; + + atomic { + cc = mycount.count; + } + + String outStr = "Count = " + cc + "\n"; + output.write(outStr.getBytes()); + System.out.println("\n\n\nFinished!!!!!!\n\n\n\n"); + output.close(); + + + } + + public static void main(String[] args) { + Simple[] s; + Counting c; + int numthreads = 3; + int[] mid = new int[numthreads]; + FileOutputStream out = new FileOutputStream("output"); + +/* mid[0] = (128<<24)|(195<<16)|(180<<8)|26; //dw-7 + mid[1] = (128<<24)|(195<<16)|(180<<8)|24; //dw-5 + mid[2] = (128<<24)|(195<<16)|(180<<8)|21; //dw-2 +*/ +// mid[1] = (128<<24)|(195<<16)|(180<<8)|22; //dw-3 + mid[0] = (128<<24)|(195<<16)|(136<<8)|162; //dc-1 + mid[1] = (128<<24)|(195<<16)|(136<<8)|163; //dc-2 + mid[2] = (128<<24)|(195<<16)|(136<<8)|164; //dc-3 + mid[2] = (128<<24)|(195<<16)|(136<<8)|164; //dc-3 + mid[2] = (128<<24)|(195<<16)|(136<<8)|164; //dc-3 + mid[2] = (128<<24)|(195<<16)|(136<<8)|164; //dc-3 + mid[2] = (128<<24)|(195<<16)|(136<<8)|164; //dc-3 + mid[2] = (128<<24)|(195<<16)|(136<<8)|164; //dc-3 +// mid[3] = (128<<24)|(195<<16)|(136<<8)|165; //dc-4 + + + atomic { + + c = global new Counting(); + s = global new Simple[numthreads]; + for(int i = 0; i < numthreads; i++) { + s[i] = global new Simple(c, mid[i]); + } + + } + + ccc od = new ccc(); + ddd ad = new ddd(); + od.increment(); + + od.increment(3); + + od = (ccc)ad; + + od.increment(5); + + + + + System.out.println("##Done creating objects"); + Simple tmp; + for(int i = 0; i < numthreads; i++) { + atomic { + tmp = s[i]; + } + System.out.println("##Temp gets simple object; start temp simple object"); +// tmp.start(mid[i]); + Thread.myStart(tmp,mid[i]); + } + + System.out.println("\n\n##DONE starting Threads\n"); + + for(int i = 0; i < numthreads; i++) { + atomic { + tmp = s[i]; + } + System.out.println("##Wait\n"); + tmp.join(); + } + //print count + int finalcount; + atomic { + finalcount = c.count; + } + + String outStr = "Count = " + finalcount + "\n"; + out.write(outStr.getBytes()); + System.printString("Count = "+finalcount+"\n"); + out.close(); + + } + +} + +class Counting { + global int count; + public Counting() { + this.count = 0; + } + + public increment() { + count = count + 1; + } +} + +class ccc { + int dd; + public ccc() { + this.dd = 0; + } + + public increment() { + dd++; + } + + public increment(int o) { + dd += o; + } +} + +class ddd extends ccc { + + public ddd() { + this.dd = 0; + } + public increment(int u) + { + dd = u; + } +} diff --git a/Robust/src/Benchmarks/Prefetch/MicroBenchmarks/dsm/dstm.conf b/Robust/src/Benchmarks/Prefetch/MicroBenchmarks/dsm/dstm.conf new file mode 100644 index 00000000..21e620a8 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/MicroBenchmarks/dsm/dstm.conf @@ -0,0 +1,11 @@ +#128.195.180.24 +#128.195.180.21 +#128.195.180.26 +#128.195.136.162 +#128.195.136.163 +128.195.136.164 +128.195.136.165 +128.195.136.166 +128.195.136.167 +128.195.136.168 +128.195.136.169 diff --git a/Robust/src/Benchmarks/Prefetch/MicroBenchmarks/dsm/makefile b/Robust/src/Benchmarks/Prefetch/MicroBenchmarks/dsm/makefile new file mode 100644 index 00000000..93734256 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/MicroBenchmarks/dsm/makefile @@ -0,0 +1,17 @@ +MAINCLASS1=Drinker +MAINCLASS2=Simple +SRC1=${MAINCLASS1}.java +SRC2=${MAINCLASS2}.java +FLAGS1= -dsm -nooptimize -recovery -debug -mainclass ${MAINCLASS1} +FLAGS2= -dsm -nooptimize -recovery -debug -mainclass ${MAINCLASS2} +default: + ../../../../buildscript ${FLAGS1} -o ${MAINCLASS1} ${SRC1} + ../../../../buildscript ${FLAGS2} -o ${MAINCLASS2} ${SRC2} +drinker: + ../../../../buildscript ${FLAGS1} -o ${MAINCLASS1} ${SRC1} +simple: + ../../../../buildscript ${FLAGS2} -o ${MAINCLASS2} ${SRC2} + +clean: + rm -rf tmpbuilddirectory + rm *.bin -- 2.34.1