bug fixes and some more changes
authoradash <adash>
Fri, 2 May 2008 01:46:02 +0000 (01:46 +0000)
committeradash <adash>
Fri, 2 May 2008 01:46:02 +0000 (01:46 +0000)
Robust/src/Benchmarks/Prefetch/Em3d/dsm/Em3d.java
Robust/src/Benchmarks/Prefetch/LUFact/dsm/JGFLUFactBench.java
Robust/src/Benchmarks/Prefetch/LUFact/dsm/JGFLUFactBenchSizeA.java
Robust/src/Benchmarks/Prefetch/LUFact/dsm/makefile
Robust/src/Benchmarks/Prefetch/LUFact/java/JGFLUFactBench.java
Robust/src/Benchmarks/Prefetch/Moldyn/dsm/JGFMolDynBench.java
Robust/src/Benchmarks/Prefetch/Moldyn/dsm/JGFMolDynBenchSizeA.java
Robust/src/Benchmarks/Prefetch/Moldyn/dsm/makefile
Robust/src/Benchmarks/Prefetch/SOR/dsm/JGFSORBench.java
Robust/src/Benchmarks/Prefetch/SOR/dsm/JGFSORBenchSizeA.java
Robust/src/Benchmarks/Prefetch/SOR/dsm/SORRunner.java

index 7479ea62196649466d1f2d553adbde8259e16341..f094074cf719bb865cc77b51ea1e04ad2ec5e009 100644 (file)
@@ -77,11 +77,8 @@ public class Em3d extends Thread
        }
     }
 
-
     for (int i = 0; i < iteration; i++) {
       /* for  eNodes */
-       System.clearPrefetchCache();
-
        atomic {
            Node n = enodebase;
            for(int j = lowerlimit; j<upperlimit; j++) {
@@ -93,10 +90,8 @@ public class Em3d extends Thread
        }
        
        Barrier.enterBarrier(barr);
-       
        System.clearPrefetchCache();
-       
-       
+
        /* for  hNodes */
        atomic {
            Node n = hnodebase;
@@ -108,6 +103,7 @@ public class Em3d extends Thread
            }
        }
        Barrier.enterBarrier(barr);
+       System.clearPrefetchCache();
     }
   }
 
@@ -121,10 +117,15 @@ public class Em3d extends Thread
     Em3d em = new Em3d();
     Em3d.parseCmdLine(args, em);
     if (em.printMsgs) 
-      System.printString("Initializing em3d random graph...");
+      System.printString("Initializing em3d random graph...\n");
     long start0 = System.currentTimeMillis();
-    int numThreads = 1;
-    System.printString("DEBUG -> numThreads = " + numThreads);
+    int numThreads = 4;
+    int[] mid = new int[numThreads];
+    mid[0] = (128<<24)|(195<<16)|(175<<8)|69;
+    mid[1] = (128<<24)|(195<<16)|(175<<8)|78;
+    mid[2] = (128<<24)|(195<<16)|(175<<8)|73;
+    mid[3] = (128<<24)|(195<<16)|(175<<8)|79;
+    System.printString("DEBUG -> numThreads = " + numThreads+"\n");
     Barrier mybarr;
     atomic {
       mybarr = global new Barrier(numThreads);
@@ -140,21 +141,23 @@ public class Em3d extends Thread
     // compute a single iteration of electro-magnetic propagation
     if (em.printMsgs) 
       System.printString("Propagating field values for " + em.numIter + 
-          " iteration(s)...");
+          " iteration(s)...\n");
     long start1 = System.currentTimeMillis();
     Em3d[] em3d;
     atomic {
       em3d = global new Em3d[numThreads];
-      em3d[0] = global new Em3d(graph, 0, em.numNodes, em.numIter, mybarr);
+      em3d[0] = global new Em3d(graph, 0, em.numNodes/4, em.numIter, mybarr);
+      em3d[1] = global new Em3d(graph, (em.numNodes/4) + 1, em.numNodes/2, em.numIter, mybarr);
+      em3d[2] = global new Em3d(graph, (em.numNodes/2) + 1, (3*em.numNodes)/4, em.numIter, mybarr);
+      em3d[3] = global new Em3d(graph, (3*em.numNodes)/4 + 1, em.numNodes, em.numIter, mybarr);
     }
 
-    int mid = (128<<24)|(195<<16)|(175<<8)|73;
     Em3d tmp;
     for(int i = 0; i<numThreads; i++) {
       atomic {
         tmp = em3d[i];
       }
-      tmp.start(mid);
+      tmp.start(mid[i]);
     }
 
     for(int i = 0; i<numThreads; i++) {
@@ -170,18 +173,17 @@ public class Em3d extends Thread
       StringBuffer retval = new StringBuffer();
       double dvalue;
       atomic {
-        dvalue = graph.eNodes.value;
+        dvalue = graph.hNodes.value;
       }
       int intvalue = (int)dvalue;
-      System.printString("Value = " + intvalue + "\n");
     }
 
     if (em.printMsgs) {
-      System.printString("EM3D build time "+ (long)((end0 - start0)/1000.0));
-      System.printString("EM3D compute time " + (long)((end1 - start1)/1000.0));
-      System.printString("EM3D total time " + (long)((end1 - start0)/1000.0));
+      System.printString("EM3D build time "+ (long)((end0 - start0)/1000.0) + "\n");
+      System.printString("EM3D compute time " + (long)((end1 - start1)/1000.0) + "\n");
+      System.printString("EM3D total time " + (long)((end1 - start0)/1000.0) + "\n");
     }
-    System.printString("Done!");
+    System.printString("Done!"+ "\n");
   }
 
 
@@ -229,13 +231,13 @@ public class Em3d extends Thread
    **/
   public void usage()
   {
-    System.printString("usage: java Em3d -n <nodes> -d <degree> [-p] [-m] [-h]");
-    System.printString("    -n the number of nodes");
-    System.printString("    -d the out-degree of each node");
-    System.printString("    -i the number of iterations");
-    System.printString("    -p (print detailed results)");
-    System.printString("    -m (print informative messages)");
-    System.printString("    -h (this message)");
+    System.printString("usage: java Em3d -n <nodes> -d <degree> [-p] [-m] [-h]\n");
+    System.printString("    -n the number of nodes\n");
+    System.printString("    -d the out-degree of each node\n");
+    System.printString("    -i the number of iterations\n");
+    System.printString("    -p (print detailed results\n)");
+    System.printString("    -m (print informative messages)\n");
+    System.printString("    -h (this message)\n");
   }
 
 }
index b791cd819f851c0279476e8786faaf4eaae07e80..328c7a5dc934e847d8cf9754d6f8d27454d5ead9 100644 (file)
@@ -74,22 +74,25 @@ public class JGFLUFactBench {
     }
 
     //JGFInstrumentor.startTimer("Section2:LUFact:Kernel", instr.timers);  
-
     LinpackRunner tmp;
-    int mid = (128<<24)|(195<<16)|(175<<8)|73;
+    int[] mid = new int[4];
+    mid[0] = (128<<24)|(195<<16)|(175<<8)|73;
+    mid[1] = (128<<24)|(195<<16)|(175<<8)|69;
+    mid[2] = (128<<24)|(195<<16)|(175<<8)|78;
+    mid[3] = (128<<24)|(195<<16)|(175<<8)|79;
     for(int i=1;i<numthreads;i++) {
       atomic {
         thobjects[i] = global new LinpackRunner(i,lub.a,lub.lda,lub.n,lub.ipvt,br,lub.nthreads);
         tmp = thobjects[i];
       }
-      tmp.start(mid);
+      tmp.start(mid[i]);
     }
 
     atomic {
       thobjects[0] = global new LinpackRunner(0,lub.a,lub.lda,lub.n,lub.ipvt,br,lub.nthreads);
       tmp = thobjects[0];
     }
-    tmp.start(mid);
+    tmp.start(mid[0]);
     tmp.join();
 
     for(int i=1;i<numthreads;i++) {
@@ -102,6 +105,7 @@ public class JGFLUFactBench {
     atomic {
       lub.dgesl(lub.a,lub.lda,lub.n,lub.ipvt,lub.b,0);
     }
+
     //JGFInstrumentor.stopTimer("Section2:LUFact:Kernel", instr.timers); 
   }
 
@@ -142,8 +146,8 @@ public class JGFLUFactBench {
 
     if (lresidn > lref) {
       //System.printString("Validation failed");
-      System.printString("Computed Norm Res = " + (long) residn * 1000000);
-      System.printString("Reference Norm Res = " + (long) ref[size] * 1000000); 
+      //System.printString("Computed Norm Res = " + (long) residn * 1000000);
+      //System.printString("Reference Norm Res = " + (long) ref[size] * 1000000); 
       return 1;
     } else {
       return 0;
@@ -409,45 +413,4 @@ public class JGFLUFactBench {
       }
     }
   }
-  /*
-     public static void JGFvalidate(JGFLUFactBench lub) {
-     int i;
-     double eps,residn;
-     double[] ref;
-
-     ref = new double[3]; 
-     ref[0] = 6.0;
-     ref[1] = 12.0;
-     ref[2] = 20.0;
-
-     atomic {
-     for (i = 0; i < lub.n; i++) {
-     lub.x[i] = lub.b[i];
-     }
-     lub.norma = lub.matgen(lub.a,lub.lda,lub.n,lub.b);
-     for (i = 0; i < lub.n; i++) {
-     lub.b[i] = -(lub.b[i]);
-     }
-
-     lub.dmxpy(lub.n,lub.b,lub.n,lub.lda,lub.x,lub.a);
-     lub.resid = 0.0;
-     lub.normx = 0.0;
-     for (i = 0; i < lub.n; i++) {
-//resid = (resid > abs(b[i])) ? resid : abs(b[i]);
-//normx = (normx > abs(x[i])) ? normx : abs(x[i]);
-if (lub.resid <= abs(lub.b[i])) lub.resid = lub.abs(lub.b[i]);
-if (lub.normx <= abs(lub.x[i])) lub.normx = lub.abs(lub.x[i]);
-}
-eps =  lub.epslon((double)1.0);
-residn = lub.resid/( lub.n*lub.norma*lub.normx*eps );
-}
-
-if (residn > ref[size]) {
-System.printString("Validation failed");
-System.printString("Computed Norm Res = " + (long) residn);
-System.printString("Reference Norm Res = " + (long) ref[size]); 
-}
-}
-*/
-
 }
index 6c42f20972886b1d311cd04bd5680b3f9ecbec1f..be55624328040086e19f672abc044a10523da011 100644 (file)
@@ -43,20 +43,14 @@ public class JGFLUFactBenchSizeA {
       lub.JGFinitialise();
     }
     JGFLUFactBench.JGFkernel(lub);
-    System.printString("End of JGFkernel\n");
     int retval;
     atomic {
       retval = lub.JGFvalidate();
     }
-    System.printString("End of JGFvalidate\n");
     if(retval == 1) {
       System.printString("Validation failed\n");
     }
-    //JGFLUFactBench.JGFvalidate(lub);
 
-    // atomic {
-    // lub.JGFvalidate();
-    //}
     double ops;
     atomic {
       ops = lub.ops;
index 651ffc88970a445b9db2ced0788790f25e969314..8b7b40f24fd2728f5989773012dfd238b9f4a6ca 100644 (file)
@@ -6,13 +6,13 @@ JGFTimer.java \
 Barrier.java \
 Linpack.java \
 LinpackRunner.java
-FLAGS=-dsm -prefetch -optimize -debug -profile -excprefetch JGFLUFactBench.JGFkernel -excprefetch JGFLUFactBench.dmxpy -excprefetch JGFLUFactBench.JGFvalidate -excprefetch JGFLUFactBench.JGFinitialise -excprefetch JGFLUFactBench.matgen -excprefetch JGFLUFactBench.dgesl -mainclass ${MAINCLASS} -o ${MAINCLASS} -trueprob 0.8
-FLAGS2=-dsm -optimize -debug -profile -mainclass ${MAINCLASS} -o ${MAINCLASS}NP
+FLAGS=-dsm -prefetch -nooptimize -debug -profile -excprefetch JGFLUFactBench.JGFkernel -excprefetch JGFLUFactBench.dmxpy -excprefetch JGFLUFactBench.JGFvalidate -excprefetch JGFLUFactBench.JGFinitialise -excprefetch JGFLUFactBench.matgen -excprefetch JGFLUFactBench.dgesl -mainclass ${MAINCLASS} -o ${MAINCLASS} -trueprob 0.8
+FLAGS2=-dsm -nooptimize -debug -profile -mainclass ${MAINCLASS} -o ${MAINCLASS}NP
 
 default:
        ../../../../buildscript ${FLAGS2} ${SRC}
        ../../../../buildscript ${FLAGS} ${SRC}
 
 clean:
-       rm -rf tmpbuildirectory
+       rm -rf tmpbuilddirectory
        rm *.bin
index 71caa044cf9e4f63bea8c020afa523002b0bac35..4cc54a6c8a25b783f6b84c8f87898e9ebfd156e6 100644 (file)
@@ -33,7 +33,6 @@ public class JGFLUFactBench {
   int ipvt[];
 
   public JGFLUFactBench(int nthreads, JGFInstrumentor instr) {
-  //public JGFLUFactBench(int nthreads) {
     this.nthreads=nthreads;
     this.instr = instr;
     datasizes = new int[3];
index c72ebab50882e80d4991a114d1a9c227b3c8d5ab..3fa7505bfd7cd0990d1a26580b61d981f1823145 100644 (file)
@@ -96,7 +96,11 @@ public class JGFMolDynBench {
       br= global new Barrier(numthreads);
     }
 
-    int mid = (128<<24)|(195<<16)|(175<<8)|73;
+    int[] mid = new int[4];
+    mid[0] = (128<<24)|(195<<16)|(175<<8)|73;
+    mid[1] = (128<<24)|(195<<16)|(175<<8)|69;
+    mid[2] = (128<<24)|(195<<16)|(175<<8)|79;
+    mid[3] = (128<<24)|(195<<16)|(175<<8)|78;
     mdRunner tmp;
 
     for(int i=1;i<numthreads;i++) {
@@ -104,14 +108,14 @@ public class JGFMolDynBench {
         thobjects[i] = global new mdRunner(i,mold.mm,sh_force,sh_force2,br,mold.nthreads,mold);
         tmp = thobjects[i];
       }
-      tmp.start(mid);
+      tmp.start(mid[i]);
     }
 
     atomic {
       thobjects[0] = global new mdRunner(0,mold.mm,sh_force,sh_force2,br,mold.nthreads,mold);
       tmp = thobjects[0];
     }
-    tmp.start(mid);
+    tmp.start(mid[0]);
     tmp.join();
 
     for(int i=1;i<numthreads;i++) {
@@ -183,304 +187,306 @@ class mdRunner extends Thread {
 
   public void run() {
 
-      /* Parameter determination */
-      
-      int tmpmdsize;
-      double tmpden;
-      int movemx=50;
-      Barrier tmpbr;
-      
+    /* Parameter determination */
+
+    int tmpmdsize;
+    double tmpden;
+    int movemx=50;
+    Barrier tmpbr;
+
+    atomic {
+      tmpbr=br;
+      mdsize = mymd.PARTSIZE;
+      one = global new particle[mdsize];
+      l = mymd.LENGTH;
+      tmpmdsize = mdsize;
+      tmpden = den;
+      side = Math.pow((tmpmdsize/tmpden),0.3333333);
+      rcoff = mm/4.0;
+
+      a = side/mm;
+      sideh = side*0.5;
+      hsq = h*h;
+      hsq2 = hsq*0.5;
+      npartm = tmpmdsize - 1;
+      rcoffs = rcoff * rcoff;
+      tscale = 16.0 / (1.0 * tmpmdsize - 1.0);
+      vaver = 1.13 * Math.sqrt(tref / 24.0);
+      vaverh = vaver * h;
+
+      /* Particle Generation */
+
+      xvelocity = 0.0;
+      yvelocity = 0.0;
+      zvelocity = 0.0;
+      ijk = 0;
+
+      for (lg=0; lg<=1; lg++) {
+        for (i=0; i<mm; i++) {
+          for (j=0; j<mm; j++) {
+            for (k=0; k<mm; k++) {
+              one[ijk] = global new particle((i*a+lg*a*0.5),(j*a+lg*a*0.5),(k*a),
+                  xvelocity,yvelocity,zvelocity,sh_force,sh_force2,id,this);
+              ijk = ijk + 1;
+            }
+          }
+        }
+      }
+
+      for (lg=1; lg<=2; lg++) {
+        for (i=0; i<mm; i++) {
+          for (j=0; j<mm; j++) {
+            for (k=0; k<mm; k++) {
+              one[ijk] = global new particle((i*a+(2-lg)*a*0.5),(j*a+(lg-1)*a*0.5),
+                  (k*a+a*0.5),xvelocity,yvelocity,zvelocity,sh_force,sh_force2,id,this);
+              ijk = ijk + 1;
+            }
+          }
+        }
+      }
+
+      /* Initialise velocities */
+
+      iseed = 0;
+      v1 = 0.0;
+      v2 = 0.0;
+      randnum = global new random(iseed,v1,v2);
+
+      for (i=0; i<tmpmdsize; i+=2) {
+        r  = randnum.seed();
+        one[i].xvelocity = r*randnum.v1;
+        one[i+1].xvelocity  = r*randnum.v2;
+      }
+
+      for (i=0; i<tmpmdsize; i+=2) {
+        r  = randnum.seed();
+        one[i].yvelocity = r*randnum.v1;
+        one[i+1].yvelocity  = r*randnum.v2;
+      }
+
+      for (i=0; i<tmpmdsize; i+=2) {
+        r  = randnum.seed();
+        one[i].zvelocity = r*randnum.v1;
+        one[i+1].zvelocity  = r*randnum.v2;
+      }
+
+
+      /* velocity scaling */
+
+      ekin = 0.0;
+      sp = 0.0;
+
+      for(i=0;i<tmpmdsize;i++) {
+        sp = sp + one[i].xvelocity;
+      }
+      sp = sp / tmpmdsize;
+
+      for(i=0;i<tmpmdsize;i++) {
+        one[i].xvelocity = one[i].xvelocity - sp;
+        ekin = ekin + one[i].xvelocity*one[i].xvelocity;
+      }
+
+      sp = 0.0;
+      for(i=0;i<tmpmdsize;i++) {
+        sp = sp + one[i].yvelocity;
+      }
+      sp = sp / tmpmdsize;
+
+      for(i=0;i<tmpmdsize;i++) {
+        one[i].yvelocity = one[i].yvelocity - sp;
+        ekin = ekin + one[i].yvelocity*one[i].yvelocity;
+      }
+
+
+      sp = 0.0;
+      for(i=0;i<tmpmdsize;i++) {
+        sp = sp + one[i].zvelocity;
+      }
+      sp = sp / tmpmdsize;
+
+      for(i=0;i<tmpmdsize;i++) {
+        one[i].zvelocity = one[i].zvelocity - sp;
+        ekin = ekin + one[i].zvelocity*one[i].zvelocity;
+      }
+
+      ts = tscale * ekin;
+      sc = h * Math.sqrt(tref/ts);
+
+
+      for(i=0;i<tmpmdsize;i++) {
+
+        one[i].xvelocity = one[i].xvelocity * sc;     
+        one[i].yvelocity = one[i].yvelocity * sc;     
+        one[i].zvelocity = one[i].zvelocity * sc;     
+
+      }
+    }
+
+    /* Synchronise threads and start timer before MD simulation */
+
+    Barrier.enterBarrier(tmpbr);
+    System.clearPrefetchCache();
+
+    /* MD simulation */
+
+    for (int move=0;move<movemx;move++) {
       atomic {
-         tmpbr=br;
-         mdsize = mymd.PARTSIZE;
-         one = global new particle[mdsize];
-         l = mymd.LENGTH;
-         tmpmdsize = mdsize;
-         tmpden = den;
-         side = Math.pow((tmpmdsize/tmpden),0.3333333);
-         rcoff = mm/4.0;
-         
-         a = side/mm;
-         sideh = side*0.5;
-         hsq = h*h;
-         hsq2 = hsq*0.5;
-         npartm = tmpmdsize - 1;
-         rcoffs = rcoff * rcoff;
-         tscale = 16.0 / (1.0 * tmpmdsize - 1.0);
-         vaver = 1.13 * Math.sqrt(tref / 24.0);
-         vaverh = vaver * h;
-         
-         /* Particle Generation */
-         
-         xvelocity = 0.0;
-         yvelocity = 0.0;
-         zvelocity = 0.0;
-         ijk = 0;
-         
-         for (lg=0; lg<=1; lg++) {
-             for (i=0; i<mm; i++) {
-                 for (j=0; j<mm; j++) {
-                     for (k=0; k<mm; k++) {
-                         one[ijk] = global new particle((i*a+lg*a*0.5),(j*a+lg*a*0.5),(k*a),
-                                                        xvelocity,yvelocity,zvelocity,sh_force,sh_force2,id,this);
-                         ijk = ijk + 1;
-                     }
-                 }
-             }
-         }
-         
-         for (lg=1; lg<=2; lg++) {
-             for (i=0; i<mm; i++) {
-                 for (j=0; j<mm; j++) {
-                     for (k=0; k<mm; k++) {
-                         one[ijk] = global new particle((i*a+(2-lg)*a*0.5),(j*a+(lg-1)*a*0.5),
-                                                        (k*a+a*0.5),xvelocity,yvelocity,zvelocity,sh_force,sh_force2,id,this);
-                         ijk = ijk + 1;
-                     }
-                 }
-             }
-         }
-         
-         /* Initialise velocities */
-         
-         iseed = 0;
-         v1 = 0.0;
-         v2 = 0.0;
-         randnum = global new random(iseed,v1,v2);
-         
-         for (i=0; i<tmpmdsize; i+=2) {
-             r  = randnum.seed();
-             one[i].xvelocity = r*randnum.v1;
-             one[i+1].xvelocity  = r*randnum.v2;
-         }
-         
-         for (i=0; i<tmpmdsize; i+=2) {
-             r  = randnum.seed();
-             one[i].yvelocity = r*randnum.v1;
-             one[i+1].yvelocity  = r*randnum.v2;
-         }
-         
-         for (i=0; i<tmpmdsize; i+=2) {
-             r  = randnum.seed();
-             one[i].zvelocity = r*randnum.v1;
-             one[i+1].zvelocity  = r*randnum.v2;
-         }
-         
-         
-         /* velocity scaling */
-         
-         ekin = 0.0;
-         sp = 0.0;
-         
-         for(i=0;i<tmpmdsize;i++) {
-             sp = sp + one[i].xvelocity;
-         }
-         sp = sp / tmpmdsize;
-         
-         for(i=0;i<tmpmdsize;i++) {
-             one[i].xvelocity = one[i].xvelocity - sp;
-             ekin = ekin + one[i].xvelocity*one[i].xvelocity;
-         }
-         
-         sp = 0.0;
-         for(i=0;i<tmpmdsize;i++) {
-             sp = sp + one[i].yvelocity;
-         }
-         sp = sp / tmpmdsize;
-         
-         for(i=0;i<tmpmdsize;i++) {
-             one[i].yvelocity = one[i].yvelocity - sp;
-             ekin = ekin + one[i].yvelocity*one[i].yvelocity;
-         }
-         
-         
-         sp = 0.0;
-         for(i=0;i<tmpmdsize;i++) {
-             sp = sp + one[i].zvelocity;
-         }
-         sp = sp / tmpmdsize;
-         
-         for(i=0;i<tmpmdsize;i++) {
-             one[i].zvelocity = one[i].zvelocity - sp;
-             ekin = ekin + one[i].zvelocity*one[i].zvelocity;
-         }
-         
-         ts = tscale * ekin;
-         sc = h * Math.sqrt(tref/ts);
-         
-         
-         for(i=0;i<tmpmdsize;i++) {
-             
-             one[i].xvelocity = one[i].xvelocity * sc;     
-             one[i].yvelocity = one[i].yvelocity * sc;     
-             one[i].zvelocity = one[i].zvelocity * sc;     
-             
-         }
+        /* move the particles and update velocities */
+
+        for (i=0;i<tmpmdsize;i++) {
+          one[i].domove(side,i);       
+        }
       }
 
-      /* Synchronise threads and start timer before MD simulation */
-      
+      /* Barrier */
       Barrier.enterBarrier(tmpbr);
-      //if (id == 0) JGFInstrumentor.startTimer("Section3:MolDyn:Run", instr.timers);
-      //Barrier.enterBarrier(tmpbr);
-      
-      /* MD simulation */
-      
-      for (int move=0;move<movemx;move++) {
-         atomic {
-             
-             
-             /* move the particles and update velocities */
-             
-             for (i=0;i<tmpmdsize;i++) {
-                 one[i].domove(side,i);       
-             }
-         }
-             
-         /* Barrier */
-         Barrier.enterBarrier(tmpbr);
-         atomic {
-             
-             if(id==0) {
-                 for(j=0;j<3;j++) {
-                     for (i=0;i<tmpmdsize;i++) {
-                         sh_force[j][i] = 0.0;
-                     }
-                 }
-             }
-             
-             mymd.epot[id] = 0.0;
-             mymd.vir[id] = 0.0;
-             mymd.interacts[id] = 0;
-         }
-         
-         
-         /* Barrier */
-         Barrier.enterBarrier(tmpbr);
-             
-         atomic {
-             /* compute forces */
-             
-             for (i=0+id;i<tmpmdsize;i+=nthreads) {
-                 one[i].force(side,rcoff,tmpmdsize,i,xx,yy,zz,mymd); 
-             }
-             
-         }
-         /* Barrier */
-         Barrier.enterBarrier(tmpbr);
-             
-         /* update force arrays */
-         atomic {
-
-             if(id == 0) {
-                 for(int k=0;k<3;k++) {
-                     for(i=0;i<tmpmdsize;i++) {
-                         for(j=0;j<nthreads;j++) {
-                             sh_force[k][i] += sh_force2[k][j][i];
-                         }
-                     }
-                 }
-             }
-             
-             if(id == 0) {
-                 for(int k=0;k<3;k++) {
-                     for(i=0;i<tmpmdsize;i++) {
-                         for(j=0;j<nthreads;j++) {
-                             sh_force2[k][j][i] = 0.0;
-                         }
-                     }
-                 }
-             }
-             
-             if(id==0) {
-                 for(j=1;j<nthreads;j++) {
-                     mymd.epot[0] += mymd.epot[j];
-                     mymd.vir[0] += mymd.vir[j];
-                 }
-                 for(j=1;j<nthreads;j++) {       
-                     mymd.epot[j] = mymd.epot[0];
-                     mymd.vir[j] = mymd.vir[0];
-                 }
-                 for(j=0;j<nthreads;j++) {
-                     mymd.interactions += mymd.interacts[j]; 
-                 }
-             }
-         }
-
-         /* Barrier */
-         Barrier.enterBarrier(tmpbr);
-          
-         atomic {
-             if(id == 0) {
-                 for (j=0;j<3;j++) {
-                     for (i=0;i<tmpmdsize;i++) {
-                         sh_force[j][i] = sh_force[j][i] * hsq2;
-                     }
-                 }
-             }
-             
-             sum = 0.0;
-         }
-             
-         
-         /* Barrier */
-         Barrier.enterBarrier(tmpbr);
-         
-         atomic {
-             /*scale forces, update velocities */
-             
-             for (i=0;i<tmpmdsize;i++) {
-                 sum = sum + one[i].mkekin(hsq2,i);  
-             }
-             
-             ekin = sum/hsq;
-             
-             vel = 0.0;
-             count = 0.0;
-             
-             /* average velocity */
-             
-             for (i=0;i<tmpmdsize;i++) {
-                 velt = one[i].velavg(vaverh,h);
-                 if(velt > vaverh) { count = count + 1.0; }
-                 vel = vel + velt;                    
-             }
-             
-             vel = vel / h;
-             
-             /* temperature scale if required */
-             
-             if((move < istop) && (((move+1) % irep) == 0)) {
-                 sc = Math.sqrt(tref / (tscale*ekin));
-                 for (i=0;i<tmpmdsize;i++) {
-                     one[i].dscal(sc,1);
-                 }
-                 ekin = tref / tscale;
-             }
-             
-             /* sum to get full potential energy and virial */
-             
-             if(((move+1) % iprint) == 0) {
-                 mymd.ek[id] = 24.0*ekin;
-                 mymd.epot[id] = 4.0*mymd.epot[id];
-                 etot = mymd.ek[id] + mymd.epot[id];
-                 temp = tscale * ekin;
-                 pres = tmpden * 16.0 * (ekin - mymd.vir[id]) / tmpmdsize;
-                 vel = vel / tmpmdsize; 
-                 rp = (count / tmpmdsize) * 100.0;
-             }
-         }
-         Barrier.enterBarrier(tmpbr);
+      System.clearPrefetchCache();
+
+      atomic {
+
+        if(id==0) {
+          for(j=0;j<3;j++) {
+            for (i=0;i<tmpmdsize;i++) {
+              sh_force[j][i] = 0.0;
+            }
+          }
+        }
+
+        mymd.epot[id] = 0.0;
+        mymd.vir[id] = 0.0;
+        mymd.interacts[id] = 0;
       }
 
+
+      /* Barrier */
       Barrier.enterBarrier(tmpbr);
-      //if (id == 0) JGFInstrumentor.stopTimer("Section3:MolDyn:Run", instr.timers);
-  }
+      System.clearPrefetchCache();
 
-}
+      atomic {
+        /* compute forces */
+
+        for (i=0+id;i<tmpmdsize;i+=nthreads) {
+          one[i].force(side,rcoff,tmpmdsize,i,xx,yy,zz,mymd); 
+        }
+
+      }
+      /* Barrier */
+      Barrier.enterBarrier(tmpbr);
+      System.clearPrefetchCache();
+
+      /* update force arrays */
+      atomic {
+
+        if(id == 0) {
+          for(int k=0;k<3;k++) {
+            for(i=0;i<tmpmdsize;i++) {
+              for(j=0;j<nthreads;j++) {
+                sh_force[k][i] += sh_force2[k][j][i];
+              }
+            }
+          }
+        }
+
+        if(id == 0) {
+          for(int k=0;k<3;k++) {
+            for(i=0;i<tmpmdsize;i++) {
+              for(j=0;j<nthreads;j++) {
+                sh_force2[k][j][i] = 0.0;
+              }
+            }
+          }
+        }
+
+        if(id==0) {
+          for(j=1;j<nthreads;j++) {
+            mymd.epot[0] += mymd.epot[j];
+            mymd.vir[0] += mymd.vir[j];
+          }
+          for(j=1;j<nthreads;j++) {       
+            mymd.epot[j] = mymd.epot[0];
+            mymd.vir[j] = mymd.vir[0];
+          }
+          for(j=0;j<nthreads;j++) {
+            mymd.interactions += mymd.interacts[j]; 
+          }
+        }
+      }
+
+      /* Barrier */
+      Barrier.enterBarrier(tmpbr);
+      System.clearPrefetchCache();
+
+      atomic {
+        if(id == 0) {
+          for (j=0;j<3;j++) {
+            for (i=0;i<tmpmdsize;i++) {
+              sh_force[j][i] = sh_force[j][i] * hsq2;
+            }
+          }
+        }
+
+        sum = 0.0;
+      }
+
+
+      /* Barrier */
+      Barrier.enterBarrier(tmpbr);
+      System.clearPrefetchCache();
+
+      atomic {
+        /*scale forces, update velocities */
+
+        for (i=0;i<tmpmdsize;i++) {
+          sum = sum + one[i].mkekin(hsq2,i);  
+        }
+
+        ekin = sum/hsq;
+
+        vel = 0.0;
+        count = 0.0;
+
+        /* average velocity */
 
+        for (i=0;i<tmpmdsize;i++) {
+          velt = one[i].velavg(vaverh,h);
+          if(velt > vaverh) { count = count + 1.0; }
+          vel = vel + velt;                    
+        }
 
+        vel = vel / h;
 
+        /* temperature scale if required */
+
+        if((move < istop) && (((move+1) % irep) == 0)) {
+          sc = Math.sqrt(tref / (tscale*ekin));
+          for (i=0;i<tmpmdsize;i++) {
+            one[i].dscal(sc,1);
+          }
+          ekin = tref / tscale;
+        }
+
+        /* sum to get full potential energy and virial */
+
+        if(((move+1) % iprint) == 0) {
+          mymd.ek[id] = 24.0*ekin;
+          mymd.epot[id] = 4.0*mymd.epot[id];
+          etot = mymd.ek[id] + mymd.epot[id];
+          temp = tscale * ekin;
+          pres = tmpden * 16.0 * (ekin - mymd.vir[id]) / tmpmdsize;
+          vel = vel / tmpmdsize; 
+          rp = (count / tmpmdsize) * 100.0;
+        }
+      }
+      Barrier.enterBarrier(tmpbr);
+      System.clearPrefetchCache();
+    }
+
+    Barrier.enterBarrier(tmpbr);
+    System.clearPrefetchCache();
+    //if (id == 0) JGFInstrumentor.stopTimer("Section3:MolDyn:Run", instr.timers);
+  }
+
+}
 
 class particle {
 
index 518cf4db7a8280c9473edaaf69b6780ab4382fd3..ca92207f9d25510b8190ef8f873bc648c3b85b46 100644 (file)
@@ -51,9 +51,6 @@ public class JGFMolDynBenchSizeA {
       mold.JGFinitialise(); 
     }
     JGFMolDynBench.JGFapplication(mold); 
-    atomic {
-      mold.JGFvalidate(); 
-    }
 
     /* Validate data */
     double[] refval = new double[2];
@@ -64,7 +61,9 @@ public class JGFMolDynBenchSizeA {
       dval = mold.ek[0];
     }
     double dev = Math.fabs(dval - refval[size]);
-    if (dev > 1.0e-10 ){
+    long l = (long) refval[size] *1000000;
+    long r = (long) dval * 1000000;
+    if (l != r ){
       System.printString("Validation failed\n");
       System.printString("Kinetic Energy = " + (long)dval + "  " + (long)dev + "  " + size + "\n");
     }
index 7b6529e65b3e432c48161b0a1e61ca449a50f3ec..f50cb0f8553ae5116d89e3c9d157c39dc4221a40 100644 (file)
@@ -3,7 +3,7 @@ SRC=${MAINCLASS}.java \
 JGFInstrumentor.java \
 JGFTimer.java \
 JGFMolDynBench.java \
-DebugBarrier.java
+Barrier.java
 FLAGS=-dsm -prefetch -excprefetch particle.force -excprefetch particle.domove -excprefetch particle.mkekin -excprefetch TournamentBarrier.DoBarrier -excprefetch JGFMolDynBench.JGFvalidate -excprefetch JGFMolDynBench.JGFapplication -optimize -debug -profile -mainclass ${MAINCLASS} -o ${MAINCLASS} -trueprob 0.8
 FLAGS2=-dsm -optimize -debug -profile -mainclass ${MAINCLASS} -o ${MAINCLASS}NP
 
@@ -12,5 +12,5 @@ default:
        ../../../../buildscript ${FLAGS} ${SRC}
 
 clean:
-       rm -rf tmpbuildirectory
+       rm -rf tmpbuilddirectory/
        rm *.bin
index 4e947197810b1056fde8babc4d432b8d3a5623f7..b0f1a1b7f8df70c30891851ca960439281536aa6 100644 (file)
@@ -58,7 +58,6 @@ public class JGFSORBench {
     double[][] G;
     int M, N;
     atomic {
-      //G = global new double[datasize][datasize];
       G = sor.RandomMatrix(datasize, datasize, rand);
       M = G.length;
       N = G[0].length;
@@ -92,20 +91,23 @@ public class JGFSORBench {
     //JGFInstrumentor.startTimer("Section2:SOR:Kernel", instr.timers); 
 
     SORRunner tmp;
-    int mid = (128<<24)|(195<<16)|(175<<8)|73;
+    int[] mid = new int[4];
+    mid[0] = (128<<24)|(195<<16)|(175<<8)|69;
+    mid[1] = (128<<24)|(195<<16)|(175<<8)|78;
+    mid[2] = (128<<24)|(195<<16)|(175<<8)|73;
+    mid[3] = (128<<24)|(195<<16)|(175<<8)|79;
     for(int i=1;i<numthreads;i++) {
       atomic {
         thobjects[i] =  global new SORRunner(i,omega,G,num_iterations,sor.sync,numthreads);
         tmp = thobjects[i];
       }
-      tmp.start(mid);
+      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,sor.sync,numthreads);
       tmp = thobjects[0];
     }
-    tmp.start(mid);
+    tmp.start(mid[0]);
     tmp.join();
 
     for(int i=1;i<numthreads;i++) {
@@ -116,7 +118,6 @@ public class JGFSORBench {
     }
 
     //JGFInstrumentor.stopTimer("Section2:SOR:Kernel", instr.timers);
-
     atomic {
       for (int i=1; i<Nm1; i++) {
         for (int j=1; j<Nm1; j++) {
@@ -127,7 +128,8 @@ public class JGFSORBench {
   }
 
   public long[][] init_sync(int nthreads, int cachelinesize) {
-    long sync[][] = global new long [nthreads][cachelinesize];
+    long[][] sync;
+    sync = global new long [nthreads][cachelinesize];
     for (int i = 0; i<nthreads; i++)
       sync[i][0] = 0;
     return sync;
@@ -153,7 +155,9 @@ public class JGFSORBench {
     refval[1] = 1.1234778980135105;
     refval[2] = 1.9954895063582696;
     double dev = Math.fabs(Gtotal - refval[size]);
-    if (dev > 1.0e-12 ){
+    long l = (long) refval[size] * 1000000;
+    long r = (long) Gtotal * 1000000;
+    if (l != r ){
       //System.printString("Validation failed");
       //System.printString("Gtotal = " + (long) Gtotal * 1000000 + "  " +(long) dev * 1000000 + "  " + size);
       return 1;
@@ -161,29 +165,4 @@ public class JGFSORBench {
       return 0;
     }
   }
-
-  /*
-     public void JGFtidyup(){
-     System.gc();
-     }  
-
-     public void JGFrun(int size){
-
-
-     JGFInstrumentor.addTimer("Section2:SOR:Kernel", "Iterations",size);
-
-     JGFsetsize(size); 
-     JGFinitialise(); 
-     JGFkernel(); 
-     JGFvalidate(); 
-     JGFtidyup(); 
-
-
-     JGFInstrumentor.addOpsToTimer("Section2:SOR:Kernel", (double) (JACOBI_NUM_ITER));
-
-     JGFInstrumentor.printTimer("Section2:SOR:Kernel"); 
-     }
-     */
-
-
 }
index dd9fd607002422b288862d127fce073b94dcba37..23f272240cae5f3c85030fa57ba18042de244dc7 100644 (file)
@@ -27,8 +27,8 @@ public class JGFSORBenchSizeA{
     if(argv.length != 0 ) {
       nthreads = Integer.parseInt(argv[0]);
     } else {
-      System.printString("The no of threads has not been specified, defaulting to 1");
-      System.printString("  ");
+      System.printString("The no of threads has not been specified, defaulting to 1\n");
+      System.printString("  \n");
       nthreads = 1;
     }
 
@@ -47,13 +47,12 @@ public class JGFSORBenchSizeA{
       sor.JGFsetsize(size); 
     }
     JGFSORBench.JGFkernel(sor); 
-    System.printString("End of JGFkernel\n");
     int retval;
     atomic {
       retval = sor.JGFvalidate(); 
     }
     if(retval!=0) {
-      System.printString("Validation failed");
+      System.printString("Validation failed\n");
     }
 
     int jacobi;
index a4d0087267bd06bebc34ee5a68c0fd96c07d7314..bc9097303db7275de682c9ce82a7789662a34ba0 100644 (file)
@@ -21,6 +21,7 @@
 
 class SORRunner extends Thread {
 
+  int donecount, prevvalue;
   int id,num_iterations;
   double G[][],omega;
   long sync[][];
@@ -33,12 +34,14 @@ class SORRunner extends Thread {
     this.num_iterations=num_iterations;
     this.sync=sync;
     this.nthreads = nthreads;
+    this.prevvalue = 0;
+    this.donecount = 0;
   }
 
   public void run() {
-
     int tmpid, M, N, numthreads;
     double omega_over_four, one_minus_omega;
+    int numiterations;
     atomic {
       M = G.length;
       N = G[0].length;
@@ -46,6 +49,7 @@ class SORRunner extends Thread {
       one_minus_omega = 1.0 - omega;
       numthreads = nthreads;
       tmpid = id;
+      numiterations = num_iterations;
     }
 
     // update interior points
@@ -65,7 +69,7 @@ class SORRunner extends Thread {
     if (tmpid == (numthreads-1)) iupper = Mm1+1;
 
     atomic {
-      for (int p=0; p<2*num_iterations; p++) {
+      for (int p=0; p<2*numiterations; p++) {
         for (int i=ilow+(p%2); i<iupper; i=i+2) {
 
           double [] Gi = G[i];
@@ -107,18 +111,33 @@ class SORRunner extends Thread {
           }
 
         }
-
         // Signal this thread has done iteration
         sync[id][0]++;
 
+        /* My modifications */
+        while (donecount < nthreads-1) {
+          if (sync[id][0] > prevvalue) {
+            donecount++;
+          }
+        }
+        if (id == 0) {
+          donecount = 0;
+          prevvalue++;
+        }
+        /*
         // Wait for neighbours;
         if (id > 0) {
+          System.printString("id: " + id + " sync: id-1 0 " + sync[id-1][0] + " id 0" + sync[id][0] + "\n");
           while (sync[id-1][0] < sync[id][0]) ;
+          System.printString("id: " + id + " sync: id-1 0 " + sync[id-1][0] + " id 0" + sync[id][0] + "\n");
         }
         if (id < nthreads -1) {
+          System.printString("id: " + id + " sync: id 0 " + sync[id][0] + " id+1 0" + sync[id+1][0] + "\n");
           while (sync[id+1][0] < sync[id][0]) ;
+          System.printString("id: " + id + " sync: id 0 " + sync[id][0] + " id+1 0" + sync[id+1][0] + "\n");
         }
-      }//end of outer for
-    }//end of atomic
-  }//end of run
+        */
+      }
+    } //end of atomic
+  } //end of run()
 }