From: adash Date: Sat, 30 May 2009 01:39:13 +0000 (+0000) Subject: working version of SSCA2, X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=20494e560454fb2011136117f211f14b9eb9bdf6;p=IRC.git working version of SSCA2, gives out of memory errors for scale s > 17 does not use the joptimize flag for optimization --- diff --git a/Robust/src/Benchmarks/SingleTM/SSCA2/Alg_Radix_Smp.java b/Robust/src/Benchmarks/SingleTM/SSCA2/Alg_Radix_Smp.java index cd48fba1..e066a636 100644 --- a/Robust/src/Benchmarks/SingleTM/SSCA2/Alg_Radix_Smp.java +++ b/Robust/src/Benchmarks/SingleTM/SSCA2/Alg_Radix_Smp.java @@ -156,7 +156,6 @@ public class Alg_Radix_Smp { * q (elems/proc) must be a multiple of NODES * ============================================================================= */ - /* public void all_countsort_node_aux_seq (int q, int[] lKey, @@ -206,7 +205,6 @@ public class Alg_Radix_Smp { psHisto = null; myHisto = null; } -*/ /* ============================================================================= @@ -376,7 +374,6 @@ public class Alg_Radix_Smp { * q (elems/proc) must be a multiple of NODES * ============================================================================= */ - /* public void all_radixsort_node_aux_s3_seq (int q, int[] lKeys, @@ -397,7 +394,6 @@ public class Alg_Radix_Smp { lTemp = null; lTemp2 = null; } - */ /* ============================================================================= diff --git a/Robust/src/Benchmarks/SingleTM/SSCA2/ComputeGraph.java b/Robust/src/Benchmarks/SingleTM/SSCA2/ComputeGraph.java index 3a972217..346d0a31 100644 --- a/Robust/src/Benchmarks/SingleTM/SSCA2/ComputeGraph.java +++ b/Robust/src/Benchmarks/SingleTM/SSCA2/ComputeGraph.java @@ -124,7 +124,6 @@ public class ComputeGraph { } } - /* ============================================================================= * computeGraph * ============================================================================= @@ -133,12 +132,7 @@ public class ComputeGraph { computeGraph (int myId, int numThread, Globals glb, ComputeGraph computeGraphArgs) { - Barrier.enterBarrier(); - - //Graph GPtr = computeGraphArgs.GPtr; - //GraphSDG SDGdataPtr = computeGraphArgs.SDGdata; - //int j; int maxNumVertices = 0; int numEdgesPlaced = computeGraphArgs.SDGdataPtr.numEdgesPlaced; @@ -154,10 +148,10 @@ public class ComputeGraph { maxNumVertices = computeGraphArgs.SDGdataPtr.startVertex[i]; } } - + atomic { int tmp_maxNumVertices = computeGraphArgs.global_maxNumVertices; - int new_maxNumVertices = CreatePartition.MAX( tmp_maxNumVertices, maxNumVertices) + 1; + int new_maxNumVertices = ((CreatePartition.MAX(tmp_maxNumVertices, maxNumVertices)) + 1); computeGraphArgs.global_maxNumVertices = new_maxNumVertices; } @@ -166,7 +160,12 @@ public class ComputeGraph { maxNumVertices = computeGraphArgs.global_maxNumVertices; if (myId == 0) { - + //FIXME temp fix for array sizes equal to pow(2, glb.SCALE) + { + int realMaxNumVertices = (int) (Math.pow(2, glb.SCALE)); + if(maxNumVertices == realMaxNumVertices); + maxNumVertices++; + } computeGraphArgs.GPtr.numVertices = maxNumVertices; computeGraphArgs.GPtr.numEdges = numEdgesPlaced; computeGraphArgs.GPtr.intWeight = computeGraphArgs.SDGdataPtr.intWeight; @@ -181,7 +180,6 @@ public class ComputeGraph { } computeGraphArgs.GPtr.outDegree = new int[computeGraphArgs.GPtr.numVertices]; - computeGraphArgs.GPtr.outVertexIndex = new int[computeGraphArgs.GPtr.numVertices]; } @@ -270,8 +268,10 @@ public class ComputeGraph { Barrier.enterBarrier(); + outVertexListSize = computeGraphArgs.global_outVertexListSize; + if (myId == 0) { computeGraphArgs.GPtr.numDirectedEdges = outVertexListSize; computeGraphArgs.GPtr.outVertexList = new int[outVertexListSize]; @@ -314,7 +314,7 @@ public class ComputeGraph { int ii = (computeGraphArgs.GPtr.outVertexIndex[i]); int r = 0; computeGraphArgs.GPtr.paralEdgeIndex[ii] = i0; - computeGraphArgs.GPtr.outVertexList[ii] = computeGraphArgs.SDGdataPtr.endVertex[ i0]; + computeGraphArgs.GPtr.outVertexList[ii] = computeGraphArgs.SDGdataPtr.endVertex[i0]; r++; for (int t = (i0+1); t < j; t++) { if (computeGraphArgs.SDGdataPtr.endVertex[t] != @@ -433,7 +433,7 @@ public class ComputeGraph { } else { /* Use auxiliary array to store the implied edge */ /* Create an array if it's not present already */ - int[] a = null; + int[] a; if ((inDegree % glb.MAX_CLUSTER_SIZE) == 0) { a = new int[glb.MAX_CLUSTER_SIZE]; auxArr[v] = a; @@ -447,6 +447,7 @@ public class ComputeGraph { } } /* for i */ + Barrier.enterBarrier(); computeGraphArgs.prefix_sums(myId, numThread, computeGraphArgs.GPtr.inVertexIndex, computeGraphArgs.GPtr.inDegree, computeGraphArgs.GPtr.numVertices); diff --git a/Robust/src/Benchmarks/SingleTM/SSCA2/CreatePartition.java b/Robust/src/Benchmarks/SingleTM/SSCA2/CreatePartition.java index bc7a6b93..96c92741 100644 --- a/Robust/src/Benchmarks/SingleTM/SSCA2/CreatePartition.java +++ b/Robust/src/Benchmarks/SingleTM/SSCA2/CreatePartition.java @@ -54,7 +54,6 @@ 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; diff --git a/Robust/src/Benchmarks/SingleTM/SSCA2/GenScalData.java b/Robust/src/Benchmarks/SingleTM/SSCA2/GenScalData.java index 38e8e84e..8e624ab6 100644 --- a/Robust/src/Benchmarks/SingleTM/SSCA2/GenScalData.java +++ b/Robust/src/Benchmarks/SingleTM/SSCA2/GenScalData.java @@ -83,11 +83,628 @@ public class GenScalData { * genScalData_seq * ============================================================================= **/ - void - genScalData_seq (GraphSDG SDGdataPtr) + public static void + genScalData_seq (Globals glb, GraphSDG SDGdataPtr, GenScalData gsd, Alg_Radix_Smp radixsort) { - System.out.println("Call to genScalData_seq(), Unimplemented: TODO\n"); - System.exit(0); + /* + * STEP 0: Create the permutations required to randomize the vertices + */ + Random randomPtr = new Random(); + randomPtr.random_alloc(); + randomPtr.random_seed(0); + + int[] permV; /* the vars associated with the graph tuple */ + permV = new int[glb.TOT_VERTICES]; + + /* Initialize the array */ + for (int i = 0; i < glb.TOT_VERTICES; i++) { + permV[i] = i; + } + + for (int i = 0; i < glb.TOT_VERTICES; i++) { + int t1 = (int) (randomPtr.random_generate()); + if(t1 < 0) + t1*=(-1); + int t = i + t1 % (glb.TOT_VERTICES - i); + if (t != i) { + int t2 = permV[t]; + permV[t] = permV[i]; + permV[i] = t2; + } + } + + /* + * STEP 1: Create Cliques + */ + + int[] cliqueSizes; + + int estTotCliques = (int)(Math.ceil(1.5 * glb.TOT_VERTICES / ((1+glb.MAX_CLIQUE_SIZE)/2))); + + /* + * Allocate mem for Clique array + * Estimate number of clique required and pad by 50% + */ + cliqueSizes = new int[estTotCliques]; + + /* Generate random clique sizes. */ + for (int i = 0; i < estTotCliques; i++) { + 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 + } + + int totCliques = 0; + + /* + * Allocate memory for cliqueList + */ + + int[] lastVsInCliques; + int[] firstVsInCliques; + + lastVsInCliques = new int[estTotCliques]; + firstVsInCliques = new int[estTotCliques]; + + /* + * Sum up vertices in each clique to determine the lastVsInCliques array + */ + + lastVsInCliques[0] = cliqueSizes[0] - 1; + { + int i; + for (i = 1; i < estTotCliques; i++) { + lastVsInCliques[i] = cliqueSizes[i] + lastVsInCliques[i-1]; + if (lastVsInCliques[i] >= glb.TOT_VERTICES-1) { + break; + } + } + totCliques = i + 1; + } + + /* + * Fix the size of the last clique + */ + cliqueSizes[totCliques-1] = + glb.TOT_VERTICES - lastVsInCliques[totCliques-2] - 1; + lastVsInCliques[totCliques-1] = glb.TOT_VERTICES - 1; + + firstVsInCliques[0] = 0; + + + /* + * Compute start Vertices in cliques. + */ + for (int i = 1; i < totCliques; i++) { + firstVsInCliques[i] = lastVsInCliques[i-1] + 1; + } + + /* TODO: if required +#ifdef WRITE_RESULT_FILES + // Write the generated cliques to file for comparison with Kernel 4 + FILE* outfp = fopen("cliques.txt", "w"); + fSystem.out.println(outfp, "No. of cliques - %lu\n", totCliques); + for (i = 0; i < totCliques; i++) { + fSystem.out.println(outfp, "Clq %lu - ", i); + long j; + for (j = firstVsInCliques[i]; j <= lastVsInCliques[i]; j++) { + fSystem.out.println(outfp, "%lu ", permV[j]); + } + fSystem.out.println(outfp, "\n"); + } + fclose(outfp); +#endif +*/ + + /* + * STEP 2: Create the edges within the cliques + */ + + /* + * Estimate number of edges - using an empirical measure + */ + int estTotEdges; + if (glb.SCALE >= 12) { + estTotEdges = (int) (Math.ceil(((glb.MAX_CLIQUE_SIZE-1) * glb.TOT_VERTICES))); + } else { + estTotEdges = (int) (Math.ceil(1.2 * (((glb.MAX_CLIQUE_SIZE-1)*glb.TOT_VERTICES) + * ((1 + glb.MAX_PARAL_EDGES)/2) + glb.TOT_VERTICES*2))); + } + + /* + * Initialize edge counter + */ + int i_edgePtr = 0; + float p = glb.PROB_UNIDIRECTIONAL; + + /* + * Partial edgeLists + */ + + int[] startV; + int[] endV; + int numByte = estTotEdges; + startV = new int[numByte]; + endV = new int[numByte]; + + /* + * Tmp array to keep track of the no. of parallel edges in each direction + */ + int[][] tmpEdgeCounter = new int [glb.MAX_CLIQUE_SIZE][glb.MAX_CLIQUE_SIZE]; + + /* + * Create edges + */ + for (int i_clique = 0; i_clique < totCliques; i_clique++) { + + /* + * Get current clique parameters + */ + + int i_cliqueSize = cliqueSizes[i_clique]; + int i_firstVsInClique = firstVsInCliques[i_clique]; + + /* + * First create at least one edge between two vetices in a clique + */ + + for (int i = 0; i < i_cliqueSize; i++) { + for (int j = 0; j < i; j++) { + + float r = (float)( randomPtr.random_generate() % 1000) / (float)1000; + if (r >= p) { + + startV[i_edgePtr] = i + i_firstVsInClique; + endV[i_edgePtr] = j + i_firstVsInClique; + i_edgePtr++; + tmpEdgeCounter[i][j] = 1; + + startV[i_edgePtr] = j + i_firstVsInClique; + endV[i_edgePtr] = i + i_firstVsInClique; + i_edgePtr++; + tmpEdgeCounter[j][i] = 1; + + } else if (r >= 0.5) { + + startV[i_edgePtr] = i + i_firstVsInClique; + endV[i_edgePtr] = j + i_firstVsInClique; + i_edgePtr++; + tmpEdgeCounter[i][j] = 1; + tmpEdgeCounter[j][i] = 0; + + } else { + + startV[i_edgePtr] = j + i_firstVsInClique; + endV[i_edgePtr] = i + i_firstVsInClique; + i_edgePtr++; + tmpEdgeCounter[j][i] = 1; + tmpEdgeCounter[i][j] = 0; + + } + + } /* for j */ + } /* for i */ + + if (i_cliqueSize != 1) { + 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 + + 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) { + /* Copy to edge structure. */ + startV[i_edgePtr] = i + i_firstVsInClique; + endV[i_edgePtr] = j + i_firstVsInClique; + i_edgePtr++; + tmpEdgeCounter[i][j]++; + } + } + } + } + + } /* for i_clique */ + + /* + * Merge partial edge lists + */ + + int i_edgeStartCounter = 0; + int i_edgeEndCounter = i_edgePtr; + int edgeNum = i_edgePtr; + + /* + * Initialize edge list arrays + */ + + int[] startVertex; + int[] endVertex; + + if (glb.SCALE < 10) { + numByte = 2 * edgeNum; + startVertex = new int[numByte]; + endVertex = new int[numByte]; + } else { + numByte = (edgeNum + glb.MAX_PARAL_EDGES * glb.TOT_VERTICES); + startVertex = new int[numByte]; + endVertex = new int[numByte]; + } + + for (int i = i_edgeStartCounter; i < i_edgeEndCounter; i++) { + startVertex[i] = startV[i-i_edgeStartCounter]; + endVertex[i] = endV[i-i_edgeStartCounter]; + } + + int numEdgesPlacedInCliques = edgeNum; + + /* + * STEP 3: Connect the cliques + */ + + i_edgePtr = 0; + p = glb.PROB_INTERCL_EDGES; + + /* + * Generating inter-clique edges as given in the specs + */ + + for (int i = 0; i < glb.TOT_VERTICES; i++) { + + int tempVertex1 = i; + int h = totCliques; + int l = 0; + int t = -1; + while (h - l > 1) { + int m = (h + l) / 2; + if (tempVertex1 >= firstVsInCliques[m]) { + l = m; + } else { + if ((tempVertex1 < firstVsInCliques[m]) && (m > 0)) { + if (tempVertex1 >= firstVsInCliques[m-1]) { + t = m - 1; + break; + } else { + h = m; + } + } + } + } + + if (t == -1) { + int m; + for (m = (l + 1); m < h; m++) { + if (tempVertex1 1) { + int m = (h + l) / 2; + if (tempVertex2 >= firstVsInCliques[m]) { + l = m; + } else { + if ((tempVertex2 < firstVsInCliques[m]) && (m > 0)) { + if (firstVsInCliques[m-1] <= tempVertex2) { + t = m - 1; + break; + } else { + h = m; + } + } + } + } + + if (t == -1) { + int m; + for (m = (l + 1); m < h; m++) { + if (tempVertex2 < firstVsInCliques[m]) { + break; + } + } + t = m - 1; + } + + int t2 = firstVsInCliques[t]; + + if (t1 != t2) { + int randNumEdges = + (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; + i_edgePtr++; + } + } + + } /* r <= p */ + + float r0 = (float)(randomPtr.random_generate() % 1000) / (float)1000; + + if ((r0 <= p) && (i-d>=0)) { + + int tempVertex2 = (i-d) % glb.TOT_VERTICES; + + h = totCliques; + l = 0; + t = -1; + while (h - l > 1) { + int m = (h + l) / 2; + if (tempVertex2 >= firstVsInCliques[m]) { + l = m; + } else { + if ((tempVertex2 < firstVsInCliques[m]) && (m > 0)) { + if (firstVsInCliques[m-1] <= tempVertex2) { + t = m - 1; + break; + } else { + h = m; + } + } + } + } + + if (t == -1) { + int m; + for (m = (l + 1); m < h; m++) { + if (tempVertex2 < firstVsInCliques[m]) { + break; + } + } + t = m - 1; + } + + int t2 = firstVsInCliques[t]; + + if (t1 != t2) { + int randNumEdges = (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 (j = 0; j < randNumEdges; j++) { + startV[i_edgePtr] = tempVertex1; + endV[i_edgePtr] = tempVertex2; + i_edgePtr++; + } + } + + } /* r0 <= p && (i-d) > 0 */ + + } /* for d, p */ + + } /* for i */ + + + i_edgeEndCounter = i_edgePtr; + i_edgeStartCounter = 0; + + + edgeNum = i_edgePtr; + int numEdgesPlacedOutside = edgeNum; + + for (int i = i_edgeStartCounter; i < i_edgeEndCounter; i++) { + startVertex[i+numEdgesPlacedInCliques] = startV[i-i_edgeStartCounter]; + int a = i+numEdgesPlacedInCliques; + endVertex[i+numEdgesPlacedInCliques] = endV[i-i_edgeStartCounter]; + } + + int numEdgesPlaced = numEdgesPlacedInCliques + numEdgesPlacedOutside; + + SDGdataPtr.numEdgesPlaced = numEdgesPlaced; + + System.out.println("Finished generating edges"); + System.out.println("No. of intra-clique edges - " + numEdgesPlacedInCliques); + System.out.println("No. of inter-clique edges - " + numEdgesPlacedOutside); + System.out.println("Total no. of edges - " + numEdgesPlaced); + + /* + * STEP 4: Generate edge weights + */ + + SDGdataPtr.intWeight = new int[numEdgesPlaced]; + + p = glb.PERC_INT_WEIGHTS; + int numStrWtEdges = 0; + + for (int i = 0; i < numEdgesPlaced; i++) { + float r = (float)(randomPtr.random_generate() % 1000) / (float)1000; + if (r <= p) { + SDGdataPtr.intWeight[i] = + (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++; + } + } + + { + int t = 0; + for (int i = 0; i < numEdgesPlaced; i++) { + if (SDGdataPtr.intWeight[i] < 0) { + SDGdataPtr.intWeight[i] = -t; + t++; + } + } + } + + SDGdataPtr.strWeight = new char[numStrWtEdges * glb.MAX_STRLEN]; + + for (int i = 0; i < numEdgesPlaced; i++) { + if (SDGdataPtr.intWeight[i] <= 0) { + for (int j = 0; j < glb.MAX_STRLEN; j++) { + SDGdataPtr.strWeight[(-SDGdataPtr.intWeight[i])*glb.MAX_STRLEN+j] = + (char) (1 + randomPtr.random_generate() % 127); + } + } + } + + /* + * Choose SOUGHT STRING randomly if not assigned + */ + + if (glb.SOUGHT_STRING.length != glb.MAX_STRLEN) { + glb.SOUGHT_STRING = new char[glb.MAX_STRLEN]; + } + + { + int t = (int) (randomPtr.random_generate() % numStrWtEdges); + for (int j = 0; j < glb.MAX_STRLEN; j++) { + glb.SOUGHT_STRING[j] = + SDGdataPtr.strWeight[(t*glb.MAX_STRLEN+j)]; + } + } + + /* + * STEP 5: Permute Vertices + */ + + for (int i = 0; i < numEdgesPlaced; i++) { + startVertex[i] = permV[(startVertex[i])]; + endVertex[i] = permV[(endVertex[i])]; + } + + /* + * STEP 6: Sort Vertices + */ + + /* + * Radix sort with StartVertex as primary key + */ + + numByte = numEdgesPlaced; + SDGdataPtr.startVertex = new int[numByte]; + SDGdataPtr.endVertex = new int[numByte]; + + radixsort.all_radixsort_node_aux_s3_seq(numEdgesPlaced, + startVertex, + SDGdataPtr.startVertex, + endVertex, + SDGdataPtr.endVertex); + + if (glb.SCALE < 12) { + + /* + * Sort with endVertex as secondary key + */ + + int i0 = 0; + int i1 = 0; + int i = 0; + + while (i < numEdgesPlaced) { + + for (i = i0; i < numEdgesPlaced; i++) { + if (SDGdataPtr.startVertex[i] != + SDGdataPtr.startVertex[i1]) + { + i1 = i; + break; + } + } + + for (int j = i0; j < i1; j++) { + for (int k = j+1; k < i1; k++) { + if (SDGdataPtr.endVertex[k] < + SDGdataPtr.endVertex[j]) + { + int t = SDGdataPtr.endVertex[j]; + SDGdataPtr.endVertex[j] = SDGdataPtr.endVertex[k]; + SDGdataPtr.endVertex[k] = t; + } + } + } + + if (SDGdataPtr.startVertex[i0] != glb.TOT_VERTICES-1) { + i0 = i1; + } else { + for (int j=i0; j= 12 */ } @@ -303,7 +920,7 @@ Barrier.enterBarrier(); 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 */ @@ -355,7 +972,7 @@ Barrier.enterBarrier(); 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) @@ -530,7 +1147,6 @@ Barrier.enterBarrier(); } if (t == -1) { - //int m; int m; for (m = (l + 1); m < h; m++) { if (tempVertex2 < firstVsInCliques[m]) { @@ -547,7 +1163,6 @@ Barrier.enterBarrier(); (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; endV[i_edgePtr] = tempVertex2; @@ -717,8 +1332,7 @@ Barrier.enterBarrier(); if (SDGdataPtr.intWeight[i] <= 0) { for (int j = 0; j < glb.MAX_STRLEN; j++) { SDGdataPtr.strWeight[(-SDGdataPtr.intWeight[i])*glb.MAX_STRLEN+j] = - // (char) (1 + PRANDOM_GENERATE(stream) % 127); - //FIXME + //FIXME if needed (char) (1 + (randomPtr.random_generate() % 127)); } } @@ -732,16 +1346,14 @@ Barrier.enterBarrier(); 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 = (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 glb.SOUGHT_STRING[j] = - SDGdataPtr.strWeight[(t*glb.MAX_STRLEN+j)]; + SDGdataPtr.strWeight[(t*glb.MAX_STRLEN+j)]; } } @@ -775,8 +1387,6 @@ Barrier.enterBarrier(); Barrier.enterBarrier(); - //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, @@ -811,9 +1421,7 @@ Barrier.enterBarrier(); } } - //int j; for (int j = i0; j < i1; j++) { - //int k; for (int k = j+1; k < i1; k++) { if (SDGdataPtr.endVertex[k] < SDGdataPtr.endVertex[j]) @@ -828,9 +1436,7 @@ Barrier.enterBarrier(); if (SDGdataPtr.startVertex[i0] != glb.TOT_VERTICES-1) { i0 = i1; } else { - //int j; for (int j=i0; j=0 && glb.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"); + System.exit(0); + } } else if(arg.equals("-l")) { if(i < args.length) { glb.SUBGR_EDGE_LENGTH = new Integer(args[i++]).intValue(); @@ -145,8 +147,15 @@ public class GetUserParameters { } } - if(glb.THREADS == 0) + if(glb.THREADS == 0) { + System.out.println("Num processors cannot be Zero\n"); displayUsage(); + } + + if((glb.THREADS & (glb.THREADS -1)) != 0) { + System.out.println("Number of [t]hreads must be power of 2\n"); + displayUsage(); + } } /* ============================================================================= diff --git a/Robust/src/Benchmarks/SingleTM/SSCA2/SSCA2.java b/Robust/src/Benchmarks/SingleTM/SSCA2/SSCA2.java index f3d6211e..3d9117ff 100644 --- a/Robust/src/Benchmarks/SingleTM/SSCA2/SSCA2.java +++ b/Robust/src/Benchmarks/SingleTM/SSCA2/SSCA2.java @@ -100,13 +100,14 @@ public class SSCA2 extends Thread { } public void run() { - -#ifdef ENABLE_KERNEL1 +#ifdef USE_PARALLEL_DATA_GENERATION /* Generate Scaldata */ Barrier.enterBarrier(); GenScalData.genScalData(threadid, numThread, glb, SDGdata, gsd, radixsort); Barrier.enterBarrier(); +#endif +#ifdef ENABLE_KERNEL1 /* Kernel 1 */ Barrier.enterBarrier(); ComputeGraph.computeGraph(threadid, numThread, glb, computeGraphArgs); @@ -192,16 +193,23 @@ public class SSCA2 extends Thread { ssca[i].start(); } - -#ifdef ENABLE_KERNEL1 + System.out.println("\nScalable Data Generator - genScalData() beginning execution...\n"); +#ifdef USE_PARALLEL_DATA_GENERATION /* * Scalable Data Generator */ - System.out.println("\nScalable Data Generator - genScalData() beginning execution...\n"); parallel_work_genScalData(nthreads, glb, SDGdata, gsd, radixsort); + +#else + + GenScalData.genScalData_seq(glb, SDGdata, gsd, radixsort); + +#endif System.out.println("\n\tgenScalData() completed execution."); +#ifdef ENABLE_KERNEL1 + /* ------------------------------------------------------------------------- * Kernel 1 - Graph Construction * @@ -214,7 +222,6 @@ public class SSCA2 extends Thread { #endif - #ifdef ENABLE_KERNEL2 /* ------------------------------------------------------------------------- @@ -332,7 +339,8 @@ public class SSCA2 extends Thread { /** * Work done by primary thread in parallel with other threads **/ -#ifdef ENABLE_KERNEL1 + +#ifdef USE_PARALLEL_DATA_GENERATION public static void parallel_work_genScalData(int numThread, Globals glb, GraphSDG SDGdata, GenScalData gsd, Alg_Radix_Smp radixsort) { Barrier.enterBarrier(); @@ -340,6 +348,10 @@ public class SSCA2 extends Thread { Barrier.enterBarrier(); } +#endif + +#ifdef ENABLE_KERNEL1 + public static void parallel_work_computeGraph(int numThread, Globals glb, ComputeGraph computeGraphArgs) { Barrier.enterBarrier(); ComputeGraph.computeGraph(0, numThread, glb, computeGraphArgs);