From 9b6349bcbb598329be0549b4fe418eb6b0504de1 Mon Sep 17 00:00:00 2001 From: stephey Date: Sat, 19 Jun 2010 00:15:30 +0000 Subject: [PATCH] Adding Labyrinth3D files in mlp, Normal_Java is a form of Labyrinth3D that can compile under normal Java. in mlp, rBlocked is the rBlocked version that will compile with our compiler NOTE: there seems to be a bug with make java in that the program skips right over rBlocks to print out statistics on the last part of the program EVEN THOUGH there are data dependencies. Yonghun suspects it's a bug in the compiler and will investigate over the weekend in Original, Normal_Java is the original Labyrinth3D code with TM code removed and slightly modded to work with Normal Java. --- .../Original/Normal_Java/Coordinate.java | 178 +++++++ .../Original/Normal_Java/Grid.java | 281 +++++++++++ .../Original/Normal_Java/Labyrinth.java | 248 ++++++++++ .../Original/Normal_Java/List_Iter.java | 38 ++ .../Original/Normal_Java/List_Node.java | 10 + .../Original/Normal_Java/List_t.java | 306 ++++++++++++ .../Original/Normal_Java/Math.java | 136 ++++++ .../Original/Normal_Java/Maze.java | 406 ++++++++++++++++ .../Original/Normal_Java/Pair.java | 86 ++++ .../Original/Normal_Java/Point.java | 25 + .../Original/Normal_Java/Queue_Int.java | 412 ++++++++++++++++ .../Original/Normal_Java/Queue_t.java | 300 ++++++++++++ .../Original/Normal_Java/Router.java | 415 ++++++++++++++++ .../Original/Normal_Java/Solve_arg.java | 15 + .../Original/Normal_Java/Vector_t.java | 140 ++++++ .../Original/Normal_Java/extractLines | 3 + .../mlp/Normal_Java/CoordPathWrapper.java | 12 + .../mlp/Normal_Java/Coordinate.java | 175 +++++++ .../Labyrinth3D/mlp/Normal_Java/Grid.java | 287 +++++++++++ .../mlp/Normal_Java/Labyrinth.java | 239 +++++++++ .../mlp/Normal_Java/List_Iter.java | 38 ++ .../mlp/Normal_Java/List_Node.java | 10 + .../Labyrinth3D/mlp/Normal_Java/List_t.java | 307 ++++++++++++ .../Labyrinth3D/mlp/Normal_Java/Math.java | 136 ++++++ .../Labyrinth3D/mlp/Normal_Java/Maze.java | 417 ++++++++++++++++ .../Labyrinth3D/mlp/Normal_Java/Pair.java | 86 ++++ .../Labyrinth3D/mlp/Normal_Java/Point.java | 25 + .../mlp/Normal_Java/Queue_Int.java | 412 ++++++++++++++++ .../Labyrinth3D/mlp/Normal_Java/Queue_t.java | 308 ++++++++++++ .../Labyrinth3D/mlp/Normal_Java/Router.java | 459 ++++++++++++++++++ .../mlp/Normal_Java/Solve_Arg.java | 16 + .../Labyrinth3D/mlp/Normal_Java/Vector_t.java | 140 ++++++ .../Labyrinth3D/mlp/Normal_Java/extractLines | 3 + .../mlp/rBlocked/CoordPathWrapper.java | 20 + .../Labyrinth3D/mlp/rBlocked/Coordinate.java | 175 +++++++ .../Labyrinth3D/mlp/rBlocked/Grid.java | 287 +++++++++++ .../Labyrinth3D/mlp/rBlocked/Labyrinth.java | 239 +++++++++ .../Labyrinth3D/mlp/rBlocked/List_Iter.java | 38 ++ .../Labyrinth3D/mlp/rBlocked/List_Node.java | 10 + .../Labyrinth3D/mlp/rBlocked/List_t.java | 307 ++++++++++++ .../Labyrinth3D/mlp/rBlocked/Maze.java | 395 +++++++++++++++ .../Labyrinth3D/mlp/rBlocked/Pair.java | 86 ++++ .../Labyrinth3D/mlp/rBlocked/Point.java | 25 + .../Labyrinth3D/mlp/rBlocked/Queue_Int.java | 412 ++++++++++++++++ .../Labyrinth3D/mlp/rBlocked/Queue_t.java | 308 ++++++++++++ .../Labyrinth3D/mlp/rBlocked/Router.java | 453 +++++++++++++++++ .../Labyrinth3D/mlp/rBlocked/Solve_Arg.java | 16 + .../Labyrinth3D/mlp/rBlocked/Vector_t.java | 140 ++++++ 48 files changed, 8980 insertions(+) create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/Coordinate.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/Grid.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/Labyrinth.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/List_Iter.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/List_Node.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/List_t.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/Math.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/Maze.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/Pair.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/Point.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/Queue_Int.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/Queue_t.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/Router.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/Solve_arg.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/Vector_t.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/extractLines create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/CoordPathWrapper.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/Coordinate.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/Grid.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/Labyrinth.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/List_Iter.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/List_Node.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/List_t.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/Math.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/Maze.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/Pair.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/Point.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/Queue_Int.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/Queue_t.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/Router.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/Solve_Arg.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/Vector_t.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/extractLines create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/CoordPathWrapper.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/Coordinate.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/Grid.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/Labyrinth.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/List_Iter.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/List_Node.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/List_t.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/Maze.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/Pair.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/Point.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/Queue_Int.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/Queue_t.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/Router.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/Solve_Arg.java create mode 100644 Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/Vector_t.java diff --git a/Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/Coordinate.java b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/Coordinate.java new file mode 100644 index 00000000..68f792b9 --- /dev/null +++ b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/Coordinate.java @@ -0,0 +1,178 @@ +/* ============================================================================= + * + * coordinate.java + * + * ============================================================================= + * + * Copyright (C) Stanford University, 2006. All Rights Reserved. + * Author: Chi Cao Minh + * + * ============================================================================= + * + * For the license of bayes/sort.h and bayes/sort.c, please see the header + * of the files. + * + * ------------------------------------------------------------------------ + * + * For the license of kmeans, please see kmeans/LICENSE.kmeans + * + * ------------------------------------------------------------------------ + * + * For the license of ssca2, please see ssca2/COPYRIGHT + * + * ------------------------------------------------------------------------ + * + * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the + * header of the files. + * + * ------------------------------------------------------------------------ + * + * For the license of lib/rbtree.h and lib/rbtree.c, please see + * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree + * + * ------------------------------------------------------------------------ + * + * Unless otherwise noted, the following license applies to STAMP files: + * + * Copyright (c) 2007, Stanford University + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Stanford University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * ============================================================================= + */ + + + + +import java.lang.Math; + +public class Coordinate { + + public int x; + public int y; + public int z; + + public Coordinate() {} + + + // coordiate_alloc will be constructor + // coordinate_t* coordinate_alloc(long x, long y, long z) + public Coordinate(int x,int y,int z) { + this.x = x; + this.y = y; + this.z = z; + } + + public static Coordinate alloc(int x,int y,int z) { + Coordinate c = new Coordinate(x,y,z); + + return c; + } + + + // deallocate memory + // may not need + // coordinate_free + + /*======================================================== + // coordinate_isEqual + ==========================================================*/ + public static boolean isEqual(Coordinate a,Coordinate b) + { + if((a.x == b.x) && (a.y == b.y) && (a.z == b.z)) + return true; + + return false; + } + + /*========================================================== + * + * getPairDistance + * + *========================================================*/ + private static double getPairDistance(Pair p) + { + Coordinate a = (Coordinate)p.first; + Coordinate b = (Coordinate)p.second; + int dx = a.x - b.x; + int dy = a.y - b.y; + int dz = a.z - b.z; + int dx2 = dx* dx; + int dy2 = dy* dy; + int dz2 = dz* dz; + + return Math.sqrt((double)(dx2+dy2+dz2)); + } + + + /*================================================ + // coordinat_ comparePair + * -- For sorting in list of source/destination pairs + * -- Route longer paths first so they are more likely to suceed + + *================================================*/ + public static int comparePair(final Object a,final Object b) + { + double aDistance = getPairDistance((Pair)a); + double bDistance = getPairDistance((Pair)b); + + if(aDistance < bDistance) { + return 1; + } else if(aDistance > bDistance) { + return -1; + } + + return 0; + } + + /*======================================================= + * coordinate_areAdjacent + *=======================================================*/ + + public static boolean areAdjacent(Coordinate a,Coordinate b) + { + int dx = a.x - b.x; + int dy = a.y - b.y; + int dz = a.z - b.z; + int dx2 = dx * dx; + int dy2 = dy * dy; + int dz2 = dz * dz; + + return (((dx2 + dy2 + dz2) == 1) ? true : false); + } + } + + /*===================================================== + * + * End of Coordinate + * + *====================================================*/ + + diff --git a/Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/Grid.java b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/Grid.java new file mode 100644 index 00000000..6e4e2acc --- /dev/null +++ b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/Grid.java @@ -0,0 +1,281 @@ +/* ============================================================================= + * + * grid.java + * + * ============================================================================= + * + * Copyright (C) Stanford University, 2006. All Rights Reserved. + * Author: Chi Cao Minh + * + * ============================================================================= + * + * For the license of bayes/sort.h and bayes/sort.c, please see the header + * of the files. + * + * ------------------------------------------------------------------------ + * + * For the license of kmeans, please see kmeans/LICENSE.kmeans + * + * ------------------------------------------------------------------------ + * + * For the license of ssca2, please see ssca2/COPYRIGHT + * + * ------------------------------------------------------------------------ + * + * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the + * header of the files. + * + * ------------------------------------------------------------------------ + * + * For the license of lib/rbtree.h and lib/rbtree.c, please see + * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree + * + * ------------------------------------------------------------------------ + * + * Unless otherwise noted, the following license applies to STAMP files: + * + * Copyright (c) 2007, Stanford University + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Stanford University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * ============================================================================= + */ + +import java.lang.Long; + +public class Grid { + public int width; + public int height; + public int depth; + public int[][][] points_unaligned; + + public static int GRID_POINT_FULL; + public static int GRID_POINT_EMPTY; + + public Grid() + { + GRID_POINT_FULL = -2; + GRID_POINT_EMPTY = -1; + } + +/* ============================================================================= + * grid_alloc + * ============================================================================= + grid_t* grid_alloc (long width, long height, long depth); + + well... need to implement + got stuck +*/ + public static Grid alloc(int width,int height,int depth) { + Grid grid = new Grid(); + + grid.width = width; + grid.height = height; + grid.depth = depth; + + int[][][] points_unaligned = new int[width][height][depth]; + + + for(int i=0;i=0 && x< width && y>=0 && y=0 && z bend cost"); + System.out.println(" i input file name"); + System.out.println(" p print routed maze"); + System.out.println(" t Number of threads"); + System.out.println(" x x movement cost"); + System.out.println(" y y movement cost"); + System.out.println(" z z movement cost"); + } + + + public static void main(String[] argv) + { + /* + * Initailization + */ + + Labyrinth labyrinth = new Labyrinth(argv); + + Maze mazePtr = Maze.alloc(); + + int numPathToRoute = mazePtr.readMaze(labyrinth.global_inputFile); + + Router routerPtr = Router.alloc(labyrinth.xCost,labyrinth.yCost, + labyrinth.zCost,labyrinth.bendCost); + + List_t pathVectorListPtr = List_t.alloc(0); // list_t.alloc(null) + /* + * Run transactions + */ + Solve_Arg routerArg = new Solve_Arg(routerPtr,mazePtr,pathVectorListPtr); + + /* Create and start thread */ + + Labyrinth[] lb = new Labyrinth[labyrinth.numThread]; + + for(int i = 1; i= 0) { + return prevPtr; + } + prevPtr = nodePtr; + } + + return prevPtr; + } + + /* ============================================================================= + * list_find + * -- Returns NULL if not found, else returns pointer to data + * ============================================================================= + * void* list_find (list_t* listPtr, void* dataPtr); + */ + public Object find(Object dataPtr) { + List_Node nodePtr; + List_Node prevPtr = findPrevious(dataPtr); + + nodePtr = prevPtr.nextPtr; + + if((nodePtr == null) || + (compare(nodePtr.dataPtr,dataPtr) != 0)) { + return null; + } + + return (nodePtr.dataPtr); + } + + public int compare(Object obj1,Object obj2) + { + if(isCoordinate) + { + return Coordinate.comparePair(obj1,obj2); + } + else + return compareObject(obj1,obj2); + } + +/* ============================================================================= + * list_insert + * -- Return TRUE on success, else FALSE + * ============================================================================= + * bool_t list_insert (list_t* listPtr, void* dataPtr); + */ + public boolean insert(Object dataPtr) { + List_Node prevPtr; + List_Node nodePtr; + List_Node currPtr; + + prevPtr = findPrevious(dataPtr); + currPtr = prevPtr.nextPtr; + + nodePtr = allocNode(dataPtr); + if (nodePtr == null) { + return false; + } + + nodePtr.nextPtr = currPtr; + prevPtr.nextPtr = nodePtr; + size++; + + return true; + } + + +/* ============================================================================= + * list_remove + * -- Returns TRUE if successful, else FALSE + * ============================================================================= + * bool_t list_remove (list_t* listPtr, void* dataPtr); + */ + public boolean remove(Object dataPtr) + { + List_Node prevPtr; + List_Node nodePtr; + + prevPtr = findPrevious(dataPtr); + + nodePtr = prevPtr.nextPtr; + + if((nodePtr != null) && + (compare(nodePtr.dataPtr,dataPtr) == 0)) + { + prevPtr.nextPtr = nodePtr.nextPtr; + nodePtr.nextPtr = null; + nodePtr = null; + size--; + + return true; + } + + return false; + } + + int compareObject(Object obj1,Object obj2) { + return 1; + } + + +/* ============================================================================= + * list_clear + * -- Removes all elements + * ============================================================================= + * void list_clear (list_t* listPtr); + */ + public void clear() { + head = new List_Node(); + size = 0; + } + +/* ============================================================================= + * + * End of list.java + * + * ============================================================================= + */ + + /* Test list */ + + public static void main(String[] argv) { + List_t listPtr; + int[] data1 = new int[5]; + int[] data2 = new int[6]; + + int i; + + System.out.println("Starting..."); + } + +} + + + diff --git a/Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/Math.java b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/Math.java new file mode 100644 index 00000000..7e6a59f6 --- /dev/null +++ b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/Math.java @@ -0,0 +1,136 @@ +public class Math { + + public static double setPI() { + double PI = 3.14159265358979323846; + return PI; + } + + // an alias for setPI() + public static double PI() { + double PI = 3.14159265358979323846; + return PI; + } + + public static int abs(int x) { + if (x < 0) { + return -x; + } else { + return x; + } + } + + public static double fabs(double x) { + if (x < 0) { + return -x; + } else { + return x; + } + } + + public static double abs(double x) { + if (x < 0) { + return -x; + } else { + return x; + } + } + + public static float abs(float a) { + if (a<0) + return -a; + else return a; + } + + public static double max(double a, double b) { + if(a == b) + return a; + if(a > b) { + return a; + } else { + return b; + } + } + + public static int max(int a, int b) { + if(a == b) + return a; + if(a > b) { + return a; + } else { + return b; + } + } + + public static int imax(int a, int b) { + if(a == b) + return a; + if(a > b) { + return a; + } else { + return b; + } + } + + public static int imin(int a, int b) { + if(a == b) + return a; + if(a > b) { + return b; + } else { + return a; + } + } + + /** sqrt(a^2 + b^2) without under/overflow. **/ + public static double hypot(double a, double b) { + double r; + if (fabs(a) > fabs(b)) { + r = b/a; + r = fabs(a)*sqrt(1+r*r); + } else if (b != 0) { + r = a/b; + r = fabs(b)*sqrt(1+r*r); + } else { + r = 0.0; + } + return r; + } + + public static double rint(double x) { + double y = ceil(x); + double d = y - x; + if( d == 0.5 ) { + if( ((int)y)%2 == 0 ) { + return y; + } else { + return y - 1.0; + } + } else if( d < 0.5 ) { + return y; + } + return y - 1.0; + } + + public static native double sin(double a); + public static native double cos(double a); + public static native double asin(double a); + public static native double acos(double a); + public static native double tan(double a); + public static native double atan(double a); + public static native double atan2(double a, double b); + public static native double exp(double a); + public static native double sqrt(double a); + public static native double log(double a); + public static native double pow(double a, double b); + + public static native double ceil(double a); + public static native double floor(double a); + + public static native float sinf(float a); + public static native float cosf(float a); + public static native float expf(float a); + public static native float sqrtf(float a); + public static native float logf(float a); + public static native float powf(float a, float b); + public static native float ceilf(float a); +} diff --git a/Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/Maze.java b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/Maze.java new file mode 100644 index 00000000..354269e8 --- /dev/null +++ b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/Original/Normal_Java/Maze.java @@ -0,0 +1,406 @@ +import java.io.File; +import java.util.Scanner; +import java.util.StringTokenizer; + +/*============================================================================= + * + * Maze.java + * + * ============================================================================= + * + * Copyright (C) Stanford University, 2006. All Rights Reserved. + * Author: Chi Cao Minh + * + * ============================================================================= + * + * For the license of bayes/sort.h and bayes/sort.c, please see the header + * of the files. + * + * ------------------------------------------------------------------------ + * + * For the license of kmeans, please see kmeans/LICENSE.kmeans + * + * ------------------------------------------------------------------------ + * + * For the license of ssca2, please see ssca2/COPYRIGHT + * + * ------------------------------------------------------------------------ + * + * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the + * header of the files. + * + * ------------------------------------------------------------------------ + * + * For the license of lib/rbtree.h and lib/rbtree.c, please see + * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree + * + * ------------------------------------------------------------------------ + * + * Unless otherwise noted, the following license applies to STAMP files: + * + * Copyright (c) 2007, Stanford University + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Stanford University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * ============================================================================= + */ + +public class Maze { + Grid gridPtr; + Queue_t workQueuePtr; + Vector_t wallVectorPtr; /* contains source/destination pairs to route */ + Vector_t srcVectorPtr; /* obstacles */ + Vector_t dstVectorPtr; /* destinations */ + + public int GRID_POINT_FULL; + public int GRID_POINT_EMPTY; + + public Maze() + { + GRID_POINT_FULL = -2; + GRID_POINT_EMPTY = -1; + } + + +/* ============================================================================= + * maze_alloc + * ============================================================================= + maze_t* maze_alloc (); + */ + public static Maze alloc() + { + Maze mazePtr = new Maze(); + + mazePtr.gridPtr = null; + mazePtr.workQueuePtr = Queue_t.queue_alloc(1024); + mazePtr.wallVectorPtr = Vector_t.vector_alloc(1); + mazePtr.srcVectorPtr = Vector_t.vector_alloc(1); + mazePtr.dstVectorPtr = Vector_t.vector_alloc(1); + + + return mazePtr; + } + +/* ============================================================================= + * maze_free + * ============================================================================= + void maze_free (maze_t* mazePtr); + */ + public static void free(Maze m) + { + m = null; + } + +/* ============================================================================= + * addToGrid + * ============================================================================= + */ + private void addToGrid(Grid gridPtr,Vector_t vectorPtr,String type) + { + int i; + int n = vectorPtr.vector_getSize(); + + for(i = 0; i < n; i++) { + Coordinate coordinatePtr = (Coordinate)vectorPtr.vector_at(i); + if(!gridPtr.isPointValid(coordinatePtr.x,coordinatePtr.y,coordinatePtr.z)) + { + System.out.println("Error: " + type + " (" + coordinatePtr.x + + ", " + coordinatePtr.y + + ", " + coordinatePtr.z); + System.exit(1); + } + } + gridPtr.addPath(vectorPtr); + } +/* ============================================================================= + * maze_read + * -- Return number of path to route + * ============================================================================= + long maze_read (maze_t* mazePtr, char* inputFileName); + */ + public int readMaze(String inputFileName) + { + //TODO remove TRY + try + { +// FileInputStream in = new FileInputStream(inputFileName); + //TODO remove this and uncomment the line above. + Scanner in = new Scanner(new File(inputFileName)); + /* + * Parse input file + */ + int lineNumber = 0; + int height = -1; + int width = -1; + int depth = -1; + boolean isParseError = false; + List_t workListPtr = List_t.alloc(1); // List.alloc(Coordinate.comparePair); + String line; + + //TODO change this back as well +// while((line = in.readLine()) != null) { + while(in.hasNextLine()){ + line = in.nextLine(); + //TODO remove the above + + String code; + int[] xy = new int[6]; // equivalent to x1,y1,z1,x2,y2,z2 + int numToken = 0; + + StringTokenizer tok = new StringTokenizer(line); + + if((numToken = tok.countTokens()) < 1 ) { + continue; + } + + code = tok.nextToken(); + + if(code.equals("#")) { + /* comment line */ + continue; + } + for(int i=0;i ttt$1 diff --git a/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/CoordPathWrapper.java b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/CoordPathWrapper.java new file mode 100644 index 00000000..790681cd --- /dev/null +++ b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/CoordPathWrapper.java @@ -0,0 +1,12 @@ + +public class CoordPathWrapper { + Pair coordinatePair; + Vector_t pathVector; + + public CoordPathWrapper(Pair coordinatePairPtr, Vector_t path) { + coordinatePair = coordinatePairPtr; + pathVector = path; + + } + +} diff --git a/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/Coordinate.java b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/Coordinate.java new file mode 100644 index 00000000..a9c9c549 --- /dev/null +++ b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/Coordinate.java @@ -0,0 +1,175 @@ +/* ============================================================================= + * + * coordinate.java + * + * ============================================================================= + * + * Copyright (C) Stanford University, 2006. All Rights Reserved. + * Author: Chi Cao Minh + * + * ============================================================================= + * + * For the license of bayes/sort.h and bayes/sort.c, please see the header + * of the files. + * + * ------------------------------------------------------------------------ + * + * For the license of kmeans, please see kmeans/LICENSE.kmeans + * + * ------------------------------------------------------------------------ + * + * For the license of ssca2, please see ssca2/COPYRIGHT + * + * ------------------------------------------------------------------------ + * + * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the + * header of the files. + * + * ------------------------------------------------------------------------ + * + * For the license of lib/rbtree.h and lib/rbtree.c, please see + * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree + * + * ------------------------------------------------------------------------ + * + * Unless otherwise noted, the following license applies to STAMP files: + * + * Copyright (c) 2007, Stanford University + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Stanford University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * ============================================================================= + */ + +import java.lang.Math; + +public class Coordinate { + + public int x; + public int y; + public int z; + + public Coordinate() {} + + + // coordiate_alloc will be constructor + // coordinate_t* coordinate_alloc(long x, long y, long z) + public Coordinate(int x,int y,int z) { + this.x = x; + this.y = y; + this.z = z; + } + + public Coordinate alloc(int x,int y,int z) { + Coordinate c = new Coordinate(x,y,z); + + return c; + } + + + // deallocate memory + // may not need + // coordinate_free + + /*======================================================== + // coordinate_isEqual + ==========================================================*/ + public boolean isEqual(Coordinate a,Coordinate b) + { + if((a.x == b.x) && (a.y == b.y) && (a.z == b.z)) + return true; + + return false; + } + + /*========================================================== + * + * getPairDistance + * + *========================================================*/ + private double getPairDistance(Pair p) + { + Coordinate a = (Coordinate)p.first; + Coordinate b = (Coordinate)p.second; + int dx = a.x - b.x; + int dy = a.y - b.y; + int dz = a.z - b.z; + int dx2 = dx* dx; + int dy2 = dy* dy; + int dz2 = dz* dz; + + return Math.sqrt((double)(dx2+dy2+dz2)); + } + + + /*================================================ + // coordinat_ comparePair + * -- For sorting in list of source/destination pairs + * -- Route longer paths first so they are more likely to suceed + + *================================================*/ + public int comparePair(final Object a,final Object b) + { + double aDistance = getPairDistance((Pair)a); + double bDistance = getPairDistance((Pair)b); + + if(aDistance < bDistance) { + return 1; + } else if(aDistance > bDistance) { + return -1; + } + + return 0; + } + + /*======================================================= + * coordinate_areAdjacent + *=======================================================*/ + + public boolean areAdjacent(Coordinate a,Coordinate b) + { + int dx = a.x - b.x; + int dy = a.y - b.y; + int dz = a.z - b.z; + int dx2 = dx * dx; + int dy2 = dy * dy; + int dz2 = dz * dz; + + return (((dx2 + dy2 + dz2) == 1) ? true : false); + } + } + + /*===================================================== + * + * End of Coordinate + * + *====================================================*/ + + diff --git a/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/Grid.java b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/Grid.java new file mode 100644 index 00000000..b609e81a --- /dev/null +++ b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/Grid.java @@ -0,0 +1,287 @@ +/* ============================================================================= + * + * grid.java + * + * ============================================================================= + * + * Copyright (C) Stanford University, 2006. All Rights Reserved. + * Author: Chi Cao Minh + * + * ============================================================================= + * + * For the license of bayes/sort.h and bayes/sort.c, please see the header + * of the files. + * + * ------------------------------------------------------------------------ + * + * For the license of kmeans, please see kmeans/LICENSE.kmeans + * + * ------------------------------------------------------------------------ + * + * For the license of ssca2, please see ssca2/COPYRIGHT + * + * ------------------------------------------------------------------------ + * + * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the + * header of the files. + * + * ------------------------------------------------------------------------ + * + * For the license of lib/rbtree.h and lib/rbtree.c, please see + * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree + * + * ------------------------------------------------------------------------ + * + * Unless otherwise noted, the following license applies to STAMP files: + * + * Copyright (c) 2007, Stanford University + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Stanford University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * ============================================================================= + */ + + +public class Grid { + public int width; + public int height; + public int depth; + public int[][][] points_unaligned; + + public static int GRID_POINT_FULL; + public static int GRID_POINT_EMPTY; + + public Grid() + { + GRID_POINT_FULL = -2; + GRID_POINT_EMPTY = -1; + } + + +/* ============================================================================= + * grid_alloc + * ============================================================================= + grid_t* grid_alloc (long width, long height, long depth); + + well... need to implement + got stuck +*/ + public Grid alloc(int width,int height,int depth) { + Grid grid = new Grid(); + + grid.width = width; + grid.height = height; + grid.depth = depth; + + int[][][] points_unaligned = new int[width][height][depth]; + + + for(int i=0;i=0 && x< width && y>=0 && y=0 && z bend cost"); + System.out.println(" i input file name"); + System.out.println(" p print routed maze"); + System.out.println(" t Number of threads"); + System.out.println(" x x movement cost"); + System.out.println(" y y movement cost"); + System.out.println(" z z movement cost"); + System.out.println(" w Workload per rBlock"); + } + + + public static void main(String[] argv) + { + /* + * Initailization + */ + Maze maze = new Maze(); + Router router = new Router(); + Labyrinth labyrinth = new Labyrinth(argv); + + Maze mazePtr = maze.alloc(); + + int numPathToRoute = mazePtr.readMaze(labyrinth.global_inputFile); + + Router routerPtr = router.alloc(labyrinth.xCost,labyrinth.yCost, + labyrinth.zCost,labyrinth.bendCost); + + List_t list_t = new List_t(); + List_t pathVectorListPtr = list_t.alloc(0); // list_t.alloc(null) + Solve_Arg routerArg = new Solve_Arg(routerPtr,mazePtr,pathVectorListPtr, global_workload); + + /* Create and start thread */ + long start = System.currentTimeMillis(); + routerPtr.solve(routerArg); + + /* End of Solve */ + long finish = System.currentTimeMillis(); + long diff=finish-start; + System.out.println("TIME= " + diff); + + + int numPathRouted = 0; + List_Iter it = new List_Iter(); + + it.reset(pathVectorListPtr); + while(it.hasNext(pathVectorListPtr)) { + Vector_t pathVectorPtr = (Vector_t)it.next(pathVectorListPtr); + numPathRouted += pathVectorPtr.vector_getSize(); + } + + double elapsed = (finish-start)/1000.0; + + System.out.println("Paths routed = " + numPathRouted); + System.out.println("Elapsed time = " + elapsed); + + boolean stats = mazePtr.checkPaths(pathVectorListPtr,labyrinth.global_doPrint); + if(!stats) + System.out.println("Verification not passed"); + else + System.out.println("Verification passed."); + + System.out.println("Finished"); + } +} + +/* ============================================================================= + * + * End of labyrinth.c + * + * ============================================================================= + */ diff --git a/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/List_Iter.java b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/List_Iter.java new file mode 100644 index 00000000..351e80d0 --- /dev/null +++ b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/List_Iter.java @@ -0,0 +1,38 @@ +public class List_Iter { + List_Node itPtr; + + /* ============================================================================= + * list_iter_reset + * ============================================================================= + void list_iter_reset (list_iter_t* itPtr, list_t* listPtr); + */ + public List_Iter() { + itPtr = null; + } + + public void reset(List_t listPtr) + { + itPtr = listPtr.head; + } + + /* ============================================================================= + * list_iter_hasNext + * ============================================================================= + * bool_t list_iter_hasNext (list_iter_t* itPtr, list_t* listPtr); + */ + public boolean hasNext(List_t listPtr) { + return (itPtr.nextPtr != null)? true : false; + } + + /* ============================================================================= + * list_iter_next + * ============================================================================= + * void* list_iter_next (list_iter_t* itPtr, list_t* listPtr); + */ + public Object next(List_t listPtr) + { + itPtr = itPtr.nextPtr; + return itPtr.dataPtr; + } +} + diff --git a/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/List_Node.java b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/List_Node.java new file mode 100644 index 00000000..806baa19 --- /dev/null +++ b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/List_Node.java @@ -0,0 +1,10 @@ + +public class List_Node { + Object dataPtr; + List_Node nextPtr; + + public List_Node() { + dataPtr = null; + nextPtr = null; + } +} diff --git a/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/List_t.java b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/List_t.java new file mode 100644 index 00000000..3b73d646 --- /dev/null +++ b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/List_t.java @@ -0,0 +1,307 @@ +/* ============================================================================= + * + * List_t.java + * -- Sorted singly linked list + * -- Options: duplicate allowed + * (DLIST_NO_DUPLICATES) is no implemented yet (default: allow duplicates) + * + * ============================================================================= + * + * Copyright (C) Stanford University, 2006. All Rights Reserved. + * Author: Chi Cao Minh + * + * ============================================================================= + * + * For the license of bayes/sort.h and bayes/sort.c, please see the header + * of the files. + * + * ------------------------------------------------------------------------ + * + * For the license of kmeans, please see kmeans/LICENSE.kmeans + * + * ------------------------------------------------------------------------ + * + * For the license of ssca2, please see ssca2/COPYRIGHT + * + * ------------------------------------------------------------------------ + * + * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the + * header of the files. + * + * ------------------------------------------------------------------------ + * + * For the license of lib/rbtree.h and lib/rbtree.c, please see + * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree + * + * ------------------------------------------------------------------------ + * + * Unless otherwise noted, the following license applies to STAMP files: + * + * Copyright (c) 2007, Stanford University + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Stanford University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * ============================================================================= + */ + + +public class List_t { + + public List_Node head; + boolean isCoordinate; + int size; + + public List_t() { + head = new List_Node(); + } + + + /* ======================================================================= + * allocNode + * -- Returns null on failure + * ======================================================================= + */ + private List_Node allocNode(Object dataPtr) + { + List_Node nodePtr = new List_Node(); + + + nodePtr.dataPtr = dataPtr; + nodePtr.nextPtr = null; + + return nodePtr; + } + + +/* ============================================================================= + * list_alloc + * -- If NULL passed for 'compare' function, will compare data pointer addresses + * -- Returns NULL on failure + * ============================================================================= + * list_t* list_alloc (long (*compare)(const void*, const void*)); + * + * + */ + + public List_t alloc(int isCoordinate) + { + List_t listPtr = new List_t(); + + + listPtr.head.dataPtr = null; + listPtr.head.nextPtr = null; + listPtr.size = 0; + + listPtr.isCoordinate = (isCoordinate==1)?true:false; + + return listPtr; + } + +/* ============================================================================= + * list_free + * -- If NULL passed for 'compare' function, will compare data pointer addresses + * -- Returns NULL on failure + * ============================================================================= + * void list_free (list_t* listPtr); + */ + public void free(List_t listPtr) + { + listPtr = null; + } + +// privae freeList + +/* ============================================================================= + * list_isEmpty + * -- Return TRUE if list is empty, else FALSE + * ============================================================================= + * bool_t list_isEmpty (list_t* listPtr); + */ + public boolean isEmpty() + { + return (head.nextPtr == null); + } + +/* ============================================================================= + * list_getSize + * -- Returns size of list + * ============================================================================= + * long list_getSize (list_t* listPtr); + */ + public int getSize() { + return size; + } + +/* ============================================================================= + * findPrevious + * ============================================================================= + * void* list_find (list_t* listPtr, void* dataPtr); + */ + private List_Node findPrevious(Object dataPtr) + { + List_Node prevPtr = head; + List_Node nodePtr = prevPtr.nextPtr; + + for(; nodePtr != null; nodePtr = nodePtr.nextPtr) { + if (compare(nodePtr.dataPtr,dataPtr) >= 0) { + return prevPtr; + } + prevPtr = nodePtr; + } + + return prevPtr; + } + + /* ============================================================================= + * list_find + * -- Returns NULL if not found, else returns pointer to data + * ============================================================================= + * void* list_find (list_t* listPtr, void* dataPtr); + */ + public Object find(Object dataPtr) { + List_Node nodePtr; + List_Node prevPtr = findPrevious(dataPtr); + + nodePtr = prevPtr.nextPtr; + + if((nodePtr == null) || + (compare(nodePtr.dataPtr,dataPtr) != 0)) { + return null; + } + + return (nodePtr.dataPtr); + } + + public int compare(Object obj1,Object obj2) + { + Coordinate coordinate = new Coordinate(); + if(isCoordinate) + { + return coordinate.comparePair(obj1,obj2); + } + else + return compareObject(obj1,obj2); + } + +/* ============================================================================= + * list_insert + * -- Return TRUE on success, else FALSE + * ============================================================================= + * bool_t list_insert (list_t* listPtr, void* dataPtr); + */ + public boolean insert(Object dataPtr) { + List_Node prevPtr; + List_Node nodePtr; + List_Node currPtr; + + prevPtr = findPrevious(dataPtr); + currPtr = prevPtr.nextPtr; + + nodePtr = allocNode(dataPtr); + if (nodePtr == null) { + return false; + } + + nodePtr.nextPtr = currPtr; + prevPtr.nextPtr = nodePtr; + size++; + + return true; + } + + +/* ============================================================================= + * list_remove + * -- Returns TRUE if successful, else FALSE + * ============================================================================= + * bool_t list_remove (list_t* listPtr, void* dataPtr); + */ + public boolean remove(Object dataPtr) + { + List_Node prevPtr; + List_Node nodePtr; + + prevPtr = findPrevious(dataPtr); + + nodePtr = prevPtr.nextPtr; + + if((nodePtr != null) && + (compare(nodePtr.dataPtr,dataPtr) == 0)) + { + prevPtr.nextPtr = nodePtr.nextPtr; + nodePtr.nextPtr = null; + nodePtr = null; + size--; + + return true; + } + + return false; + } + + int compareObject(Object obj1,Object obj2) { + return 1; + } + + +/* ============================================================================= + * list_clear + * -- Removes all elements + * ============================================================================= + * void list_clear (list_t* listPtr); + */ + public void clear() { + head = new List_Node(); + size = 0; + } + +/* ============================================================================= + * + * End of list.java + * + * ============================================================================= + */ + + /* Test list */ + +// public static void main(String[] argv) { +// List_t listPtr; +// int[] data1 = new int[5]; +// int[] data2 = new int[6]; +// +// int i; +// +// System.out.println("Starting..."); +// } +// +} + + + diff --git a/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/Math.java b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/Math.java new file mode 100644 index 00000000..7e6a59f6 --- /dev/null +++ b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/Math.java @@ -0,0 +1,136 @@ +public class Math { + + public static double setPI() { + double PI = 3.14159265358979323846; + return PI; + } + + // an alias for setPI() + public static double PI() { + double PI = 3.14159265358979323846; + return PI; + } + + public static int abs(int x) { + if (x < 0) { + return -x; + } else { + return x; + } + } + + public static double fabs(double x) { + if (x < 0) { + return -x; + } else { + return x; + } + } + + public static double abs(double x) { + if (x < 0) { + return -x; + } else { + return x; + } + } + + public static float abs(float a) { + if (a<0) + return -a; + else return a; + } + + public static double max(double a, double b) { + if(a == b) + return a; + if(a > b) { + return a; + } else { + return b; + } + } + + public static int max(int a, int b) { + if(a == b) + return a; + if(a > b) { + return a; + } else { + return b; + } + } + + public static int imax(int a, int b) { + if(a == b) + return a; + if(a > b) { + return a; + } else { + return b; + } + } + + public static int imin(int a, int b) { + if(a == b) + return a; + if(a > b) { + return b; + } else { + return a; + } + } + + /** sqrt(a^2 + b^2) without under/overflow. **/ + public static double hypot(double a, double b) { + double r; + if (fabs(a) > fabs(b)) { + r = b/a; + r = fabs(a)*sqrt(1+r*r); + } else if (b != 0) { + r = a/b; + r = fabs(b)*sqrt(1+r*r); + } else { + r = 0.0; + } + return r; + } + + public static double rint(double x) { + double y = ceil(x); + double d = y - x; + if( d == 0.5 ) { + if( ((int)y)%2 == 0 ) { + return y; + } else { + return y - 1.0; + } + } else if( d < 0.5 ) { + return y; + } + return y - 1.0; + } + + public static native double sin(double a); + public static native double cos(double a); + public static native double asin(double a); + public static native double acos(double a); + public static native double tan(double a); + public static native double atan(double a); + public static native double atan2(double a, double b); + public static native double exp(double a); + public static native double sqrt(double a); + public static native double log(double a); + public static native double pow(double a, double b); + + public static native double ceil(double a); + public static native double floor(double a); + + public static native float sinf(float a); + public static native float cosf(float a); + public static native float expf(float a); + public static native float sqrtf(float a); + public static native float logf(float a); + public static native float powf(float a, float b); + public static native float ceilf(float a); +} diff --git a/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/Maze.java b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/Maze.java new file mode 100644 index 00000000..e439d034 --- /dev/null +++ b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/Normal_Java/Maze.java @@ -0,0 +1,417 @@ +import java.io.File; +import java.util.Scanner; +import java.util.StringTokenizer; + +/*============================================================================= + * + * Maze.java + * + * ============================================================================= + * + * Copyright (C) Stanford University, 2006. All Rights Reserved. + * Author: Chi Cao Minh + * + * ============================================================================= + * + * For the license of bayes/sort.h and bayes/sort.c, please see the header + * of the files. + * + * ------------------------------------------------------------------------ + * + * For the license of kmeans, please see kmeans/LICENSE.kmeans + * + * ------------------------------------------------------------------------ + * + * For the license of ssca2, please see ssca2/COPYRIGHT + * + * ------------------------------------------------------------------------ + * + * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the + * header of the files. + * + * ------------------------------------------------------------------------ + * + * For the license of lib/rbtree.h and lib/rbtree.c, please see + * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree + * + * ------------------------------------------------------------------------ + * + * Unless otherwise noted, the following license applies to STAMP files: + * + * Copyright (c) 2007, Stanford University + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Stanford University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * ============================================================================= + */ + +public class Maze { + Grid gridPtr; + Queue_t workQueuePtr; + Vector_t wallVectorPtr; /* contains source/destination pairs to route */ + Vector_t srcVectorPtr; /* obstacles */ + Vector_t dstVectorPtr; /* destinations */ + + public int GRID_POINT_FULL; + public int GRID_POINT_EMPTY; + + public Maze() + { + GRID_POINT_FULL = -2; + GRID_POINT_EMPTY = -1; + } + + +/* ============================================================================= + * maze_alloc + * ============================================================================= + maze_t* maze_alloc (); + */ + public Maze alloc() + { + Maze mazePtr = new Maze(); + Vector_t vector_t = new Vector_t(); + Queue_t queue_t = new Queue_t(); + + mazePtr.gridPtr = null; + mazePtr.workQueuePtr = queue_t.queue_alloc(1024); + mazePtr.wallVectorPtr = vector_t.vector_alloc(1); + mazePtr.srcVectorPtr = vector_t.vector_alloc(1); + mazePtr.dstVectorPtr = vector_t.vector_alloc(1); + + + return mazePtr; + } + +/* ============================================================================= + * maze_free + * ============================================================================= + void maze_free (maze_t* mazePtr); + */ + public void free(Maze m) + { + m = null; + } + +/* ============================================================================= + * addToGrid + * ============================================================================= + */ + private void addToGrid(Grid gridPtr,Vector_t vectorPtr,String type) + { + int i; + int n = vectorPtr.vector_getSize(); + + for(i = 0; i < n; i++) { + Coordinate coordinatePtr = (Coordinate)vectorPtr.vector_at(i); + if(!gridPtr.isPointValid(coordinatePtr.x,coordinatePtr.y,coordinatePtr.z)) + { + System.out.println("Error: " + type + " (" + coordinatePtr.x + + ", " + coordinatePtr.y + + ", " + coordinatePtr.z); + System.exit(1); + } + } + gridPtr.addPath(vectorPtr); + } +/* ============================================================================= + * maze_read + * -- Return number of path to route + * ============================================================================= + long maze_read (maze_t* mazePtr, char* inputFileName); + */ + public int readMaze(String inputFileName) + { + //TODO remove TRY + try + { + + //Added for mlp compatiability + List_t list_t = new List_t(); + Coordinate coordinate = new Coordinate(); + Pair pair = new Pair(); + +// FileInputStream in = new FileInputStream(inputFileName); + //TODO remove this and uncomment the line above. + Scanner in = new Scanner(new File(inputFileName)); + + /* + * Parse input file + */ + int lineNumber = 0; + int height = -1; + int width = -1; + int depth = -1; + boolean isParseError = false; + List_t workListPtr = list_t.alloc(1); // List.alloc(Coordinate.comparePair); + String line; + + //TODO change this back as well +// while((line = in.readLine()) != null) { + while(in.hasNextLine()){ + line = in.nextLine(); + //TODO remove the above + + String code; + int[] xy = new int[6]; // equivalent to x1,y1,z1,x2,y2,z2 + int numToken = 0; + + StringTokenizer tok = new StringTokenizer(line); + + if((numToken = tok.countTokens()) < 1 ) { + continue; + } + + code = tok.nextToken(); + + if(code.equals("#")) { + /* comment line */ + continue; + } + for(int i=0;i ttt$1 diff --git a/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/CoordPathWrapper.java b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/CoordPathWrapper.java new file mode 100644 index 00000000..52a6fdc8 --- /dev/null +++ b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/CoordPathWrapper.java @@ -0,0 +1,20 @@ +/* ============================================================================= + * + * CoordPathWrapper.java + * + * ============================================================================= + * + * Author: Stephen Yang + * University of California, Irvine + */ +public class CoordPathWrapper { + Pair coordinatePair; + Vector_t pathVector; + + public CoordPathWrapper(Pair coordinatePairPtr, Vector_t path) { + coordinatePair = coordinatePairPtr; + pathVector = path; + + } + +} diff --git a/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/Coordinate.java b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/Coordinate.java new file mode 100644 index 00000000..a9c9c549 --- /dev/null +++ b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/Coordinate.java @@ -0,0 +1,175 @@ +/* ============================================================================= + * + * coordinate.java + * + * ============================================================================= + * + * Copyright (C) Stanford University, 2006. All Rights Reserved. + * Author: Chi Cao Minh + * + * ============================================================================= + * + * For the license of bayes/sort.h and bayes/sort.c, please see the header + * of the files. + * + * ------------------------------------------------------------------------ + * + * For the license of kmeans, please see kmeans/LICENSE.kmeans + * + * ------------------------------------------------------------------------ + * + * For the license of ssca2, please see ssca2/COPYRIGHT + * + * ------------------------------------------------------------------------ + * + * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the + * header of the files. + * + * ------------------------------------------------------------------------ + * + * For the license of lib/rbtree.h and lib/rbtree.c, please see + * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree + * + * ------------------------------------------------------------------------ + * + * Unless otherwise noted, the following license applies to STAMP files: + * + * Copyright (c) 2007, Stanford University + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Stanford University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * ============================================================================= + */ + +import java.lang.Math; + +public class Coordinate { + + public int x; + public int y; + public int z; + + public Coordinate() {} + + + // coordiate_alloc will be constructor + // coordinate_t* coordinate_alloc(long x, long y, long z) + public Coordinate(int x,int y,int z) { + this.x = x; + this.y = y; + this.z = z; + } + + public Coordinate alloc(int x,int y,int z) { + Coordinate c = new Coordinate(x,y,z); + + return c; + } + + + // deallocate memory + // may not need + // coordinate_free + + /*======================================================== + // coordinate_isEqual + ==========================================================*/ + public boolean isEqual(Coordinate a,Coordinate b) + { + if((a.x == b.x) && (a.y == b.y) && (a.z == b.z)) + return true; + + return false; + } + + /*========================================================== + * + * getPairDistance + * + *========================================================*/ + private double getPairDistance(Pair p) + { + Coordinate a = (Coordinate)p.first; + Coordinate b = (Coordinate)p.second; + int dx = a.x - b.x; + int dy = a.y - b.y; + int dz = a.z - b.z; + int dx2 = dx* dx; + int dy2 = dy* dy; + int dz2 = dz* dz; + + return Math.sqrt((double)(dx2+dy2+dz2)); + } + + + /*================================================ + // coordinat_ comparePair + * -- For sorting in list of source/destination pairs + * -- Route longer paths first so they are more likely to suceed + + *================================================*/ + public int comparePair(final Object a,final Object b) + { + double aDistance = getPairDistance((Pair)a); + double bDistance = getPairDistance((Pair)b); + + if(aDistance < bDistance) { + return 1; + } else if(aDistance > bDistance) { + return -1; + } + + return 0; + } + + /*======================================================= + * coordinate_areAdjacent + *=======================================================*/ + + public boolean areAdjacent(Coordinate a,Coordinate b) + { + int dx = a.x - b.x; + int dy = a.y - b.y; + int dz = a.z - b.z; + int dx2 = dx * dx; + int dy2 = dy * dy; + int dz2 = dz * dz; + + return (((dx2 + dy2 + dz2) == 1) ? true : false); + } + } + + /*===================================================== + * + * End of Coordinate + * + *====================================================*/ + + diff --git a/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/Grid.java b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/Grid.java new file mode 100644 index 00000000..b609e81a --- /dev/null +++ b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/Grid.java @@ -0,0 +1,287 @@ +/* ============================================================================= + * + * grid.java + * + * ============================================================================= + * + * Copyright (C) Stanford University, 2006. All Rights Reserved. + * Author: Chi Cao Minh + * + * ============================================================================= + * + * For the license of bayes/sort.h and bayes/sort.c, please see the header + * of the files. + * + * ------------------------------------------------------------------------ + * + * For the license of kmeans, please see kmeans/LICENSE.kmeans + * + * ------------------------------------------------------------------------ + * + * For the license of ssca2, please see ssca2/COPYRIGHT + * + * ------------------------------------------------------------------------ + * + * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the + * header of the files. + * + * ------------------------------------------------------------------------ + * + * For the license of lib/rbtree.h and lib/rbtree.c, please see + * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree + * + * ------------------------------------------------------------------------ + * + * Unless otherwise noted, the following license applies to STAMP files: + * + * Copyright (c) 2007, Stanford University + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Stanford University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * ============================================================================= + */ + + +public class Grid { + public int width; + public int height; + public int depth; + public int[][][] points_unaligned; + + public static int GRID_POINT_FULL; + public static int GRID_POINT_EMPTY; + + public Grid() + { + GRID_POINT_FULL = -2; + GRID_POINT_EMPTY = -1; + } + + +/* ============================================================================= + * grid_alloc + * ============================================================================= + grid_t* grid_alloc (long width, long height, long depth); + + well... need to implement + got stuck +*/ + public Grid alloc(int width,int height,int depth) { + Grid grid = new Grid(); + + grid.width = width; + grid.height = height; + grid.depth = depth; + + int[][][] points_unaligned = new int[width][height][depth]; + + + for(int i=0;i=0 && x< width && y>=0 && y=0 && z bend cost"); + System.out.println(" i input file name"); + System.out.println(" p print routed maze"); + System.out.println(" t Number of threads"); + System.out.println(" x x movement cost"); + System.out.println(" y y movement cost"); + System.out.println(" z z movement cost"); + System.out.println(" w Workload per rBlock"); + } + + + public static void main(String[] argv) + { + /* + * Initailization + */ + Maze maze = new Maze(); + Router router = new Router(); + Labyrinth labyrinth = new Labyrinth(argv); + + Maze mazePtr = maze.alloc(); + + int numPathToRoute = mazePtr.readMaze(labyrinth.global_inputFile); + + Router routerPtr = router.alloc(labyrinth.xCost,labyrinth.yCost, + labyrinth.zCost,labyrinth.bendCost); + + List_t list_t = new List_t(); + List_t pathVectorListPtr = list_t.alloc(0); // list_t.alloc(null) + Solve_Arg routerArg = new Solve_Arg(routerPtr,mazePtr,pathVectorListPtr, labyrinth.global_workload); + + /* Create and start thread */ + long start = System.currentTimeMillis(); + routerPtr.solve(routerArg); + + /* End of Solve */ + long finish = System.currentTimeMillis(); + long diff=finish-start; + System.out.println("TIME= " + diff); + + + int numPathRouted = 0; + List_Iter it = new List_Iter(); + + it.reset(pathVectorListPtr); + while(it.hasNext(pathVectorListPtr)) { + Vector_t pathVectorPtr = (Vector_t)it.next(pathVectorListPtr); + numPathRouted += pathVectorPtr.vector_getSize(); + } + + double elapsed = (finish-start)/1000.0; + + System.out.println("Paths routed = " + numPathRouted); + System.out.println("Elapsed time = " + elapsed); + + boolean stats = mazePtr.checkPaths(pathVectorListPtr,labyrinth.global_doPrint); + if(!stats) + System.out.println("Verification not passed"); + else + System.out.println("Verification passed."); + + System.out.println("Finished"); + } +} + +/* ============================================================================= + * + * End of labyrinth.c + * + * ============================================================================= + */ diff --git a/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/List_Iter.java b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/List_Iter.java new file mode 100644 index 00000000..351e80d0 --- /dev/null +++ b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/List_Iter.java @@ -0,0 +1,38 @@ +public class List_Iter { + List_Node itPtr; + + /* ============================================================================= + * list_iter_reset + * ============================================================================= + void list_iter_reset (list_iter_t* itPtr, list_t* listPtr); + */ + public List_Iter() { + itPtr = null; + } + + public void reset(List_t listPtr) + { + itPtr = listPtr.head; + } + + /* ============================================================================= + * list_iter_hasNext + * ============================================================================= + * bool_t list_iter_hasNext (list_iter_t* itPtr, list_t* listPtr); + */ + public boolean hasNext(List_t listPtr) { + return (itPtr.nextPtr != null)? true : false; + } + + /* ============================================================================= + * list_iter_next + * ============================================================================= + * void* list_iter_next (list_iter_t* itPtr, list_t* listPtr); + */ + public Object next(List_t listPtr) + { + itPtr = itPtr.nextPtr; + return itPtr.dataPtr; + } +} + diff --git a/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/List_Node.java b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/List_Node.java new file mode 100644 index 00000000..806baa19 --- /dev/null +++ b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/List_Node.java @@ -0,0 +1,10 @@ + +public class List_Node { + Object dataPtr; + List_Node nextPtr; + + public List_Node() { + dataPtr = null; + nextPtr = null; + } +} diff --git a/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/List_t.java b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/List_t.java new file mode 100644 index 00000000..3b73d646 --- /dev/null +++ b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/List_t.java @@ -0,0 +1,307 @@ +/* ============================================================================= + * + * List_t.java + * -- Sorted singly linked list + * -- Options: duplicate allowed + * (DLIST_NO_DUPLICATES) is no implemented yet (default: allow duplicates) + * + * ============================================================================= + * + * Copyright (C) Stanford University, 2006. All Rights Reserved. + * Author: Chi Cao Minh + * + * ============================================================================= + * + * For the license of bayes/sort.h and bayes/sort.c, please see the header + * of the files. + * + * ------------------------------------------------------------------------ + * + * For the license of kmeans, please see kmeans/LICENSE.kmeans + * + * ------------------------------------------------------------------------ + * + * For the license of ssca2, please see ssca2/COPYRIGHT + * + * ------------------------------------------------------------------------ + * + * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the + * header of the files. + * + * ------------------------------------------------------------------------ + * + * For the license of lib/rbtree.h and lib/rbtree.c, please see + * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree + * + * ------------------------------------------------------------------------ + * + * Unless otherwise noted, the following license applies to STAMP files: + * + * Copyright (c) 2007, Stanford University + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Stanford University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * ============================================================================= + */ + + +public class List_t { + + public List_Node head; + boolean isCoordinate; + int size; + + public List_t() { + head = new List_Node(); + } + + + /* ======================================================================= + * allocNode + * -- Returns null on failure + * ======================================================================= + */ + private List_Node allocNode(Object dataPtr) + { + List_Node nodePtr = new List_Node(); + + + nodePtr.dataPtr = dataPtr; + nodePtr.nextPtr = null; + + return nodePtr; + } + + +/* ============================================================================= + * list_alloc + * -- If NULL passed for 'compare' function, will compare data pointer addresses + * -- Returns NULL on failure + * ============================================================================= + * list_t* list_alloc (long (*compare)(const void*, const void*)); + * + * + */ + + public List_t alloc(int isCoordinate) + { + List_t listPtr = new List_t(); + + + listPtr.head.dataPtr = null; + listPtr.head.nextPtr = null; + listPtr.size = 0; + + listPtr.isCoordinate = (isCoordinate==1)?true:false; + + return listPtr; + } + +/* ============================================================================= + * list_free + * -- If NULL passed for 'compare' function, will compare data pointer addresses + * -- Returns NULL on failure + * ============================================================================= + * void list_free (list_t* listPtr); + */ + public void free(List_t listPtr) + { + listPtr = null; + } + +// privae freeList + +/* ============================================================================= + * list_isEmpty + * -- Return TRUE if list is empty, else FALSE + * ============================================================================= + * bool_t list_isEmpty (list_t* listPtr); + */ + public boolean isEmpty() + { + return (head.nextPtr == null); + } + +/* ============================================================================= + * list_getSize + * -- Returns size of list + * ============================================================================= + * long list_getSize (list_t* listPtr); + */ + public int getSize() { + return size; + } + +/* ============================================================================= + * findPrevious + * ============================================================================= + * void* list_find (list_t* listPtr, void* dataPtr); + */ + private List_Node findPrevious(Object dataPtr) + { + List_Node prevPtr = head; + List_Node nodePtr = prevPtr.nextPtr; + + for(; nodePtr != null; nodePtr = nodePtr.nextPtr) { + if (compare(nodePtr.dataPtr,dataPtr) >= 0) { + return prevPtr; + } + prevPtr = nodePtr; + } + + return prevPtr; + } + + /* ============================================================================= + * list_find + * -- Returns NULL if not found, else returns pointer to data + * ============================================================================= + * void* list_find (list_t* listPtr, void* dataPtr); + */ + public Object find(Object dataPtr) { + List_Node nodePtr; + List_Node prevPtr = findPrevious(dataPtr); + + nodePtr = prevPtr.nextPtr; + + if((nodePtr == null) || + (compare(nodePtr.dataPtr,dataPtr) != 0)) { + return null; + } + + return (nodePtr.dataPtr); + } + + public int compare(Object obj1,Object obj2) + { + Coordinate coordinate = new Coordinate(); + if(isCoordinate) + { + return coordinate.comparePair(obj1,obj2); + } + else + return compareObject(obj1,obj2); + } + +/* ============================================================================= + * list_insert + * -- Return TRUE on success, else FALSE + * ============================================================================= + * bool_t list_insert (list_t* listPtr, void* dataPtr); + */ + public boolean insert(Object dataPtr) { + List_Node prevPtr; + List_Node nodePtr; + List_Node currPtr; + + prevPtr = findPrevious(dataPtr); + currPtr = prevPtr.nextPtr; + + nodePtr = allocNode(dataPtr); + if (nodePtr == null) { + return false; + } + + nodePtr.nextPtr = currPtr; + prevPtr.nextPtr = nodePtr; + size++; + + return true; + } + + +/* ============================================================================= + * list_remove + * -- Returns TRUE if successful, else FALSE + * ============================================================================= + * bool_t list_remove (list_t* listPtr, void* dataPtr); + */ + public boolean remove(Object dataPtr) + { + List_Node prevPtr; + List_Node nodePtr; + + prevPtr = findPrevious(dataPtr); + + nodePtr = prevPtr.nextPtr; + + if((nodePtr != null) && + (compare(nodePtr.dataPtr,dataPtr) == 0)) + { + prevPtr.nextPtr = nodePtr.nextPtr; + nodePtr.nextPtr = null; + nodePtr = null; + size--; + + return true; + } + + return false; + } + + int compareObject(Object obj1,Object obj2) { + return 1; + } + + +/* ============================================================================= + * list_clear + * -- Removes all elements + * ============================================================================= + * void list_clear (list_t* listPtr); + */ + public void clear() { + head = new List_Node(); + size = 0; + } + +/* ============================================================================= + * + * End of list.java + * + * ============================================================================= + */ + + /* Test list */ + +// public static void main(String[] argv) { +// List_t listPtr; +// int[] data1 = new int[5]; +// int[] data2 = new int[6]; +// +// int i; +// +// System.out.println("Starting..."); +// } +// +} + + + diff --git a/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/Maze.java b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/Maze.java new file mode 100644 index 00000000..197f91a2 --- /dev/null +++ b/Robust/src/Benchmarks/Java-Single/Labyrinth3D/mlp/rBlocked/Maze.java @@ -0,0 +1,395 @@ +/*============================================================================= + * + * Maze.java + * + * ============================================================================= + * + * Copyright (C) Stanford University, 2006. All Rights Reserved. + * Author: Chi Cao Minh + * + * ============================================================================= + * + * For the license of bayes/sort.h and bayes/sort.c, please see the header + * of the files. + * + * ------------------------------------------------------------------------ + * + * For the license of kmeans, please see kmeans/LICENSE.kmeans + * + * ------------------------------------------------------------------------ + * + * For the license of ssca2, please see ssca2/COPYRIGHT + * + * ------------------------------------------------------------------------ + * + * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the + * header of the files. + * + * ------------------------------------------------------------------------ + * + * For the license of lib/rbtree.h and lib/rbtree.c, please see + * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree + * + * ------------------------------------------------------------------------ + * + * Unless otherwise noted, the following license applies to STAMP files: + * + * Copyright (c) 2007, Stanford University + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Stanford University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * ============================================================================= + */ + +public class Maze { + Grid gridPtr; + Queue_t workQueuePtr; + Vector_t wallVectorPtr; /* contains source/destination pairs to route */ + Vector_t srcVectorPtr; /* obstacles */ + Vector_t dstVectorPtr; /* destinations */ + + public int GRID_POINT_FULL; + public int GRID_POINT_EMPTY; + + public Maze() + { + GRID_POINT_FULL = -2; + GRID_POINT_EMPTY = -1; + } + + +/* ============================================================================= + * maze_alloc + * ============================================================================= + maze_t* maze_alloc (); + */ + public Maze alloc() + { + Maze mazePtr = new Maze(); + Vector_t vector_t = new Vector_t(); + Queue_t queue_t = new Queue_t(); + + mazePtr.gridPtr = null; + mazePtr.workQueuePtr = queue_t.queue_alloc(1024); + mazePtr.wallVectorPtr = vector_t.vector_alloc(1); + mazePtr.srcVectorPtr = vector_t.vector_alloc(1); + mazePtr.dstVectorPtr = vector_t.vector_alloc(1); + + + return mazePtr; + } + +/* ============================================================================= + * maze_free + * ============================================================================= + void maze_free (maze_t* mazePtr); + */ + public void free(Maze m) + { + m = null; + } + +/* ============================================================================= + * addToGrid + * ============================================================================= + */ + private void addToGrid(Grid gridPtr,Vector_t vectorPtr,String type) + { + int i; + int n = vectorPtr.vector_getSize(); + + for(i = 0; i < n; i++) { + Coordinate coordinatePtr = (Coordinate)vectorPtr.vector_at(i); + if(!gridPtr.isPointValid(coordinatePtr.x,coordinatePtr.y,coordinatePtr.z)) + { + System.out.println("Error: " + type + " (" + coordinatePtr.x + + ", " + coordinatePtr.y + + ", " + coordinatePtr.z); + System.exit(1); + } + } + gridPtr.addPath(vectorPtr); + } +/* ============================================================================= + * maze_read + * -- Return number of path to route + * ============================================================================= + long maze_read (maze_t* mazePtr, char* inputFileName); + */ + public int readMaze(String inputFileName) + { + //Added for mlp compatiability + List_t list_t = new List_t(); + Coordinate coordinate = new Coordinate(); + Pair pair = new Pair(); + + FileInputStream in = new FileInputStream(inputFileName); + + /* + * Parse input file + */ + int lineNumber = 0; + int height = -1; + int width = -1; + int depth = -1; + boolean isParseError = false; + List_t workListPtr = list_t.alloc(1); // List.alloc(Coordinate.comparePair); + String line; + + while((line = in.readLine()) != null) { + String code; + int[] xy = new int[6]; // equivalent to x1,y1,z1,x2,y2,z2 + int numToken = 0; + + StringTokenizer tok = new StringTokenizer(line); + + if((numToken = tok.countTokens()) < 1 ) { + continue; + } + + code = tok.nextToken(); + + if(code.equals("#")) { + /* comment line */ + continue; + } + for(int i=0;i