From: bdemsky Date: Sun, 12 Jul 2009 23:01:51 +0000 (+0000) Subject: changes to support wrapper types X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3a0a58ff51fa75d1e7d0245c9a862e2ca7a829fd;p=IRC.git changes to support wrapper types --- diff --git a/Robust/src/Benchmarks/SingleTM/SSCA2/ComputeGraph.java b/Robust/src/Benchmarks/SingleTM/SSCA2/ComputeGraph.java index 167f0c10..a9d803dd 100644 --- a/Robust/src/Benchmarks/SingleTM/SSCA2/ComputeGraph.java +++ b/Robust/src/Benchmarks/SingleTM/SSCA2/ComputeGraph.java @@ -51,8 +51,8 @@ public class ComputeGraph { public int[] global_p; public int global_maxNumVertices; public int global_outVertexListSize; - public int[] global_impliedEdgeList; - public int[][] global_auxArr; + public int[][] global_impliedEdgeList; + public Objectwrapper[] global_auxArr; public ComputeGraph() { global_p = null; @@ -120,17 +120,67 @@ public class ComputeGraph { Barrier.enterBarrier(); } + public void + prefix_sumsin (int myId, int numThread, int[] result, intwrapper[] input, int arraySize) + { + int[] p; + if (myId == 0) { + p = new int[NOSHARE(numThread)]; + global_p = p; + } + + Barrier.enterBarrier(); + + p = global_p; + + int start; + int end; + + int r = arraySize / numThread; + start = myId * r + 1; + end = (myId + 1) * r; + if (myId == (numThread - 1)) { + end = arraySize; + } + + for (int j = start; j < end; j++) { + result[j] = input[j-1] + result[j-1]; + } + + p[NOSHARE(myId)] = result[end-1]; + + Barrier.enterBarrier(); + + if (myId == 0) { + for (int j = 1; j < numThread; j++) { + p[NOSHARE(j)] += p[NOSHARE(j-1)]; + } + } + + Barrier.enterBarrier(); + + if (myId > 0) { + int add_value = p[NOSHARE(myId-1)]; + for (int j = start-1; j < end; j++) { + result[j] += add_value; + } + } + + Barrier.enterBarrier(); + } + /* ============================================================================= * computeGraph * ============================================================================= */ public static void - computeGraph (int myId, int numThread, Globals glb, ComputeGraph computeGraphArgs) - - { - + computeGraph (int myId, int numThread, Globals glb, ComputeGraph computeGraphArgs) { + int maxNumVertices = 0; int numEdgesPlaced = computeGraphArgs.SDGdataPtr.numEdgesPlaced; + Graph GPtr=computeGraphArgs.GPtr; + GraphSDG SDGdataPtr=computeGraphArgs.SDGdataPtr; + int MAX_CLUSTER_SIZE=glb.MAX_CLUSTER_SIZE; /* * First determine the number of vertices by scanning the tuple @@ -139,8 +189,8 @@ public class ComputeGraph { LocalStartStop lss = new LocalStartStop(); CreatePartition.createPartition(0, numEdgesPlaced, myId, numThread, lss); for (int i = lss.i_start; i < lss.i_stop; i++) { - if (computeGraphArgs.SDGdataPtr.startVertex[i] > maxNumVertices) { - maxNumVertices = computeGraphArgs.SDGdataPtr.startVertex[i]; + if (SDGdataPtr.startVertex[i] > maxNumVertices) { + maxNumVertices = SDGdataPtr.startVertex[i]; } } @@ -161,30 +211,30 @@ public class ComputeGraph { if(maxNumVertices == realMaxNumVertices); maxNumVertices++; } - computeGraphArgs.GPtr.numVertices = maxNumVertices; - computeGraphArgs.GPtr.numEdges = numEdgesPlaced; - computeGraphArgs.GPtr.intWeight = computeGraphArgs.SDGdataPtr.intWeight; - computeGraphArgs.GPtr.strWeight = computeGraphArgs.SDGdataPtr.strWeight; + GPtr.numVertices = maxNumVertices; + GPtr.numEdges = numEdgesPlaced; + GPtr.intWeight = SDGdataPtr.intWeight; + GPtr.strWeight = SDGdataPtr.strWeight; for (int i = 0; i < numEdgesPlaced; i++) { - 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; + if (GPtr.intWeight[numEdgesPlaced-i-1] < 0) { + GPtr.numStrEdges = -(GPtr.intWeight[numEdgesPlaced-i-1]) + 1; + GPtr.numIntEdges = numEdgesPlaced - GPtr.numStrEdges; break; } } - computeGraphArgs.GPtr.outDegree = new int[computeGraphArgs.GPtr.numVertices]; - computeGraphArgs.GPtr.outVertexIndex = new int[computeGraphArgs.GPtr.numVertices]; + GPtr.outDegree = new int[GPtr.numVertices]; + GPtr.outVertexIndex = new int[GPtr.numVertices]; } Barrier.enterBarrier(); - CreatePartition.createPartition(0, computeGraphArgs.GPtr.numVertices, myId, numThread, lss); + CreatePartition.createPartition(0, GPtr.numVertices, myId, numThread, lss); for (int i = lss.i_start; i < lss.i_stop; i++) { - computeGraphArgs.GPtr.outDegree[i] = 0; - computeGraphArgs.GPtr.outVertexIndex[i] = 0; + GPtr.outDegree[i] = 0; + GPtr.outVertexIndex[i] = 0; } int outVertexListSize = 0; @@ -192,13 +242,12 @@ public class ComputeGraph { Barrier.enterBarrier(); int i0 = -1; - for (int i = lss.i_start; i < lss.i_stop; i++) { int k = i; if ((outVertexListSize == 0) && (k != 0)) { while (i0 == -1) { for (int j = 0; j < numEdgesPlaced; j++) { - if (k == computeGraphArgs.SDGdataPtr.startVertex[j]) { + if (k == SDGdataPtr.startVertex[j]) { i0 = j; break; } @@ -213,20 +262,20 @@ public class ComputeGraph { } for (int j = i0; j < numEdgesPlaced; j++) { - if (i == computeGraphArgs.GPtr.numVertices-1) { + if (i == GPtr.numVertices-1) { break; } - if ((i != computeGraphArgs.SDGdataPtr.startVertex[j])) { - if ((j > 0) && (i == computeGraphArgs.SDGdataPtr.startVertex[j-1])) { + if ((i != SDGdataPtr.startVertex[j])) { + if ((j > 0) && (i == SDGdataPtr.startVertex[j-1])) { if (j-i0 >= 1) { outVertexListSize++; - computeGraphArgs.GPtr.outDegree[i]++; + GPtr.outDegree[i]++; for (int t = (i0+1); t < j; t++) { - if (computeGraphArgs.SDGdataPtr.endVertex[t] != - computeGraphArgs.SDGdataPtr.endVertex[t-1]) + if (SDGdataPtr.endVertex[t] != + SDGdataPtr.endVertex[t-1]) { outVertexListSize++; - computeGraphArgs.GPtr.outDegree[i] = computeGraphArgs.GPtr.outDegree[i]+1; + GPtr.outDegree[i] = GPtr.outDegree[i]+1; } } } @@ -236,14 +285,14 @@ public class ComputeGraph { } } - if (i == computeGraphArgs.GPtr.numVertices-1) { + if (i == GPtr.numVertices-1) { if (numEdgesPlaced-i0 >= 0) { outVertexListSize++; - computeGraphArgs.GPtr.outDegree[i]++; + GPtr.outDegree[i]++; for (int t = (i0+1); t < numEdgesPlaced; t++) { - if (computeGraphArgs.SDGdataPtr.endVertex[t] != computeGraphArgs.SDGdataPtr.endVertex[t-1]) { + if (SDGdataPtr.endVertex[t] != SDGdataPtr.endVertex[t-1]) { outVertexListSize++; - computeGraphArgs.GPtr.outDegree[i]++; + GPtr.outDegree[i]++; } } } @@ -253,7 +302,7 @@ public class ComputeGraph { Barrier.enterBarrier(); - computeGraphArgs.prefix_sums(myId, numThread, computeGraphArgs.GPtr.outVertexIndex, computeGraphArgs.GPtr.outDegree, computeGraphArgs.GPtr.numVertices); + computeGraphArgs.prefix_sums(myId, numThread, GPtr.outVertexIndex, GPtr.outDegree, GPtr.numVertices); Barrier.enterBarrier(); @@ -268,10 +317,10 @@ public class ComputeGraph { if (myId == 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]; + GPtr.numDirectedEdges = outVertexListSize; + GPtr.outVertexList = new int[outVertexListSize]; + GPtr.paralEdgeIndex = new int[outVertexListSize]; + GPtr.outVertexList[0] = SDGdataPtr.endVertex[0]; } Barrier.enterBarrier(); @@ -281,13 +330,12 @@ public class ComputeGraph { */ i0 = -1; - for (int i = lss.i_start; i < lss.i_stop; i++) { int k = i; while ((i0 == -1) && (k != 0)) { for (int j = 0; j < numEdgesPlaced; j++) { - if (k == computeGraphArgs.SDGdataPtr.startVertex[j]) { + if (k == SDGdataPtr.startVertex[j]) { i0 = j; break; } @@ -300,23 +348,23 @@ public class ComputeGraph { } for (int j = i0; j < numEdgesPlaced; j++) { - if (i == computeGraphArgs.GPtr.numVertices-1) { + if (i == GPtr.numVertices-1) { break; } - if (i != computeGraphArgs.SDGdataPtr.startVertex[j]) { - if ((j > 0) && (i == computeGraphArgs.SDGdataPtr.startVertex[j-1])) { + if (i != SDGdataPtr.startVertex[j]) { + if ((j > 0) && (i == SDGdataPtr.startVertex[j-1])) { if (j-i0 >= 1) { - int ii = (computeGraphArgs.GPtr.outVertexIndex[i]); + int ii = (GPtr.outVertexIndex[i]); int r = 0; - computeGraphArgs.GPtr.paralEdgeIndex[ii] = i0; - computeGraphArgs.GPtr.outVertexList[ii] = computeGraphArgs.SDGdataPtr.endVertex[i0]; + GPtr.paralEdgeIndex[ii] = i0; + GPtr.outVertexList[ii] = SDGdataPtr.endVertex[i0]; r++; for (int t = (i0+1); t < j; t++) { - if (computeGraphArgs.SDGdataPtr.endVertex[t] != - computeGraphArgs.SDGdataPtr.endVertex[t-1]) + if (SDGdataPtr.endVertex[t] != + SDGdataPtr.endVertex[t-1]) { - computeGraphArgs.GPtr.paralEdgeIndex[ii+r] = t; - computeGraphArgs.GPtr.outVertexList[ii+r] = computeGraphArgs.SDGdataPtr.endVertex[t]; + GPtr.paralEdgeIndex[ii+r] = t; + GPtr.outVertexList[ii+r] = SDGdataPtr.endVertex[t]; r++; } } @@ -328,17 +376,17 @@ public class ComputeGraph { } } /* for j */ - if (i == computeGraphArgs.GPtr.numVertices-1) { + if (i == GPtr.numVertices-1) { int r = 0; if (numEdgesPlaced-i0 >= 0) { - int ii = computeGraphArgs.GPtr.outVertexIndex[i]; - computeGraphArgs.GPtr.paralEdgeIndex[ii+r] = i0; - computeGraphArgs.GPtr.outVertexList[ii+r] = computeGraphArgs.SDGdataPtr.endVertex[i0]; + int ii = GPtr.outVertexIndex[i]; + GPtr.paralEdgeIndex[ii+r] = i0; + GPtr.outVertexList[ii+r] = SDGdataPtr.endVertex[i0]; r++; for (int t = i0+1; t < numEdgesPlaced; 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]; + if (SDGdataPtr.endVertex[t] != SDGdataPtr.endVertex[t-1]) { + GPtr.paralEdgeIndex[ii+r] = t; + GPtr.outVertexList[ii+r] = SDGdataPtr.endVertex[t]; r++; } } @@ -347,27 +395,29 @@ public class ComputeGraph { } /* for i */ + Barrier.enterBarrier(); if (myId == 0) { - computeGraphArgs.SDGdataPtr.startVertex = null; - computeGraphArgs.SDGdataPtr.endVertex = null; - computeGraphArgs.GPtr.inDegree = new int[computeGraphArgs.GPtr.numVertices]; - computeGraphArgs.GPtr.inVertexIndex = new int[computeGraphArgs.GPtr.numVertices]; + SDGdataPtr.startVertex = null; + SDGdataPtr.endVertex = null; + GPtr.inDegree = new intwrapper[GPtr.numVertices]; + GPtr.inVertexIndex = new int[GPtr.numVertices]; } Barrier.enterBarrier(); - for (int i = lss.i_start; i < lss.i_stop; i++) { - computeGraphArgs.GPtr.inDegree[i] = 0; - computeGraphArgs.GPtr.inVertexIndex[i] = 0; - } + //No need to zero memory, this is Java + //for (int i = lss.i_start; i < lss.i_stop; i++) { + // GPtr.inDegree[i] = 0; + // GPtr.inVertexIndex[i] = 0; + //} /* A temp. array to store the inplied edges */ - int[] impliedEdgeList; + int[][] impliedEdgeList; if (myId == 0) { - impliedEdgeList = new int[computeGraphArgs.GPtr.numVertices * glb.MAX_CLUSTER_SIZE]; + impliedEdgeList = new int[GPtr.numVertices][MAX_CLUSTER_SIZE]; computeGraphArgs.global_impliedEdgeList = impliedEdgeList; } @@ -376,23 +426,32 @@ public class ComputeGraph { impliedEdgeList = computeGraphArgs.global_impliedEdgeList; CreatePartition.createPartition(0, - (computeGraphArgs.GPtr.numVertices * glb.MAX_CLUSTER_SIZE), + GPtr.numVertices, myId, numThread, lss); + + //No need to zero memory, this is Java! + // for (int i = lss.i_start; i < lss.i_stop; i++) { + // for (int j=0;j glb.MAX_CLUSTER_SIZE) { + if (GPtr.inDegree[i] > MAX_CLUSTER_SIZE) { auxArr[i] = null; } } diff --git a/Robust/src/Benchmarks/SingleTM/SSCA2/Graph.java b/Robust/src/Benchmarks/SingleTM/SSCA2/Graph.java index 6651374f..7b1ac28b 100644 --- a/Robust/src/Benchmarks/SingleTM/SSCA2/Graph.java +++ b/Robust/src/Benchmarks/SingleTM/SSCA2/Graph.java @@ -14,7 +14,7 @@ public class Graph { public int[] outVertexList; public int[] paralEdgeIndex; - public int[] inDegree; + public intwrapper[] inDegree; public int[] inVertexIndex; public int[] inVertexList;