polish source code + last changes.
authoryeom <yeom>
Tue, 3 Aug 2010 18:47:33 +0000 (18:47 +0000)
committeryeom <yeom>
Tue, 3 Aug 2010 18:47:33 +0000 (18:47 +0000)
Robust/src/Benchmarks/oooJava/barneshut/Barneshut.java
Robust/src/Benchmarks/oooJava/barneshut/OctTreeLeafNodeData.java
Robust/src/Benchmarks/oooJava/kmeans/KMeans.java
Robust/src/Benchmarks/oooJava/mergesort/BMergeSort4.java
Robust/src/Benchmarks/oooJava/mergesort/MergeSort.java
Robust/src/Benchmarks/oooJava/sor/JGFSORBenchSizeD.java
Robust/src/Benchmarks/oooJava/sor/SORRunner.java

index f76236220df4eb5e6b393d4cec8ce064dc720f44..42b97b1190a919cb8a7cba78c70e894a7dfb61a9 100644 (file)
@@ -1,5 +1,3 @@
-import System;
-
 /*
 Lonestar Benchmark Suite for irregular applications that exhibit 
 amorphous data-parallelism.
@@ -164,8 +162,7 @@ public   void ComputeCenterOfMass(ArrayIndexedGraph octree, ArrayIndexedNode roo
 
  public static void Insert(ArrayIndexedGraph octree, ArrayIndexedNode root, OctTreeLeafNodeData b, double r) { // builds the tree
     double x = 0.0, y = 0.0, z = 0.0;
-//    OctTreeNodeData n = octree.getNodeData(root);
-    OctTreeNodeData n = root.data;
+    OctTreeNodeData n = octree.getNodeData(root);
     int i = 0;
     if (n.posx < b.posx) {
       i = 1;
@@ -186,8 +183,7 @@ public   void ComputeCenterOfMass(ArrayIndexedGraph octree, ArrayIndexedNode roo
       octree.setNeighbor(root, i, newnode);
     } else {
       double rh = 0.5 * r;
-//      OctTreeNodeData ch = octree.getNodeData(child);
-      OctTreeNodeData ch = child.data;
+      OctTreeNodeData ch = octree.getNodeData(child);
       if (!(ch instanceof OctTreeLeafNodeData)) {
         Insert(octree, child, b, rh);
       } else {
@@ -211,11 +207,11 @@ public   void ComputeCenterOfMass(ArrayIndexedGraph octree, ArrayIndexedNode roo
     mintime =9223372036854775807L;
     run = 0;
     
-    while (((run < 3) || (Math.abs(lasttime-runtime)*64 > min(lasttime, runtime))) && (run < 7)) {
+//    while (((run < 3) || (Math.abs(lasttime-runtime)*64 > min(lasttime, runtime))) && (run < 7)) {
       runtime = bh.run(args);
       if (runtime < mintime) mintime = runtime;
       run++;
-    }
+//    }
     System.out.println("minimum runtime: " + mintime + " ms");
     System.out.println("");
   }
@@ -244,6 +240,7 @@ public   void ComputeCenterOfMass(ArrayIndexedGraph octree, ArrayIndexedNode roo
     int local_nbodies=nbodies;
     int local_ntimesteps=ntimesteps;
 
+    long start_time = System.currentTimeMillis();
     for (int step = 0; step < local_ntimesteps; step++) { // time-step the system
       ComputeCenterAndDiameter();
       ArrayIndexedGraph octree = new ArrayIndexedGraph(8);
@@ -259,44 +256,36 @@ public   void ComputeCenterOfMass(ArrayIndexedGraph octree, ArrayIndexedNode roo
       // summarize subtree info in each internal node (plus restructure tree and sort bodies for performance reasons)
       ComputeCenterOfMass(octree, root);
 
-//      long id = Time.getNewTimeId();
-      long start_time = System.currentTimeMillis();
       for(int i=0; i < local_nbodies; i++){
-//      for (OctTreeLeafNodeData n : body) {
         // compute the acceleration of each body (consumes most of the total runtime)
-//        n.ComputeForce(octree, root, diameter, itolsq, step, dthf, epssq);
+        // n.ComputeForce(octree, root, diameter, itolsq, step, dthf, epssq);
         OctTreeLeafNodeData eachbody=body[i];
         double di=diameter;
         double it=itolsq;
         double dt=dthf;
         double ep=epssq;   
         sese parallel{
-//          body[i].ComputeForce(octree, root, diameter, itolsq, step, dthf, epssq);
-//          eachbody.ComputeForce(octree, root, diameter, itolsq, step, dthf, epssq);
-            eachbody.ComputeForce(octree, root, di, it, step, dt, ep);
+            eachbody.ComputeForce(octree, di, it, step, dt, ep);
         }
       }
-      long end_time=System.currentTimeMillis();
-      runtime += (end_time-start_time);
-//      runtime += Time.elapsedTime(id);
-      for (int i = 0; i < local_nbodies; i++) {
+
+      for (int i = 0; i < local_nbodies; i++) {        
         body[i].Advance(dthf, dtime); // advance the position and velocity of each body
       }
+
     } // end of time step
 
+    long end_time=System.currentTimeMillis();
+    
     if (isFirstRun) {
-      // DecimalFormat df = new DecimalFormat("0.0000E00");
-      // for (int i = 0; i < nbodies; i++) {
-      // System.out.println(df.format(body[i].posx) + " " +
-      // df.format(body[i].posy) + " " + df.format(body[i].posz)); // print
-      // result
-      // }
-      for (int i = 0; i < local_nbodies; i++) {
-//        System.out.println(body[i].posx + " " + body[i].posy + " " + body[i].posz); // print
-                                                                                    // result
-      }
+      /*
+        for (int i = 0; i < local_nbodies; i++) {
+          System.out.println(body[i].posx + " " + body[i].posy + " " + body[i].posz); // print result
+        }
+     */
       System.out.println("");
     }
+    runtime += (end_time-start_time);
     System.out.println("runtime: " + runtime + " ms");
 
     isFirstRun = false;
index 7552a0e6fc6f49d76bff26a2f9e9a7f951323832..1a6dccd264ae17d7a29eb516047aae92420eb78b 100644 (file)
@@ -67,7 +67,7 @@ public class OctTreeLeafNodeData extends OctTreeNodeData { // the tree leaves ar
     velz = velhz + dvelz;
   }
 
-  void ComputeForce(ArrayIndexedGraph octree, ArrayIndexedNode root, double size, double itolsq,
+  void ComputeForce(ArrayIndexedGraph octree,  double size, double itolsq,
       int step, double dthf, double epssq) { // computes the acceleration and velocity of a body
     double ax, ay, az;
     ax = accx;
@@ -87,7 +87,6 @@ public class OctTreeLeafNodeData extends OctTreeNodeData { // the tree leaves ar
   private void RecurseForce(ArrayIndexedGraph octree, ArrayIndexedNode nn, double dsq,
       double epssq) { // recursively walks the tree to compute the force on a body
     double drx, dry, drz, drsq, nphi, scale, idr;
-//    OctTreeNodeData n = octree.getNodeData(nn);
     OctTreeNodeData n = nn.data;
     drx = n.posx - posx;
     dry = n.posy - posy;
@@ -96,35 +95,27 @@ public class OctTreeLeafNodeData extends OctTreeNodeData { // the tree leaves ar
     if (drsq < dsq) {
       if (!(n instanceof OctTreeLeafNodeData)) { // n is a cell
         dsq *= 0.25;
-//        ArrayIndexedNode child = octree.getNeighbor(nn, 0);
         ArrayIndexedNode child =nn.neighbors[0];
         if (child != null) {
           RecurseForce(octree, child, dsq, epssq);
-//          child = octree.getNeighbor(nn, 1);
           child =nn.neighbors[1];
           if (child != null) {
             RecurseForce(octree, child, dsq, epssq);
-//            child = octree.getNeighbor(nn, 2);
             child =nn.neighbors[2];
             if (child != null) {
               RecurseForce(octree, child, dsq, epssq);
-//              child = octree.getNeighbor(nn, 3);
               child =nn.neighbors[3];
               if (child != null) {
                 RecurseForce(octree, child, dsq, epssq);
-//                child = octree.getNeighbor(nn, 4);
                 child =nn.neighbors[4];
                 if (child != null) {
                   RecurseForce(octree, child, dsq, epssq);
-//                  child = octree.getNeighbor(nn, 5);
                   child =nn.neighbors[5];
                   if (child != null) {
                     RecurseForce(octree, child, dsq, epssq);
-//                    child = octree.getNeighbor(nn, 6);
                     child =nn.neighbors[6];
                     if (child != null) {
                       RecurseForce(octree, child, dsq, epssq);
-//                      child = octree.getNeighbor(nn, 7);
                       child =nn.neighbors[7];
                       if (child != null) {
                         RecurseForce(octree, child, dsq, epssq);
index d7e107f823e67bcaa3b46364a7f50c4e720258d8..16adc36a028906aac3532c23b14e8cacb7a76e9d 100644 (file)
@@ -229,7 +229,7 @@ public class KMeans /*extends Thread*/ {
     attributes = new float[numObjects][numAttributes];
     KMeans.readFromFile(inputFile, kms.filename, buf, MAX_LINE_LENGTH);
     System.out.println("Finished Reading from file ......");
-
+    long startT=System.currentTimeMillis();
     /*
      * The core of the clustering
      */
@@ -271,12 +271,15 @@ public class KMeans /*extends Thread*/ {
           g_args);                // Global arguments common to all threads
     }
 
-    System.out.println("TIME="+g_args.global_time);
+    long endT=System.currentTimeMillis();
+    System.out.println("running time="+(endT-startT));
+//    System.out.println("TIME="+g_args.global_time);
 
     System.out.println("Printing output......");
     System.out.println("Best_nclusters= " + kms.best_nclusters);
 
     /* Output: the coordinates of the cluster centres */
+    /*
     {
       for (int i = 0; i < kms.best_nclusters; i++) {
         System.out.print(i + " ");
@@ -286,6 +289,7 @@ public class KMeans /*extends Thread*/ {
         System.out.println("\n");
       }
     }
+    */
 
     System.out.println("Finished......");
     System.exit(0);
index 254df675b2773355fa87bdef77ebdc22648798eb..899a3bbf128fd5ee94417f2069d58084b3ebfb6d 100644 (file)
@@ -42,7 +42,7 @@ public class MergeSort4 extends MergeSort {
       int max = R.length;\r
       int j = low;\r
       for (int i = 0; i < max; i++) {\r
-        R[i] = A[j++];\r
+          R[i] = A[j++];\r
       }\r
       quickSort(R, 0, R.length - 1);\r
       return R;\r
@@ -77,7 +77,7 @@ public class MergeSort4 extends MergeSort {
         int max = R.length;\r
         int j = low;\r
         for (int i = 0; i < max; i++) {\r
-          R[i] = A[j++];\r
+            R[i] = A[j++];\r
         }\r
         quickSort(R, 0, R.length-1);\r
         return R;\r
index 8301df61261105fe2130ef2dacac630c546ef812..4289bf13c36388292411623a33cfa7426eb103aa 100644 (file)
@@ -63,9 +63,9 @@ public class MergeSort {
     sese run{\r
       sort(input);\r
     }\r
-//    sese test{\r
-//      checkSorted(input);\r
-//    }\r
+    sese test{\r
+      checkSorted(input);\r
+    }\r
   }\r
 \r
   public void sort(int A[]) {\r
index bd1ce691e0005bd3b6b599785c7191e9ae20a81f..6ef9add16464f20d2242e138e8c2f6be04012334 100644 (file)
@@ -23,21 +23,18 @@ public class JGFSORBenchSizeD{
   public static void main(String argv[]){
 
     int nthreads;
+    nthreads = 1;
+    int size = 3;
     if(argv.length != 0 ) {
-      nthreads = Integer.parseInt(argv[0]);
-    } else {
-      System.printString("The no of threads has not been specified, defaulting to 1\n");
-      System.printString("  \n");
-      nthreads = 1;
-    }
+      size = Integer.parseInt(argv[0]);
+    } 
 
     JGFInstrumentor instr = new JGFInstrumentor();
-    //JGFInstrumentor.printHeader(2,0,nthreads);
 
     JGFSORBench sor;
     sor = new JGFSORBench(nthreads); 
 
-    int size = 3;
+   
     JGFInstrumentor.addTimer("Section2:SOR:Kernel", "Iterations",size, instr.timers);
 
     sor.JGFsetsize(size); 
index deb5bfbe3bb843922f032cfb31f9ef4cae786bf1..a8c8dc4c7a920c6bbea5781ce1207935c3c23393 100644 (file)
@@ -19,7 +19,7 @@
  *                                                                         *
  **************************************************************************/
 
-class SORRunner {
+class SORRunner  {
 
   int id, num_iterations;
   double G[][],omega;