start of new file
[IRC.git] / Robust / src / Benchmarks / Prefetch / Em3d / dsm / Em3d2.java
index 1a5444026606d1d0b1a5d66c046b96036965fd6b..3d73a5d0a74bf67ca2b60ab4d1d269112eeb7aa6 100644 (file)
@@ -61,49 +61,41 @@ public class Em3d extends Thread {
     Random random;
     String hname;
 
-    barr = new Barrier("128.195.175.78");
-    //System.printString("Inside run\n");
+    barr = new Barrier("128.195.175.79");
     atomic {
        iteration = numIter;
        degree = numDegree;
        random = new Random(lowerlimit);
-    //barr =  mybarr;
     }
 
-    //System.printString("Here 1\n");
     atomic {
        //This is going to conflict badly...Minimize work here
        bg.allocateNodes ( lowerlimit, upperlimit, threadindex);
     }
     Barrier.enterBarrier(barr);
     System.clearPrefetchCache();
-    //System.printString("Here 2\n");
 
     atomic {
        //initialize the eNodes
        bg.initializeNodes(bg.eNodes, bg.hNodes, lowerlimit, upperlimit, degree, random, threadindex);
     }
     Barrier.enterBarrier(barr);
-    //System.printString("Here 3\n");
 
     atomic {
        //initialize the hNodes
        bg.initializeNodes(bg.hNodes, bg.eNodes, lowerlimit, upperlimit, degree, random, threadindex);
     }
     Barrier.enterBarrier(barr);
-    //System.printString("Here 4\n");
 
     atomic {
        bg.makeFromNodes(bg.hNodes, lowerlimit, upperlimit, random);
     }
     Barrier.enterBarrier(barr);
-    //System.printString("Here 5\n");
 
     atomic {
        bg.makeFromNodes(bg.eNodes, lowerlimit, upperlimit, random);
     }
     Barrier.enterBarrier(barr);
-    //System.printString("Here 6\n");
 
     //Do the computation
     for (int i = 0; i < iteration; i++) {
@@ -120,7 +112,6 @@ public class Em3d extends Thread {
        
        Barrier.enterBarrier(barr);
        
-    //System.printString("Here 7\n");
        /* for  hNodes */
        atomic {
            for(int j = lowerlimit; j<upperlimit; j++) {
@@ -131,7 +122,6 @@ public class Em3d extends Thread {
            }
        }
        Barrier.enterBarrier(barr);
-    //System.printString("Here 8\n");
     }
   }
 
@@ -149,16 +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;
@@ -176,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;
@@ -197,18 +179,21 @@ public class Em3d extends Thread {
       }
     }
 
-    //TODO check if correct
-    //
-    mybarr.start(mid[1]);
-    System.printString("Starting Barrier run\n");
+    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();
     }
-    //System.printString("Join Barrier run\n");
-    //mybarr.join();
     System.printString("Done!"+ "\n");
   }