From 1937d2bdcb4a4ac145eb392728d83e970e18ff4b Mon Sep 17 00:00:00 2001 From: stephey Date: Fri, 1 Apr 2011 19:55:05 +0000 Subject: [PATCH] These are the files that were giving me trouble last night. The single version runs fine, the rcr version errors out (either it's a RCR build problem, an RCR runtime error, or it screws with the data of the actual program and causes it to error out at Cavity.build...). This may indicate that there's something wrong with our runtime... --- .../oooJava/DelaunayRefinement/Cavity.java | 71 ++++++++---- .../SerialDelaunayRefinement.java | 106 +++++++++++------- 2 files changed, 114 insertions(+), 63 deletions(-) diff --git a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Cavity.java b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Cavity.java index c584b9fe..82176e24 100644 --- a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Cavity.java +++ b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Cavity.java @@ -36,14 +36,14 @@ public class Cavity { connections.clear(); frontier = new LinkedList(); centerNode = node; - for (centerElement = (Element) graph.getNodeData(centerNode); graph.containsNode(centerNode) + for (centerElement = (Element) getNodeData(centerNode); graph.containsNode(centerNode) && centerElement.isObtuse();) { Edge_d oppositeEdge = getOpposite(centerNode); - if (graph.getSource(oppositeEdge) == centerNode) - centerNode = graph.getDest(oppositeEdge); + if (getSource(oppositeEdge) == centerNode) + centerNode = getDest(oppositeEdge); else - centerNode = graph.getSource(oppositeEdge); - centerElement = (Element) graph.getNodeData(centerNode); + centerNode = getSource(oppositeEdge); + centerElement = (Element) getNodeData(centerNode); if (centerNode == null) System.exit(-1); } @@ -55,7 +55,7 @@ public class Cavity { } private Edge_d getOpposite(Node node) { - Element element = (Element) graph.getNodeData(node); + Element element = (Element) getNodeData(node); // Don't think we'd run into it but.. // TODO check this. @@ -64,10 +64,10 @@ public class Cavity { // Integer.valueOf(neighbors.size()) // })); - for (Iterator iterator = graph.getOutNeighbors(node); iterator.hasNext();) { + for (Iterator iterator = getOutNeighbors(node); iterator.hasNext();) { Node neighbor = (Node) iterator.next(); - Edge_d edge = graph.getEdge(node, neighbor); - ElementEdge edge_data = (ElementEdge) graph.getEdgeData(edge); + Edge_d edge = getEdge(node, neighbor); + ElementEdge edge_data = (ElementEdge) getEdgeData(edge); if (element.getObtuse().notEquals(edge_data.getPoint(0)) && element.getObtuse().notEquals(edge_data.getPoint(1))) return edge; @@ -79,17 +79,17 @@ public class Cavity { } public boolean isMember(Node node) { - Element element = (Element) graph.getNodeData(node); + Element element = (Element) getNodeData(node); return element.inCircle(center); } public void build() { while (frontier.size() != 0) { Node curr = (Node) frontier.removeFirst(); - for (Iterator iterator = graph.getOutNeighbors(curr); iterator.hasNext();) { + for (Iterator iterator = getOutNeighbors(curr); iterator.hasNext();) { Node next = (Node) iterator.next(); - Element nextElement = (Element) graph.getNodeData(next); - Edge_d edge = graph.getEdge(curr, next); + Element nextElement = (Element) getNodeData(next); + Edge_d edge = getEdge(curr, next); if ((dim != 2 || nextElement.getDim() != 2 || next == centerNode) && isMember(next)) { if (nextElement.getDim() == 2 && dim != 2) { initialize(next); @@ -122,17 +122,17 @@ public class Cavity { Node ne_node; for (HashMapIterator iterator = connections.iterator(); iterator.hasNext(); post.addNode(ne_node)) { Edge_d conn = (Edge_d) iterator.next(); - ElementEdge edge = (ElementEdge) graph.getEdgeData(conn); + ElementEdge edge = (ElementEdge) getEdgeData(conn); Element new_element = new Element(center, edge.getPoint(0), edge.getPoint(1)); ne_node = graph.createNode(new_element); Node ne_connection; - if (pre.existsNode(graph.getDest(conn))) - ne_connection = graph.getSource(conn); + if (pre.existsNode(getDest(conn))) + ne_connection = getSource(conn); else - ne_connection = graph.getDest(conn); + ne_connection = getDest(conn); ElementEdge new_edge = - new_element.getRelatedEdge((Element) graph.getNodeData(ne_connection)); - post.addEdge(graph.createEdge(ne_node, ne_connection, new_edge)); + new_element.getRelatedEdge((Element) getNodeData(ne_connection)); + post.addEdge(createEdge(ne_node, ne_connection, new_edge)); // Collection postnodes = (Collection)post.getNodes().clone(); LinkedList postnodes = new LinkedList(); @@ -142,12 +142,41 @@ public class Cavity { for (Iterator iterator1 = postnodes.iterator(); iterator1.hasNext();) { Node node = (Node) iterator1.next(); - Element element = (Element) graph.getNodeData(node); + Element element = (Element) getNodeData(node); if (element.isRelated(new_element)) { ElementEdge ele_edge = new_element.getRelatedEdge(element); - post.addEdge(graph.createEdge(ne_node, node, ele_edge)); + post.addEdge(createEdge(ne_node, node, ele_edge)); } } } } + + private Object getNodeData(Node n) { + return ((EdgeGraphNode) n).data; + } + + public Node getSource(Edge_d e) { + return ((GraphEdge) e).getSrc(); + } + + public Node getDest(Edge_d e) { + return ((GraphEdge) e).getDest(); + } + + public Edge_d getEdge(Node src, Node dest) { + return ((EdgeGraphNode) src).getOutEdge((EdgeGraphNode) dest); + } + + + public Edge_d createEdge(Node src, Node dest, Object e) { + return new GraphEdge((EdgeGraphNode) src, (EdgeGraphNode) dest, e); + } + + public Iterator getOutNeighbors(Node src) { + return ((EdgeGraphNode) src).getOutNeighbors(); + } + + public Object getEdgeData(Edge_d e) { + return ((GraphEdge) e).d; + } } diff --git a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/SerialDelaunayRefinement.java b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/SerialDelaunayRefinement.java index ccf56c89..97be45cc 100644 --- a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/SerialDelaunayRefinement.java +++ b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/SerialDelaunayRefinement.java @@ -96,61 +96,46 @@ public class SerialDelaunayRefinement { long startTime = System.currentTimeMillis(); while (!worklist.isEmpty()) { - - -// Node bad_element = (Node) worklist.pop(); - Node[] bad_elements = new Node[20]; - for(int i=0;i<20;i++) { + Node[] bad_elements = new Node[23]; + for(int i=0;i<23;i++) { if(worklist.isEmpty()) { - bad_elements[i] = null; + bad_elements[i] = null; } else { bad_elements[i] = (Node) worklist.pop(); } } - for(int i = 0; i<20;i++) - { + // Node bad_element = (Node) worklist.pop(); + for(int i=0;i<23;i++) { Node bad_element = bad_elements[i]; if (bad_element != null && mesh.containsNode(bad_element)) { - rblock P { - Cavity cavity = new Cavity(mesh); - cavity.initialize(bad_element); - cavity.build(); - cavity.update(); - - //remove old data - Node node; - for (Iterator iterator = cavity.getPre().getNodes().iterator(); iterator.hasNext();) { - node = (Node) iterator.next(); - mesh.removeNode(node); - } - - //add new data - for (Iterator iterator1 = cavity.getPost().getNodes().iterator(); iterator1.hasNext();) { - node = (Node) iterator1.next(); - mesh.addNode(node); - } - - Edge_d edge; - for (Iterator iterator2 = cavity.getPost().getEdges().iterator(); iterator2.hasNext();) { - edge = (Edge_d) iterator2.next(); - mesh.addEdge(edge); - } + sese P { + //takes < 1 sec + Cavity cavity = new Cavity(mesh); + + //Appears to only call getters (only possible conflict is inherent in Hashmap) + cavity.initialize(bad_element); + + //Takes up 15% of computation + //Problem:: Build is recursive upon building neighbor upon neighbor upon neighbor + //This is could be a problem.... + //TODO check dimensions problem + cavity.build(); + + //Takes up a whooping 50% of computation time and changes NOTHING but cavity :D + cavity.update(); } - rblock S { - // worklist.addAll(cavity.getPost().newBad(mesh)); - it = cavity.getPost().newBad(mesh).iterator(); - while (it.hasNext()) { - worklist.push((Node)it.next()); - } - - if (mesh.containsNode(bad_element)) { - worklist.push((Node) bad_element); - } + sese S { + //28% of runtime #Removes stuff out of our mesh + middle(mesh, cavity); + + //1.5% of runtime # adds stuff back to the work queue. + end(mesh, worklist, bad_element, cavity); } } + } } long time = System.currentTimeMillis() - startTime; @@ -163,6 +148,43 @@ public class SerialDelaunayRefinement { return time; } + private void end(EdgeGraph mesh, Stack worklist, Node bad_element, Cavity cavity) { + HashMapIterator it2 = cavity.getPost().newBad(mesh).iterator(); + while (it2.hasNext()) { + worklist.push((Node)it2.next()); + } + + if (mesh.containsNode(bad_element)) { + worklist.push((Node) bad_element); + } + } + + private void middle(EdgeGraph mesh, Cavity cavity) { + //remove old data + Node node; + + //Takes up 8.9% of runtime + for (Iterator iterator = cavity.getPre().getNodes().iterator(); iterator.hasNext();) { + node = (Node) iterator.next(); + mesh.removeNode(node); + } + + //add new data + //Takes up 1.7% of runtime + for (Iterator iterator1 = cavity.getPost().getNodes().iterator(); iterator1.hasNext();) { + node = (Node) iterator1.next(); + mesh.addNode(node); + } + + + //Takes up 7.8% of runtime + Edge_d edge; + for (Iterator iterator2 = cavity.getPost().getEdges().iterator(); iterator2.hasNext();) { + edge = (Edge_d) iterator2.next(); + mesh.addEdge(edge); + } + } + public void verify(EdgeGraph result) { //Put in cuz of static issues. Mesh m = new Mesh(); -- 2.34.1