start of new file
[IRC.git] / Robust / src / Benchmarks / Prefetch / Em3d / dsm / Em3d2.java
index 2263e0f54b888f24e22e60b41eb6d1796c9b6f83..3d73a5d0a74bf67ca2b60ab4d1d269112eeb7aa6 100644 (file)
@@ -42,16 +42,14 @@ public class Em3d extends Thread {
   BiGraph bg;
   int upperlimit;
   int lowerlimit;
-  Barrier mybarr;
     public Em3d() {
     }
 
-    public Em3d(BiGraph bg, int lowerlimit, int upperlimit, int numIter, Barrier mybarr, int numDegree, int threadindex) {
+    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.mybarr = mybarr;
     this.numDegree = numDegree;
     this.threadindex=threadindex;
   }
@@ -61,19 +59,21 @@ public class Em3d extends Thread {
     Barrier barr;
     int degree;
     Random random;
+    String hname;
 
+    barr = new Barrier("128.195.175.79");
     atomic {
        iteration = numIter;
-       barr=mybarr;
        degree = numDegree;
        random = new Random(lowerlimit);
     }
 
     atomic {
        //This is going to conflict badly...Minimize work here
-       bg.allocateNodes( lowerlimit, upperlimit, threadindex);
+       bg.allocateNodes ( lowerlimit, upperlimit, threadindex);
     }
     Barrier.enterBarrier(barr);
+    System.clearPrefetchCache();
 
     atomic {
        //initialize the eNodes
@@ -140,11 +140,12 @@ public class Em3d extends Thread {
     int numThreads = em.numThreads;
     int[] mid = new int[4];
     mid[0] = (128<<24)|(195<<16)|(175<<8)|79;//dw-1
-    mid[1] = (128<<24)|(195<<16)|(175<<8)|80;//dw-2
-    mid[2] = (128<<24)|(195<<16)|(175<<8)|73;
-    mid[3] = (128<<24)|(195<<16)|(175<<8)|78;
+    mid[1] = (128<<24)|(195<<16)|(175<<8)|73;//dw-2
+    mid[2] = (128<<24)|(195<<16)|(175<<8)|78;
+    mid[3] = (128<<24)|(195<<16)|(175<<8)|69;
+
     System.printString("DEBUG -> numThreads = " + numThreads+"\n");
-    Barrier mybarr;
+    BarrierServer mybarr;
     BiGraph graph;
 
     
@@ -152,9 +153,11 @@ public class Em3d extends Thread {
    // System.printString( "Allocating BiGraph.\n" );
 
     atomic {
-      mybarr = global new Barrier(numThreads);
+      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;
@@ -168,21 +171,30 @@ 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, mybarr, em.numDegree, 1);
+             tmp = global new Em3d(graph, base, em.numNodes, em.numIter, em.numDegree, i);
          else
-             tmp = global new Em3d(graph, base, base+increment, em.numIter, mybarr, em.numDegree, 1);
+             tmp = global new Em3d(graph, base, base+increment, em.numIter, em.numDegree, i);
          em3d[i]=new Em3dWrap(tmp);
          base+=increment;
       }
     }
 
-    for(int i = 0; i<numThreads; i++) {
-       em3d[i].em3d.start(mid[i]);
+    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]);
+    }
     for(int i = 0; i<numThreads; i++) {
-       em3d[i].em3d.join();
+      em3d[i].em3d.join();
     }
+    System.printString("Done!"+ "\n");
   }