small changes + removed comments
authoradash <adash>
Tue, 6 May 2008 22:11:44 +0000 (22:11 +0000)
committeradash <adash>
Tue, 6 May 2008 22:11:44 +0000 (22:11 +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 21773b9e88623442aa32fafe2a73190e66fbc2cb..273155a7662f94a40f1b69bb6bf132b400623d7d 100644 (file)
@@ -27,7 +27,7 @@ public class JGFSORBench {
   Random R;
   public double Gtotal;
   public int cachelinesize;
-  public long sync[][];
+  public int sync[][];
 
   public JGFSORBench(int nthreads){
     this.nthreads = nthreads;
@@ -127,9 +127,9 @@ public class JGFSORBench {
     }
   }
 
-  public long[][] init_sync(int nthreads, int cachelinesize) {
-    long[][] sync;
-    sync = global new long [nthreads][cachelinesize];
+  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;
index 73d2b1500d76ce9cf56a9eb4c8fe9c52e8178552..611d5a857c97a0a4ded6bef265ad6599813ed994 100644 (file)
@@ -23,10 +23,10 @@ class SORRunner extends Thread {
 
   int id,num_iterations;
   double G[][],omega;
-  long sync[][];
+  int sync[][];
   int nthreads;
 
-  public SORRunner(int id, double omega, double G[][], int num_iterations,long[][] sync, int nthreads) {
+  public SORRunner(int id, double omega, double G[][], int num_iterations,int[][] sync, int nthreads) {
     this.id = id;
     this.omega=omega;
     this.G=G;
@@ -65,68 +65,69 @@ class SORRunner extends Thread {
     if (iupper > Mm1) iupper =  Mm1+1;
     if (tmpid == (numthreads-1)) iupper = Mm1+1;
 
-      for (int p=0; p<2*numiterations; p++) {
-        atomic {
-          for (int i=ilow+(p%2); i<iupper; i=i+2) {
+    for (int p=0; p<2*numiterations; p++) {
+      atomic {
+        for (int i=ilow+(p%2); i<iupper; i=i+2) {
 
-            double [] Gi = G[i];
-            double [] Gim1 = G[i-1];
+          double [] Gi = G[i];
+          double [] Gim1 = G[i-1];
 
-            if(i == 1) { 
-              double [] Gip1 = G[i+1];
+          if(i == 1) { 
+            double [] Gip1 = G[i+1];
 
-              for (int j=1; j<Nm1; j=j+2){
-                Gi[j] = omega_over_four * (Gim1[j] + Gip1[j] + Gi[j-1]
-                    + Gi[j+1]) + one_minus_omega * Gi[j];
+            for (int j=1; j<Nm1; j=j+2){
+              Gi[j] = omega_over_four * (Gim1[j] + Gip1[j] + Gi[j-1]
+                  + Gi[j+1]) + one_minus_omega * Gi[j];
 
-              }
-            } else if (i == Mm1) {
+            }
+          } else if (i == Mm1) {
 
-              double [] Gim2 = G[i-2];
+            double [] Gim2 = G[i-2];
 
-              for (int j=1; j<Nm1; j=j+2){
-                if((j+1) != Nm1) {
-                  Gim1[j+1]=omega_over_four * (Gim2[j+1] + Gi[j+1] + Gim1[j]
-                      + Gim1[j+2]) + one_minus_omega * Gim1[j+1];
-                }
+            for (int j=1; j<Nm1; j=j+2){
+              if((j+1) != Nm1) {
+                Gim1[j+1]=omega_over_four * (Gim2[j+1] + Gi[j+1] + Gim1[j]
+                    + Gim1[j+2]) + one_minus_omega * Gim1[j+1];
               }
+            }
 
-            } else {
+          } else {
 
-              double [] Gip1 = G[i+1];
-              double [] Gim2 = G[i-2];
+            double [] Gip1 = G[i+1];
+            double [] Gim2 = G[i-2];
 
-              for (int j=1; j<Nm1; j=j+2){
-                Gi[j] = omega_over_four * (Gim1[j] + Gip1[j] + Gi[j-1]
-                    + Gi[j+1]) + one_minus_omega * Gi[j];
+            for (int j=1; j<Nm1; j=j+2){
+              Gi[j] = omega_over_four * (Gim1[j] + Gip1[j] + Gi[j-1]
+                  + Gi[j+1]) + one_minus_omega * Gi[j];
 
-                if((j+1) != Nm1) {
-                  Gim1[j+1]=omega_over_four * (Gim2[j+1] + Gi[j+1] + Gim1[j]
-                      + Gim1[j+2]) + one_minus_omega * Gim1[j+1];
-                }
+              if((j+1) != Nm1) {
+                Gim1[j+1]=omega_over_four * (Gim2[j+1] + Gi[j+1] + Gim1[j]
+                    + Gim1[j+2]) + one_minus_omega * Gim1[j+1];
               }
             }
           }
-        } //close atomic
-        // Signal this thread has done iteration
+        }
+      } //close atomic
 
-        // Wait for neighbours;
-        long ourcount;
-        boolean done=true;
 
-        atomic {
-          sync[tmpid][0]++;
-          ourcount=sync[tmpid][0];
-        }
+      int ourcount;
+      boolean done=true;
+      atomic {
+        // Signal this thread has done iteration
+        sync[tmpid][0]++;
+        ourcount=sync[tmpid][0];
+      }
 
-       while(done) {
-           atomic {
-               if ((tmpid==0 || ourcount <= sync[tmpid-1][0])
-                   &&((tmpid==(numthreads-1))||ourcount<=sync[tmpid+1][0]))
-                   done=false;
-           }
+      // Wait for neighbours;
+      while(done) {
+        atomic {
+          if ((tmpid==0 || ourcount <= sync[tmpid-1][0])
+              &&((tmpid==(numthreads-1))||ourcount<=sync[tmpid+1][0]))
+            done=false;
         }
+      }
 
-      }//end of for
+      System.clearPrefetchCache();
+    }//end of for
   } //end of run()
 }
index 4615bc045336105ac42ae71fea173363daf9ec4c..084e9c507d7a94b8fa77b581eabfcfde765a6ec0 100644 (file)
@@ -4,18 +4,18 @@ SRC=${MAINCLASS}.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.8
+FLAGS=-dsm -prefetch -nooptimize -debug -profile -excprefetch JGFSORBench.RandomMatrix -excprefetch JGFSORBench.init_sync -excprefetch JGFSORBench.JGFkernel -mainclass ${MAINCLASS} -trueprob 0.80
 FLAGS2=-dsm -nooptimize -debug -profile -mainclass ${MAINCLASS}
 
 default:
-       ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}NP ${SRC}
-       ../../../../buildscript ${FLAGS} -o ${MAINCLASS}  ${SRC}
+#      ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}NP ${SRC}
+#      ../../../../buildscript ${FLAGS} -o ${MAINCLASS}  ${SRC}
        ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}1NP ${SRC}
        ../../../../buildscript ${FLAGS} -o ${MAINCLASS}1  ${SRC}
-       ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}2NP ${SRC}
-       ../../../../buildscript ${FLAGS} -o ${MAINCLASS}2  ${SRC}
-       ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}4NP ${SRC}
-       ../../../../buildscript ${FLAGS} -o ${MAINCLASS}4  ${SRC}
+       cp ${MAINCLASS}1NP.bin ${MAINCLASS}2NP.bin
+       cp ${MAINCLASS}1.bin ${MAINCLASS}2.bin
+       cp ${MAINCLASS}1NP.bin ${MAINCLASS}4NP.bin
+       cp ${MAINCLASS}1.bin ${MAINCLASS}4.bin
 
 clean:
        rm -rf tmpbuilddirectory