From: jihoonl Date: Tue, 23 Jun 2009 06:13:57 +0000 (+0000) Subject: compiled X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3bdb892af092eab454ecc49ee22a42978b948f6e;p=IRC.git compiled --- diff --git a/Robust/src/Benchmarks/SingleTM/Labyrinth/Coordinate.java b/Robust/src/Benchmarks/SingleTM/Labyrinth/Coordinate.java index 0aca62e6..68f792b9 100644 --- a/Robust/src/Benchmarks/SingleTM/Labyrinth/Coordinate.java +++ b/Robust/src/Benchmarks/SingleTM/Labyrinth/Coordinate.java @@ -79,6 +79,8 @@ public class Coordinate { public int y; public int z; + public Coordinate() {} + // coordiate_alloc will be constructor // coordinate_t* coordinate_alloc(long x, long y, long z) @@ -117,8 +119,8 @@ public class Coordinate { *========================================================*/ private static double getPairDistance(Pair p) { - Coordinate a = (Coordinate)p.a; - Coordinate b = (Coordinate)p.b; + 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; @@ -139,7 +141,7 @@ public class Coordinate { public static int comparePair(final Object a,final Object b) { double aDistance = getPairDistance((Pair)a); - double bDistnace = getPairDistance((Pair)b); + double bDistance = getPairDistance((Pair)b); if(aDistance < bDistance) { return 1; diff --git a/Robust/src/Benchmarks/SingleTM/Labyrinth/Grid.java b/Robust/src/Benchmarks/SingleTM/Labyrinth/Grid.java index 1d94d153..09bd64f0 100644 --- a/Robust/src/Benchmarks/SingleTM/Labyrinth/Grid.java +++ b/Robust/src/Benchmarks/SingleTM/Labyrinth/Grid.java @@ -81,6 +81,7 @@ public class Grid { public int points_index; public int[][] points_unaligned; + public Grid() {} /* ============================================================================= @@ -94,7 +95,7 @@ public class Grid { public static Grid alloc(int width,int height,int depth) { Grid grid = new Grid(); - if(grid) { + if(grid != null) { grid.width = width; grid.height = height; @@ -110,7 +111,7 @@ public class Grid { grid.points_index = CACHE_LINE_SIZE; // not sure it is right.. for(int i=grid.points_index;i 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) { /* @@ -166,32 +180,30 @@ public class Labyrinth extends Thread{ */ Labyrinth labyrinth = new Labyrinth(argv); - Barrier.setBarrier(laybyrinth.numThread); + Barrier.setBarrier(labyrinth.numThread); Maze mazePtr = Maze.alloc(); - int numPathToRoute = mazePtr.read(global_inputFile); + int numPathToRoute = mazePtr.readMaze(labyrinth.global_inputFile); - Router routerPtr = Router.alloc(laybyrinth.xCost,laybyrinth.yCost, - laybyrinth.zCost,laybyrinth.bendCost); + 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); - + Solve_Arg routerArg = new Solve_Arg(routerPtr,mazePtr,pathVectorListPtr); /* Create and start thread */ - Layrinth[] lb = new Labyrinth[numThread]; + Labyrinth[] lb = new Labyrinth[labyrinth.numThread]; - for(int i = 1; i= 0) { return prevPtr; } @@ -224,7 +227,7 @@ public class List_t { List_Node currPtr; prevPtr = findPrevious(dataPtr); - currPtr = prePtr.nextPtr; + currPtr = prevPtr.nextPtr; nodePtr = allocNode(dataPtr); if (nodePtr == null) { @@ -232,7 +235,7 @@ public class List_t { } nodePtr.nextPtr = currPtr; - prevPtr.nextPr = nodePtr; + prevPtr.nextPtr = nodePtr; size++; return true; @@ -269,7 +272,7 @@ public class List_t { } int compareObject(Object obj1,Object obj2) { - return obj1 - obj2; + return 1; } @@ -296,7 +299,7 @@ public class List_t { public static void main(String[] argv) { List_t listPtr; int[] data1 = new int[5]; - int[] data2 = new int [6]; + int[] data2 = new int[6]; int i; diff --git a/Robust/src/Benchmarks/SingleTM/Labyrinth/Maze.java b/Robust/src/Benchmarks/SingleTM/Labyrinth/Maze.java index 56417db8..c2ac425b 100644 --- a/Robust/src/Benchmarks/SingleTM/Labyrinth/Maze.java +++ b/Robust/src/Benchmarks/SingleTM/Labyrinth/Maze.java @@ -68,14 +68,18 @@ * ============================================================================= */ +#define GRID_POINT_FULL -2 +#define GRID_POINT_EMPTY -1 public class Maze { Grid gridPtr; - Queue workQueuePtr; - Vector_t wallvectorPtr; /* contains source/destination pairs to route */ + Queue_t workQueuePtr; + Vector_t wallVectorPtr; /* contains source/destination pairs to route */ Vector_t srcVectorPtr; /* obstacles */ Vector_t dstVectorPtr; /* destinations */ + public Maze() {} + /* ============================================================================= * maze_alloc @@ -88,10 +92,10 @@ public class Maze { if(mazePtr != null) { mazePtr.gridPtr = null; - mazePtr.workQueuePtr = Queue.alloc(1024); - mazePtr.wallVectorPtr = Vector.alloc(1); - mazePtr.srcVectorPtr = Vector.alloc(1); - mazePtr.dstVectorPtr = Vector.alloc(1); + 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); } @@ -112,18 +116,18 @@ public class Maze { * addToGrid * ============================================================================= */ - private void addToGrid(Grid gridPtr,Vector_t vectorPtr,char[] type) + private void addToGrid(Grid gridPtr,Vector_t vectorPtr,String type) { int i; - int n = vectorPtr.getSize(); + int n = vectorPtr.vector_getSize(); for(i = 0; i < n; i++) { Coordinate coordinatePtr = (Coordinate)vectorPtr.vector_at(i); - if(!gridPtr.isPointValid(coodinatePtr.x,coordinatePtr.y,coordinatePtr.z)) + if(!gridPtr.isPointValid(coordinatePtr.x,coordinatePtr.y,coordinatePtr.z)) { - System.err.println("Error: " + type + " (" + coordinate.x + - ", " + coordinate.y + - ", " + coordinate.z); + System.out.println("Error: " + type + " (" + coordinatePtr.x + + ", " + coordinatePtr.y + + ", " + coordinatePtr.z); System.exit(1); } } @@ -135,10 +139,9 @@ public class Maze { * ============================================================================= long maze_read (maze_t* mazePtr, char* inputFileName); */ - public int read(String inputFileName) + public int readMaze(String inputFileName) { - BufferedReader in = new BufferedReader(new FileReader(inputFileName)); - + FileInputStream in = new FileInputStream(inputFileName); /* * Parse input file */ @@ -146,34 +149,33 @@ public class Maze { int height = -1; int width = -1; int depth = -1; - char[] line = new char[256]; boolean isParseError = false; - List_t workListPtr = List.alloc(1); // List.alloc(Coordinate.comparePair); + List_t workListPtr = List_t.alloc(1); // List.alloc(Coordinate.comparePair); String line; - while(line = in.readLine()) { + while((line = in.readLine()) != null) { - char code; + 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 ) { + if((numToken = tok.countTokens()) < 1 ) { continue; } - code = (char)tok.nextElement(); + code = tok.nextToken(); - for(i=0;i tmp${MAINCLASS}.java cpp Grid.java > tmpGrid.java cpp Router.java > tmpRouter.java + cpp Maze.java > tmpMaze.java + cpp Queue_t.java > tmpQueue_t.java ./extractLines tmp${MAINCLASS}.java ./extractLines tmpGrid.java ./extractLines tmpRouter.java + ./extractLines tmpMaze.java + ./extractLines tmpQueue_t.java ../../../buildscript ${FLAGS} -o ${MAINCLASS} ${SRC} rm ttt*.java tmp*.java