Working version of SSCA2 benchmark for kernel 1
authoradash <adash>
Thu, 21 May 2009 23:43:44 +0000 (23:43 +0000)
committeradash <adash>
Thu, 21 May 2009 23:43:44 +0000 (23:43 +0000)
-singleTM flag problems for more than 1 thread still exists, some problem in TRANSREAD, Amem_cpy()

16 files changed:
Robust/src/Benchmarks/SingleTM/KMeans/README
Robust/src/Benchmarks/SingleTM/SSCA2/Alg_Radix_Smp.java
Robust/src/Benchmarks/SingleTM/SSCA2/ComputeGraph.java
Robust/src/Benchmarks/SingleTM/SSCA2/CreatePartition.java
Robust/src/Benchmarks/SingleTM/SSCA2/FindSubGraphs0_arg_t.java [new file with mode: 0644]
Robust/src/Benchmarks/SingleTM/SSCA2/GenScalData.java
Robust/src/Benchmarks/SingleTM/SSCA2/GetUserParameters.java
Robust/src/Benchmarks/SingleTM/SSCA2/Globals.java
Robust/src/Benchmarks/SingleTM/SSCA2/Graph.java
Robust/src/Benchmarks/SingleTM/SSCA2/LocalStartStop.java
Robust/src/Benchmarks/SingleTM/SSCA2/README
Robust/src/Benchmarks/SingleTM/SSCA2/SSCA2.java [new file with mode: 0644]
Robust/src/Benchmarks/SingleTM/SSCA2/VList.java
Robust/src/Benchmarks/SingleTM/common/Random.java [new file with mode: 0644]
Robust/src/ClassLibrary/Integer.java
Robust/src/IR/Flat/BuildCode.java

index 7b051e2fa786cd412a21f412639614ba727ca0ee..b25fc24dabf68e1ac2d64266a2f0db5586733286 100644 (file)
@@ -26,10 +26,10 @@ To build the application, simply run:
 
     make 
 
-By default, this produces an executable named "kmeans", which can then be
+By default, this produces an executable named "KMeans.bin", which can then be
 run in the following manner:
 
-    ./kmeans -m <max_clusters> \
+    ./KMeans.bin -m <max_clusters> \
              -n <min_clusters> \
              -t <threshold> \
              -i <input_file_name> \
index 2e21f24257a985a9ac4fc6f8590a3a6d067b4fed..cd48fba1a914b0f5611e8e5ce08b339fc03162d1 100644 (file)
  */
 
 public class Alg_Radix_Smp {
-  int[] global_myHisto;
-  int[] global_psHisto;
-  int[] global_lTemp;
-  int[] global_lTemp2;
-  int myId;
-  int numThread;
-
-  public class Alg_Radix_Smp(int myId, int numThread) {
+  public int[] global_myHisto;
+  public int[] global_psHisto;
+  public int[] global_lTemp;
+  public int[] global_lTemp2;
+
+  public Alg_Radix_Smp() {
     global_myHisto = null;
     global_psHisto = null;
     global_lTemp   = null;
     global_lTemp2  = null;
-    this.myId = myId;
-    this.numThread = numThread;
   }
 
-  public int BITS(x, k, j) {
+  public int BITS(int x, int k, int j) {
     int retval = ((x>>k) & ~(~0<<j));
     return retval;
   }
@@ -73,14 +69,15 @@ public class Alg_Radix_Smp {
    * q (elems/proc) must be a multiple of NODES
    * =============================================================================
    */
-  void
-    all_countsort_node (int q,
+  /*
+  public void
+    all_countsort_node (
+        int q,
         int[] lKey,
         int[] lSorted,
         int R,
         int bitOff,
-        int m,
-        )
+        int m)
     {
       int[] myHisto = null;
       int[] psHisto = null;
@@ -106,7 +103,7 @@ public class Alg_Radix_Smp {
       LocalStartStop lss = new LocalStartStop();
       CreatePartition.createPartition(0, q, myId, numThread, lss);
 
-      for (int k = lss.i_start; k < i_stop; k++) {
+      for (int k = lss.i_start; k < lss.i_stop; k++) {
         myHisto[(myId * R) + BITS(lKey[k],bitOff,m)]++;
       }
 
@@ -127,7 +124,7 @@ public class Alg_Radix_Smp {
 
       int offset = 0;
 
-      for (k = 0; k < R; k++) {
+      for (int k = 0; k < R; k++) {
         myHisto[(myId * R) + k] = (psHisto[(myId * R) + k] - myHisto[(myId * R) + k]) + offset;
         offset += psHisto[((numThread - 1) * R) + k];
       }
@@ -149,6 +146,7 @@ public class Alg_Radix_Smp {
         myHisto = null;
       }
     }
+*/
 
 
   /* =============================================================================
@@ -158,7 +156,8 @@ public class Alg_Radix_Smp {
    * q (elems/proc) must be a multiple of NODES
    * =============================================================================
    */
-  void
+  /*
+  public void
     all_countsort_node_aux_seq (int q,
         int[] lKey,
         int[] lSorted,
@@ -197,16 +196,17 @@ public class Alg_Radix_Smp {
         auxSorted[myHisto[j]] = lKey[k];
         myHisto[j]++;
 
-        /*
-        lSorted[mhp[j]] = lKey[k];
-        auxSorted[mhp[j]] = auxKey[k];
-        mhp[j]++;
-        */
+        //
+        //lSorted[mhp[j]] = lKey[k];
+        //auxSorted[mhp[j]] = auxKey[k];
+        //mhp[j]++;
+        
       }
 
       psHisto = null;
       myHisto = null;
     }
+*/
 
 
   /* =============================================================================
@@ -216,30 +216,33 @@ public class Alg_Radix_Smp {
    * q (elems/proc) must be a multiple of NODES
    * =============================================================================
    */
-  void
-    all_countsort_node_aux (int q,
+  public void
+    all_countsort_node_aux (int myId,
+        int numThread,
+        int q,
         int[] lKey,
         int[] lSorted,
         int[] auxKey,
         int[] auxSorted,
         int R,
         int bitOff,
-        int m)
+        int m,
+        Alg_Radix_Smp rdxsort)
     {
       int[] myHisto = null;
       int[] psHisto = null;
 
       if (myId == 0) {
         myHisto = new int[numThread * R];
-        global_myHisto = myHisto;
+        rdxsort.global_myHisto = myHisto;
         psHisto = new int[numThread * R];
-        global_psHisto = psHisto;
+        rdxsort.global_psHisto = psHisto;
       }
 
       Barrier.enterBarrier();
 
-      myHisto = global_myHisto;
-      psHisto = global_psHisto;
+      myHisto = rdxsort.global_myHisto;
+      psHisto = rdxsort.global_psHisto;
 
       for (int k = 0; k <  R; k++) {
         myHisto[((myId*R) + k)] = 0;
@@ -270,7 +273,7 @@ public class Alg_Radix_Smp {
       int offset = 0;
 
       for (int k = 0; k < R; k++) {
-        myHisto[(myId*R) +k] = (psHisto[ ((myId*R) + k)] - myHisto[ ((myId*R) +k])) + offset;
+        myHisto[(myId*R)+k] = (psHisto[(myId*R) + k] - myHisto[(myId*R) +k]) + offset;
         offset += psHisto[((numThread -1) * R) + k];
       }
 
@@ -300,7 +303,8 @@ public class Alg_Radix_Smp {
    * q (elems/proc) must be a multiple of NODES
    * =============================================================================
    */
-  void
+  /*
+  public void
     all_radixsort_node_s3 (int q,
         int[] lKeys,
         int[] lSorted)
@@ -324,9 +328,10 @@ public class Alg_Radix_Smp {
       Barrier.enterBarrier();
 
       if (myId == 0) {
-        lTemp = null
+        lTemp = null;
       }
     }
+    */
 
 
   /* =============================================================================
@@ -335,7 +340,8 @@ public class Alg_Radix_Smp {
    * q (elems/proc) must be a multiple of NODES
    * =============================================================================
    */
-  void
+  /*
+  public void
     all_radixsort_node_s2 (int q,
         int[] lKeys,
         int[] lSorted)
@@ -361,6 +367,7 @@ public class Alg_Radix_Smp {
         lTemp = null;
       }
     }
+    */
 
 
   /* =============================================================================
@@ -369,7 +376,8 @@ public class Alg_Radix_Smp {
    * q (elems/proc) must be a multiple of NODES
    * =============================================================================
    */
-  void
+  /*
+  public void
     all_radixsort_node_aux_s3_seq (int q,
         int[] lKeys,
         int[] lSorted,
@@ -389,6 +397,7 @@ public class Alg_Radix_Smp {
       lTemp = null;
       lTemp2 = null;
     }
+    */
 
 
   /* =============================================================================
@@ -398,34 +407,37 @@ public class Alg_Radix_Smp {
    * =============================================================================
    */
   public static void
-    all_radixsort_node_aux_s3 (int q,
+    all_radixsort_node_aux_s3 (int myId,
+        int numThread,
+        int q,
         int[] lKeys,
         int[] lSorted,
         int[] auxKey,
-        int[] auxSorted)
+        int[] auxSorted,
+        Alg_Radix_Smp rdxsort)
     {
       int[] lTemp  = null;
       int[] lTemp2 = null;
 
       if (myId == 0) {
         lTemp = new int[ q];
-        global_lTemp = lTemp;
+        rdxsort.global_lTemp = lTemp;
         lTemp2 = new int[ q];
-        global_lTemp2 = lTemp2;
+        rdxsort.global_lTemp2 = lTemp2;
       }
 
       Barrier.enterBarrier();
 
-      lTemp  = global_lTemp;
-      lTemp2 = global_lTemp2;
+      lTemp  = rdxsort.global_lTemp;
+      lTemp2 = rdxsort.global_lTemp2;
 
-      all_countsort_node_aux(q, lKeys, lSorted, auxKey, auxSorted, (1<<11),  0, 11);
-      all_countsort_node_aux(q, lSorted, lTemp, auxSorted, lTemp2, (1<<11), 11, 11);
-      all_countsort_node_aux(q, lTemp, lSorted, lTemp2, auxSorted, (1<<10), 22, 10);
+      rdxsort.all_countsort_node_aux(myId, numThread, q, lKeys, lSorted, auxKey, auxSorted, (1<<11),  0, 11, rdxsort);
+      rdxsort.all_countsort_node_aux(myId, numThread, q, lSorted, lTemp, auxSorted, lTemp2, (1<<11), 11, 11, rdxsort);
+      rdxsort.all_countsort_node_aux(myId, numThread, q, lTemp, lSorted, lTemp2, auxSorted, (1<<10), 22, 10, rdxsort);
 
       Barrier.enterBarrier();
 
-      if(myId = 0) {
+      if(myId == 0) {
         lTemp = null;
         lTemp2 = null;
       }
index cd62d35f932023c7f16395087262ef7b84a25691..3a97221767abf5bd9010556dd4476b24f8425ef7 100644 (file)
@@ -112,7 +112,7 @@ public class ComputeGraph {
 
       if (myId > 0) {
         int add_value = p[NOSHARE(myId-1)];
-        for (j = start-1; j < end; j++) {
+        for (int j = start-1; j < end; j++) {
           result[j] += add_value;
         }
       }
@@ -138,7 +138,7 @@ public class ComputeGraph {
       //Graph GPtr = computeGraphArgs.GPtr;
       //GraphSDG SDGdataPtr = computeGraphArgs.SDGdata;
 
-      int j;
+      //int j;
       int maxNumVertices = 0;
       int numEdgesPlaced = computeGraphArgs.SDGdataPtr.numEdgesPlaced;
 
@@ -156,14 +156,14 @@ public class ComputeGraph {
       }
 
       atomic {
-        int tmp_maxNumVertices = global_maxNumVertices;
+        int tmp_maxNumVertices = computeGraphArgs.global_maxNumVertices;
         int new_maxNumVertices = CreatePartition.MAX( tmp_maxNumVertices, maxNumVertices) + 1;
-        global_maxNumVertices = new_maxNumVertices;
+        computeGraphArgs.global_maxNumVertices = new_maxNumVertices;
       }
 
       Barrier.enterBarrier();
 
-      maxNumVertices = global_maxNumVertices;
+      maxNumVertices = computeGraphArgs.global_maxNumVertices;
 
       if (myId == 0) {
 
@@ -189,7 +189,7 @@ public class ComputeGraph {
 
       CreatePartition.createPartition(0, computeGraphArgs.GPtr.numVertices, myId, numThread, lss);
 
-      for (i = lss.i_start; i < lss.i_stop; i++) {
+      for (int i = lss.i_start; i < lss.i_stop; i++) {
         computeGraphArgs.GPtr.outDegree[i] = 0;
         computeGraphArgs.GPtr.outVertexIndex[i] = 0;
       }
@@ -260,17 +260,17 @@ public class ComputeGraph {
 
       Barrier.enterBarrier();
 
-      prefix_sums(myId, numThread, computeGraphArgs.GPtr.outVertexIndex, computeGraphArgs.GPtr.outDegree, computeGraphArgs.GPtr.numVertices);
+      computeGraphArgs.prefix_sums(myId, numThread, computeGraphArgs.GPtr.outVertexIndex, computeGraphArgs.GPtr.outDegree, computeGraphArgs.GPtr.numVertices);
 
       Barrier.enterBarrier();
 
       atomic {
-        global_outVertexListSize = global_outVertexListSize + outVertexListSize;
+        computeGraphArgs.global_outVertexListSize = computeGraphArgs.global_outVertexListSize + outVertexListSize;
       }
 
       Barrier.enterBarrier();
 
-      outVertexListSize = global_outVertexListSize;
+      outVertexListSize = computeGraphArgs.global_outVertexListSize;
 
       if (myId == 0) {
         computeGraphArgs.GPtr.numDirectedEdges = outVertexListSize;
@@ -373,12 +373,12 @@ public class ComputeGraph {
       
       if (myId == 0) {
         impliedEdgeList = new int[computeGraphArgs.GPtr.numVertices * glb.MAX_CLUSTER_SIZE];
-        global_impliedEdgeList = impliedEdgeList;
+        computeGraphArgs.global_impliedEdgeList = impliedEdgeList;
       }
 
       Barrier.enterBarrier();
 
-      impliedEdgeList = global_impliedEdgeList;
+      impliedEdgeList = computeGraphArgs.global_impliedEdgeList;
 
       CreatePartition.createPartition(0,
           (computeGraphArgs.GPtr.numVertices * glb.MAX_CLUSTER_SIZE),
@@ -398,18 +398,18 @@ public class ComputeGraph {
       int[][] auxArr;
       if (myId == 0) {
         auxArr = new int[computeGraphArgs.GPtr.numVertices][glb.MAX_CLUSTER_SIZE];
-        global_auxArr = auxArr;
+        computeGraphArgs.global_auxArr = auxArr;
       }
 
       Barrier.enterBarrier();
 
-      auxArr = global_auxArr;
+      auxArr = computeGraphArgs.global_auxArr;
 
       CreatePartition.createPartition(0, computeGraphArgs.GPtr.numVertices, myId, numThread, lss);
 
       for (int i = lss.i_start; i < lss.i_stop; i++) {
         /* Inspect adjacency list of vertex i */
-        for (j = computeGraphArgs.GPtr.outVertexIndex[i];
+        for (int j = computeGraphArgs.GPtr.outVertexIndex[i];
             j < (computeGraphArgs.GPtr.outVertexIndex[i] + computeGraphArgs.GPtr.outDegree[i]);
             j++)
         {
@@ -429,7 +429,7 @@ public class ComputeGraph {
               int inDegree = computeGraphArgs.GPtr.inDegree[v];
               computeGraphArgs.GPtr.inDegree[v] =  (inDegree + 1);
               if ( inDegree < glb.MAX_CLUSTER_SIZE) {
-                impliedEdgeList[v*glb.MAX_CLUSTER_SIZE+inDegree] = i
+                impliedEdgeList[v*glb.MAX_CLUSTER_SIZE+inDegree] = i;
               } else {
                 /* Use auxiliary array to store the implied edge */
                 /* Create an array if it's not present already */
@@ -440,7 +440,7 @@ public class ComputeGraph {
                 } else {
                   a = auxArr[v];
                 }
-                a[inDegree % MAX_CLUSTER_SIZE] = i;
+                a[inDegree % glb.MAX_CLUSTER_SIZE] = i;
               }
             }
           }
@@ -449,7 +449,7 @@ public class ComputeGraph {
 
       Barrier.enterBarrier();
 
-      prefix_sums(myId, numThread, computeGraphArgs.GPtr.inVertexIndex, computeGraphArgs.GPtr.inDegree, computeGraphArgs.GPtr.numVertices);
+      computeGraphArgs.prefix_sums(myId, numThread, computeGraphArgs.GPtr.inVertexIndex, computeGraphArgs.GPtr.inDegree, computeGraphArgs.GPtr.numVertices);
 
       if (myId == 0) {
         computeGraphArgs.GPtr.numUndirectedEdges = computeGraphArgs.GPtr.inVertexIndex[computeGraphArgs.GPtr.numVertices-1]
@@ -484,8 +484,8 @@ public class ComputeGraph {
         impliedEdgeList = null;
       }
 
-      for (i = i_start; i < i_stop; i++) {
-        if (computeGraphArgs.GPtr.inDegree[i] > MAX_CLUSTER_SIZE) {
+      for (int i = lss.i_start; i < lss.i_stop; i++) {
+        if (computeGraphArgs.GPtr.inDegree[i] > glb.MAX_CLUSTER_SIZE) {
           auxArr[i] = null;
         }
       }
@@ -493,7 +493,7 @@ public class ComputeGraph {
       Barrier.enterBarrier();
 
       if (myId == 0) {
-        auxArr = null
+        auxArr = null;
       }
 
     }
index f83f9d56b72341d44a04cec72fea32e40d8cbeac..bc7a6b93a5876e9ef6523ce39e5b4e4d64c633f5 100644 (file)
@@ -54,6 +54,7 @@ public class CreatePartition {
   public static void
     createPartition (int min, int max, int id, int n, LocalStartStop lss)
     {
+      //System.out.println("Inside createPartition() \n");
       int range = max - min;
       int chunk = MAX(1, ((range + n/2) / n)); /* rounded */
       int start = min + chunk * id;
@@ -64,8 +65,8 @@ public class CreatePartition {
         stop = MIN(max, (start + chunk));
       }
 
-      lss.start = start;
-      lss.stop = stop;
+      lss.i_start = start;
+      lss.i_stop = stop;
     }
 
   public static int MAX(int a, int b) {
diff --git a/Robust/src/Benchmarks/SingleTM/SSCA2/FindSubGraphs0_arg_t.java b/Robust/src/Benchmarks/SingleTM/SSCA2/FindSubGraphs0_arg_t.java
new file mode 100644 (file)
index 0000000..1733905
--- /dev/null
@@ -0,0 +1,13 @@
+public class FindSubGraphs0_arg_t {
+  Graph GPtr;
+  VList intWtVList;
+  VList strWtVList;
+  Edge maxIntWtList;
+  int maxIntWtListSize;
+  Edge soughtStrWtList;
+  int soughtStrWtListSize;
+
+  public FindSubGraphs0_arg_t() {
+
+  }
+}
index 0f98b576109b954749d70ce8507eb5b301bed3bf..15a3f1bfd714745b6303d41e685952df73c6c48f 100644 (file)
@@ -63,7 +63,7 @@ public class GenScalData {
    * Constructor
    **/
   public GenScalData() {
-    global_permV;              = null;
+    global_permV              = null;
     global_cliqueSizes        = null;
     global_totCliques         = 0;
     global_firstVsInCliques   = null;
@@ -98,30 +98,30 @@ public class GenScalData {
    */
 
   public static void
-    genScalData (int myId, int numThread, Globals glb, GraphSDG SDGdataPtr)
+    genScalData (int myId, int numThread, Globals glb, GraphSDG SDGdataPtr, GenScalData gsd, Alg_Radix_Smp radixsort)
     {
       /*
        * STEP 0: Create the permutations required to randomize the vertices
        */
 
       Random randomPtr = new Random();
-      randomPtr = randomPtr.random_alloc();
+      randomPtr.random_alloc();
       randomPtr.random_seed(myId);
 
       int[] permV;
 
       if (myId == 0) {
         permV = new int[glb.TOT_VERTICES];
-        global_permV = permV;
+        gsd.global_permV = permV;
       }
 
       Barrier.enterBarrier();
 
-      permV = global_permV;
+      permV = gsd.global_permV;
 
       LocalStartStop lss = new LocalStartStop();
-      CreatePartition cp = new CreatePartition();
-      cp.createPartition(0, glb.TOT_VERTICES, myId, numThread, lss);
+      //CreatePartition cp = new CreatePartition();
+      CreatePartition.createPartition(0, glb.TOT_VERTICES, myId, numThread, lss);
 
       /* Initialize the array */
       for (int i = lss.i_start; i < lss.i_stop; i++) {
@@ -130,8 +130,10 @@ public class GenScalData {
 
       Barrier.enterBarrier();
 
-      for (int i = i_start; i < i_stop; i++) {
-        int t1 = randomPtr.random_generate();
+      for (int i = lss.i_start; i < lss.i_stop; i++) {
+        int t1 = (int) (randomPtr.random_generate());
+        if(t1 < 0) 
+          t1*=(-1);
         int t = i + t1 % (glb.TOT_VERTICES - i);
         if (t != i) {
           atomic {
@@ -148,7 +150,7 @@ public class GenScalData {
 
       int[] cliqueSizes;
 
-      int estTotCliques = (int)(Math.ceil(1.5d * glb.TOT_VERTICES / ((1+glb.MAX_CLIQUE_SIZE)/2)));
+      int estTotCliques = (int)(Math.ceil(1.5 * glb.TOT_VERTICES / ((1+glb.MAX_CLIQUE_SIZE)/2)));
 
       /*
        * Allocate mem for Clique array
@@ -156,18 +158,20 @@ public class GenScalData {
        */
       if (myId == 0) {
         cliqueSizes = new int[estTotCliques];
-        global_cliqueSizes = cliqueSizes;
+        gsd.global_cliqueSizes = cliqueSizes;
       }
 
       Barrier.enterBarrier();
 
-      cliqueSizes = global_cliqueSizes;
+      cliqueSizes = gsd.global_cliqueSizes;
 
-      cp.createPartition(0, estTotCliques, myId, numThread, lss);
+      CreatePartition.createPartition(0, estTotCliques, myId, numThread, lss);
 
       /* Generate random clique sizes. */
       for (int i = lss.i_start; i < lss.i_stop; i++) {
-        cliqueSizes[i] = 1 + (randomPtr.random_generate() % glb.MAX_CLIQUE_SIZE);
+        cliqueSizes[i] = (int) ( 1 + (randomPtr.random_generate() % glb.MAX_CLIQUE_SIZE));
+        if(cliqueSizes[i] < 0) 
+          cliqueSizes[i] *= -1; //TODO fix the long->int casting error that creates negative numbers for randomPtr
       }
 
       Barrier.enterBarrier();
@@ -178,14 +182,14 @@ public class GenScalData {
        * Allocate memory for cliqueList
        */
 
-      int[] firstVsInCliques;
+      int[] lastVsInCliques;
       int[] firstVsInCliques;
 
       if (myId == 0) {
         lastVsInCliques = new int[estTotCliques];
-        global_lastVsInCliques = lastVsInCliques;
+        gsd.global_lastVsInCliques = lastVsInCliques;
         firstVsInCliques = new int[estTotCliques];
-        global_firstVsInCliques = firstVsInCliques;
+        gsd.global_firstVsInCliques = firstVsInCliques;
 
         /*
          * Sum up vertices in each clique to determine the lastVsInCliques array
@@ -201,7 +205,7 @@ public class GenScalData {
         }
         totCliques = i + 1;
 
-        global_totCliques = totCliques;
+        gsd.global_totCliques = totCliques;
 
         /*
          * Fix the size of the last clique
@@ -216,13 +220,13 @@ public class GenScalData {
 
       Barrier.enterBarrier();
 
-      lastVsInCliques  = global_lastVsInCliques;
-      firstVsInCliques = global_firstVsInCliques;
-      totCliques = global_totCliques;
+      lastVsInCliques  = gsd.global_lastVsInCliques;
+      firstVsInCliques = gsd.global_firstVsInCliques;
+      totCliques = gsd.global_totCliques;
 
       /* Compute start Vertices in cliques. */
-      cp.createPartition(1, totCliques, myId, numThread, lss);
-      for (int i = i_start; i < i_stop; i++) {
+      CreatePartition.createPartition(1, totCliques, myId, numThread, lss);
+      for (int i = lss.i_start; i < lss.i_stop; i++) {
         firstVsInCliques[i] = lastVsInCliques[i-1] + 1;
       }
 
@@ -279,7 +283,7 @@ Barrier.enterBarrier();
       int[] endV;
 
       if (numThread > 3) {
-        int numByte = 1.5 * (estTotEdges/numThread);
+        int numByte = (int) (1.5 * (estTotEdges/numThread));
         startV = new int[numByte];
         endV = new int[numByte];
       } else  {
@@ -297,10 +301,10 @@ Barrier.enterBarrier();
        * Create edges in parallel
        */
       //int i_clique;
-      cp.createPartition(0, totCliques, myId, numThread, lss);
+      CreatePartition.createPartition(0, totCliques, myId, numThread, lss);
 
       for (int i_clique = lss.i_start; i_clique < lss.i_stop; i_clique++) {
-
+        
         /*
          * Get current clique parameters
          */
@@ -349,11 +353,17 @@ Barrier.enterBarrier();
         } /* for i */
 
         if (i_cliqueSize != 1) {
-          int randNumEdges = randomPtr.random_generate() % (2*i_cliqueSize*glb.MAX_PARAL_EDGES);
+          int randNumEdges = (int) (randomPtr.random_generate() % (2*i_cliqueSize*glb.MAX_PARAL_EDGES));
+          if(randNumEdges < 0)
+            randNumEdges *= -1; //TODO fix the long->int casting error that creates negative numbers for randomPtr
           //int i_paralEdge;
           for (int i_paralEdge = 0; i_paralEdge < randNumEdges; i_paralEdge++) {
             int i = (int) (randomPtr.random_generate() % i_cliqueSize);
+            if(i < 0)
+              i *= -1; //TODO fix the long->int casting error that creates negative numbers for randomPtr
             int j = (int) (randomPtr.random_generate() % i_cliqueSize);
+            if(j < 0)
+              j *= -1; //TODO fix the long->int casting error that creates negative numbers for randomPtr
             if ((i != j) && (tmpEdgeCounter[i][j] < glb.MAX_PARAL_EDGES)) {
               float r = (float)(randomPtr.random_generate() % 1000) / (float)1000;
               if (r >= p) {
@@ -379,16 +389,16 @@ Barrier.enterBarrier();
       int[] i_edgeEndCounter;
 
       if (myId == 0) {
-        i_edgeStartCounter = new int[ numThread];
-        global_i_edgeStartCounter = i_edgeStartCounter;
+        i_edgeStartCounter = new int[numThread];
+        gsd.global_i_edgeStartCounter = i_edgeStartCounter;
         i_edgeEndCounter = new int[numThread];
-        global_i_edgeEndCounter = i_edgeEndCounter;
+        gsd.global_i_edgeEndCounter = i_edgeEndCounter;
       }
 
       Barrier.enterBarrier();
 
-      i_edgeStartCounter = global_i_edgeStartCounter;
-      i_edgeEndCounter   = global_i_edgeEndCounter;
+      i_edgeStartCounter = gsd.global_i_edgeStartCounter;
+      i_edgeEndCounter   = gsd.global_i_edgeEndCounter;
 
       i_edgeEndCounter[myId] = i_edgePtr;
       i_edgeStartCounter[myId] = 0;
@@ -403,12 +413,12 @@ Barrier.enterBarrier();
       }
 
       atomic {
-        global_edgeNum = global_edgeNum + i_edgePtr;
+        gsd.global_edgeNum = gsd.global_edgeNum + i_edgePtr;
       }
 
       Barrier.enterBarrier();
 
-      int edgeNum = global_edgeNum;
+      int edgeNum = gsd.global_edgeNum;
 
       /*
        * Initialize edge list arrays
@@ -427,14 +437,14 @@ Barrier.enterBarrier();
           startVertex = new int[numByte];
           endVertex = new int[numByte];
         }
-        global_startVertex = startVertex;
-        global_endVertex = endVertex;
+        gsd.global_startVertex = startVertex;
+        gsd.global_endVertex = endVertex;
       }
 
       Barrier.enterBarrier();
 
-      startVertex = global_startVertex;
-      endVertex = global_endVertex;
+      startVertex = gsd.global_startVertex;
+      endVertex = gsd.global_endVertex;
 
       for (int i =  i_edgeStartCounter[myId]; i <  i_edgeEndCounter[myId]; i++) {
         startVertex[i] = startV[i-i_edgeStartCounter[myId]];
@@ -450,13 +460,13 @@ Barrier.enterBarrier();
        */
 
       i_edgePtr = 0;
-      p = PROB_INTERCL_EDGES;
+      p = glb.PROB_INTERCL_EDGES;
 
       /*
        * Generating inter-clique edges as given in the specs
        */
 
-      cp.createPartition(0, glb.TOT_VERTICES, myId, numThread, lss);
+      CreatePartition.createPartition(0, glb.TOT_VERTICES, myId, numThread, lss);
 
       for (int i = lss.i_start; i < lss.i_stop; i++) {
         int tempVertex1 = i;
@@ -492,7 +502,8 @@ Barrier.enterBarrier();
         int t1 = firstVsInCliques[t];
 
         //int d;
-        for (int d = 1, p = glb.PROB_INTERCL_EDGES; d < glb.TOT_VERTICES; d *= 2, p /= 2) {
+        p = glb.PROB_INTERCL_EDGES;
+        for (int d = 1; d < glb.TOT_VERTICES; d *= 2, p /= 2) {
 
           float r = (float)(randomPtr.random_generate() % 1000) / (float)1000;
 
@@ -504,7 +515,7 @@ Barrier.enterBarrier();
             l = 0;
             t = -1;
             while (h - l > 1) {
-              int m = (((h + l) / 2);
+              int m = (h + l) / 2;
               if (tempVertex2 >= firstVsInCliques[m]) {
                 l = m;
               } else {
@@ -534,7 +545,9 @@ Barrier.enterBarrier();
 
             if (t1 != t2) {
               int randNumEdges =
-                randomPtr.random_generate() % glb.MAX_PARAL_EDGES + 1;
+                (int) (randomPtr.random_generate() % glb.MAX_PARAL_EDGES + 1);
+              if(randNumEdges < 0)
+                randNumEdges *= -1; //TODO fix the long->int casting error that creates negative numbers for randomPtr
               //int j;
               for (int j = 0; j < randNumEdges; j++) {
                 startV[i_edgePtr] = tempVertex1;
@@ -583,7 +596,9 @@ Barrier.enterBarrier();
 
             if (t1 != t2) {
               int randNumEdges =
-                randomPtr.random_generate() % glb.MAX_PARAL_EDGES + 1;
+                (int) (randomPtr.random_generate() % glb.MAX_PARAL_EDGES + 1);
+              if(randNumEdges < 0) 
+                randNumEdges *= -1; //TODO fix the long->int casting error that creates negative numbers for randomPtr
               for (int j = 0; j <  randNumEdges; j++) {
                 startV[i_edgePtr] = tempVertex1;
                 endV[i_edgePtr] = tempVertex2;
@@ -602,7 +617,7 @@ Barrier.enterBarrier();
       i_edgeStartCounter[myId] = 0;
 
       if (myId == 0) {
-        global_edgeNum = 0;
+        gsd.global_edgeNum = 0;
       }
 
       Barrier.enterBarrier();
@@ -615,15 +630,15 @@ Barrier.enterBarrier();
       }
 
       atomic {
-        global_edgeNum = global_edgeNum + i_edgePtr;
+        gsd.global_edgeNum = gsd.global_edgeNum + i_edgePtr;
       }
 
       Barrier.enterBarrier();
 
-      edgeNum = global_edgeNum;
-      int numEdgesPlacedOutside = global_edgeNum;
+      edgeNum = gsd.global_edgeNum;
+      int numEdgesPlacedOutside = gsd.global_edgeNum;
 
-      for (int i = (i_edgeStartCounter[myId]; i <  i_edgeEndCounter[myId]; i++) {
+      for (int i = i_edgeStartCounter[myId]; i <  i_edgeEndCounter[myId]; i++) {
         startVertex[i+numEdgesPlacedInCliques] = startV[i-i_edgeStartCounter[myId]];
         endVertex[i+numEdgesPlacedInCliques] = endV[i-i_edgeStartCounter[myId]];
       }
@@ -656,13 +671,15 @@ Barrier.enterBarrier();
       p = glb.PERC_INT_WEIGHTS;
       int numStrWtEdges  = 0;
 
-      cp.createPartition(0, numEdgesPlaced, myId, numThread, lss);
+      CreatePartition.createPartition(0, numEdgesPlaced, myId, numThread, lss);
 
       for (int i = lss.i_start; i < lss.i_stop; i++) {
         float r = (float)(randomPtr.random_generate() % 1000) / (float)1000;
         if (r <= p) {
           SDGdataPtr.intWeight[i] =
-            1 + (randomPtr.random_generate() % (MAX_INT_WEIGHT-1));
+            (int) (1 + (randomPtr.random_generate() % (glb.MAX_INT_WEIGHT-1)));
+          if(SDGdataPtr.intWeight[i] < 0)
+            SDGdataPtr.intWeight[i] *= -1; //TODO fix the long->int casting error that creates negative numbers for randomPtr
         } else {
           SDGdataPtr.intWeight[i] = -1;
           numStrWtEdges++;
@@ -682,12 +699,12 @@ Barrier.enterBarrier();
       }
 
       atomic {
-        global_numStrWtEdges = global_numStrWtEdges + numStrWtEdges;
+        gsd.global_numStrWtEdges = gsd.global_numStrWtEdges + numStrWtEdges;
       }
 
       Barrier.enterBarrier();
 
-      numStrWtEdges = global_numStrWtEdges;
+      numStrWtEdges = gsd.global_numStrWtEdges;
 
       if (myId == 0) {
         SDGdataPtr.strWeight = new char[numStrWtEdges * glb.MAX_STRLEN];
@@ -695,7 +712,7 @@ Barrier.enterBarrier();
 
       Barrier.enterBarrier();
 
-      cp.createPartition(0, numEdgesPlaced, myId, numThread, lss);
+      CreatePartition.createPartition(0, numEdgesPlaced, myId, numThread, lss);
 
       for (int i = lss.i_start; i < lss.i_stop; i++) {
         if (SDGdataPtr.intWeight[i] <= 0) {
@@ -714,15 +731,18 @@ Barrier.enterBarrier();
 
       if (myId == 0) {
 
-        if (SOUGHT_STRING.length != glb.MAX_STRLEN) {
-          glb.SOUGHT_STRING = new char[MAX_STRLEN];
+        if (glb.SOUGHT_STRING.length != glb.MAX_STRLEN) {
+          glb.SOUGHT_STRING = new char[glb.MAX_STRLEN];
+          //glb.SOUGHT_STRING = new String(MAX_STRLEN);
         }
 
-        int t = randomPtr.random_generate() % numStrWtEdges;
+        int t = (int) (randomPtr.random_generate() % numStrWtEdges);
+        if (t < 0) 
+          t *= -1; //TODO fix the long->int casting error that creates negative numbers for randomPtr
         for (int j = 0; j < glb.MAX_STRLEN; j++) {
           //FIXME
-          SOUGHT_STRING[j] =
-            (char) (SDGdataPtr.strWeight[(t*glb.MAX_STRLEN+j)]);
+          glb.SOUGHT_STRING[j] =
+             SDGdataPtr.strWeight[(t*glb.MAX_STRLEN+j)];
         }
 
       }
@@ -734,8 +754,8 @@ Barrier.enterBarrier();
        */
 
       for (int i = lss.i_start; i < lss.i_stop; i++) {
-        startVertex[i] = permV[(startVertex[i])];
-        endVertex[i] = permV[(endVertex[i])];
+        startVertex[i] = permV[startVertex[i]];
+        endVertex[i] = permV[endVertex[i]];
       }
 
       Barrier.enterBarrier();
@@ -756,11 +776,16 @@ Barrier.enterBarrier();
 
       Barrier.enterBarrier();
 
-      Alg_Radix_Smp.all_radixsort_node_aux_s3(numEdgesPlaced,
+      //Alg_Radix_Smp radixsort = new Alg_Radix_Smp(myId, numThread);
+      //radixsort.all_radixsort_node_aux_s3(numEdgesPlaced,
+      Alg_Radix_Smp.all_radixsort_node_aux_s3(myId,
+          numThread,
+          numEdgesPlaced,
           startVertex,
           SDGdataPtr.startVertex,
           endVertex,
-          SDGdataPtr.endVertex);
+          SDGdataPtr.endVertex,
+          radixsort);
 
       Barrier.enterBarrier();
 
@@ -830,7 +855,7 @@ Barrier.enterBarrier();
         if (myId == 0) {
 
           tempIndex = new int[glb.TOT_VERTICES + 1];
-          global_tempIndex = tempIndex;
+          gsd.global_tempIndex = tempIndex;
 
           /*
            * Update degree of each vertex
@@ -859,7 +884,7 @@ Barrier.enterBarrier();
 
         Barrier.enterBarrier();
 
-        tempIndex = global_tempIndex;
+        tempIndex = gsd.global_tempIndex;
 
         /*
          * Insertion sort for now, replace with something better later on
index c74f3e48788f4b4af6faf27126071658c7e4412d..8402cfd81b926c34c1eb11dbaed92deacfc1e9e7 100644 (file)
  */
 public class GetUserParameters {
 
-  Globals glb;
-
   public GetUserParameters(Globals glb) {
-    this.glb = glb;
-
     /*
      * Scalable Data Generator parameters - defaults
      */
     glb.THREADS             = 1;
     glb.SCALE               = 20;              /* binary scaling heuristic */
     glb.MAX_PARAL_EDGES     = 3;               /* between vertices. */
-    glb.PERC_INT_WEIGHTS    = 0.6;             /* % int (vs. string) edge weights */
-    glb.PROB_UNIDIRECTIONAL = 0.1;
-    glb.PROB_INTERCL_EDGES  = 0.5;             /* Init probability link between cliques */
+    glb.PERC_INT_WEIGHTS    = (float) 0.6f;             /* % int (vs. string) edge weights */
+    glb.PROB_UNIDIRECTIONAL = (float) 0.1f;
+    glb.PROB_INTERCL_EDGES  = (float) 0.5f;             /* Init probability link between cliques */
 
     glb.SUBGR_EDGE_LENGTH   = 3;               /* Kernel 3: max. path length,       */
                                                /* measured by num edges in subgraph */
@@ -76,24 +72,24 @@ public class GetUserParameters {
     glb.K3_DS               = 2;               /* 0 - Array         */
                                                /* 1 - Linked List   */
                                                /* 2 - Dynamic Array */
-
   }
+
   /* =============================================================================
    * displayUsage
    * =============================================================================
    */
-  static void
+  public static void
     displayUsage ()
     {
-      System.out.println("Usage: ./SSCA.bin [options]\n");
-      System.out.println("    i <double>    Probability [i]nter-clique      (%f)\n",  PROB_INTERCL_EDGES);
-      System.out.println("    k <int>   [k]ind: 0=array 1=list 2=vector (%li)\n", K3_DS);
-      System.out.println("    l <int>   Max path [l]ength               (%li)\n", SUBGR_EDGE_LENGTH);
-      System.out.println("    p <int>   Max [p]arallel edges            (%li)\n", MAX_PARAL_EDGES);
-      System.out.println("    s <int>   Problem [s]cale                 (%li)\n", SCALE);
-      System.out.println("    t <int>   Number of [t]hreads             (%li)\n", THREADS);
-      System.out.println("    u <double>    Probability [u]nidirectional    (%f)\n",  PROB_UNIDIRECTIONAL);
-      System.out.println("    w <double>    Fraction integer [w]eights      (%f)\n",  PERC_INT_WEIGHTS);
+      System.out.println("Usage: ./SSCA.bin [options]");
+      System.out.println("    i <float>    Probability [i]nter-clique      ");
+      System.out.println("    k <int>   [k]ind: 0=array 1=list 2=vector ");
+      System.out.println("    l <int>   Max path [l]ength               ");
+      System.out.println("    p <int>   Max [p]arallel edges            ");
+      System.out.println("    s <int>   Problem [s]cale                 ");
+      System.out.println("    t <int>   Number of [t]hreads             ");
+      System.out.println("    u <float>    Probability [u]nidirectional    ");
+      System.out.println("    w <float>    Fraction integer [w]eights      ");
       System.exit(-1);
     }
 
@@ -102,8 +98,8 @@ public class GetUserParameters {
    * parseArgs
    * =============================================================================
    */
-  public static void
-    parseArgs(String[] args)
+  public void
+    parseArgs(String[] args, Globals glb)
     {
       int i = 0;
       String arg;
@@ -112,13 +108,13 @@ public class GetUserParameters {
         //check options
         if(arg.equals("-i")) {
           if(i < args.length) {
-            glb.PROB_INTERCL_EDGES = new Integer(args[i++]).doubleValue();
+            glb.PROB_INTERCL_EDGES = new Integer(args[i++]).floatValue();
           }
         } else if(arg.equals("-k")) {
           if(i < args.length) {
             glb.K3_DS = new Integer(args[i++]).intValue();
           }
-          if(!(glb.K3_DS >=0 && K3_DS <=2))
+          if(!(glb.K3_DS >=0 && glb.K3_DS <=2))
             System.out.println("Input a valid number for -k option between >=0 and <= 2");
         } else if(arg.equals("-l")) {
           if(i < args.length) {
@@ -138,11 +134,11 @@ public class GetUserParameters {
           }
         } else if(arg.equals("-u")) {
           if(i < args.length) {
-            glb.PROB_UNIDIRECTIONAL = new Integer(args[i++]).doubleValue();
+            glb.PROB_UNIDIRECTIONAL = new Integer(args[i++]).floatValue();
           }
         } else if(arg.equals("-w")) {
           if(i < args.length) {
-            glb.PERC_INT_WEIGHTS = new Integer(args[i++]).doubleValue();
+            glb.PERC_INT_WEIGHTS = new Integer(args[i++]).floatValue();
           }
         } else if(arg.equals("-h")) {
           displayUsage();
@@ -157,8 +153,8 @@ public class GetUserParameters {
    * getUserParameters
    * =============================================================================
    */
-  static void
-    getUserParameters (String[] argv)
+  public void
+    getUserParameters (String[] argv, Globals glb)
     {
       /*
        * Scalable Data Generator parameters - defaults
@@ -167,9 +163,9 @@ public class GetUserParameters {
       glb.THREADS             = 1;
       glb.SCALE               = 20;              /* binary scaling heuristic */
       glb.MAX_PARAL_EDGES     = 3;               /* between vertices. */
-      glb.PERC_INT_WEIGHTS    = 0.6;             /* % int (vs. string) edge weights */
-      glb.PROB_UNIDIRECTIONAL = 0.1;
-      glb.PROB_INTERCL_EDGES  = 0.5;             /* Init probability link between cliques */
+      glb.PERC_INT_WEIGHTS    = (float)0.6;             /* % int (vs. string) edge weights */
+      glb.PROB_UNIDIRECTIONAL = (float)0.1;
+      glb.PROB_INTERCL_EDGES  = (float)0.5;             /* Init probability link between cliques */
 
       glb.SUBGR_EDGE_LENGTH   = 3;               /* Kernel 3: max. path length,       */
       /* measured by num edges in subgraph */
@@ -184,7 +180,7 @@ public class GetUserParameters {
       /* 1 - Linked List   */
       /* 2 - Dynamic Array */
 
-      parseArgs(argv); /* overrides default values set above */
+      parseArgs(argv, glb); /* overrides default values set above */
 
 
       glb.TOT_VERTICES        = (1<<glb.SCALE);
@@ -192,7 +188,7 @@ public class GetUserParameters {
       glb.MAX_INT_WEIGHT      = (1<<glb.SCALE);      /* Max int value in edge weight */
       glb.MAX_STRLEN          = glb.SCALE;
 
-      glb.SOUGHT_STRING       = "";              /* Kernel 2: Character string sought:  */
+      glb.SOUGHT_STRING       = new char[1];              /* Kernel 2: Character string sought:  */
       /* specify here, else it is picked     */
       /* picked from randomly selected entry */
       /* in genScalData.c                    */
index 1c64acb979a1295b724d25cde204dca866b4c215..0daafa8847a2d363e54a2205248ec30166d92eb4 100644 (file)
@@ -60,7 +60,6 @@ public class Globals {
   public float PROB_INTERCL_EDGES;
   public int SUBGR_EDGE_LENGTH;
   public int MAX_CLUSTER_SIZE;
-  public int MAX_STRLEN;
   public int K3_DS;
   public int THREADS;
 }
index d41b12364c2fb820079808b2779de6874058e4bb..a649ff4652c093ec5f355884c5a7972cad19b2c3 100644 (file)
@@ -14,9 +14,9 @@ public class Graph {
   public int[] outVertexList;
   public int[] paralEdgeIndex;
 
-  public int inDegree;
-  public int inVertexIndex;
-  public int inVertexList;
+  public int[] inDegree;
+  public int[] inVertexIndex;
+  public int[] inVertexList;
 
   public int[]  intWeight;
   public char[] strWeight;
index 7555726d395babc64f6aa9de3abb742b076b9434..81e1e34ec5bfbc73bc00a41f47b79b2c5fa972c3 100644 (file)
@@ -3,12 +3,7 @@ public class LocalStartStop {
   int i_stop;
 
   public LocalStartStop() {
-    i_start = 0L;
-    i_stop = 0L;
-  }
-
-  public static void init() {
-    i_start = 0L;
-    i_stop = 0L;
+    i_start = 0;
+    i_stop = 0;
   }
 }
index 0ef14b998e8fa2ce5d684f9ca931990bb4fe8a63..73eedd3e5b899af77aa3dbc5be5767a47f419990 100644 (file)
@@ -25,16 +25,12 @@ Compiling and Running
 
 To build the application, simply run:
 
-    make -f <makefile>
+    make
 
-in the source directory. For example, for the sequential flavor, run:
-
-    make -f Makefile.seq
-
-By default, this produces an executable named "yada", which can then be
+By default, this produces an executable named "SSCA2.bin", which can then be
 run in the following manner:
 
-    ./ssca2 -i <probability_of_inter_clique> \
+    ./SSCA2.bin -i <probability_of_inter_clique> \
             -k <data_structure_kind> \
             -l <max_path_length> \
             -p <max_number_of_parallel_edges> \
@@ -45,11 +41,11 @@ run in the following manner:
 
 The following arguments are recommended for simulated runs:
 
-    -s13 -i1.0 -u1.0 -l3 -p3
+    -s 13 -i 1.0 -u 1.0 -l 3 -p 3 -t 1
 
 For non-simulator runs, a larger input can be used:
 
-    -s20 -i1.0 -u1.0 -l3 -p3
+    -s 20 -i 1.0 -u 1.0 -l 3 -p 3 -t 1
 
 
 References
diff --git a/Robust/src/Benchmarks/SingleTM/SSCA2/SSCA2.java b/Robust/src/Benchmarks/SingleTM/SSCA2/SSCA2.java
new file mode 100644 (file)
index 0000000..b8a20f1
--- /dev/null
@@ -0,0 +1,385 @@
+/* =============================================================================
+ *
+ * ssca2.java
+ *
+ * =============================================================================
+ * 
+ * Unless otherwise noted, the following license applies to STAMP files:
+ * 
+ * Copyright (c) 2007, Stanford University
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ * 
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ * 
+ *     * Neither the name of Stanford University nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * =============================================================================
+ */
+
+public class SSCA2 extends Thread {
+  /*
+   * Tuple for Scalable Data Generation
+   * stores startVertex, endVertex, long weight and other info
+   */
+  GraphSDG SDGdata;
+
+  /**
+   * The graph data structure for this benchmark - see defs.h
+   **/
+  Graph G;
+
+  /**
+   *
+   */
+  ComputeGraph computeGraphArgs;
+
+  /**
+   * thread id
+   **/
+  int threadid;
+
+  /**
+   * Total number of threads
+   **/
+  int numThread;
+
+  /**
+   * Global Arguments 
+   **/
+  Globals glb;
+
+
+  /**
+   *  Gen scalable data
+   **/
+  GenScalData gsd;
+
+  /**
+   **
+   **/
+  GetStartLists getStartListsArg;
+
+
+  Alg_Radix_Smp radixsort;
+
+  public SSCA2(int myId, int numThread, Globals glb, ComputeGraph computeGraphArgs, 
+      GenScalData gsd, GetStartLists getStartListsArg, Alg_Radix_Smp radixsort) {
+    this.threadid = myId;
+    this.numThread = numThread;
+    this.glb = glb;
+    this.computeGraphArgs = computeGraphArgs;
+    this.G = computeGraphArgs.GPtr;
+    this.SDGdata = computeGraphArgs.SDGdataPtr;
+    this.gsd = gsd;
+    this. getStartListsArg = getStartListsArg;
+    this.radixsort = radixsort;
+  }
+
+  public void run() {
+
+#ifdef ENABLE_KERNEL1
+    /* Generate Scaldata */
+    Barrier.enterBarrier();
+    GenScalData.genScalData(threadid, numThread, glb, SDGdata, gsd, radixsort);
+    Barrier.enterBarrier();
+
+    /* Kernel 1 */
+    Barrier.enterBarrier();
+    ComputeGraph.computeGraph(threadid, numThread, glb, computeGraphArgs);
+    Barrier.enterBarrier();
+#endif /* Enable Kernel1 */
+
+#ifdef ENABLE_KERNEL2
+    /* Kernel 2 */
+    Barrier.enterBarrier();
+    GetStartLists.getStartLists(threadid, numThread, glb, getStartListsArg);
+    Barrier.enterBarrier();
+#endif /* Enable Kernel2 */
+  }   
+
+  /* =============================================================================
+   * main
+   * =============================================================================
+   */
+  public static void main(String[] args) {
+    /*
+     * Tuple for Scalable Data Generation
+     * stores startVertex, endVertex, long weight and other info
+     */
+    GraphSDG SDGdata = new GraphSDG();
+
+    /*
+     * The graph data structure for this benchmark - see defs.h
+     */
+    Graph G = new Graph();
+
+    /*
+     * The Global arguments
+     */
+    ComputeGraph computeGraphArgs = new ComputeGraph();
+
+    computeGraphArgs.GPtr       = G;
+    computeGraphArgs.SDGdataPtr = SDGdata;
+    /* -------------------------------------------------------------------------
+     * Preamble
+     * -------------------------------------------------------------------------
+     */
+
+    /*
+     * User Interface: Configurable parameters, and global program control
+     */
+
+    System.out.println("\nHPCS SSCA #2 Graph Analysis Executable Specification:");
+    System.out.println("\nRunning...\n\n");
+
+    Globals glb = new Globals();
+
+    GetUserParameters gup = new GetUserParameters(glb);
+    gup.getUserParameters(args, glb);
+
+    System.out.println("Number of processors:       " + glb.THREADS);
+    System.out.println("Problem Scale:              " + glb.SCALE);
+    System.out.println("Max parallel edges:         " + glb.MAX_PARAL_EDGES);
+    System.out.println("Percent int weights:        " + glb.PERC_INT_WEIGHTS);
+    System.out.println("Probability unidirectional: " + glb.PROB_UNIDIRECTIONAL);
+    System.out.println("Probability inter-clique:   " + glb.PROB_INTERCL_EDGES);
+    System.out.println("Subgraph edge length:       " + glb.SUBGR_EDGE_LENGTH);
+    System.out.println("Kernel 3 data structure:    " + glb.K3_DS);
+
+    /* Initiate Barriers */
+    Barrier.setBarrier(glb.THREADS);
+
+    SSCA2[] ssca = new SSCA2[glb.THREADS];
+    int nthreads = glb.THREADS;
+
+    GenScalData gsd = new GenScalData();
+
+    Alg_Radix_Smp radixsort = new Alg_Radix_Smp();
+
+    GetStartLists getStartListsArg = new GetStartLists();
+    getStartListsArg.GPtr                = G;
+
+    /* Create and Start Threads */
+    for(int i = 1; i<nthreads; i++) {
+      ssca[i] = new SSCA2(i, nthreads, glb, computeGraphArgs, gsd, getStartListsArg, radixsort);
+    }
+
+    for(int i = 1; i<nthreads; i++) {
+      ssca[i].start();
+    }
+
+
+#ifdef ENABLE_KERNEL1
+
+    /*
+     * Scalable Data Generator
+     */
+    System.out.println("\nScalable Data Generator - genScalData() beginning execution...\n");
+    parallel_work_genScalData(nthreads, glb, SDGdata, gsd, radixsort);
+    System.out.println("\n\tgenScalData() completed execution.");
+
+    /* -------------------------------------------------------------------------
+     * Kernel 1 - Graph Construction
+     *
+     * From the input edges, construct the graph 'G'
+     * -------------------------------------------------------------------------
+     */
+    System.out.println("\nKernel 1 - computeGraph() beginning execution...");
+    parallel_work_computeGraph(nthreads, glb, computeGraphArgs);
+    System.out.println("\n\tcomputeGraph() completed execution.\n");
+
+#endif
+
+
+#ifdef ENABLE_KERNEL2
+
+    /* -------------------------------------------------------------------------
+     * Kernel 2 - Find Max weight and sought string
+     * -------------------------------------------------------------------------
+     */
+
+    System.out.println("\nKernel 2 - getStartLists() beginning execution...\n");
+    parallel_work_getStartLists(nthreads, glb, getStartListsArg);
+    System.out.println("\n\tgetStartLists() completed execution.\n");
+
+#endif // ENABLE_KERNEL2 
+
+#ifdef ENABLE_KERNEL3
+
+#  ifndef ENABLE_KERNEL2
+#    error KERNEL3 requires KERNEL2
+#  endif
+#endif
+
+#ifdef ENABLE_KERNEL3
+
+    /* -------------------------------------------------------------------------
+     * Kernel 3 - Graph Extraction
+     * -------------------------------------------------------------------------
+     */
+    VList[] intWtVList = null;
+    VList[] strWtVList = null;
+
+    System.out.println("\nKernel 3 - FindSubGraphs() beginning execution...\n");
+
+    if (glb.K3_DS == 0) {
+      intWtVList = new VList[G.numVertices * getStartListsArg.maxIntWtListSize];
+      strWtVList = new VList[G.numVertices * getStartListsArg.soughtStrWtListSize];
+
+      FindSubGraphs0_arg_t findSubGraphs0Arg;
+      findSubGraphs0Arg.GPtr                = G;
+      findSubGraphs0Arg.intWtVList          = intWtVList;
+      findSubGraphs0Arg.strWtVList          = strWtVList;
+      findSubGraphs0Arg.maxIntWtList        = getStartListsArg.maxIntWtList;
+      findSubGraphs0Arg.maxIntWtListSize    = getStartListsArg.maxIntWtListSize;
+      findSubGraphs0Arg.soughtStrWtList     = getStartListsArg.soughtStrWtList;
+      findSubGraphs0Arg.soughtStrWtListSize = getStartListsArg.soughtStrWtListSize;
+
+      parallel_work_FindSubGraphs0(findSubGraphs0Arg);
+
+    } else if (K3_DS == 1) {
+
+      intWtVList = new VL[getStartListsArg.maxIntWtListSize];
+      strWtVList = new VL[getStartListsArg.soughtStrWtListSize];
+
+      FindSubGraphs1_arg_t findSubGraphs1Arg;
+      findSubGraphs1Arg.GPtr                = G;
+      findSubGraphs1Arg.intWtVLList         = intWtVLList;
+      findSubGraphs1Arg.strWtVLList         = strWtVLList;
+      findSubGraphs1Arg.maxIntWtList        = maxIntWtList;
+      findSubGraphs1Arg.maxIntWtListSize    = maxIntWtListSize;
+      findSubGraphs1Arg.soughtStrWtList     = soughtStrWtList;
+      findSubGraphs1Arg.soughtStrWtListSize = soughtStrWtListSize;
+
+      parallel_work_FindSubGraphs1(findSubGraphs1Arg);
+
+    } else if (K3_DS == 2) {
+
+      intWtVList = new VL[getStartListsArg.maxIntWtListSize];
+      strWtVList = new VL[getStartListsArg.soughtStrWtListSize];
+
+      FindSubGraphs2_arg_t findSubGraphs2Arg;
+      findSubGraphs2Arg.GPtr                = G;
+      findSubGraphs2Arg.intWtVDList         = intWtVDList;
+      findSubGraphs2Arg.strWtVDList         = strWtVDList;
+      findSubGraphs2Arg.maxIntWtList        = maxIntWtList;
+      findSubGraphs2Arg.maxIntWtListSize    = maxIntWtListSize;
+      findSubGraphs2Arg.soughtStrWtList     = soughtStrWtList;
+      findSubGraphs2Arg.soughtStrWtListSize = soughtStrWtListSize;
+
+      parallel_work_FindSubGraphs2(findSubGraphs2Arg);
+
+    } else {
+      ;
+    }
+
+    System.out.println("\n\tFindSubGraphs() completed execution.\n");
+    System.out.println("\nTime taken for kernel 3 is %9.6f sec.\n\n", time);
+
+#endif /* ENABLE_KERNEL3 */
+
+#ifdef ENABLE_KERNEL4
+
+    /* -------------------------------------------------------------------------
+     * Kernel 4 - Graph Clustering
+     * -------------------------------------------------------------------------
+     */
+
+    System.out.println("\nKernel 4 - cutClusters() beginning execution...\n");
+    parallel_work_cutClusters(G);
+    System.out.println("\n\tcutClusters() completed execution.\n");
+
+#endif /* ENABLE_KERNEL4 */
+
+    System.exit(0);
+  }
+
+  /**
+   * Work done by primary thread in parallel with other threads
+   **/
+#ifdef ENABLE_KERNEL1
+
+  public static void parallel_work_genScalData(int numThread, Globals glb, GraphSDG SDGdata, GenScalData gsd, Alg_Radix_Smp radixsort) {
+    Barrier.enterBarrier();
+    GenScalData.genScalData(0, numThread, glb, SDGdata, gsd, radixsort); // threadId = 0 because primary thread
+    Barrier.enterBarrier();
+  }
+
+  public static void parallel_work_computeGraph(int numThread, Globals glb, ComputeGraph computeGraphArgs) {
+    Barrier.enterBarrier();
+    ComputeGraph.computeGraph(0, numThread, glb, computeGraphArgs);
+    Barrier.enterBarrier();
+  }
+
+#endif
+
+#ifdef ENABLE_KERNEL2
+
+  public static void parallel_work_getStartLists(int numThread, Globals glb, GetStartLists getStartListsArg) {
+    Barrier.enterBarrier();
+    GetStartLists.getStartLists(0, numThread, glb, getStartListsArg);
+    Barrier.enterBarrier();
+  }
+
+#endif
+
+#ifdef ENABLE_KERNEL3
+
+  public static void parallel_work_FindSubGraphs0(FindSubGraphs0_arg_t findSubGraphs0Arg) {
+    Barrier.enterBarrier();
+    Barrier.enterBarrier();
+  }
+
+  public static void parallel_work_FindSubGraphs1(FindSubGraphs1_arg_t findSubGraphs1Arg) {
+    Barrier.enterBarrier();
+    Barrier.enterBarrier();
+  }
+
+  public static void parallel_work_FindSubGraphs2(FindSubGraphs2_arg_t findSubGraphs2Arg) {
+    Barrier.enterBarrier();
+    Barrier.enterBarrier();
+  }
+
+#endif
+
+#ifdef ENABLE_KERNEL4
+
+  public static void parallel_work_cutClusters(Graph G) {
+    Barrier.enterBarrier();
+    Barrier.enterBarrier();
+  }
+
+#endif
+
+}
+
+/* =============================================================================
+ *
+ * End of ssca2.java
+ *
+ * =============================================================================
+ */
index c47a335200bab068124c428b83f4cdbaf59055ac..2d9da95b41ff72b1329fde5387dc941e08dcb3c1 100644 (file)
@@ -1,10 +1,9 @@
 /* Vertex list returned by Kernel 3 */
 public class VList {
-  public long num;
-  public long depth;
+  public int num;
+  public int depth;
 
   public VList() {
 
   }
-
 }
diff --git a/Robust/src/Benchmarks/SingleTM/common/Random.java b/Robust/src/Benchmarks/SingleTM/common/Random.java
new file mode 100644 (file)
index 0000000..9cb065a
--- /dev/null
@@ -0,0 +1,92 @@
+public class Random {
+  long[] mt; 
+  int mti;
+  long RANDOM_DEFAULT_SEED;
+  /* period parameter */
+  int N;
+  int M;
+  long MATRIX_A;
+  long UPPER_MASK;
+  long LOWER_MASK;
+
+  public Random() {
+    RANDOM_DEFAULT_SEED = 0L;
+    N = 624;
+    M = 397;
+    mt = new long[N];
+    mti = N;
+    MATRIX_A = 0x9908b0dfL;   /* constant vector a */
+    UPPER_MASK = 0x80000000L; /* most significant w-r bits */
+    LOWER_MASK = 0x7fffffffL; /* least significant r bits */
+  }
+
+  public void random_alloc() {
+    init_genrand(this.RANDOM_DEFAULT_SEED);
+  }
+
+  /* initializes mt[N] with a seed */
+  public void init_genrand(long s) {
+    int mti;
+    mt[0]= s & 0xFFFFFFFFL;
+    for (mti=1; mti<N; mti++) {
+     mt[mti] = (1812433253L * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti);
+      /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
+      /* In the previous versions, MSBs of the seed affect   */
+      /* only MSBs of the array mt[].                        */
+      /* 2002/01/09 modified by Makoto Matsumoto             */
+      mt[mti] &= 0xFFFFFFFFL;
+      /* for >32 bit machines */
+    }
+    this.mti=mti;
+  }
+
+  public void random_seed(long seed) {
+    init_genrand(seed);
+  }
+
+  public long random_generate() {
+    return genrand_int32();
+  }
+
+  public long genrand_int32() {
+    long y;
+    long[] mag01= new long[2];
+    mag01[0] = 0x0L;
+    mag01[1] = MATRIX_A;
+    int mti = this.mti;
+
+    /* mag01[x] = x * MATRIX_A  for x=0,1 */
+
+    if (mti >= N) { /* generate N words at one time */
+      int kk;
+
+      if (mti == N+1)   /* if init_genrand() has not been called, */
+        init_genrand(5489L); /* a default initial seed is used */
+
+      for (kk=0;kk<N-M;kk++) {
+        y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
+        mt[kk] = mt[kk+M] ^ (y >> 1) ^ mag01[(int)(y & 0x1L)];
+      }
+      for (;kk<N-1;kk++) {
+        y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
+        mt[kk] = mt[kk+(M-N)] ^ (y >> 1) ^ mag01[(int)(y & 0x1L)];
+      }
+      y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK);
+      mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[(int)(y & 0x1L)];
+
+      mti = 0;
+    }
+
+    y = mt[mti++];
+
+    /* Tempering */
+    y ^= (y >> 11);
+    y ^= (y << 7) & 0x9d2c5680L;
+    y ^= (y << 15) & 0xefc60000L;
+    y ^= (y >> 18);
+
+    this.mti = mti;
+
+    return y;
+  }
+}
index 7bb38585a184dd55a6b76073a8950aece243e769..39f76d25d24f8468eb35424c6c9d028eb6ffa11c 100644 (file)
@@ -17,6 +17,10 @@ public class Integer {
     return (double)value;
   }
 
+  public float floatValue() {
+    return (float)value;
+  }
+
   public byte[] intToByteArray() {
     byte[] b = new byte[4];
     for (int i = 0; i < 4; i++) {
index 8cced84666526c282de338101b91eafdb82db3d0..fab702aeb9fb91e5dbc7519ba9b6416cfe99d6b9 100644 (file)
@@ -1653,7 +1653,7 @@ public class BuildCode {
                               FlatSESEExitNode stop,
                               PrintWriter output) {
 
-    System.out.println( "generating code, stop="+stop );
+    //System.out.println( "generating code, stop="+stop );
 
     /* Assign labels to FlatNode's if necessary.*/
     Hashtable<FlatNode, Integer> nodetolabel=assignLabels(first, stop);
@@ -1673,7 +1673,7 @@ public class BuildCode {
       visited.add(current_node);
       if (nodetolabel.containsKey(current_node)) {
 
-       System.out.println( "  *"+current_node+" preceeded with label "+nodetolabel.get(current_node) );
+       //System.out.println( "  *"+current_node+" preceeded with label "+nodetolabel.get(current_node) );
 
        output.println("L"+nodetolabel.get(current_node)+":");
       }
@@ -1762,9 +1762,11 @@ public class BuildCode {
        }
 
 
+    /*
        if( nodetolabel.get(nn) != null ) {
          System.out.println( "  "+nn+" has label "+nodetolabel.get(nn) );
        }
+    */
 
       }
     }