From: adash Date: Fri, 27 Feb 2009 21:01:01 +0000 (+0000) Subject: Basic RainForest benchmark that compiles...needs more work X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7b56f1da10335e4a6d644d7c8fd51499364dfb12;p=IRC.git Basic RainForest benchmark that compiles...needs more work --- diff --git a/Robust/src/Benchmarks/Distributed/RainForest/dsm/Barrier.java b/Robust/src/Benchmarks/Distributed/RainForest/dsm/Barrier.java new file mode 100644 index 00000000..f8389c47 --- /dev/null +++ b/Robust/src/Benchmarks/Distributed/RainForest/dsm/Barrier.java @@ -0,0 +1,52 @@ +public class BarrierServer extends Thread { + int numthreads; + boolean done; + + public BarrierServer(int n) { + numthreads=n; + done=false; + } + + public void run() { + int n; + ServerSocket ss=new ServerSocket(2000); + atomic { + n=numthreads; + done=true; + } + Socket ar[]=new Socket[n]; + for(int i=0; i= rows) + highx = rows-1; + if (highy >= cols) + highx = cols-1; + } + + public int kind() { + return type; + } + + public void setPosition(int x, int y) { + this.x = x; + this.y = y; + return; + } + + public int getX() { + return x; + } + + public int getY() { + return y; + } + + public int getId() { + return id; + } + +} + diff --git a/Robust/src/Benchmarks/Distributed/RainForest/dsm/RainForest.java b/Robust/src/Benchmarks/Distributed/RainForest/dsm/RainForest.java new file mode 100644 index 00000000..061a4148 --- /dev/null +++ b/Robust/src/Benchmarks/Distributed/RainForest/dsm/RainForest.java @@ -0,0 +1,130 @@ +#define ROW 10 /* columns in the map */ +#define COLUMN 10 /* rows of in the map */ +#define ROUNDS 100 /* Number of moves by each player */ +#define PLAYERS 20 /* Number of Players when num Players != num of client machines */ +#define RATI0 0.5 /* Number of lumberjacks to number of planters */ +#define BLOCK 3 /* Area around the gamer to consider */ +#define TREE_ZONE 0.4 /* Max percentage of trees in a zone */ + +#define LUMBERJACK 0 +#define PLANTER 1 + +public class RainForest extends Thread { + GameMap land; + Player gamer; + + public RainForest(GameMap land, Player gamer) { + this.land = land; + this.gamer = gamer; + } + + public void run() { + // For N interations do one move and synchronise + return; + } + + public static void main(String[] args) { + int numThreads= 1; + BarrierServer mybarr; + + int[] mid = new int[8]; + mid[0] = (128<<24)|(195<<16)|(136<<8)|162;//dc-1 + mid[1] = (128<<24)|(195<<16)|(136<<8)|163;//dc-2 + mid[2] = (128<<24)|(195<<16)|(136<<8)|164;//dc-3 + mid[3] = (128<<24)|(195<<16)|(136<<8)|165;//dc-4 + mid[4] = (128<<24)|(195<<16)|(136<<8)|166;//dc-5 + mid[5] = (128<<24)|(195<<16)|(136<<8)|167;//dc-6 + mid[6] = (128<<24)|(195<<16)|(136<<8)|168;//dc-7 + mid[7] = (128<<24)|(195<<16)|(136<<8)|169;//dc-8 + + // Init land and place rocks in boundaries + GameMap[][] world; + atomic { + mybarr = global new BarrierServer(numThreads); + world = global new GameMap[ROW][COLUMN]; + int i, j; + for (i = 0; i < ROW; i++) { + for (j = 0; j < COLUMN; j++) { + world[i][j] = global new GameMap(); + if (j == 0 || j == COLUMN-1) { + RockType r = global new RockType(); + world[i][j].putRock(r); + } + } + if (i == 0 || i == ROW-1) { + RockType r = global new RockType(); + world[i][j].putRock(r); + } + } + } + + mybarr.start(mid[0]); + + // Create P players + // Parse args get number of threads + // For each thread, init either a lumberjack/planter + Player[] players; + atomic { + players = global new Player[numThreads]; + for (int i = 0; i < numThreads; i++) { + Random rand = new Random(i); + int row = rand.nextInt(ROW-1); + int col = rand.nextInt(COLUMN-1); + int type = rand.nextInt(1); + int person; + if (type == 0) { + person = LUMBERJACK; + } else { + person = PLANTER; + } + players[i] = global new Player(person, row, col, i, ROW, COLUMN, BLOCK); + } + } + + // Set up threads + RainForest[] rf; + atomic { + rf = global new RainForest[numThreads]; + for(int i=0; i tmpRainForest.java diff --git a/Robust/src/Benchmarks/Distributed/RainForest/dsm/makefile b/Robust/src/Benchmarks/Distributed/RainForest/dsm/makefile new file mode 100644 index 00000000..6ce4c58e --- /dev/null +++ b/Robust/src/Benchmarks/Distributed/RainForest/dsm/makefile @@ -0,0 +1,21 @@ +MAINCLASS=RainForest +SRC=tmp${MAINCLASS}.java \ + Player.java \ + TreeType.java \ + GameMap.java \ + RockType.java \ + Barrier.java + +FLAGS1=-dsm -optimize -mainclass ${MAINCLASS} +FLAGS2=-dsm -dsmcaching -optimize -mainclass ${MAINCLASS} +FLAGS3=-dsm -dsmcaching -prefetch -optimize -mainclass ${MAINCLASS} -trueprob 0.90 +FLAGS4=-dsm -dsmcaching -rangeprefetch -optimize -mainclass ${MAINCLASS} -trueprob 0.90 + +default: + cpp ${MAINCLASS}.java > tmp1${MAINCLASS}.java + ./extractLines + ../../../../buildscript ${FLAGS1} -o ${MAINCLASS}NPNC ${SRC} + +clean: + rm -rf tmpbuilddirectory + rm *.bin