From affcc79dc11438d400d5674ac5fa5162a5df0820 Mon Sep 17 00:00:00 2001 From: adash Date: Tue, 10 Feb 2009 01:34:56 +0000 Subject: [PATCH] added files for new dsm directory --- .../LookUpService/dsm/LookUpService.java | 179 ++++++++++++++++++ .../Distributed/LookUpService/dsm/makefile | 14 ++ 2 files changed, 193 insertions(+) create mode 100644 Robust/src/Benchmarks/Distributed/LookUpService/dsm/LookUpService.java create mode 100644 Robust/src/Benchmarks/Distributed/LookUpService/dsm/makefile diff --git a/Robust/src/Benchmarks/Distributed/LookUpService/dsm/LookUpService.java b/Robust/src/Benchmarks/Distributed/LookUpService/dsm/LookUpService.java new file mode 100644 index 00000000..fd2aa212 --- /dev/null +++ b/Robust/src/Benchmarks/Distributed/LookUpService/dsm/LookUpService.java @@ -0,0 +1,179 @@ +public class LookUpService extends Thread { + DistributedHashMap mydhmap; + /** + * The thread id involved + **/ + private int threadid; + /** + * The total number of threads + **/ + private int numthreads; + + /** + * The total number of transactions + **/ + private int numtrans; + + /** + * The total number of objects created + **/ + private int nobjs; + + /** + * The probability of initiating a look up + * the read probability % between 0-99 + **/ + private int rdprob; + + public LookUpService() { + } + + public LookUpService(DistributedHashMap dmap, int threadid, int numthreads, int nobjs, int numtrans, int rdprob) { + mydhmap = dmap; + this.threadid = threadid; + this.numthreads = numthreads; + this.nobjs = nobjs; + this.numtrans = numtrans; + this.rdprob = rdprob; + } + + public void run() { + Barrier barr; + barr = new Barrier("128.195.136.162"); + //Add to the hash map + int ntrans; + atomic { + for(int i = 0; i < nobjs; i++) { + Integer key = global new Integer(threadid*nobjs+i); + Integer val = global new Integer(i); + Object o1 = key; + Object o2 = val; + mydhmap.put(o1, o2); + } + ntrans = numtrans; + } + Barrier.enterBarrier(barr); + // Do read/writes + for (int i = 0; i < ntrans; i++) { + atomic { + Random rand = new Random(i); + int rdwr = rand.nextInt(100); + int rwkey = rand.nextInt(nobjs*numthreads); + Integer key = global new Integer(rwkey); + Object o1 = key; + if (rdwr < rdprob) { + Object o3 = mydhmap.get(o1); //Read + } else { + Integer val = global new Integer(i); + Object o2 = val; + mydhmap.put(o1, o2); //Modify + } + } + } + } + + public static void main(String[] args) { + LookUpService ls = new LookUpService(); + LookUpService.parseCmdLine(args,ls); + BarrierServer mybarr; + + int nthreads = ls.numthreads; + 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 + + LookUpService[] lus; + DistributedHashMap dhmap; + atomic { + mybarr = global new BarrierServer(nthreads); + } + + mybarr.start(mid[0]); + atomic { + dhmap = global new DistributedHashMap(100, 100, 0.75f); + lus = global new LookUpService[nthreads]; + for(int i = 0; i -nEntry -nTrans -probRead \n"); + System.printString(" -N the number of threads\n"); + System.printString(" -nEntry 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(" -h help with usage\n"); + } +} diff --git a/Robust/src/Benchmarks/Distributed/LookUpService/dsm/makefile b/Robust/src/Benchmarks/Distributed/LookUpService/dsm/makefile new file mode 100644 index 00000000..b8eb7282 --- /dev/null +++ b/Robust/src/Benchmarks/Distributed/LookUpService/dsm/makefile @@ -0,0 +1,14 @@ +MAINCLASS=LookUpService +SRC1=${MAINCLASS}.java \ + ../../../ClassLibrary/DistributedHashMap.java +FLAGS1=-dsm -dsmcaching -rangeprefetch -optimize -mainclass ${MAINCLASS} -trueprob 0.90 +FLAGS2=-dsm -dsmcaching -prefetch -optimize -excprefetch String.hashCode -excprefetch DistributedHashMap.resize -excprefetch String.equals -excprefetch LookUpService.main -mainclass ${MAINCLASS} -trueprob 0.90 +FLAGS3=-dsm -optimize -mainclass ${MAINCLASS} +default: + ../../../buildscript ${FLAGS3} -o ${MAINCLASS}NPNC ${SRC1} + ../../../buildscript ${FLAGS2} -o ${MAINCLASS}N ${SRC1} + ../../../buildscript ${FLAGS1} -o ${MAINCLASS}RangeN ${SRC1} + +clean: + rm -rf tmpbuilddirectory + rm *.bin -- 2.34.1