Sor files with out new barrier implementation
authoradash <adash>
Fri, 8 Aug 2008 00:22:58 +0000 (00:22 +0000)
committeradash <adash>
Fri, 8 Aug 2008 00:22:58 +0000 (00:22 +0000)
Robust/src/Benchmarks/Prefetch/SOR/dsm/JGFSORBench.java
Robust/src/Benchmarks/Prefetch/SOR/dsm/SORRunner.java
Robust/src/Benchmarks/Prefetch/SOR/dsm/makefile

index 11741f1dddec1db4466c24d3caaca11fbe11c016..30cef0144996e1cd5f279b57fdafb3755187315b 100644 (file)
@@ -26,8 +26,6 @@ public class JGFSORBench {
   public int nthreads;
   Random R;
   public double Gtotal;
-  public int cachelinesize;
-  public int sync[][];
 
   public JGFSORBench(int nthreads){
     this.nthreads = nthreads;
@@ -39,7 +37,6 @@ public class JGFSORBench {
     RANDOM_SEED = 10101010;
     R = global new Random(RANDOM_SEED);
     Gtotal = 0.0;
-    cachelinesize = 1;
   }
 
   public void JGFsetsize(int size){
@@ -48,12 +45,22 @@ public class JGFSORBench {
 
   public static void JGFkernel(JGFSORBench sor) {
     int numthreads, datasize;
+    BarrierServer mybarr;
     Random rand;
+
+    int[] mid = new int[4];
+    mid[0] = (128<<24)|(195<<16)|(175<<8)|79;
+    mid[1] = (128<<24)|(195<<16)|(175<<8)|73;
+    mid[2] = (128<<24)|(195<<16)|(175<<8)|78;
+    mid[3] = (128<<24)|(195<<16)|(175<<8)|69;
+
     atomic {
       numthreads = sor.nthreads;
       rand = sor.R;
       datasize = sor.datasizes[sor.size];
+      mybarr = global new BarrierServer(numthreads);
     }
+    mybarr.start(mid[0]);
 
     double[][] G;
     int M, N;
@@ -77,34 +84,31 @@ public class JGFSORBench {
     int Nm1 = N-1;
 
     //spawn threads
-    int tmpcachelinesize;
-    atomic {
-      tmpcachelinesize = sor.cachelinesize;
-    }
-
     SORRunner[] thobjects;
     atomic {
       thobjects = global new SORRunner[numthreads];
-      sor.sync = sor.init_sync(numthreads, tmpcachelinesize);
     }
 
     //JGFInstrumentor.startTimer("Section2:SOR:Kernel", instr.timers); 
 
+    boolean waitfordone=true;
+    while(waitfordone) {
+      atomic {
+        if (mybarr.done)
+          waitfordone=false;
+      }
+    }
+
     SORRunner tmp;
-    int[] mid = new int[4];
-    mid[0] = (128<<24)|(195<<16)|(175<<8)|79;
-    mid[1] = (128<<24)|(195<<16)|(175<<8)|73;
-    mid[2] = (128<<24)|(195<<16)|(175<<8)|78;
-    mid[3] = (128<<24)|(195<<16)|(175<<8)|69;
     for(int i=1;i<numthreads;i++) {
       atomic {
-        thobjects[i] =  global new SORRunner(i,omega,G,num_iterations,sor.sync,numthreads);
+        thobjects[i] =  global new SORRunner(i,omega,G,num_iterations,numthreads);
         tmp = thobjects[i];
       }
       tmp.start(mid[i]);
     }
     atomic {
-      thobjects[0] =  global new SORRunner(0,omega,G,num_iterations,sor.sync,numthreads);
+      thobjects[0] =  global new SORRunner(0,omega,G,num_iterations,numthreads);
       tmp = thobjects[0];
     }
     tmp.start(mid[0]);
@@ -127,14 +131,6 @@ public class JGFSORBench {
     }
   }
 
-  public int[][] init_sync(int nthreads, int cachelinesize) {
-    int[][] sync;
-    sync = global new int [nthreads][cachelinesize];
-    for (int i = 0; i<nthreads; i++)
-      sync[i][0] = 0;
-    return sync;
-  }
-
   public double[][] RandomMatrix(int M, int N, Random R)
   {
     double A[][] = global new double[M][N];
index 9a41faecacdd710d1dfa345aa318ead642898f96..954aa1ce326536b89bfbed4340786561fb5b668e 100644 (file)
@@ -23,15 +23,13 @@ class SORRunner extends Thread {
 
   int id,num_iterations;
   double G[][],omega;
-  int sync[][];
   int nthreads;
 
-  public SORRunner(int id, double omega, double G[][], int num_iterations,int[][] sync, int nthreads) {
+  public SORRunner(int id, double omega, double G[][], int num_iterations, int nthreads) {
     this.id = id;
     this.omega=omega;
     this.G=G;
     this.num_iterations=num_iterations;
-    this.sync=sync;
     this.nthreads = nthreads;
   }
 
@@ -39,7 +37,10 @@ class SORRunner extends Thread {
     int tmpid, M, N, numthreads;
     double omega_over_four, one_minus_omega;
     int numiterations;
+    Barrier barr;
+    barr = new Barrier("128.195.175.79");
     atomic {
+      System.printString("Inside atomic 1\n");
       M = G.length;
       N = G[0].length;
       omega_over_four = omega * 0.25;
@@ -109,23 +110,7 @@ class SORRunner extends Thread {
         }
       } //close atomic
 
-
-      int ourcount;
-      boolean done=true;
-      atomic {
-        // Signal this thread has done iteration
-        sync[tmpid][0]++;
-        ourcount=sync[tmpid][0];
-      }
-
-      // Wait for neighbours;
-      while(done) {
-        atomic {
-          if ((tmpid==0 || ourcount <= sync[tmpid-1][0])
-              &&((tmpid==(numthreads-1))||ourcount<=sync[tmpid+1][0]))
-            done=false;
-        }
-      }
+      Barrier.enterBarrier(barr);
     }//end of for
   } //end of run()
 }
index a9310b36fcf2e734865f95f12463a00b168e35a7..a2b55b5b2ceba7152ba04f8c1a2561a5d970640c 100644 (file)
@@ -3,9 +3,9 @@ SRC=${MAINCLASS}.java \
        JGFSORBench.java \
        JGFInstrumentor.java \
        JGFTimer.java \
-       SORRunner.java
-FLAGS=-dsm -prefetch -nooptimize -debug -profile -excprefetch JGFSORBench.RandomMatrix -excprefetch JGFSORBench.init_sync -excprefetch JGFSORBench.JGFkernel -mainclass ${MAINCLASS} -trueprob 0.88
-FLAGS2=-dsm -nooptimize -debug -profile -mainclass ${MAINCLASS}
+       SORRunner.java 
+FLAGS=-dsm -prefetch -optimize -excprefetch JGFSORBench.JGFSORBench -excprefetch JGFSORBenchSizeA.main -excprefetch JGFSORBench.RandomMatrix -excprefetch JGFSORBench.init_sync -excprefetch JGFSORBench.JGFkernel -mainclass ${MAINCLASS} -trueprob 0.88
+FLAGS2=-dsm -optimize -mainclass ${MAINCLASS}
 
 default:
        ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}NP ${SRC}