start of new file
[IRC.git] / Robust / src / Benchmarks / Prefetch / Em3d / dsm / Em3d2.java
index 93776f2eef6e340f81ef22ca94838db183de502e..3d73a5d0a74bf67ca2b60ab4d1d269112eeb7aa6 100644 (file)
@@ -42,17 +42,14 @@ public class Em3d extends Thread {
   BiGraph bg;
   int upperlimit;
   int lowerlimit;
- //Barrier barr;
- String hostname;
     public Em3d() {
     }
 
-    public Em3d(BiGraph bg, int lowerlimit, int upperlimit, int numIter, int numDegree, int threadindex, String name) {
+    public Em3d(BiGraph bg, int lowerlimit, int upperlimit, int numIter, int numDegree, int threadindex) {
     this.bg = bg;
     this.lowerlimit = lowerlimit;
     this.upperlimit = upperlimit;
     this.numIter = numIter;
-    this.hostname = name;
     this.numDegree = numDegree;
     this.threadindex=threadindex;
   }
@@ -62,8 +59,9 @@ public class Em3d extends Thread {
     Barrier barr;
     int degree;
     Random random;
+    String hname;
 
-    barr = new Barrier(hostname);
+    barr = new Barrier("128.195.175.79");
     atomic {
        iteration = numIter;
        degree = numDegree;
@@ -141,14 +139,6 @@ public class Em3d extends Thread {
     long start0 = System.currentTimeMillis();
     int numThreads = em.numThreads;
     int[] mid = new int[4];
-    String[] hostname;
-    atomic {
-      hostname = global new String[4];
-      hostname[0] = global new String("128.195.175.79");
-      hostname[1] =  global new String("128.195.175.73");
-      hostname[2] = global new String("128.195.175.78");
-      hostname[3] = global new String("128.195.175.69");
-    }
     mid[0] = (128<<24)|(195<<16)|(175<<8)|79;//dw-1
     mid[1] = (128<<24)|(195<<16)|(175<<8)|73;//dw-2
     mid[2] = (128<<24)|(195<<16)|(175<<8)|78;
@@ -166,6 +156,8 @@ public class Em3d extends Thread {
       mybarr = global new BarrierServer(numThreads);
       graph =  BiGraph.create(em.numNodes, em.numDegree, numThreads);
     }
+    mybarr.start(mid[0]);
+
 
     Em3dWrap[] em3d=new Em3dWrap[numThreads];    
     int increment = em.numNodes/numThreads;
@@ -179,21 +171,26 @@ public class Em3d extends Thread {
       for(int i=0;i<numThreads;i++) {
          Em3d tmp;
          if ((i+1)==numThreads)
-             tmp = global new Em3d(graph, base, em.numNodes, em.numIter, em.numDegree, i, hostname[0]);
+             tmp = global new Em3d(graph, base, em.numNodes, em.numIter, em.numDegree, i);
          else
-             tmp = global new Em3d(graph, base, base+increment, em.numIter, em.numDegree, i, hostname[0]);
+             tmp = global new Em3d(graph, base, base+increment, em.numIter, em.numDegree, i);
          em3d[i]=new Em3dWrap(tmp);
          base+=increment;
       }
     }
 
-    //TODO check if correct
-    mybarr.start(mid[0]);
+    boolean waitfordone=true;
+    while(waitfordone) {
+       atomic {
+           if (mybarr.done)
+               waitfordone=false;
+       }
+    }
+
+    //System.printString("Starting Barrier run\n");
     for(int i = 0; i<numThreads; i++) {
       em3d[i].em3d.start(mid[i]);
     }
-
-    mybarr.join();
     for(int i = 0; i<numThreads; i++) {
       em3d[i].em3d.join();
     }