From 722529aa416bfcb116ae1fe434131b8ad8683aa8 Mon Sep 17 00:00:00 2001 From: adash Date: Sat, 16 May 2009 00:39:38 +0000 Subject: [PATCH] use int and float data type for arrays/variables (Compatible with size used in C version) --- .../SingleTM/SSCA2/Alg_Radix_Smp.java | 188 +++++------ .../SingleTM/SSCA2/ComputeGraph.java | 225 +++++++------- .../src/Benchmarks/SingleTM/SSCA2/Edge.java | 6 +- .../SingleTM/SSCA2/GenScalData.java | 292 +++++++++--------- .../Benchmarks/SingleTM/SSCA2/Globals.java | 6 +- .../src/Benchmarks/SingleTM/SSCA2/Graph.java | 18 +- .../Benchmarks/SingleTM/SSCA2/GraphSDG.java | 10 +- .../SingleTM/SSCA2/LocalStartStop.java | 8 +- 8 files changed, 375 insertions(+), 378 deletions(-) diff --git a/Robust/src/Benchmarks/SingleTM/SSCA2/Alg_Radix_Smp.java b/Robust/src/Benchmarks/SingleTM/SSCA2/Alg_Radix_Smp.java index 595c2597..2e21f242 100644 --- a/Robust/src/Benchmarks/SingleTM/SSCA2/Alg_Radix_Smp.java +++ b/Robust/src/Benchmarks/SingleTM/SSCA2/Alg_Radix_Smp.java @@ -45,10 +45,10 @@ */ public class Alg_Radix_Smp { - long[] global_myHisto; - long[] global_psHisto; - long[] global_lTemp; - long[] global_lTemp2; + int[] global_myHisto; + int[] global_psHisto; + int[] global_lTemp; + int[] global_lTemp2; int myId; int numThread; @@ -62,7 +62,7 @@ public class Alg_Radix_Smp { } public int BITS(x, k, j) { - int retval = (int) ((x>>k) & ~(~0<>k) & ~(~0< 0) { - long add_value = p[NOSHARE(myId-1)]; + int add_value = p[NOSHARE(myId-1)]; for (j = start-1; j < end; j++) { result[j] += add_value; } @@ -130,13 +130,17 @@ public class ComputeGraph { * ============================================================================= */ public static void - computeGraph (int myId, int numThread, Graph GPtr, GraphSDG SDGdataPtrGlobals glb) + computeGraph (int myId, int numThread, Globals glb, ComputeGraph computeGraphArgs) + { Barrier.enterBarrier(); + //Graph GPtr = computeGraphArgs.GPtr; + //GraphSDG SDGdataPtr = computeGraphArgs.SDGdata; + int j; - long maxNumVertices = 0; - int numEdgesPlaced = SDGdataPtr.numEdgesPlaced; + int maxNumVertices = 0; + int numEdgesPlaced = computeGraphArgs.SDGdataPtr.numEdgesPlaced; /* * First determine the number of vertices by scanning the tuple @@ -146,20 +150,15 @@ public class ComputeGraph { CreatePartition.createPartition(0, numEdgesPlaced, myId, numThread, lss); for (int i = lss.i_start; i < lss.i_stop; i++) { - if (SDGdataPtr.startVertex[i] > maxNumVertices) { - maxNumVertices = SDGdataPtr.startVertex[i]; + if (computeGraphArgs.SDGdataPtr.startVertex[i] > maxNumVertices) { + maxNumVertices = computeGraphArgs.SDGdataPtr.startVertex[i]; } } atomic { - long tmp_maxNumVertices = global_maxNumVertices; - long new_maxNumVertices = CreatePartition.MAX((int) tmp_maxNumVertices, maxNumVertices) + 1; + int tmp_maxNumVertices = global_maxNumVertices; + int new_maxNumVertices = CreatePartition.MAX( tmp_maxNumVertices, maxNumVertices) + 1; global_maxNumVertices = new_maxNumVertices; - /* - long tmp_maxNumVertices = (long)TM_SHARED_READ(global_maxNumVertices); - long new_maxNumVertices = MAX(tmp_maxNumVertices, maxNumVertices) + 1; - TM_SHARED_WRITE(global_maxNumVertices, new_maxNumVertices); - */ } Barrier.enterBarrier(); @@ -168,31 +167,31 @@ public class ComputeGraph { if (myId == 0) { - GPtr.numVertices = maxNumVertices; - GPtr.numEdges = numEdgesPlaced; - GPtr.intWeight = SDGdataPtr.intWeight; - GPtr.strWeight = SDGdataPtr.strWeight; + computeGraphArgs.GPtr.numVertices = maxNumVertices; + computeGraphArgs.GPtr.numEdges = numEdgesPlaced; + computeGraphArgs.GPtr.intWeight = computeGraphArgs.SDGdataPtr.intWeight; + computeGraphArgs.GPtr.strWeight = computeGraphArgs.SDGdataPtr.strWeight; for (int i = 0; i < numEdgesPlaced; i++) { - if (GPtr.intWeight[numEdgesPlaced-i-1] < 0) { - GPtr.numStrEdges = -(GPtr.intWeight[numEdgesPlaced-i-1]) + 1; - GPtr.numIntEdges = numEdgesPlaced - GPtr.numStrEdges; + if (computeGraphArgs.GPtr.intWeight[numEdgesPlaced-i-1] < 0) { + computeGraphArgs.GPtr.numStrEdges = -(computeGraphArgs.GPtr.intWeight[numEdgesPlaced-i-1]) + 1; + computeGraphArgs.GPtr.numIntEdges = numEdgesPlaced - computeGraphArgs.GPtr.numStrEdges; break; } } - GPtr.outDegree = new long[GPtr.numVertices]; + computeGraphArgs.GPtr.outDegree = new int[computeGraphArgs.GPtr.numVertices]; - GPtr.outVertexIndex = new long[GPtr.numVertices]; + computeGraphArgs.GPtr.outVertexIndex = new int[computeGraphArgs.GPtr.numVertices]; } Barrier.enterBarrier(); - CreatePartition.createPartition(0, GPtr.numVertices, myId, numThread, lss); + CreatePartition.createPartition(0, computeGraphArgs.GPtr.numVertices, myId, numThread, lss); for (i = lss.i_start; i < lss.i_stop; i++) { - GPtr.outDegree[i] = 0; - GPtr.outVertexIndex[i] = 0; + computeGraphArgs.GPtr.outDegree[i] = 0; + computeGraphArgs.GPtr.outVertexIndex[i] = 0; } int outVertexListSize = 0; @@ -202,11 +201,11 @@ public class ComputeGraph { int i0 = -1; for (int i = lss.i_start; i < lss.i_stop; i++) { - long k = i; + int k = i; if ((outVertexListSize == 0) && (k != 0)) { while (i0 == -1) { for (int j = 0; j < numEdgesPlaced; j++) { - if (k == SDGdataPtr.startVertex[j]) { + if (k == computeGraphArgs.SDGdataPtr.startVertex[j]) { i0 = j; break; } @@ -221,20 +220,20 @@ public class ComputeGraph { } for (int j = i0; j < numEdgesPlaced; j++) { - if (i == GPtr.numVertices-1) { + if (i == computeGraphArgs.GPtr.numVertices-1) { break; } - if ((i != SDGdataPtr.startVertex[j])) { - if ((j > 0) && (i == SDGdataPtr.startVertex[j-1])) { + if ((i != computeGraphArgs.SDGdataPtr.startVertex[j])) { + if ((j > 0) && (i == computeGraphArgs.SDGdataPtr.startVertex[j-1])) { if (j-i0 >= 1) { outVertexListSize++; - GPtr.outDegree[i]++; + computeGraphArgs.GPtr.outDegree[i]++; for (int t = (i0+1); t < j; t++) { - if (SDGdataPtr.endVertex[t] != - SDGdataPtr.endVertex[t-1]) + if (computeGraphArgs.SDGdataPtr.endVertex[t] != + computeGraphArgs.SDGdataPtr.endVertex[t-1]) { outVertexListSize++; - GPtr.outDegree[i] = GPtr.outDegree[i]+1; + computeGraphArgs.GPtr.outDegree[i] = computeGraphArgs.GPtr.outDegree[i]+1; } } } @@ -244,14 +243,14 @@ public class ComputeGraph { } } - if (i == GPtr.numVertices-1) { + if (i == computeGraphArgs.GPtr.numVertices-1) { if (numEdgesPlaced-i0 >= 0) { outVertexListSize++; - GPtr.outDegree[i]++; - for (int t = (int) (i0+1); t < numEdgesPlaced; t++) { - if (SDGdataPtr.endVertex[t] != SDGdataPtr.endVertex[t-1]) { + computeGraphArgs.GPtr.outDegree[i]++; + for (int t = (i0+1); t < numEdgesPlaced; t++) { + if (computeGraphArgs.SDGdataPtr.endVertex[t] != computeGraphArgs.SDGdataPtr.endVertex[t-1]) { outVertexListSize++; - GPtr.outDegree[i]++; + computeGraphArgs.GPtr.outDegree[i]++; } } } @@ -261,7 +260,7 @@ public class ComputeGraph { Barrier.enterBarrier(); - prefix_sums(myId, numThread, GPtr.outVertexIndex, GPtr.outDegree, GPtr.numVertices); + prefix_sums(myId, numThread, computeGraphArgs.GPtr.outVertexIndex, computeGraphArgs.GPtr.outDegree, computeGraphArgs.GPtr.numVertices); Barrier.enterBarrier(); @@ -274,10 +273,10 @@ public class ComputeGraph { outVertexListSize = global_outVertexListSize; if (myId == 0) { - GPtr.numDirectedEdges = outVertexListSize; - GPtr.outVertexList = new long[outVertexListSize]; - GPtr.paralEdgeIndex = new long[outVertexListSize]; - GPtr.outVertexList[0] = SDGdataPtr.endVertex[0]; + computeGraphArgs.GPtr.numDirectedEdges = outVertexListSize; + computeGraphArgs.GPtr.outVertexList = new int[outVertexListSize]; + computeGraphArgs.GPtr.paralEdgeIndex = new int[outVertexListSize]; + computeGraphArgs.GPtr.outVertexList[0] = computeGraphArgs.SDGdataPtr.endVertex[0]; } Barrier.enterBarrier(); @@ -290,10 +289,10 @@ public class ComputeGraph { for (int i = lss.i_start; i < lss.i_stop; i++) { - long k = (long) i; + int k = i; while ((i0 == -1) && (k != 0)) { for (int j = 0; j < numEdgesPlaced; j++) { - if (k == SDGdataPtr.startVertex[j]) { + if (k == computeGraphArgs.SDGdataPtr.startVertex[j]) { i0 = j; break; } @@ -306,23 +305,23 @@ public class ComputeGraph { } for (int j = i0; j < numEdgesPlaced; j++) { - if (i == GPtr.numVertices-1) { + if (i == computeGraphArgs.GPtr.numVertices-1) { break; } - if (i != SDGdataPtr.startVertex[j]) { - if ((j > 0) && (i == SDGdataPtr.startVertex[j-1])) { + if (i != computeGraphArgs.SDGdataPtr.startVertex[j]) { + if ((j > 0) && (i == computeGraphArgs.SDGdataPtr.startVertex[j-1])) { if (j-i0 >= 1) { - int ii = (int) (GPtr.outVertexIndex[i]); + int ii = (computeGraphArgs.GPtr.outVertexIndex[i]); int r = 0; - GPtr.paralEdgeIndex[ii] = i0; - GPtr.outVertexList[ii] = SDGdataPtr.endVertex[(int) i0]; + computeGraphArgs.GPtr.paralEdgeIndex[ii] = i0; + computeGraphArgs.GPtr.outVertexList[ii] = computeGraphArgs.SDGdataPtr.endVertex[ i0]; r++; - for (int t = (int) (i0+1); t < j; t++) { - if (SDGdataPtr.endVertex[t] != - SDGdataPtr.endVertex[t-1]) + for (int t = (i0+1); t < j; t++) { + if (computeGraphArgs.SDGdataPtr.endVertex[t] != + computeGraphArgs.SDGdataPtr.endVertex[t-1]) { - GPtr.paralEdgeIndex[ii+r] = t; - GPtr.outVertexList[ii+r] = SDGdataPtr.endVertex[t]; + computeGraphArgs.GPtr.paralEdgeIndex[ii+r] = t; + computeGraphArgs.GPtr.outVertexList[ii+r] = computeGraphArgs.SDGdataPtr.endVertex[t]; r++; } } @@ -334,17 +333,17 @@ public class ComputeGraph { } } /* for j */ - if (i == GPtr.numVertices-1) { + if (i == computeGraphArgs.GPtr.numVertices-1) { int r = 0; if (numEdgesPlaced-i0 >= 0) { - int ii = GPtr.outVertexIndex[i]; - GPtr.paralEdgeIndex[ii+r] = i0; - GPtr.outVertexList[ii+r] = SDGdataPtr.endVertex[i0]; + int ii = computeGraphArgs.GPtr.outVertexIndex[i]; + computeGraphArgs.GPtr.paralEdgeIndex[ii+r] = i0; + computeGraphArgs.GPtr.outVertexList[ii+r] = computeGraphArgs.SDGdataPtr.endVertex[i0]; r++; for (int t = i0+1; t < numEdgesPlaced; t++) { - if (SDGdataPtr.endVertex[t] != SDGdataPtr.endVertex[t-1]) { - GPtr.paralEdgeIndex[ii+r] = t; - GPtr.outVertexList[ii+r] = SDGdataPtr.endVertex[t]; + if (computeGraphArgs.SDGdataPtr.endVertex[t] != computeGraphArgs.SDGdataPtr.endVertex[t-1]) { + computeGraphArgs.GPtr.paralEdgeIndex[ii+r] = t; + computeGraphArgs.GPtr.outVertexList[ii+r] = computeGraphArgs.SDGdataPtr.endVertex[t]; r++; } } @@ -356,24 +355,24 @@ public class ComputeGraph { Barrier.enterBarrier(); if (myId == 0) { - SDGdataPtr.startVertex = null; - SDGdataPtr.endVertex = null; - GPtr.inDegree = new long[GPtr.numVertices]; - GPtr.inVertexIndex = new long[GPtr.numVertices]; + computeGraphArgs.SDGdataPtr.startVertex = null; + computeGraphArgs.SDGdataPtr.endVertex = null; + computeGraphArgs.GPtr.inDegree = new int[computeGraphArgs.GPtr.numVertices]; + computeGraphArgs.GPtr.inVertexIndex = new int[computeGraphArgs.GPtr.numVertices]; } Barrier.enterBarrier(); for (int i = lss.i_start; i < lss.i_stop; i++) { - GPtr.inDegree[i] = 0; - GPtr.inVertexIndex[i] = 0; + computeGraphArgs.GPtr.inDegree[i] = 0; + computeGraphArgs.GPtr.inVertexIndex[i] = 0; } /* A temp. array to store the inplied edges */ - long[] impliedEdgeList; + int[] impliedEdgeList; if (myId == 0) { - impliedEdgeList = new long[GPtr.numVertices * glb.MAX_CLUSTER_SIZE]; + impliedEdgeList = new int[computeGraphArgs.GPtr.numVertices * glb.MAX_CLUSTER_SIZE]; global_impliedEdgeList = impliedEdgeList; } @@ -382,7 +381,7 @@ public class ComputeGraph { impliedEdgeList = global_impliedEdgeList; CreatePartition.createPartition(0, - (GPtr.numVertices * glb.MAX_CLUSTER_SIZE), + (computeGraphArgs.GPtr.numVertices * glb.MAX_CLUSTER_SIZE), myId, numThread, lss); @@ -396,9 +395,9 @@ public class ComputeGraph { * MAX_CLUSTER_SIZE */ - long[][] auxArr; + int[][] auxArr; if (myId == 0) { - auxArr = new long[GPtr.numVertices][glb.MAX_CLUSTER_SIZE]; + auxArr = new int[computeGraphArgs.GPtr.numVertices][glb.MAX_CLUSTER_SIZE]; global_auxArr = auxArr; } @@ -406,37 +405,37 @@ public class ComputeGraph { auxArr = global_auxArr; - CreatePartition.createPartition(0, GPtr.numVertices, myId, numThread, lss); + 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 = GPtr.outVertexIndex[i]; - j < (GPtr.outVertexIndex[i] + GPtr.outDegree[i]); + for (j = computeGraphArgs.GPtr.outVertexIndex[i]; + j < (computeGraphArgs.GPtr.outVertexIndex[i] + computeGraphArgs.GPtr.outDegree[i]); j++) { - int v = (int) (GPtr.outVertexList[j]); + int v = (computeGraphArgs.GPtr.outVertexList[j]); int k; - for (k = GPtr.outVertexIndex[v]; - k < (GPtr.outVertexIndex[v] + GPtr.outDegree[v]); + for (k = computeGraphArgs.GPtr.outVertexIndex[v]; + k < (computeGraphArgs.GPtr.outVertexIndex[v] + computeGraphArgs.GPtr.outDegree[v]); k++) { - if (GPtr.outVertexList[k] == i) { + if (computeGraphArgs.GPtr.outVertexList[k] == i) { break; } } - if (k == GPtr.outVertexIndex[v]+GPtr.outDegree[v]) { + if (k == computeGraphArgs.GPtr.outVertexIndex[v]+computeGraphArgs.GPtr.outDegree[v]) { atomic { /* Add i to the impliedEdgeList of v */ - long inDegree = GPtr.inDegree[v]; - GPtr.inDegree[v] = (inDegree + 1); - if ((int) inDegree < glb.MAX_CLUSTER_SIZE) { + 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 } else { /* Use auxiliary array to store the implied edge */ /* Create an array if it's not present already */ - long[] a = null; - if (((int)inDegree % glb.MAX_CLUSTER_SIZE) == 0) { - a = new long[glb.MAX_CLUSTER_SIZE]; + int[] a = null; + if ((inDegree % glb.MAX_CLUSTER_SIZE) == 0) { + a = new int[glb.MAX_CLUSTER_SIZE]; auxArr[v] = a; } else { a = auxArr[v]; @@ -450,12 +449,12 @@ public class ComputeGraph { Barrier.enterBarrier(); - prefix_sums(myId, numThread, GPtr.inVertexIndex, GPtr.inDegree, GPtr.numVertices); + prefix_sums(myId, numThread, computeGraphArgs.GPtr.inVertexIndex, computeGraphArgs.GPtr.inDegree, computeGraphArgs.GPtr.numVertices); if (myId == 0) { - GPtr.numUndirectedEdges = GPtr.inVertexIndex[GPtr.numVertices-1] - + GPtr.inDegree[GPtr.numVertices-1]; - GPtr.inVertexList = new long[GPtr.numUndirectedEdges]; + computeGraphArgs.GPtr.numUndirectedEdges = computeGraphArgs.GPtr.inVertexIndex[computeGraphArgs.GPtr.numVertices-1] + + computeGraphArgs.GPtr.inDegree[computeGraphArgs.GPtr.numVertices-1]; + computeGraphArgs.GPtr.inVertexList = new int[computeGraphArgs.GPtr.numUndirectedEdges]; } Barrier.enterBarrier(); @@ -465,16 +464,16 @@ public class ComputeGraph { */ for (int i = lss.i_start; i < lss.i_stop; i++) { - for (int j = GPtr.inVertexIndex[i]; - j < (GPtr.inVertexIndex[i] + GPtr.inDegree[i]); + for (int j = computeGraphArgs.GPtr.inVertexIndex[i]; + j < (computeGraphArgs.GPtr.inVertexIndex[i] + computeGraphArgs.GPtr.inDegree[i]); j++) { - if ((j - GPtr.inVertexIndex[i]) < glb.MAX_CLUSTER_SIZE) { - GPtr.inVertexList[j] = - impliedEdgeList[i*glb.MAX_CLUSTER_SIZE+j-GPtr.inVertexIndex[i]]; + if ((j - computeGraphArgs.GPtr.inVertexIndex[i]) < glb.MAX_CLUSTER_SIZE) { + computeGraphArgs.GPtr.inVertexList[j] = + impliedEdgeList[i*glb.MAX_CLUSTER_SIZE+j-computeGraphArgs.GPtr.inVertexIndex[i]]; } else { - GPtr.inVertexList[j] = - auxArr[i][(j-GPtr.inVertexIndex[i]) % glb.MAX_CLUSTER_SIZE]; + computeGraphArgs.GPtr.inVertexList[j] = + auxArr[i][(j-computeGraphArgs.GPtr.inVertexIndex[i]) % glb.MAX_CLUSTER_SIZE]; } } } @@ -486,7 +485,7 @@ public class ComputeGraph { } for (i = i_start; i < i_stop; i++) { - if (GPtr.inDegree[i] > MAX_CLUSTER_SIZE) { + if (computeGraphArgs.GPtr.inDegree[i] > MAX_CLUSTER_SIZE) { auxArr[i] = null; } } diff --git a/Robust/src/Benchmarks/SingleTM/SSCA2/Edge.java b/Robust/src/Benchmarks/SingleTM/SSCA2/Edge.java index a706bdec..f3ceb084 100644 --- a/Robust/src/Benchmarks/SingleTM/SSCA2/Edge.java +++ b/Robust/src/Benchmarks/SingleTM/SSCA2/Edge.java @@ -1,7 +1,7 @@ public class Edge { - public long startVertex; - public long endVertex; - public long edgeNum; + public int startVertex; + public int endVertex; + public int edgeNum; public Edge() { } diff --git a/Robust/src/Benchmarks/SingleTM/SSCA2/GenScalData.java b/Robust/src/Benchmarks/SingleTM/SSCA2/GenScalData.java index 91c34e51..0f98b576 100644 --- a/Robust/src/Benchmarks/SingleTM/SSCA2/GenScalData.java +++ b/Robust/src/Benchmarks/SingleTM/SSCA2/GenScalData.java @@ -46,18 +46,18 @@ public class GenScalData { - public long[] global_permV; - public long[] global_cliqueSizes; + public int[] global_permV; + public int[] global_cliqueSizes; public int global_totCliques; - public long[] global_firstVsInCliques; - public long[] global_lastVsInCliques; - public long[] global_i_edgeStartCounter; - public long[] global_i_edgeEndCounter; - public long global_edgeNum; - public long global_numStrWtEdges; - public long[] global_startVertex; - public long[] global_endVertex; - public long[] global_tempIndex; + public int[] global_firstVsInCliques; + public int[] global_lastVsInCliques; + public int[] global_i_edgeStartCounter; + public int[] global_i_edgeEndCounter; + public int global_edgeNum; + public int global_numStrWtEdges; + public int[] global_startVertex; + public int[] global_endVertex; + public int[] global_tempIndex; /** * Constructor @@ -70,8 +70,8 @@ public class GenScalData { global_lastVsInCliques = null; global_i_edgeStartCounter = null; global_i_edgeEndCounter = null; - global_edgeNum = 0L; - global_numStrWtEdges = 0L; + global_edgeNum = 0; + global_numStrWtEdges = 0; global_startVertex = null; global_endVertex = null; global_tempIndex = null; @@ -84,7 +84,7 @@ public class GenScalData { * ============================================================================= **/ void - genScalData_seq (graphSDG* SDGdataPtr) + genScalData_seq (GraphSDG SDGdataPtr) { System.out.println("Call to genScalData_seq(), Unimplemented: TODO\n"); System.exit(0); @@ -105,13 +105,13 @@ public class GenScalData { */ Random randomPtr = new Random(); - randomPtr = randomPtr.random_alloc(randomPtr); - randomPtr.random_seed(randomPtr, myId); + randomPtr = randomPtr.random_alloc(); + randomPtr.random_seed(myId); - long[] permV; + int[] permV; if (myId == 0) { - permV = new long[glb.TOT_VERTICES]; + permV = new int[glb.TOT_VERTICES]; global_permV = permV; } @@ -131,11 +131,11 @@ public class GenScalData { Barrier.enterBarrier(); for (int i = i_start; i < i_stop; i++) { - int t1 = (int) (randomPtr.random_generate(randomPtr)); + int t1 = randomPtr.random_generate(); int t = i + t1 % (glb.TOT_VERTICES - i); if (t != i) { atomic { - long t2 = permV[t]; + int t2 = permV[t]; permV[t] = permV[i]; permV[i] = t2; } @@ -146,7 +146,7 @@ public class GenScalData { * STEP 1: Create Cliques */ - long[] cliqueSizes; + int[] cliqueSizes; int estTotCliques = (int)(Math.ceil(1.5d * glb.TOT_VERTICES / ((1+glb.MAX_CLIQUE_SIZE)/2))); @@ -155,7 +155,7 @@ public class GenScalData { * Estimate number of clique required and pad by 50% */ if (myId == 0) { - cliqueSizes = new long[estTotCliques]; + cliqueSizes = new int[estTotCliques]; global_cliqueSizes = cliqueSizes; } @@ -167,7 +167,7 @@ public class GenScalData { /* Generate random clique sizes. */ for (int i = lss.i_start; i < lss.i_stop; i++) { - cliqueSizes[i] = 1 + (randomPtr.random_generate(randomPtr) % MAX_CLIQUE_SIZE); + cliqueSizes[i] = 1 + (randomPtr.random_generate() % glb.MAX_CLIQUE_SIZE); } Barrier.enterBarrier(); @@ -178,13 +178,13 @@ public class GenScalData { * Allocate memory for cliqueList */ - long[] firstVsInCliques; - long[] firstVsInCliques; + int[] firstVsInCliques; + int[] firstVsInCliques; if (myId == 0) { - lastVsInCliques = new long[estTotCliques]; + lastVsInCliques = new int[estTotCliques]; global_lastVsInCliques = lastVsInCliques; - firstVsInCliques = new long[estTotCliques]; + firstVsInCliques = new int[estTotCliques]; global_firstVsInCliques = firstVsInCliques; /* @@ -192,7 +192,8 @@ public class GenScalData { */ lastVsInCliques[0] = cliqueSizes[0] - 1; - for (int i = 1; i < estTotCliques; i++) { + int i; + for (i = 1; i < estTotCliques; i++) { lastVsInCliques[i] = cliqueSizes[i] + lastVsInCliques[i-1]; if (lastVsInCliques[i] >= glb.TOT_VERTICES-1) { break; @@ -205,8 +206,8 @@ public class GenScalData { /* * Fix the size of the last clique */ - cliqueSizes[totCliques-1] = - glb.TOT_VERTICES - lastVsInCliques[totCliques-2] - 1; + cliqueSizes[(totCliques-1)] = + glb.TOT_VERTICES - lastVsInCliques[(totCliques-2)] - 1; lastVsInCliques[totCliques-1] = glb.TOT_VERTICES - 1; firstVsInCliques[0] = 0; @@ -220,8 +221,8 @@ public class GenScalData { totCliques = global_totCliques; /* Compute start Vertices in cliques. */ - createPartition(1, totCliques, myId, numThread, lss); - for (i = i_start; i < i_stop; i++) { + cp.createPartition(1, totCliques, myId, numThread, lss); + for (int i = i_start; i < i_stop; i++) { firstVsInCliques[i] = lastVsInCliques[i-1] + 1; } @@ -233,14 +234,14 @@ Barrier.enterBarrier(); // Write the generated cliques to file for comparison with Kernel 4 if (myId == 0) { FILE* outfp = fopen("cliques.txt", "w"); - fprintf(outfp, "No. of cliques - %lu\n", totCliques); + fSystem.out.println(outfp, "No. of cliques - %lu\n", totCliques); for (i = 0; i < totCliques; i++) { - fprintf(outfp, "Clq %lu - ", i); - long j; + fSystem.out.println(outfp, "Clq %lu - ", i); + int j; for (j = firstVsInCliques[i]; j <= lastVsInCliques[i]; j++) { - fprintf(outfp, "%lu ", permV[j]); + fSystem.out.println(outfp, "%lu ", permV[j]); } - fprintf(outfp, "\n"); + fSystem.out.println(outfp, "\n"); } fclose(outfp); } @@ -256,11 +257,11 @@ Barrier.enterBarrier(); /* * Estimate number of edges - using an empirical measure */ - long estTotEdges; + int estTotEdges; if (glb.SCALE >= 12) { - estTotEdges = (long) (Math.ceil(1.0d *((glb.MAX_CLIQUE_SIZE-1) * glb.TOT_VERTICES))); + estTotEdges = (int) (Math.ceil(1.0d *((glb.MAX_CLIQUE_SIZE-1) * glb.TOT_VERTICES))); } else { - estTotEdges = (long) (Math.ceil(1.2d * (((glb.MAX_CLIQUE_SIZE-1)*glb.TOT_VERTICES) + estTotEdges = (int) (Math.ceil(1.2d * (((glb.MAX_CLIQUE_SIZE-1)*glb.TOT_VERTICES) * ((1 + glb.MAX_PARAL_EDGES)/2) + glb.TOT_VERTICES*2))); } @@ -268,54 +269,52 @@ Barrier.enterBarrier(); * Initialize edge counter */ int i_edgePtr = 0; + float p = glb.PROB_UNIDIRECTIONAL; /* * Partial edgeLists */ - long[] startV; - long[] endV; + int[] startV; + int[] endV; if (numThread > 3) { int numByte = 1.5 * (estTotEdges/numThread); - startV = new long[numByte]; - endV = new long[numByte]; + startV = new int[numByte]; + endV = new int[numByte]; } else { int numByte = (estTotEdges/numThread); - startV = new long[numByte]; - endV = new long[numByte]; + startV = new int[numByte]; + endV = new int[numByte]; } /* * Tmp array to keep track of the no. of parallel edges in each direction */ - long[][] tmpEdgeCounter = new long[glb.MAX_CLIQUE_SIZE][glb.MAX_CLIQUE_SIZE]; + int[][] tmpEdgeCounter = new int[glb.MAX_CLIQUE_SIZE][glb.MAX_CLIQUE_SIZE]; /* * Create edges in parallel */ - int i_clique; + //int i_clique; cp.createPartition(0, totCliques, myId, numThread, lss); - double p = glb.PROB_UNIDIRECTIONAL; - for (i_clique = lss.i_start; i_clique < lss.i_stop; i_clique++) { + for (int i_clique = lss.i_start; i_clique < lss.i_stop; i_clique++) { /* * Get current clique parameters */ - long i_cliqueSize = cliqueSizes[i_clique]; - long i_firstVsInClique = firstVsInCliques[i_clique]; + int i_cliqueSize = cliqueSizes[i_clique]; + int i_firstVsInClique = firstVsInCliques[i_clique]; /* * First create at least one edge between two vetices in a clique */ - int i; - int j; - for (i = 0; i < (int) i_cliqueSize; i++) { - for (j = 0; j < i; j++) { - double r = (double)(randomPtr.random_generate(randomPtr) % 1000) / (double)1000; + 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; @@ -350,14 +349,13 @@ Barrier.enterBarrier(); } /* for i */ if (i_cliqueSize != 1) { - long randNumEdges = (long)(randomPtr.random_generate(randomPtr) - % (2*i_cliqueSize*glb.MAX_PARAL_EDGES)); - int i_paralEdge; - for (i_paralEdge = 0; i_paralEdge < (int) randNumEdges; i_paralEdge++) { - i = (int) (randomPtr.random_generate(randomPtr) % i_cliqueSize); - int j = (int) (randomPtr.random_generate(randomPtr) % i_cliqueSize); + int randNumEdges = randomPtr.random_generate() % (2*i_cliqueSize*glb.MAX_PARAL_EDGES); + //int i_paralEdge; + for (int i_paralEdge = 0; i_paralEdge < randNumEdges; i_paralEdge++) { + int i = (int) (randomPtr.random_generate() % i_cliqueSize); + int j = (int) (randomPtr.random_generate() % i_cliqueSize); if ((i != j) && (tmpEdgeCounter[i][j] < glb.MAX_PARAL_EDGES)) { - double r = (double)(randomPtr.random_generate(randomPtr) % 1000) / (double)1000; + float r = (float)(randomPtr.random_generate() % 1000) / (float)1000; if (r >= p) { /* Copy to edge structure. */ startV[i_edgePtr] = i + i_firstVsInClique; @@ -371,17 +369,19 @@ Barrier.enterBarrier(); } /* for i_clique */ + tmpEdgeCounter = null; + /* * Merge partial edge lists */ - long[] i_edgeStartCounter; - long[] i_edgeEndCounter; + int[] i_edgeStartCounter; + int[] i_edgeEndCounter; if (myId == 0) { - i_edgeStartCounter = new long[numThread]; + i_edgeStartCounter = new int[ numThread]; global_i_edgeStartCounter = i_edgeStartCounter; - i_edgeEndCounter = new long[numThread]; + i_edgeEndCounter = new int[numThread]; global_i_edgeEndCounter = i_edgeEndCounter; } @@ -396,36 +396,36 @@ Barrier.enterBarrier(); Barrier.enterBarrier(); if (myId == 0) { - for (i = 1; i < numThread; i++) { + for (int i = 1; i < numThread; i++) { i_edgeEndCounter[i] = i_edgeEndCounter[i-1] + i_edgeEndCounter[i]; i_edgeStartCounter[i] = i_edgeEndCounter[i-1]; } } atomic { - global_edgeNum = (long) (global_edgeNum + i_edgePtr); + global_edgeNum = global_edgeNum + i_edgePtr; } Barrier.enterBarrier(); - long edgeNum = global_edgeNum; + int edgeNum = global_edgeNum; /* * Initialize edge list arrays */ - long[] startVertex; - long[] endVertex; + int[] startVertex; + int[] endVertex; if (myId == 0) { if (glb.SCALE < 10) { int numByte = 2 * edgeNum; - startVertex = new long[numByte]; - endVertex = new long[numByte]; + startVertex = new int[numByte]; + endVertex = new int[numByte]; } else { int numByte = (edgeNum + glb.MAX_PARAL_EDGES * glb.TOT_VERTICES); - startVertex = new long[numByte]; - endVertex = new long[numByte]; + startVertex = new int[numByte]; + endVertex = new int[numByte]; } global_startVertex = startVertex; global_endVertex = endVertex; @@ -436,7 +436,7 @@ Barrier.enterBarrier(); startVertex = global_startVertex; endVertex = global_endVertex; - for (int i = (int) i_edgeStartCounter[myId]; i < (int) i_edgeEndCounter[myId]; i++) { + for (int i = i_edgeStartCounter[myId]; i < i_edgeEndCounter[myId]; i++) { startVertex[i] = startV[i-i_edgeStartCounter[myId]]; endVertex[i] = endV[i-i_edgeStartCounter[myId]]; } @@ -459,12 +459,12 @@ Barrier.enterBarrier(); cp.createPartition(0, glb.TOT_VERTICES, myId, numThread, lss); for (int i = lss.i_start; i < lss.i_stop; i++) { - long tempVertex1 = (long) i; - long h = totCliques; - long l = 0; - long t = -1; + int tempVertex1 = i; + int h = totCliques; + int l = 0; + int t = -1; while (h - l > 1) { - int m = (int) ((h + l) / 2); + int m = ((h + l) / 2); if (tempVertex1 >= firstVsInCliques[m]) { l = m; } else { @@ -489,22 +489,22 @@ Barrier.enterBarrier(); t = m-1; } - long t1 = firstVsInCliques[t]; + int t1 = firstVsInCliques[t]; - int d; - for (d = 1, p = glb.PROB_INTERCL_EDGES; d < glb.TOT_VERTICES; d *= 2, p /= 2) { + //int d; + for (int d = 1, p = glb.PROB_INTERCL_EDGES; d < glb.TOT_VERTICES; d *= 2, p /= 2) { - double r = (double)(randomPtr.random_generate(randomPtr) % 1000) / (double)1000; + float r = (float)(randomPtr.random_generate() % 1000) / (float)1000; if (r <= p) { - long tempVertex2 = (long) ((i+d) % glb.TOT_VERTICES); + int tempVertex2 = ((i+d) % glb.TOT_VERTICES); h = totCliques; l = 0; t = -1; while (h - l > 1) { - int m = (int) ((h + l) / 2); + int m = (((h + l) / 2); if (tempVertex2 >= firstVsInCliques[m]) { l = m; } else { @@ -520,7 +520,7 @@ Barrier.enterBarrier(); } if (t == -1) { - //long m; + //int m; int m; for (m = (l + 1); m < h; m++) { if (tempVertex2 < firstVsInCliques[m]) { @@ -530,13 +530,13 @@ Barrier.enterBarrier(); t = m - 1; } - long t2 = firstVsInCliques[t]; + int t2 = firstVsInCliques[t]; if (t1 != t2) { - long randNumEdges = - randomPtr.random_generate(randomPtr) % glb.MAX_PARAL_EDGES + 1; - int j; - for (j = 0; j < randNumEdges; j++) { + int randNumEdges = + randomPtr.random_generate() % glb.MAX_PARAL_EDGES + 1; + //int j; + for (int j = 0; j < randNumEdges; j++) { startV[i_edgePtr] = tempVertex1; endV[i_edgePtr] = tempVertex2; i_edgePtr++; @@ -545,16 +545,16 @@ Barrier.enterBarrier(); } /* r <= p */ - double r0 = (double)(randomPtr.random_generate(randomPtr) % 1000) / (double)1000; + float r0 = (float)(randomPtr.random_generate() % 1000) / (float)1000; if ((r0 <= p) && (i-d>=0)) { - long tempVertex2 = (i - d) % glb.TOT_VERTICES; + int tempVertex2 = (i - d) % glb.TOT_VERTICES; h = totCliques; l = 0; t = -1; while (h - l > 1) { - int m = (int)((h + l) / 2); + int m = ((h + l) / 2); if (tempVertex2 >= firstVsInCliques[m]) { l = m; } else { @@ -571,7 +571,7 @@ Barrier.enterBarrier(); if (t == -1) { int m; - for (m = (int) (l + 1); m < (int) h; m++) { + for (m = (l + 1); m < h; m++) { if (tempVertex2 < firstVsInCliques[m]) { break; } @@ -579,13 +579,12 @@ Barrier.enterBarrier(); t = m - 1; } - long t2 = firstVsInCliques[t]; + int t2 = firstVsInCliques[t]; if (t1 != t2) { - long randNumEdges = - randomPtr.random_generate(randomPtr) % glb.MAX_PARAL_EDGES + 1; - int j; - for (j = 0; j < (int) randNumEdges; j++) { + int randNumEdges = + randomPtr.random_generate() % glb.MAX_PARAL_EDGES + 1; + for (int j = 0; j < randNumEdges; j++) { startV[i_edgePtr] = tempVertex1; endV[i_edgePtr] = tempVertex2; i_edgePtr++; @@ -609,7 +608,7 @@ Barrier.enterBarrier(); Barrier.enterBarrier(); if (myId == 0) { - for (int i = 1; i < numThread; i++) { + for (int i = 1; i < numThread; i++) { i_edgeEndCounter[i] = i_edgeEndCounter[i-1] + i_edgeEndCounter[i]; i_edgeStartCounter[i] = i_edgeEndCounter[i-1]; } @@ -622,25 +621,24 @@ Barrier.enterBarrier(); Barrier.enterBarrier(); edgeNum = global_edgeNum; - long numEdgesPlacedOutside = global_edgeNum; + int numEdgesPlacedOutside = global_edgeNum; - for (int i = (int) i_edgeStartCounter[myId]; i < (int) 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]]; } Barrier.enterBarrier(); - long numEdgesPlaced = numEdgesPlacedInCliques + numEdgesPlacedOutside; + int numEdgesPlaced = numEdgesPlacedInCliques + numEdgesPlacedOutside; if (myId == 0) { + SDGdataPtr.numEdgesPlaced = numEdgesPlaced; - SDGdataPtr.numEdgesPlaced = (int) numEdgesPlaced; - - printf("Finished generating edges\n"); - printf("No. of intra-clique edges - %lu\n", numEdgesPlacedInCliques); - printf("No. of inter-clique edges - %lu\n", numEdgesPlacedOutside); - printf("Total no. of edges - %lu\n", 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); } Barrier.enterBarrier(); @@ -650,21 +648,21 @@ Barrier.enterBarrier(); */ if (myId == 0) { - SDGdataPtr.intWeight = new long[(int) numEdgesPlaced]; + SDGdataPtr.intWeight = new int[numEdgesPlaced]; } Barrier.enterBarrier(); p = glb.PERC_INT_WEIGHTS; - long numStrWtEdges = 0; + int numStrWtEdges = 0; - cp.createPartition(0, (int) numEdgesPlaced, myId, numThread, lss); + cp.createPartition(0, numEdgesPlaced, myId, numThread, lss); for (int i = lss.i_start; i < lss.i_stop; i++) { - double r = (double)(randomPtr.random_generate(randomPtr) % 1000) / (double)1000; + float r = (float)(randomPtr.random_generate() % 1000) / (float)1000; if (r <= p) { SDGdataPtr.intWeight[i] = - 1 + (randomPtr.random_generate(randomPtr) % (MAX_INT_WEIGHT-1)); + 1 + (randomPtr.random_generate() % (MAX_INT_WEIGHT-1)); } else { SDGdataPtr.intWeight[i] = -1; numStrWtEdges++; @@ -675,7 +673,7 @@ Barrier.enterBarrier(); if (myId == 0) { int t = 0; - for (int i = 0; i < (int) numEdgesPlaced; i++) { + for (int i = 0; i < numEdgesPlaced; i++) { if (SDGdataPtr.intWeight[i] < 0) { SDGdataPtr.intWeight[i] = -t; t++; @@ -697,15 +695,15 @@ Barrier.enterBarrier(); Barrier.enterBarrier(); - cp.createPartition(0, (int) numEdgesPlaced, myId, numThread, lss); + cp.createPartition(0, numEdgesPlaced, myId, numThread, lss); for (int i = lss.i_start; i < lss.i_stop; i++) { if (SDGdataPtr.intWeight[i] <= 0) { for (int j = 0; j < glb.MAX_STRLEN; j++) { - SDGdataPtr.strWeight[(-(int) SDGdataPtr.intWeight[i])*glb.MAX_STRLEN+j] = + SDGdataPtr.strWeight[(-SDGdataPtr.intWeight[i])*glb.MAX_STRLEN+j] = // (char) (1 + PRANDOM_GENERATE(stream) % 127); //FIXME - (char) (1 + (randomPtr.random_generate(randomPtr) % 127)); + (char) (1 + (randomPtr.random_generate() % 127)); } } } @@ -720,11 +718,11 @@ Barrier.enterBarrier(); glb.SOUGHT_STRING = new char[MAX_STRLEN]; } - long t = randomPtr.random_generate(randomPtr) % numStrWtEdges; + int t = randomPtr.random_generate() % numStrWtEdges; for (int j = 0; j < glb.MAX_STRLEN; j++) { //FIXME SOUGHT_STRING[j] = - (char) ((long) SDGdataPtr.strWeight[(int) (t*glb.MAX_STRLEN+j)]); + (char) (SDGdataPtr.strWeight[(t*glb.MAX_STRLEN+j)]); } } @@ -751,9 +749,9 @@ Barrier.enterBarrier(); */ if (myId == 0) { - int numByte = (int) numEdgesPlaced; - SDGdataPtr.startVertex = new long[numByte]; - SDGdataPtr.endVertex = new long[numByte]; + int numByte = numEdgesPlaced; + SDGdataPtr.startVertex = new int[numByte]; + SDGdataPtr.endVertex = new int[numByte]; } Barrier.enterBarrier(); @@ -778,9 +776,9 @@ Barrier.enterBarrier(); int i1 = 0; int i = 0; - while (i < (int) numEdgesPlaced) { + while (i < numEdgesPlaced) { - for (i = i0; i < (int) numEdgesPlaced; i++) { + for (i = i0; i < numEdgesPlaced; i++) { if (SDGdataPtr.startVertex[i] != SDGdataPtr.startVertex[i1]) { @@ -789,31 +787,31 @@ Barrier.enterBarrier(); } } - int j; - for (j = i0; j < i1; j++) { - int k; - for (k = j+1; k < i1; k++) { + //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]) { - long t = SDGdataPtr.endVertex[j]; + int t = SDGdataPtr.endVertex[j]; SDGdataPtr.endVertex[j] = SDGdataPtr.endVertex[k]; SDGdataPtr.endVertex[k] = t; } } } - if (SDGdataPtr.startVertex[i0] != (long) glb.TOT_VERTICES-1) { + if (SDGdataPtr.startVertex[i0] != glb.TOT_VERTICES-1) { i0 = i1; } else { - int j; - for (j=i0; j<(int)numEdgesPlaced; j++) { - int k; - for (k=j+1; k<(int)numEdgesPlaced; k++) { + //int j; + for (int j=i0; j