helpful progress reporting
[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     //Write into array elements
28     Integer val;
29     for(int j=0; j<10000; j++) {
30       atomic {
31         val = global new Integer(10);
32         for(int i=start;i<start+nthreads; i++) {
33           mywa[i].val = val.intValue();
34         }
35       }
36     }
37   }
38
39   public static void main(String[] args) {
40     int nthreads;
41     BarrierServer mybarr;
42     if(args.length>0) {
43       nthreads = Integer.parseInt(args[0]);
44     }
45
46     int[] mid = new int[5];
47     mid[0] = (128<<24)|(195<<16)|(175<<8)|84;//dw-10
48     mid[1] = (128<<24)|(195<<16)|(175<<8)|85;//dw-11
49     mid[2] = (128<<24)|(195<<16)|(175<<8)|86;//dw-12
50     mid[3] = (128<<24)|(195<<16)|(175<<8)|87;//dw-13
51     mid[4] = (128<<24)|(195<<16)|(175<<8)|88;//dw-14
52
53     WriteArrayObj[] wao;
54     atomic {
55       wao=global new WriteArrayObj[nthreads*nthreads]; //create array of objects
56       mybarr = global new BarrierServer(nthreads);
57     }
58     mybarr.start(mid[0]);
59
60     WriteArrayObjWrap[] wawrap = new WriteArrayObjWrap[nthreads];
61
62     atomic {
63       for(int i=0;i<nthreads; i++) {
64         int start = i * nthreads; 
65          wawrap[i] = new WriteArrayObjWrap(global new WriteArrayObj(i,wao, nthreads,start));
66       }
67     }
68
69     boolean waitfordone=true;
70     while(waitfordone) {
71       atomic { //Master aborts come from here
72         if (mybarr.done)
73           waitfordone=false;
74       }
75     }
76
77     for(int i =0; i<nthreads; i++)
78       wawrap[i].wa.start(mid[i]);
79
80     for(int i =0; i<nthreads; i++)
81       wawrap[i].wa.join();
82
83         System.printString("Finished\n");
84   }
85 }