From 644a292c7d66fe0595f1efa610c561e3f1560746 Mon Sep 17 00:00:00 2001 From: adash Date: Sat, 7 Mar 2009 20:08:42 +0000 Subject: [PATCH] small changes and add comments --- .../Distributed/RainForest/dsm/Barrier.java | 1 + .../RainForest/dsm/RainForest.java | 31 ++++++++++++++++--- .../Distributed/RainForest/dsm/makefile | 6 ++-- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/Robust/src/Benchmarks/Distributed/RainForest/dsm/Barrier.java b/Robust/src/Benchmarks/Distributed/RainForest/dsm/Barrier.java index 927f8497..4e96379d 100644 --- a/Robust/src/Benchmarks/Distributed/RainForest/dsm/Barrier.java +++ b/Robust/src/Benchmarks/Distributed/RainForest/dsm/Barrier.java @@ -11,6 +11,7 @@ public class BarrierServer extends Thread { /** ** Update the age of all trees in a given map ** @param land The map to be searched + ** @param maxage The maxage of a tree ** @param rows The number of rows in the map ** @param cols The number of columns in the map **/ diff --git a/Robust/src/Benchmarks/Distributed/RainForest/dsm/RainForest.java b/Robust/src/Benchmarks/Distributed/RainForest/dsm/RainForest.java index e7d0cc97..ecdcf42b 100644 --- a/Robust/src/Benchmarks/Distributed/RainForest/dsm/RainForest.java +++ b/Robust/src/Benchmarks/Distributed/RainForest/dsm/RainForest.java @@ -5,7 +5,7 @@ #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 AGEUPDATETHRESHOLD 10 /* How frequently/how many rounds to increment age of tree */ +#define AGEUPDATETHRESHOLD 16 /* How frequently/how many rounds to increment age of tree */ #define MAXAGE 100 /* Max age of a tree */ @@ -66,12 +66,17 @@ public class RainForest extends Thread { maxValue = COLUMN -1; int col = (rand.nextInt(Math.abs(maxValue - minValue) + 1)) + minValue; int person; - if((id&1) == 0) { //same as id%2 + if((id&1) != 0) { //same as id%2 person = LUMBERJACK; } else { person = PLANTER; } Player gamer = new Player(person, row, col, ROW, COLUMN, BLOCK); + + // + // Debug + // System.println("Player= "+ person+ " PosX= "+row+" PosY= "+col); + // //Do N rounds //do one move per round and synchronise @@ -79,13 +84,13 @@ public class RainForest extends Thread { atomic { doOneMove(land, gamer); } - Barrier.enterBarrier(barr); if((i&15) == 0 && id == 0) { //same as i%AGEUPDATETHRESHOLD /* Update age of all trees in a Map */ atomic { barrserver.updateAge(land, MAXAGE, ROW, COLUMN); } } + Barrier.enterBarrier(barr); } } @@ -197,7 +202,11 @@ public class RainForest extends Thread { /* Reset state if there in no path from start to goal */ if(newpath == null) { - /* System.println("Path from ("+currx+","+curry+") to ("+gamer.getGoalX()+","+gamer.getGoalY()+") is null"); */ + // + // Debug + // System.println("Path from ("+currx+","+curry+") to ("+gamer.getGoalX()+","+gamer.getGoalY()+") is null"); + // + gamer.reset(land, ROW, COLUMN, BLOCK); gamer.setState(INIT); return; @@ -212,6 +221,10 @@ public class RainForest extends Thread { //If tree present, cut if (land[currx][curry].hasTree()) { land[currx][curry].cutTree(); + // + // Debug + // System.println("Cut tree"); + // } } else { // PLANTER // If empty, plant tree @@ -219,6 +232,10 @@ public class RainForest extends Thread { if(hasMoreTrees(land, currx, curry) == false) { TreeType t = global new TreeType(); land[currx][curry].putTree(t); + // + // Debug + // System.println("Put tree"); + // } } } @@ -226,6 +243,10 @@ public class RainForest extends Thread { gamer.setState(INIT); } else if(land[currx][curry].hasTree() && gamer.kind() == LUMBERJACK) { //Cut trees along the way land[currx][curry].cutTree(); + // + // Debug + // System.println("Cut tree while moving"); + // } // Not at destination - do nothing return; @@ -302,7 +323,7 @@ public class RainForest extends Thread { areaCount++; } } - if(treeCount > (TREE_ZONE * areaCount)) { + if(treeCount >= (TREE_ZONE * areaCount)) { return true; } return false; diff --git a/Robust/src/Benchmarks/Distributed/RainForest/dsm/makefile b/Robust/src/Benchmarks/Distributed/RainForest/dsm/makefile index af0c5ad4..7f98d897 100644 --- a/Robust/src/Benchmarks/Distributed/RainForest/dsm/makefile +++ b/Robust/src/Benchmarks/Distributed/RainForest/dsm/makefile @@ -10,17 +10,19 @@ SRC=tmp${MAINCLASS}.java \ Node.java \ AStarPathFinder.java -FLAGS1=-dsm -optimize -transstats -mainclass ${MAINCLASS} +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} + ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}NPC ${SRC1} ../../../../buildscript ${FLAGS3} -o ${MAINCLASS}N ${SRC} clean: + rm tmp1RainForest.java + rm tmpRainForest.java rm -rf tmpbuilddirectory rm *.bin -- 2.34.1