new script files and some bug fixes...LookUpservice java still not working well
authoradash <adash>
Mon, 9 Mar 2009 15:09:00 +0000 (15:09 +0000)
committeradash <adash>
Mon, 9 Mar 2009 15:09:00 +0000 (15:09 +0000)
13 files changed:
Robust/src/Benchmarks/Distributed/LookUpService/dsm/DistributedHashMap.java
Robust/src/Benchmarks/Distributed/LookUpService/dsm/makefile
Robust/src/Benchmarks/Distributed/LookUpService/java/LookUpClient.java
Robust/src/Benchmarks/Distributed/LookUpService/java/LookUpServerExample.java
Robust/src/Benchmarks/Distributed/LookUpService/java/LookUpServerThread.java
Robust/src/Benchmarks/Distributed/LookUpService/java/makefile
Robust/src/Benchmarks/Distributed/RainForest/dsm/makefile
Robust/src/Benchmarks/Distributed/RainForest/java/RainForestClient.java
Robust/src/Benchmarks/Distributed/RainForest/java/RainForestServerExample.java
Robust/src/Benchmarks/Distributed/RainForest/java/makefile
Robust/src/Benchmarks/Distributed/bm_args.txt [new file with mode: 0644]
Robust/src/Benchmarks/Distributed/runall.sh [new file with mode: 0755]
Robust/src/Benchmarks/Distributed/runjava.sh

index b3e6c9e851fc9c4ab95bb957571ceee884a23f11..30b73bbb8d957caaa5858b19401c476aed2a0c55 100644 (file)
@@ -78,37 +78,13 @@ public class DistributedHashMap {
   Object get(Object key) {
     int hashcode=key.hashCode();
     int index1=hash1(hashcode, table.length);
-    /****** Add Manual Prefetch *****/
-    //table[index1].array
-    Object obj = table;
-    short[] offsets = new short[4];
-    offsets[0] = (short) index1;
-    offsets[1] = (short) 0;
-    offsets[2] = getoffset {DistributedHashEntry, array};
-    offsets[3] = (short) 0;
-    System.rangePrefetch(obj,offsets);
-    /********************************/
-
+    
     DistributedHashEntry dhe=table[index1];
     if (dhe==null)
       return null;
 
     int index2=hash2(hashcode, table.length, dhe.array.length);
-    /****** Add Manual Prefetch *****/
-    //dhe.array[index2].next(5).key
-    Object obj1 = dhe;
-    short[] offsets1 = new short[8];
-    offsets1[0] = getoffset {DistributedHashEntry, array};
-    offsets1[1] = (short) 0;
-    offsets1[2] = (short) index2;
-    offsets1[3] = (short) 0;
-    offsets1[4] = getoffset {DHashEntry, next};
-    offsets1[5] = (short) 5;
-    offsets1[6] = getoffset {DHashEntry, key};
-    offsets1[7] = (short) 0;
-    System.rangePrefetch(obj1, offsets1);
-    /********************************/
-
+    
     DHashEntry ptr=dhe.array[index2];
 
     while(ptr!=null) {
index 57225532df9761d0f4810bf052a6ef1011087a3c..f31b9b6c1eb572a912cc3c0e617f91cc01fb4328 100644 (file)
@@ -1,14 +1,12 @@
 MAINCLASS=LookUpService
 SRC1=${MAINCLASS}.java \
      DistributedHashMap.java
-FLAGS1=-dsm -dsmcaching -rangeprefetch -optimize -mainclass ${MAINCLASS} -trueprob 0.95
 FLAGS2=-dsm -dsmcaching -prefetch -optimize -excprefetch String.hashCode -excprefetch DistributedHashMap.resize -excprefetch String.equals -excprefetch LookUpService.main -mainclass ${MAINCLASS} -trueprob 0.95
 FLAGS3=-dsm -optimize -mainclass ${MAINCLASS}
 FLAGS4=-dsm -dsmcaching -optimize -mainclass ${MAINCLASS}
 default:
        ../../../../buildscript ${FLAGS3} -o ${MAINCLASS}NPNC ${SRC1}
        ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}N ${SRC1}
-       ../../../../buildscript ${FLAGS1} -o ${MAINCLASS}RangeN ${SRC1}
        ../../../../buildscript ${FLAGS4} -o ${MAINCLASS}NPC ${SRC1}
 clean:
        rm -rf tmpbuilddirectory
index b26ea5d5cd77b5a4d73042b1a3fbad7cef0eb493..12c7e91261542e4592af8f674a0609bddf518848 100644 (file)
@@ -20,14 +20,18 @@ public class LookUpClient {
    **/
   private int nLookUp;
 
+
+  private int seed;
+
   public LookUpClient() {
   }
 
-  public LookUpClient(int numtrans, int nobjs, int rdprob, int nLookUp) {
+  public LookUpClient(int numtrans, int nobjs, int rdprob, int nLookUp, int seed) {
     this.numtrans = numtrans;
     this.nobjs = nobjs;
     this.rdprob = rdprob;
     this.nLookUp = nLookUp;
+    this.seed = seed;
   }
 
   public static void main(String[] args) {
@@ -35,8 +39,8 @@ public class LookUpClient {
     LookUpClient.parseCmdLine(args, lc);
 
     Socket sock = new Socket("dc-1.calit2.uci.edu",9001);
-    Random rand = new Random(0);
-
+    Random rand = new Random(lc.seed);
+    SocketInputStream sin = new SocketInputStream(sock);
 
     for (int i = 0; i < lc.numtrans; i++) {
       for (int j = 0; j < lc.nLookUp; j++) {
@@ -48,23 +52,24 @@ public class LookUpClient {
         } else {
           operation = 2;//update hashmap
         }
-        lc.doLookUp(operation, sock, rwkey);
+        lc.doLookUp(operation, sock, rwkey, sin);
       }
     }
     /** Special character to terminate computation **/
     String op = new String("t");
     sock.write(op.getBytes());
+    sock.close();
   }
 
   /**
    * Call to do a read/ write on socket
    **/
-  public void doLookUp(int operation, Socket sock, int key){
+  public void doLookUp(int operation, Socket sock, int key, SocketInputStream sin){
     String op;
     if (operation == 1) {
       sock.write(fillBytes(operation, key));
       byte b[] = new byte[4];
-      int numbytes = sock.read(b);
+      String str1 = readFromSock(sin, 4);
     } else {
       sock.write(fillBytes(operation, key));
     }
@@ -84,6 +89,10 @@ public class LookUpClient {
       int offset = (3-(i-1)) * 8;
       b[i] = (byte) ((key >> offset) & 0xFF);
     }
+    //
+    // Debug
+    // System.println("Sending b[0]= "+ (char) b[0]);
+    //
     return b;
   }
 
@@ -112,12 +121,16 @@ public class LookUpClient {
         if(i < args.length) {
           lc.nLookUp = new Integer(args[i++]).intValue();
         }
+      } else if(arg.equals("-seed")) {
+        if(i < args.length) {
+          lc.seed = new Integer(args[i++]).intValue();
+        }
       } else if(arg.equals("-h")) {
         lc.usage();
       }
     }
 
-    if(lc.nobjs == 0  || lc.numtrans == 0)
+    if(lc.nobjs == 0  || lc.numtrans == 0 || lc.nLookUp == 0)
       lc.usage();
   }
 
@@ -125,11 +138,27 @@ public class LookUpClient {
    * The usage routine which describes the program options.
    **/
   public void usage() {
-    System.printString("usage: ./Client.bin -nObjs <objects in hashmap> -nTrans <number of transactions> -probRead <read probability> -nLookUp <number of lookups>\n");
+    System.printString("usage: ./Client.bin -nObjs <objects in hashmap> -nTrans <number of transactions> -probRead <read probability> -nLookUp <number of lookups> -seed <seed value for Random variable>\n");
     System.printString("    -nObjs the number of objects to be inserted into distributed hashmap\n");
     System.printString("    -nTrans the number of transactions to run\n");
     System.printString("    -probRead the probability of read given a transaction\n");
     System.printString("    -nLookUp the number of lookups per transaction\n");
+    System.printString("    -seed the seed value for Random\n");
     System.printString("    -h help with usage\n");
   }
+
+  /**
+   ** Repeated read until you get all bytes
+   **/
+  String readFromSock(SocketInputStream si, int maxBytes) {
+    byte []b=new byte[maxBytes];
+    int numbytes;
+    if ((numbytes = si.readAll(b))<0)
+      System.out.println("Error\n");
+    //
+    // Debug
+    // System.println("numbytes received= " +  numbytes);
+    //
+    return new String(b);
+  }
 }
index 0228cf4d43899c167e057cc204b246ee4ae927ea..31d2ee49bc965e8ad16e121a104542f2c173e54a 100644 (file)
@@ -47,7 +47,10 @@ public class LookUpServerExample {
     for(int i=0; i<nthreads; i++) {
       lus[i].join();
     }
+
+    ss.close();
     System.println("Finished");
+    System.exit(0);
   }
 
   /**
index 83adafa51394e8cf795ddcee22fcd6395703206b..1e604653fc793066f18a72c63fd0013161b1b3c7 100644 (file)
@@ -1,25 +1,28 @@
 public class LookUpServerThread extends Thread {
   HashMap hmap;
   Socket sock;
+  SocketInputStream sin;
 
   public LookUpServerThread(Socket s, HashMap h) {
     hmap = h;
     sock = s;
+    this.sin = new SocketInputStream(sock);
   }
 
   public void run() {
-      Random r=new Random(0);
+    Random r=new Random(0);
+    byte b[] = new byte[1]; //1 byte to decide if terminate or continue
+    byte b1[] = new byte[4];//4 bytes to get the Key to search 
     while(true) {
-      byte b[] = new byte[1];
-      int numbytes = sock.read(b);
-      String str1 = (new String(b)).subString(0, numbytes);
+      String readStr = readFromSock(1);
+      String str1 = readStr.subString(0, 1);
       /* terminate if opcode sent is "t" */
       if(str1.equalsIgnoreCase("t")) {
         sock.close();
         break;
       } else {
-        byte b1[] = new byte[4];
-        numbytes = sock.read(b1);
+        readStr = readFromSock(4);
+        b1 = readStr.getBytes();
         int val =  getKey(b1);
         Integer keyitem = new Integer(val);
         /* read from hashmap if opcode sent is "r" */
@@ -28,8 +31,8 @@ public class LookUpServerThread extends Thread {
           //Write object to socket for client
           sock.write(tmpval.intToByteArray());
         } else {
-        /* update hashmap if opcode sent is "w" */
-           doUpdate(r, this, keyitem);
+          /* update hashmap if opcode sent is "w" */
+          doUpdate(r, this, keyitem);
         }
       }
     }
@@ -66,4 +69,19 @@ public class LookUpServerThread extends Thread {
     val = ((b[0] & 0xFF) << 24) + ((b[1] & 0xFF) << 16) + ((b[2] & 0xFF) << 8) + (b[3] & 0xFF);
     return val;
   }
+
+  /**
+   ** Repeated read until you get all bytes
+   **/
+  String readFromSock(int maxBytes) {
+    byte []b=new byte[maxBytes];
+    int numbytes;
+    if ((numbytes = sin.readAll(b))<0)
+      System.out.println("Error\n");
+    //
+    // Debug
+    // System.println("numbytes received= " +  numbytes +" b[0]= " + (char) b[0]);
+    //
+    return new String(b);
+  }
 }
index dd63bef9aa560c3da105462569dfc74df03077f1..53fc7253918d2a6c8223c5a68834d57042205332 100644 (file)
@@ -3,8 +3,8 @@ MAINCLASS2=LookUpClient
 SRC1=${MAINCLASS1}.java \
         LookUpServerThread.java
 SRC2=${MAINCLASS2}.java 
-FLAGS= -thread -optimize -mainclass ${MAINCLASS1}
-FLAGS1= -thread -optimize -mainclass ${MAINCLASS2}
+FLAGS= -thread -nooptimize -debug -mainclass ${MAINCLASS1}
+FLAGS1= -thread -nooptimize -debug -mainclass ${MAINCLASS2}
 
 default :
        ../../../../buildscript ${FLAGS} -o Server ${SRC1}
index 7f98d897465433e3c30c506c1c6292ea61e6f91d..6d30076fcdc33211f20f6855b42ed73bd41ff9c4 100644 (file)
@@ -12,13 +12,13 @@ SRC=tmp${MAINCLASS}.java \
 
 FLAGS1=-dsm -optimize -mainclass ${MAINCLASS}
 FLAGS2=-dsm -dsmcaching -optimize -mainclass ${MAINCLASS}
-FLAGS3=-dsm -dsmcaching -prefetch -optimize -mainclass ${MAINCLASS} -trueprob 0.90
+FLAGS3=-dsm -dsmcaching -prefetch -optimize -mainclass ${MAINCLASS} -excprefetch BarrierServer.updateAge -excprefetch RainForest.main -excprefetch GameMap.hasRock -excprefetch GameMap.hasTree -trueprob 0.90
 
 default:
        cpp ${MAINCLASS}.java > tmp1${MAINCLASS}.java
        ./extractLines
        ../../../../buildscript ${FLAGS1} -o ${MAINCLASS}NPNC ${SRC}
-       ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}NPC ${SRC1}
+       ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}NPC ${SRC}
        ../../../../buildscript ${FLAGS3} -o ${MAINCLASS}N ${SRC}
 
 clean:
index 888e150f58aaa739f9f658ee2723f4af49b609e1..0d72dc5d373e3dba640b25c7c83d83bdb9e93686 100644 (file)
 
 public class RainForestClient {
 
+  /**
+   ** The random seed
+   **/
+  int seed;
+
+  public RainForestClient(int seed) {
+    this.seed = seed;
+  }
+
   public RainForestClient() {
 
   }
 
   public static void main(String[] args) {
-    int seed;
-    if(args.length>0) {
-      seed = Integer.parseInt(args[0]);
-    }
-
-    Random rand = new Random(seed);
     RainForestClient rfc = new RainForestClient();
+    RainForestClient.parseCmdLine(args, rfc);
+
+    Random rand = new Random(rfc.seed);
     Socket sock = new Socket("dc-1.calit2.uci.edu",9002);
     SocketInputStream si=new SocketInputStream(sock);
 
@@ -406,4 +412,35 @@ public class RainForestClient {
         System.out.println("Error\n");
     return new String(b);
   }
+
+  /**
+   * Parse the command line options.
+   **/
+  public static void parseCmdLine(String args[], RainForestClient rfc) {
+    int i = 0;
+    String arg;
+    while(i < args.length && args[i].startsWith("-")) {
+      arg = args[i++];
+      //check options
+      if(arg.equals("-seed")) {
+        if(i < args.length) {
+          rfc.seed = new Integer(args[i++]).intValue();
+        }
+      } else if(arg.equals("-h")) {
+        rfc.usage();
+      }
+    }
+
+    if(rfc.seed <= 0)
+      rfc.usage();
+  }
+
+  /**
+   * The usage routine which describes the program options.
+   **/
+  public void usage() {
+    System.printString("usage: ./Client.bin -seed <seed value for Random variable>\n");
+    System.printString("    -seed the seed value for Random\n");
+    System.printString("    -h help with usage\n");
+  }
 }
index df1a5400e2a4e6172da8831e8f85e2b8939d201a..8f9d3f56385196571adc371900a43c815879b337 100644 (file)
@@ -2,17 +2,18 @@
 #define COLUMN              100  /* rows of in the map */
 
 public class RainForestServerExample {
-  private int numThreads;
+  /**
+   ** Number of threads
+   **/
+  int numThreads;
 
   public RainForestServerExample() {
 
   }
 
   public static int main(String args[]) {
-    int numThreads;
-    if(args.length>0) {
-      numThreads = Integer.parseInt(args[0]);
-    }
+    RainForestServerExample rfe = new RainForestServerExample();
+    RainForestServerExample.parseCmdLine(args, rfe);
 
     /**
      * Create shared Map 
@@ -35,7 +36,7 @@ public class RainForestServerExample {
     }
 
     ServerSocket ss = new ServerSocket(9002);
-    acceptConnection(ss, world, numThreads);
+    acceptConnection(ss, world, rfe.numThreads);
   }
 
   public static void acceptConnection(ServerSocket ss, GameMap[][] world, int numThreads) {
index cbe1ecafd2e7ca8e9ed18d85fb812d8a71b64e5a..d11257ddca1cc20b757e7cc0a75fdcf0e22cea23 100644 (file)
@@ -19,8 +19,8 @@ SRC1=tmp${MAINCLASS2}.java \
        AStarPathFinder.java \
        BarrierNonDSM.java
 
-FLAGS1= -thread -nooptimize -debug -mainclass ${MAINCLASS1}
-FLAGS2= -thread -nooptimize -debug -mainclass ${MAINCLASS2}
+FLAGS1= -thread -optimize -mainclass ${MAINCLASS1}
+FLAGS2= -thread -optimize -mainclass ${MAINCLASS2}
 
 default:
          cpp RainForestServerExample.java > tmp1RainForestServerExample.java
diff --git a/Robust/src/Benchmarks/Distributed/bm_args.txt b/Robust/src/Benchmarks/Distributed/bm_args.txt
new file mode 100644 (file)
index 0000000..33d4221
--- /dev/null
@@ -0,0 +1,2 @@
+LookUpService:-nObjs 160:-nObjs 160 -nTrans 1000 -probRead 96 -nLookUp 10:LookUpServerExample:LookUpClient
+RainForest::::
diff --git a/Robust/src/Benchmarks/Distributed/runall.sh b/Robust/src/Benchmarks/Distributed/runall.sh
new file mode 100755 (executable)
index 0000000..b064f7d
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+./runjava.sh 6
index 193dc2c169303aeca501368f1e0ff24604b5ac1c..d9e9026280aa4b185acb0279b0d77e850d06fdcc 100755 (executable)
@@ -72,7 +72,7 @@ function runjvm {
   done
 }
 
-exec < bm_jargs.txt
+exec < bm_args.txt
 while read line
 do
   BM_NAME=`echo $line | cut -f1 -d":"`