Add microbenchmarks with script for analyzing our Prefetch and other results
[IRC.git] / Robust / src / Benchmarks / Prefetch / MicroBenchmarks / MultiMCWritecommit.java
1 public class WriteArrayObj extends Thread {
2   WriteArrayObj[] mywa;
3   int nthreads;
4   int val, lower, start;
5
6   public WriteArrayObj() {
7   }
8
9   public WriteArrayObj(int lower, WriteArrayObj[] wa, int nthreads, int start) {
10     this.lower = lower;
11     mywa = wa;
12     this.nthreads = nthreads;
13     this.start = start;
14   }
15
16   public void run() {
17     Barrier barr;
18     barr = new Barrier("128.195.175.84");
19     //Create array objects locally
20     atomic { //Remote machine aborts come from here
21       for(int i=lower; i<nthreads*nthreads; i=i+nthreads) {
22         mywa[i] = global new WriteArrayObj();
23       }
24     }
25
26     Barrier.enterBarrier(barr);
27 /*
28     //Write into array elements
29     Integer val;
30     for(int j=0; j<10000; j++) {
31       atomic {
32         val = global new Integer(10);
33         for(int i=start;i<start+nthreads; i++) {
34           mywa[i].val = val.intValue();
35         }
36       }
37     }
38     */
39   }
40
41   public static void main(String[] args) {
42     int nthreads;
43     BarrierServer mybarr;
44     if(args.length>0) {
45       nthreads = Integer.parseInt(args[0]);
46     }
47
48     int[] mid = new int[5];
49     mid[0] = (128<<24)|(195<<16)|(175<<8)|84;//dw-10
50     mid[1] = (128<<24)|(195<<16)|(175<<8)|85;//dw-11
51     mid[2] = (128<<24)|(195<<16)|(175<<8)|86;//dw-12
52     mid[3] = (128<<24)|(195<<16)|(175<<8)|87;//dw-13
53     mid[4] = (128<<24)|(195<<16)|(175<<8)|88;//dw-14
54
55     WriteArrayObj[] wao;
56     atomic {
57       wao=global new WriteArrayObj[nthreads*nthreads]; //create array of objects
58       mybarr = global new BarrierServer(nthreads);
59     }
60     mybarr.start(mid[0]);
61
62     WriteArrayObjWrap[] wawrap = new WriteArrayObjWrap[nthreads];
63
64     atomic {
65       for(int i=0;i<nthreads; i++) {
66         int start = i * nthreads; 
67          wawrap[i] = new WriteArrayObjWrap(global new WriteArrayObj(i,wao, nthreads,start));
68       }
69     }
70
71     boolean waitfordone=true;
72     while(waitfordone) {
73       atomic { //Master aborts come from here
74         if (mybarr.done)
75           waitfordone=false;
76       }
77     }
78
79     for(int i =0; i<nthreads; i++)
80       wawrap[i].wa.start(mid[i]);
81
82     for(int i =0; i<nthreads; i++)
83       wawrap[i].wa.join();
84
85         System.printString("Finished\n");
86   }
87 }