2 Lonestar Benchmark Suite for irregular applications that exhibit
3 amorphous data-parallelism.
5 Center for Grid and Distributed Computing
6 The University of Texas at Austin
8 Copyright (C) 2007, 2008, 2009 The University of Texas at Austin
10 Licensed under the Eclipse Public License, Version 1.0 (the "License");
11 you may not use this file except in compliance with the License.
12 You may obtain a copy of the License at
14 http://www.eclipse.org/legal/epl-v10.html
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
22 File: UndirectedEdgeGraph.java
26 public class SerialDelaunayRefinement {
27 public boolean isFirstRun;
28 public SerialDelaunayRefinement() {
32 public static void main(String args[]) {
33 SerialDelaunayRefinement sdr = new SerialDelaunayRefinement();
37 public void runMain(String args[]) {
39 //Numbers below are Long.Max_Value
40 long lasttime = 0x7fffffffffffffffL;
41 long mintime = 0x7fffffffffffffffL;
42 for (long run = 0; ((run < 3) || Math.abs(lasttime - runtime) * 64 > Math.min(lasttime, runtime)) && run < 7; run++) {
44 if (runtime < mintime) {
50 System.out.println("minimum runtime: " + mintime + " ms");
51 System.out.println("");
55 public long run(String args[]) {
58 System.out.println("Lonestar Benchmark Suite v2.1");
59 System.out.println("Copyright (C) 2007, 2008, 2009 The University of Texas at Austin");
60 System.out.println("http://iss.ices.utexas.edu/lonestar/");
62 System.out.println("application: Delaunay Mesh Refinement (serial version)");
63 System.out.println("Refines a Delaunay triangulation mesh such that no angle");
64 System.out.println("in the mesh is less than 30 degrees");
65 System.out.println("http://iss.ices.utexas.edu/lonestar/delaunayrefinement.html");
68 if (args.length < 1) {
69 System.out.println("Arguments: <input file> [verify]");
73 EdgeGraph mesh = new UndirectedEdgeGraph();
76 m.read(mesh, args[0]);
78 //treat LinkedList as a stack
79 Stack worklist = new Stack();
80 // LinkedList worklist = new LinkedList();
82 // worklist.addAll(Mesh.getBad(mesh));
83 HashMapIterator it = m.getBad(mesh).iterator();
84 while (it.hasNext()) {
85 worklist.push(it.next());
89 System.out.println("configuration: " + mesh.getNumNodes() + " total triangles, " + worklist.size() + " bad triangles");
95 // long id = Time.getNewTimeId();
96 long startTime = System.currentTimeMillis();
97 while (!worklist.isEmpty()) {
99 Node[] bad_elements = new Node[23];
100 for(int i=0;i<23;i++) {
101 if(worklist.isEmpty()) {
102 bad_elements[i] = null;
104 bad_elements[i] = (Node) worklist.pop();
108 // Node bad_element = (Node) worklist.pop();
109 for(int i=0;i<23;i++) {
110 Node bad_element = bad_elements[i];
111 if (bad_element != null && mesh.containsNode(bad_element)) {
115 Cavity cavity = new Cavity(mesh);
117 //Appears to only call getters (only possible conflict is inherent in Hashmap)
118 cavity.initialize(bad_element);
120 //Takes up 15% of computation
121 //Problem:: Build is recursive upon building neighbor upon neighbor upon neighbor
122 //This is could be a problem....
123 //TODO check dimensions problem
126 //Takes up a whooping 50% of computation time and changes NOTHING but cavity :D
131 //28% of runtime #Removes stuff out of our mesh
132 middle(mesh, cavity);
134 //1.5% of runtime # adds stuff back to the work queue.
135 end(mesh, worklist, bad_element, cavity);
141 long time = System.currentTimeMillis() - startTime;
142 System.out.println("runtime: " + time + " ms");
143 //TODO note how we only verify on first run...
144 if (isFirstRun && args.length > 1) {
151 private void end(EdgeGraph mesh, Stack worklist, Node bad_element, Cavity cavity) {
152 HashMapIterator it2 = cavity.getPost().newBad(mesh).iterator();
153 while (it2.hasNext()) {
154 worklist.push((Node)it2.next());
157 if (mesh.containsNode(bad_element)) {
158 worklist.push((Node) bad_element);
162 private void middle(EdgeGraph mesh, Cavity cavity) {
166 //Takes up 8.9% of runtime
167 for (Iterator iterator = cavity.getPre().getNodes().iterator(); iterator.hasNext();) {
168 node = (Node) iterator.next();
169 mesh.removeNode(node);
173 //Takes up 1.7% of runtime
174 for (Iterator iterator1 = cavity.getPost().getNodes().iterator(); iterator1.hasNext();) {
175 node = (Node) iterator1.next();
180 //Takes up 7.8% of runtime
182 for (Iterator iterator2 = cavity.getPost().getEdges().iterator(); iterator2.hasNext();) {
183 edge = (Edge_d) iterator2.next();
188 public void verify(EdgeGraph result) {
189 //Put in cuz of static issues.
191 if (!m.verify(result)) {
192 // throw new IllegalStateException("refinement failed.");
193 System.out.println("Refinement Failed.");
197 int size = m.getBad(result).size();
199 System.out.println("refinement failed\nstill have "+size+" bad triangles left.\n");
202 System.out.println("OK");