1 public class WriteArrayObj extends Thread {
6 public WriteArrayObj() {
9 public WriteArrayObj(int lower, WriteArrayObj[] wa, int nthreads, int start) {
12 this.nthreads = nthreads;
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 //System.printString("Creating " + i + " element\n");
27 Barrier.enterBarrier(barr);
28 //System.clearPrefetchCache(); //without invalidation it always reads an old array object therefore we need a clearCache
29 //Write into array elements
31 for(int j=0; j<10000; j++) {
33 val = global new Integer(10);
34 for(int i=start;i<start+nthreads; i++) {
35 //System.printString("Reading element " + i + "\n");
36 mywa[i].val = val.intValue();
42 public static void main(String[] args) {
46 nthreads = Integer.parseInt(args[0]);
49 int[] mid = new int[8];
50 mid[0] = (128<<24)|(195<<16)|(175<<8)|84;//dw-10
51 mid[1] = (128<<24)|(195<<16)|(175<<8)|85;//dw-11
52 mid[2] = (128<<24)|(195<<16)|(175<<8)|86;//dw-12
53 mid[3] = (128<<24)|(195<<16)|(175<<8)|87;//dw-13
54 mid[4] = (128<<24)|(195<<16)|(175<<8)|88;//dw-14
55 mid[5] = (128<<24)|(195<<16)|(175<<8)|89;//dw-15
56 mid[6] = (128<<24)|(195<<16)|(175<<8)|90;//dw-16
57 mid[7] = (128<<24)|(195<<16)|(175<<8)|91;//dw-17
61 wao=global new WriteArrayObj[nthreads*nthreads]; //create array of objects
62 mybarr = global new BarrierServer(nthreads);
66 WriteArrayObjWrap[] wawrap = new WriteArrayObjWrap[nthreads];
69 for(int i=0;i<nthreads; i++) {
70 int start = i * nthreads;
71 wawrap[i] = new WriteArrayObjWrap(global new WriteArrayObj(i,wao, nthreads,start));
75 boolean waitfordone=true;
77 atomic { //Master aborts come from here
83 for(int i =0; i<nthreads; i++)
84 wawrap[i].wa.start(mid[i]);
86 for(int i =0; i<nthreads; i++)
89 System.printString("Finished\n");