From 178434b139748fcbba6a7a52f6ef5af61903435a Mon Sep 17 00:00:00 2001 From: stephey Date: Tue, 29 Mar 2011 23:37:34 +0000 Subject: [PATCH] Compiles with a few warnings... Doesn't run yet though. --- .../oooJava/DelaunayRefinement/Cavity.java | 18 +++++---- .../oooJava/DelaunayRefinement/Edge.java | 4 -- .../DelaunayRefinement/EdgeGraphNode.java | 2 +- .../oooJava/DelaunayRefinement/Edge_d.java | 2 +- .../oooJava/DelaunayRefinement/Element.java | 2 +- .../oooJava/DelaunayRefinement/GraphEdge.java | 2 +- .../oooJava/DelaunayRefinement/Mesh.java | 14 ++++--- .../oooJava/DelaunayRefinement/Node.java | 2 +- ...ent.java => SerialDelaunayRefinement.java} | 38 ++++++++++++------- .../oooJava/DelaunayRefinement/makefile | 4 +- .../oooJava/DelaunayRefinement/runs | 1 + 11 files changed, 50 insertions(+), 39 deletions(-) delete mode 100644 Robust/src/Benchmarks/oooJava/DelaunayRefinement/Edge.java rename Robust/src/Benchmarks/oooJava/DelaunayRefinement/{SerialDelaunayrefinement.java => SerialDelaunayRefinement.java} (81%) create mode 100755 Robust/src/Benchmarks/oooJava/DelaunayRefinement/runs diff --git a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Cavity.java b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Cavity.java index 9f84dc28..948c3820 100644 --- a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Cavity.java +++ b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Cavity.java @@ -3,15 +3,17 @@ public class Cavity { protected Node centerNode; protected Element centerElement; protected int dim; - protected LinkedList frontier = new LinkedList(); + protected LinkedList frontier; protected Subgraph pre = new Subgraph(); protected Subgraph post = new Subgraph(); private final EdgeGraph graph; - protected HashSet connections = new HashSet(); + protected HashSet connections; public Cavity(EdgeGraph mesh) { center = null; graph = mesh; + connections = new HashSet(); + frontier = new LinkedList(); } public Subgraph getPre() { @@ -31,8 +33,8 @@ public class Cavity { public void initialize(Node node) { pre.reset(); post.reset(); - connections.clear(); - frontier.clear(); + connections = new HashSet(); + frontier = new LinkedList(); centerNode = node; for (centerElement = (Element) graph.getNodeData(centerNode); graph.containsNode(centerNode) && centerElement.isObtuse();) { @@ -65,7 +67,7 @@ public class Cavity { for (Iterator iterator = graph.getOutNeighbors(node); iterator.hasNext();) { Node neighbor = (Node) iterator.next(); Edge_d edge = graph.getEdge(node, neighbor); - Element.Edge edge_data = (Element.Edge) graph.getEdgeData(edge); + ElementEdge edge_data = (ElementEdge) graph.getEdgeData(edge); if (element.getObtuse().notEquals(edge_data.getPoint(0)) && element.getObtuse().notEquals(edge_data.getPoint(1))) return edge; @@ -120,7 +122,7 @@ public class Cavity { Node ne_node; for (Iterator iterator = connections.iterator(); iterator.hasNext(); post.addNode(ne_node)) { Edge_d conn = (Edge_d) iterator.next(); - Element.Edge edge = (Element.Edge) graph.getEdgeData(conn); + ElementEdge edge = (ElementEdge) graph.getEdgeData(conn); Element new_element = new Element(center, edge.getPoint(0), edge.getPoint(1)); ne_node = graph.createNode(new_element); Node ne_connection; @@ -128,7 +130,7 @@ public class Cavity { ne_connection = graph.getSource(conn); else ne_connection = graph.getDest(conn); - Element.Edge new_edge = + ElementEdge new_edge = new_element.getRelatedEdge((Element) graph.getNodeData(ne_connection)); post.addEdge(graph.createEdge(ne_node, ne_connection, new_edge)); @@ -142,7 +144,7 @@ public class Cavity { Node node = (Node) iterator1.next(); Element element = (Element) graph.getNodeData(node); if (element.isRelated(new_element)) { - Element.Edge ele_edge = new_element.getRelatedEdge(element); + ElementEdge ele_edge = new_element.getRelatedEdge(element); post.addEdge(graph.createEdge(ne_node, node, ele_edge)); } } diff --git a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Edge.java b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Edge.java deleted file mode 100644 index af77980c..00000000 --- a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Edge.java +++ /dev/null @@ -1,4 +0,0 @@ -public interface Edge { - public abstract Object getData(); - public abstract Object setData(Object obj); -} diff --git a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/EdgeGraphNode.java b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/EdgeGraphNode.java index 6d273117..0c74d66c 100644 --- a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/EdgeGraphNode.java +++ b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/EdgeGraphNode.java @@ -1,4 +1,4 @@ -public class EdgeGraphNode implements Node { +public class EdgeGraphNode extends Node { protected HashMap inEdges; protected HashMap outEdges; protected Object data; diff --git a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Edge_d.java b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Edge_d.java index afa21eed..a421dbb9 100644 --- a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Edge_d.java +++ b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Edge_d.java @@ -1,4 +1,4 @@ -public interface Edge_d { +public class Edge_d { //None of the program actually uses getData/setData so I use leave Edge as a //wrapper interface. // public abstract Object getData(); diff --git a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Element.java b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Element.java index eabce7f9..64993165 100644 --- a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Element.java +++ b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Element.java @@ -7,7 +7,7 @@ public class Element { private final int dim; private final Tuple center; private final double radius_squared; - private static final double MINANGLE = 30D; + private final double MINANGLE = 30D; public Element(Tuple a, Tuple b, Tuple c) { dim = 3; diff --git a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/GraphEdge.java b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/GraphEdge.java index 1235e89b..c17e8c3c 100644 --- a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/GraphEdge.java +++ b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/GraphEdge.java @@ -1,4 +1,4 @@ -public class GraphEdge implements Edge_d { +public class GraphEdge extends Edge_d { protected EdgeGraphNode src; protected EdgeGraphNode dest; protected Object d; diff --git a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Mesh.java b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Mesh.java index 4a44bb6c..39142607 100644 --- a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Mesh.java +++ b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Mesh.java @@ -1,10 +1,11 @@ public class Mesh { - protected static final HashMap edge_map = new HashMap(); + protected HashMap edge_map; public Mesh() { + edge_map = new HashMap(); } - public static HashSet getBad(EdgeGraph mesh) { + public HashSet getBad(EdgeGraph mesh) { HashSet ret = new HashSet(); for (Iterator iterator = mesh.iterator(); iterator.hasNext();) { Node node = (Node) iterator.next(); @@ -16,7 +17,7 @@ public class Mesh { return ret; } - private static FileInputStream getScanner(String filename) { + private FileInputStream getScanner(String filename) { return new FileInputStream(filename); } @@ -96,7 +97,7 @@ public class Mesh { return node; } - public static boolean verify(EdgeGraph mesh) { + public boolean verify(EdgeGraph mesh) { for (Iterator iterator = mesh.iterator(); iterator.hasNext();) { Node node = (Node) iterator.next(); Element element = (Element) mesh.getNodeData(node); @@ -117,10 +118,11 @@ public class Mesh { } Node start = mesh.getRandom(); - Stack remaining = new Stack(); +// Stack remaining = new Stack(); + LinkedList remaining = new LinkedList(); HashSet found = new HashSet(); remaining.push(start); - while (!remaining.empty()) { + while (!remaining.isEmpty()) { Node node = (Node) remaining.pop(); if (!found.contains(node)) { found.add(node); diff --git a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Node.java b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Node.java index aed41072..5f71f4f8 100644 --- a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Node.java +++ b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/Node.java @@ -1,4 +1,4 @@ -public interface Node { +public class Node { //None of the program actually uses getData/setData so I use leave Node as a //wrapper interface. diff --git a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/SerialDelaunayrefinement.java b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/SerialDelaunayRefinement.java similarity index 81% rename from Robust/src/Benchmarks/oooJava/DelaunayRefinement/SerialDelaunayrefinement.java rename to Robust/src/Benchmarks/oooJava/DelaunayRefinement/SerialDelaunayRefinement.java index 091eed86..1746b2c6 100644 --- a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/SerialDelaunayrefinement.java +++ b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/SerialDelaunayRefinement.java @@ -1,11 +1,15 @@ -public class SerialDelaunayrefinement { - - private static boolean isFirstRun = true; - - public SerialDelaunayrefinement() { +public class SerialDelaunayRefinement { + public boolean isFirstRun; + public SerialDelaunayRefinement() { + isFirstRun = true; } public static void main(String args[]) { + SerialDelaunayRefinement sdr = new SerialDelaunayRefinement(); + sdr.runMain(args); + } + + public void runMain(String args[]) { long runtime = 0; //Numbers below are Long.Max_Value long lasttime = 0x7fffffffffffffffL; @@ -20,8 +24,9 @@ public class SerialDelaunayrefinement { System.out.println("minimum runtime: " + mintime + " ms"); System.out.println(""); } + - public static long run(String args[]) { + public long run(String args[]) { if (isFirstRun) { System.out.println(); System.out.println("Lonestar Benchmark Suite v2.1"); @@ -44,7 +49,9 @@ public class SerialDelaunayrefinement { Mesh m = new Mesh(); m.read(mesh, args[0]); - Stack worklist = new Stack(); + //treat LinkedList as a stack +// Stack worklist = new Stack(); + LinkedList worklist = new LinkedList(); // worklist.addAll(Mesh.getBad(mesh)); HashMapIterator it = m.getBad(mesh).iterator(); @@ -54,12 +61,12 @@ public class SerialDelaunayrefinement { Cavity cavity = new Cavity(mesh); if (isFirstRun) { - System.err.println("configuration: " + mesh.getNumNodes() + " total triangles, " + worklist.size() + " bad triangles"); + System.out.println("configuration: " + mesh.getNumNodes() + " total triangles, " + worklist.size() + " bad triangles"); System.out.println(); } // long id = Time.getNewTimeId(); long startTime = System.currentTimeMillis(); - while (!worklist.empty()) { + while (!worklist.isEmpty()) { Node bad_element = (Node) worklist.pop(); if (bad_element != null && mesh.containsNode(bad_element)) { cavity.initialize(bad_element); @@ -82,11 +89,11 @@ public class SerialDelaunayrefinement { // worklist.addAll(cavity.getPost().newBad(mesh)); it = cavity.getPost().newBad(mesh).iterator(); while (it.hasNext()) { - worklist.push(it.next()); + worklist.push((Node)it.next()); } if (mesh.containsNode(bad_element)) { - worklist.push(bad_element); + worklist.push((Node) bad_element); } } } @@ -99,14 +106,17 @@ public class SerialDelaunayrefinement { return time; } - public static void verify(EdgeGraph result) { - if (!Mesh.verify(result)) { + public void verify(EdgeGraph result) { + //Put in cuz of static issues. + Mesh m = new Mesh(); + + if (!m.verify(result)) { // throw new IllegalStateException("refinement failed."); System.out.println("Refinement Failed."); System.exit(-1); } - int size = Mesh.getBad(result).size(); + int size = m.getBad(result).size(); if (size != 0) { System.out.println("refinement failed\nstill have "+size+" bad triangles left.\n"); System.exit(-1); diff --git a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/makefile b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/makefile index d4ed3adb..bfc6b8b2 100644 --- a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/makefile +++ b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/makefile @@ -1,6 +1,6 @@ -PROGRAM=DelaunayRefinement +PROGRAM=SerialDelaunayRefinement -SOURCE_FILES=SerialDelaunayrefinement.java +SOURCE_FILES=SerialDelaunayRefinement.java NUM_OOO_WORKERS=24 NUM_RCR_WORKERS=23 diff --git a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/runs b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/runs new file mode 100755 index 00000000..9a0c9345 --- /dev/null +++ b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/runs @@ -0,0 +1 @@ +./SerialDelaunayRefinements.bin ./input/large.2 true -- 2.34.1