From: adash Date: Thu, 24 Apr 2008 21:19:30 +0000 (+0000) Subject: Add new benchmark...still have compile errors X-Git-Tag: preEdgeChange~142 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=001d2fd23c0319a9eab1bff709066c9b9fed48e8;p=IRC.git Add new benchmark...still have compile errors --- diff --git a/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/JGFInstrumentor.java b/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/JGFInstrumentor.java new file mode 100644 index 00000000..fc737bec --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/JGFInstrumentor.java @@ -0,0 +1,199 @@ +/************************************************************************** + * * + * Java Grande Forum Benchmark Suite - Thread Version 1.0 * + * * + * produced by * + * * + * Java Grande Benchmarking Project * + * * + * at * + * * + * Edinburgh Parallel Computing Centre * + * * + * email: epcc-javagrande@epcc.ed.ac.uk * + * * + * * + * This version copyright (c) The University of Edinburgh, 1999. * + * All rights reserved. * + * * + **************************************************************************/ +public class JGFInstrumentor{ + + protected HashMap timers; + protected HashMap data; + + public JGFInstrumentor() { + timers = new HashMap(); + data = new HashMap(); + } + + public static void addTimer (String name, HashMap timers){ + + if (timers.containsKey(name)) { + System.printString("JGFInstrumentor.addTimer: warning - timer " + name + + " already exists"); + } + else { + timers.put(name, new JGFTimer(name)); + } + } + + public static void addTimer (String name, String opname, HashMap timers){ + + if (timers.containsKey(name)) { + System.printString("JGFInstrumentor.addTimer: warning - timer " + name + + " already exists"); + } + else { + timers.put(name, new JGFTimer(name,opname)); + } + + } + + public static void addTimer (String name, String opname, int size, HashMap timers){ + + if (timers.containsKey(name)) { + System.printString("JGFInstrumentor.addTimer: warning - timer " + name + + " already exists"); + } + else { + timers.put(name, new JGFTimer(name,opname,size)); + } + + } + + public static void startTimer(String name, HashMap timers){ + if (timers.containsKey(name)) { + ((JGFTimer) timers.get(name)).start(); + } + else { + System.printString("JGFInstrumentor.startTimer: failed - timer " + name + + " does not exist"); + } + + } + + public static void stopTimer(String name, HashMap timers){ + if (timers.containsKey(name)) { + ((JGFTimer) timers.get(name)).stop(); + } + else { + System.printString("JGFInstrumentor.stopTimer: failed - timer " + name + + " does not exist"); + } + } + + public static void addOpsToTimer(String name, double count, HashMap timers){ + if (timers.containsKey(name)) { + ((JGFTimer) timers.get(name)).addops(count); + } + else { + System.printString("JGFInstrumentor.addOpsToTimer: failed - timer " + name + + " does not exist"); + } + } + + public static void addTimeToTimer(String name, double added_time, HashMap timers){ + if (timers.containsKey(name)) { + ((JGFTimer) timers.get(name)).addtime(added_time); + } + else { + System.printString("JGFInstrumentor.addTimeToTimer: failed - timer " + name + + " does not exist"); + } + + + + } + + public static double readTimer(String name, HashMap timers){ + double time; + if (timers.containsKey(name)) { + time = ((JGFTimer) timers.get(name)).time; + } + else { + System.printString("JGFInstrumentor.readTimer: failed - timer " + name + + " does not exist"); + time = 0.0; + } + return time; + } + + public static void resetTimer(String name, HashMap timers){ + if (timers.containsKey(name)) { + ((JGFTimer) timers.get(name)).reset(); + } + else { + System.printString("JGFInstrumentor.resetTimer: failed - timer " + name + + " does not exist"); + } + } + + public static void printTimer(String name, HashMap timers){ + if (timers.containsKey(name)) { + ((JGFTimer) timers.get(name)).print(); + } + else { + System.printString("JGFInstrumentor.printTimer: failed - timer " + name + + " does not exist"); + } + } + + public static void printperfTimer(String name, HashMap timers){ + if (timers.containsKey(name)) { + ((JGFTimer) timers.get(name)).printperf(); + } + else { + System.printString("JGFInstrumentor.printTimer: failed - timer " + name + + " does not exist"); + } + } + + public static void storeData(String name, Object obj, HashMap data){ + data.put(name,obj); + } + + public static void retrieveData(String name, Object obj, HashMap data){ + obj = data.get(name); + } + + public static void printHeader(int section, int size,int nthreads) { + + String header, base; + + header = ""; + base = "Java Grande Forum Thread Benchmark Suite - Version 1.0 - Section "; + + if (section == 1) + { + header = base + "1"; + } + else if (section == 2) + { + if (size == 0) + header = base + "2 - Size A"; + else if (size == 1) + header = base + "2 - Size B"; + else if (size == 2) + header = base + "2 - Size C"; + } + else if (section == 3) + { + if (size == 0) + header = base + "3 - Size A"; + else if (size == 1) + header = base + "3 - Size B"; + } + + System.printString(header); + + if (nthreads == 1) { + System.printString("Executing on " + nthreads + " thread"); + } + else { + System.printString("Executing on " + nthreads + " threads"); + } + + System.printString(""); + } +} diff --git a/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/JGFMolDynBench.java b/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/JGFMolDynBench.java new file mode 100644 index 00000000..f4dca97e --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/JGFMolDynBench.java @@ -0,0 +1,689 @@ +/************************************************************************** + * * + * Java Grande Forum Benchmark Suite - Thread Version 1.0 * + * * + * produced by * + * * + * Java Grande Benchmarking Project * + * * + * at * + * * + * Edinburgh Parallel Computing Centre * + * * + * email: epcc-javagrande@epcc.ed.ac.uk * + * * + * * + * This version copyright (c) The University of Edinburgh, 2001. * + * All rights reserved. * + * * + **************************************************************************/ +public class JGFMolDynBench { + public int ITERS; + public double LENGTH; + public double m; + public double mu; + public double kb; + public double TSIM; + public double deltat; + + public int PARTSIZE; + + public global double[] epot; + public global double[] vir; + public global double[] ek; + + int size,mm; + int[] datasizes; + + public int interactions; + public int[] interacts; + + public global int nthreads; + public global JGFInstrumentor instr; + + public JGFMolDynBench(int nthreads, JGFInstrumentor instr) { + this.nthreads=nthreads; + this.instr = instr; + } + + public void JGFsetsize(int size){ + this.size = size; + } + + public void JGFinitialise(){ + interactions = 0; + datasizes = new int[2]; + datasizes[0] = 8; + datasizes[1] = 13; + + mm = datasizes[size]; + PARTSIZE = mm*mm*mm*4; + ITERS = 100; + LENGTH = 50e-10; + m = 4.0026; + mu = 1.66056e-27; + kb = 1.38066e-23; + TSIM = 50; + deltat = 5e-16; + + //initialise(); + } + + public static void JGFapplication(JGFMolDynBench mold) { + // Create new arrays + atomic { + mold.epot = global new double [mold.nthreads]; + mold.vir = global new double [mold.nthreads]; + mold.ek = global new double [mold.nthreads]; + mold.interacts = global new int [mold.nthreads]; + } + + int partsize, numthreads; + atomic { + partsize = mold.PARTSIZE; + numthreads = mold.nthreads; + } + + double sh_force [][] = new double[3][partsize]; + double sh_force2 [][][] = new double[3][numthreads][partsize]; + + // spawn threads + //Thread thobjects[] = new Thread [nthreads]; + mdRunner[] thobjects; + TournamentBarrier br; + atomic { + thobjects = global new mdRunner[numthreads]; + br= global new TournamentBarrier(numthreads); + } + + int mid = (128<<24)|(195<<16)|(175<<8)|73; + mdRunner tmp; + + for(int i=1;i 1.0e-10 ){ + //System.printString("Validation failed"); + //System.printString("Kinetic Energy = " + (long)ek[0] + " " + (long)dev + " " + size); + } + } +} + +class mdRunner extends Thread { + + double count; + int id,i,j,k,lg,mdsize,move,mm; + double l,rcoff,rcoffs,side,sideh,hsq,hsq2,vel,velt; + double a,r,sum,tscale,sc,ekin,ts,sp; + double den; + double tref; + double h; + double vaver,vaverh,rand; + double etot,temp,pres,rp; + double u1,u2,v1,v2,s, xx, yy, zz; + double xvelocity, yvelocity, zvelocity; + + double [][] sh_force; + double [][][] sh_force2; + + int ijk,npartm,iseed,tint; + int irep; + int istop; + int iprint; + int movemx; + + TournamentBarrier br; + random randnum; + global JGFInstrumentor instr; + global JGFMolDynBench mymd; + int nthreads; + + particle[] one; + + public mdRunner(int id, int mm, double [][] sh_force, double [][][] sh_force2,TournamentBarrier br, + JGFInstrumentor instr, int nthreads, JGFMolDynBench mymd) { + this.id=id; + this.mm=mm; + this.sh_force=sh_force; + this.sh_force2=sh_force2; + this.br=br; + this.instr = instr; + this.nthreads = nthreads; + this.mymd = mymd; + count = 0.0; + den = 0.83134; + tref = 0.722; + h = 0.064; + irep = 10; + istop = 19; + iprint = 10; + movemx = 50; + } + + public void run() { + + /* Parameter determination */ + + atomic { + mdsize = mymd.PARTSIZE; + } + one = new particle [mdsize]; + atomic { + l = mymd.LENGTH; + } + + side = Math.pow((mdsize/den),0.3333333); + rcoff = mm/4.0; + + a = side/mm; + sideh = side*0.5; + hsq = h*h; + hsq2 = hsq*0.5; + npartm = mdsize - 1; + rcoffs = rcoff * rcoff; + tscale = 16.0 / (1.0 * mdsize - 1.0); + vaver = 1.13 * Math.sqrt(tref / 24.0); + vaverh = vaver * h; + + /* Particle Generation */ + + xvelocity = 0.0; + yvelocity = 0.0; + zvelocity = 0.0; + + ijk = 0; + atomic { + for (lg=0; lg<=1; lg++) { + for (i=0; i vaverh) { count = count + 1.0; } + vel = vel + velt; + } + + vel = vel / h; + + /* temperature scale if required */ + + if((move < istop) && (((move+1) % irep) == 0)) { + sc = Math.sqrt(tref / (tscale*ekin)); + for (i=0;i side) { xcoord = xcoord - side; } + if(ycoord < 0) { ycoord = ycoord + side; } + if(ycoord > side) { ycoord = ycoord - side; } + if(zcoord < 0) { zcoord = zcoord + side; } + if(zcoord > side) { zcoord = zcoord - side; } + + xvelocity = xvelocity + sh_force[0][part_id]; + yvelocity = yvelocity + sh_force[1][part_id]; + zvelocity = zvelocity + sh_force[2][part_id]; + + } + + public void force(double side, double rcoff,int mdsize,int x, double xx, double yy, double zz, JGFMolDynBench mymd) { + + double sideh; + double rcoffs; + + double fxi,fyi,fzi; + double rd,rrd,rrd2,rrd3,rrd4,rrd6,rrd7,r148; + double forcex,forcey,forcez; + + sideh = 0.5*side; + rcoffs = rcoff*rcoff; + + fxi = 0.0; + fyi = 0.0; + fzi = 0.0; + + for (int i=x+1;i (sideh)) { xx = xx - side; } + if(yy < (-sideh)) { yy = yy + side; } + if(yy > (sideh)) { yy = yy - side; } + if(zz < (-sideh)) { zz = zz + side; } + if(zz > (sideh)) { zz = zz - side; } + + + rd = xx*xx + yy*yy + zz*zz; + + if(rd <= rcoffs) { + rrd = 1.0/rd; + rrd2 = rrd*rrd; + rrd3 = rrd2*rrd; + rrd4 = rrd2*rrd2; + rrd6 = rrd2*rrd4; + rrd7 = rrd6*rrd; + mymd.epot[id] = mymd.epot[id] + (rrd6 - rrd3); + r148 = rrd7 - 0.5*rrd4; + mymd.vir[id] = mymd.vir[id] - rd*r148; + forcex = xx * r148; + fxi = fxi + forcex; + + sh_force2[0][id][i] = sh_force2[0][id][i] - forcex; + + forcey = yy * r148; + fyi = fyi + forcey; + + sh_force2[1][id][i] = sh_force2[1][id][i] - forcey; + + forcez = zz * r148; + fzi = fzi + forcez; + + sh_force2[2][id][i] = sh_force2[2][id][i] - forcez; + + mymd.interacts[id]++; + } + + } + + sh_force2[0][id][x] = sh_force2[0][id][x] + fxi; + sh_force2[1][id][x] = sh_force2[1][id][x] + fyi; + sh_force2[2][id][x] = sh_force2[2][id][x] + fzi; + + } + + public double mkekin(double hsq2,int part_id) { + + double sumt = 0.0; + + xvelocity = xvelocity + sh_force[0][part_id]; + yvelocity = yvelocity + sh_force[1][part_id]; + zvelocity = zvelocity + sh_force[2][part_id]; + + sumt = (xvelocity*xvelocity)+(yvelocity*yvelocity)+(zvelocity*zvelocity); + return sumt; + } + + public double velavg(double vaverh,double h) { + + double velt; + double sq; + + sq = Math.sqrt(xvelocity*xvelocity + yvelocity*yvelocity + + zvelocity*zvelocity); + + velt = sq; + return velt; + } + + public void dscal(double sc,int incx) { + + xvelocity = xvelocity * sc; + yvelocity = yvelocity * sc; + zvelocity = zvelocity * sc; + + + + } + +} + +class random { + + public int iseed; + public double v1,v2; + + public random(int iseed,double v1,double v2) { + this.iseed = iseed; + this.v1 = v1; + this.v2 = v2; + } + + public double update() { + + double rand; + double scale= 4.656612875e-10; + + int is1,is2,iss2; + int imult=16807; + int imod = 2147483647; + + if (iseed<=0) { iseed = 1; } + + is2 = iseed % 32768; + is1 = (iseed-is2)/32768; + iss2 = is2 * imult; + is2 = iss2 % 32768; + is1 = (is1*imult+(iss2-is2)/32768) % (65536); + + iseed = (is1*32768+is2) % imod; + + rand = scale * iseed; + + return rand; + + } + + public double seed() { + + double s,u1,u2,r; + s = 1.0; + do { + u1 = update(); + u2 = update(); + + v1 = 2.0 * u1 - 1.0; + v2 = 2.0 * u2 - 1.0; + s = v1*v1 + v2*v2; + + } while (s >= 1.0); + + r = Math.sqrt(-2.0*Math.log(s)/s); + + return r; + + } +} + + diff --git a/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/JGFMolDynBenchSizeA.java b/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/JGFMolDynBenchSizeA.java new file mode 100644 index 00000000..125f7571 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/JGFMolDynBenchSizeA.java @@ -0,0 +1,86 @@ +/************************************************************************** + * * + * Java Grande Forum Benchmark Suite - Thread Version 1.0 * + * * + * produced by * + * * + * Java Grande Benchmarking Project * + * * + * at * + * * + * Edinburgh Parallel Computing Centre * + * * + * email: epcc-javagrande@epcc.ed.ac.uk * + * * + * * + * This version copyright (c) The University of Edinburgh, 2001. * + * All rights reserved. * + * * + **************************************************************************/ +public class JGFMolDynBenchSizeA { + + public static void main(String argv[]){ + int nthreads; + if(argv.length != 0 ) { + nthreads = Integer.parseInt(argv[0]); + } else { + System.printString("The no of threads has not been specified, defaulting to 1"); + System.printString(" "); + nthreads = 1; + } + + JGFInstrumentor instr = new JGFInstrumentor(); + JGFInstrumentor.printHeader(3,0,nthreads); + + JGFMolDynBench mold; + atomic { + mold = global new JGFMolDynBench(nthreads, instr); + } + int size = 0; + JGFInstrumentor.addTimer("Section3:MolDyn:Total", "Solutions",size, instr.timers); + JGFInstrumentor.addTimer("Section3:MolDyn:Run", "Interactions",size, instr.timers); + + atomic { + mold.JGFsetsize(size); + } + + JGFInstrumentor.startTimer("Section3:MolDyn:Total", instr.timers); + + JGFMolDynBench tmp; + atomic { + mold.JGFinitialise(); + //tmp = mold; + } + JGFMolDynBench.JGFapplication(mold); + atomic { + mold.JGFvalidate(); + } + + /* Validate data */ + double[] refval = new double[2]; + refval[0] = 1731.4306625334357; + refval[1] = 7397.392307839352; + double dval; + atomic { + dval = mold.ek[0]; + } + double dev = Math.fabs(dval - refval[size]); + if (dev > 1.0e-10 ){ + System.printString("Validation failed"); + System.printString("Kinetic Energy = " + (long)dval + " " + (long)dev + " " + size); + } + + JGFInstrumentor.stopTimer("Section3:MolDyn:Total", instr.timers); + double interactions; + atomic { + interactions = mold.interactions; + } + + JGFInstrumentor.addOpsToTimer("Section3:MolDyn:Run", (double) interactions, instr.timers); + JGFInstrumentor.addOpsToTimer("Section3:MolDyn:Total", 1, instr.timers); + + JGFInstrumentor.printTimer("Section3:MolDyn:Run", instr.timers); + JGFInstrumentor.printTimer("Section3:MolDyn:Total", instr.timers); + } +} + diff --git a/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/JGFTimer.java b/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/JGFTimer.java new file mode 100644 index 00000000..6a051440 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/JGFTimer.java @@ -0,0 +1,123 @@ +/************************************************************************** + * * + * Java Grande Forum Benchmark Suite - Thread Version 1.0 * + * * + * produced by * + * * + * Java Grande Benchmarking Project * + * * + * at * + * * + * Edinburgh Parallel Computing Centre * + * * + * email: epcc-javagrande@epcc.ed.ac.uk * + * * + * * + * This version copyright (c) The University of Edinburgh, 1999. * + * All rights reserved. * + * * + **************************************************************************/ + +public class JGFTimer { + + public String name; + public String opname; + public double time; + public double opcount; + public long calls; + public int size; + + private long start_time; + private boolean on; + + public JGFTimer(String name, String opname){ + this.size = -1; + this.name = name; + this.opname = opname; + reset(); + } + + public JGFTimer(String name, String opname, int size){ + this.name = name; + this.opname = opname; + this.size = size; + reset(); + } + + public JGFTimer(String name){ + this.name = name; + this.opname = ""; + reset(); + } + + + + public void start(){ + if (on) System.printString("Warning timer " + name + " was already turned on"); + on = true; + start_time = System.currentTimeMillis(); + } + + + public void stop(){ + time += (double) (System.currentTimeMillis()-start_time) / 1000.; + if (!on) System.printString("Warning timer " + name + " wasn't turned on"); + calls++; + on = false; + } + + public void addops(double count){ + opcount += count; + } + + public void addtime(double added_time){ + time += added_time; + } + + public void reset(){ + time = 0.0; + calls = 0; + opcount = 0; + on = false; + } + + public double perf(){ + return opcount / time; + } + + public void longprint(){ + System.printString("Timer Calls Time(s) Performance("+opname+"/s)"); + System.printString(name + " " + calls + " " + (long)time + " " + (long)this.perf()); + } + + public void print(){ + if (opname.equals("")) { + System.printString(name + " " + (long)time + " (s)"); + } + else { + if(size == 0) { + System.printString(name + ":SizeA" + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)"); + } else if (size == 1) { + System.printString(name + ":SizeB" + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)"); + } else if (size == 2) { + System.printString(name + ":SizeC" + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)"); + } else{ + System.printString(name + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)"); + } + } + } + + + public void printperf(){ + + String name; + name = this.name; + + // pad name to 40 characters + while ( name.length() < 40 ) name = name + " "; + + System.printString(name + "\t" + (long)this.perf() + "\t" + + " ("+opname+"/s)"); + } + +} diff --git a/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/TournamentBarrier.java b/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/TournamentBarrier.java new file mode 100755 index 00000000..266e3cc0 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/TournamentBarrier.java @@ -0,0 +1,94 @@ +/************************************************************************** + * * + * Java Grande Forum Benchmark Suite - Thread Version 1.0 * + * * + * produced by * + * * + * Java Grande Benchmarking Project * + * * + * at * + * * + * Edinburgh Parallel Computing Centre * + * * + * email: epcc-javagrande@epcc.ed.ac.uk * + * * + * * + * This version copyright (c) The University of Edinburgh, 2001. * + * All rights reserved. * + * * + **************************************************************************/ + +// This implements a simple tournament-based barrier, using entirely its +// own synchronisation. At present Yield() is called to stop busy-waiting +// processes hogging the processor(s)! + +public class TournamentBarrier { + // Array of flags indicating whether the given process and all those + // for which it is responsible have finished. The "sense" of this + // array alternates with each barrier, to prevent having to + // reinitialise. + boolean[] IsDone; + public int maxBusyIter; + int numThreads; + + public TournamentBarrier(int n) { + numThreads = n; + maxBusyIter = 1; + // Superclass constructor should record the number of threads + // and thread manager. + //super(n); + + // Initialise the IsDone array. The choice of initial value is + // arbitrary, but must be consistent! + IsDone = new boolean[numThreads]; + for(int i = 0; i < n; i++) { + IsDone[i] = false; + } + } + + // Uses the manager's debug function, so this can only be used after + // construction! + public void debug(String s) { + // System.err.println("Debug message"); + } + + public void setMaxBusyIter(int b) { + maxBusyIter = b; + } + + public void DoBarrier(int myid) { + int b; + // debug("Thread " + myid + " checking in"); + + int roundmask = 3; + boolean donevalue = !IsDone[myid]; + + while(((myid & roundmask) == 0) && (roundmask<(numThreads<<2))) { + int spacing = (roundmask+1) >> 2; + for(int i=1; i<=3 && myid+i*spacing < numThreads; i++) { + // debug("Thread " + myid + " waiting for thread " + (myid+i*spacing)); + b = maxBusyIter; + while(IsDone[myid+i*spacing] != donevalue) { + b--; + if(b==0) { + //Thread.yield(); + b = maxBusyIter; + } + } + } + roundmask = (roundmask << 2) + 3; + } + // debug("Thread " + myid + " reporting done"); + IsDone[myid] = donevalue; + b = maxBusyIter; + while(IsDone[0] != donevalue) { + b--; + if(b==0) { + //Thread.yield(); + b = maxBusyIter; + } + } + //debug("Thread " + myid + " checking out"); + + } +} diff --git a/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/makefile b/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/makefile new file mode 100644 index 00000000..f1ad9c84 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/makefile @@ -0,0 +1,16 @@ +MAINCLASS=JGFMolDynBenchSizeA +SRC=${MAINCLASS}.java \ +JGFInstrumentor.java \ +JGFTimer.java \ +JGFMolDynBench.java \ +TournamentBarrier.java +FLAGS=-dsm -prefetch -optimize -debug -profile -mainclass ${MAINCLASS} -o ${MAINCLASS} -trueprob 0.5 +FLAGS2=-dsm -optimize -debug -profile -mainclass ${MAINCLASS} -o ${MAINCLASS}NP + +default: + ../../../../buildscript ${FLAGS2} ${SRC} + ../../../../buildscript ${FLAGS} ${SRC} + +clean: + rm -rf tmpbuildirectory + rm *.bin diff --git a/Robust/src/Benchmarks/Prefetch/Moldyn/java/JGFInstrumentor.java b/Robust/src/Benchmarks/Prefetch/Moldyn/java/JGFInstrumentor.java new file mode 100644 index 00000000..772949fa --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/Moldyn/java/JGFInstrumentor.java @@ -0,0 +1,212 @@ +/************************************************************************** + * * + * Java Grande Forum Benchmark Suite - Thread Version 1.0 * + * * + * produced by * + * * + * Java Grande Benchmarking Project * + * * + * at * + * * + * Edinburgh Parallel Computing Centre * + * * + * email: epcc-javagrande@epcc.ed.ac.uk * + * * + * * + * This version copyright (c) The University of Edinburgh, 1999. * + * All rights reserved. * + * * + **************************************************************************/ + +import java.util.*; + +public class JGFInstrumentor{ + + protected HashMap timers; + protected HashMap data; + + public JGFInstrumentor() { + timers = new HashMap(); + data = new HashMap(); + } + + public static void addTimer (String name, HashMap timers){ + + if (timers.containsKey(name)) { + System.out.println("JGFInstrumentor.addTimer: warning - timer " + name + + " already exists"); + } + else { + timers.put(name, new JGFTimer(name)); + } + } + + public static void addTimer (String name, String opname, HashMap timers){ + + if (timers.containsKey(name)) { + System.out.println("JGFInstrumentor.addTimer: warning - timer " + name + + " already exists"); + } + else { + timers.put(name, new JGFTimer(name,opname)); + } + + } + + public static void addTimer (String name, String opname, int size, HashMap timers){ + + if (timers.containsKey(name)) { + System.out.println("JGFInstrumentor.addTimer: warning - timer " + name + + " already exists"); + } + else { + timers.put(name, new JGFTimer(name,opname,size)); + } + + } + + public static void startTimer(String name, HashMap timers){ + if (timers.containsKey(name)) { + ((JGFTimer) timers.get(name)).start(); + } + else { + System.out.println("JGFInstrumentor.startTimer: failed - timer " + name + + " does not exist"); + } + + } + + public static void stopTimer(String name, HashMap timers){ + if (timers.containsKey(name)) { + ((JGFTimer) timers.get(name)).stop(); + } + else { + System.out.println("JGFInstrumentor.stopTimer: failed - timer " + name + + " does not exist"); + } + } + + public static void addOpsToTimer(String name, double count, HashMap timers){ + if (timers.containsKey(name)) { + ((JGFTimer) timers.get(name)).addops(count); + } + else { + System.out.println("JGFInstrumentor.addOpsToTimer: failed - timer " + name + + " does not exist"); + } + } + + public static void addTimeToTimer(String name, double added_time, HashMap timers){ + if (timers.containsKey(name)) { + ((JGFTimer) timers.get(name)).addtime(added_time); + } + else { + System.out.println("JGFInstrumentor.addTimeToTimer: failed - timer " + name + + " does not exist"); + } + + + + } + + public static double readTimer(String name, HashMap timers){ + double time; + if (timers.containsKey(name)) { + time = ((JGFTimer) timers.get(name)).time; + } + else { + System.out.println("JGFInstrumentor.readTimer: failed - timer " + name + + " does not exist"); + time = 0.0; + } + return time; + } + + public static void resetTimer(String name, HashMap timers){ + if (timers.containsKey(name)) { + ((JGFTimer) timers.get(name)).reset(); + } + else { + System.out.println("JGFInstrumentor.resetTimer: failed - timer " + name + + " does not exist"); + } + } + + public static void printTimer(String name, HashMap timers){ + if (timers.containsKey(name)) { + ((JGFTimer) timers.get(name)).print(); + } + else { + System.out.println("JGFInstrumentor.printTimer: failed - timer " + name + + " does not exist"); + } + } + + public static void printperfTimer(String name, HashMap timers){ + if (timers.containsKey(name)) { + ((JGFTimer) timers.get(name)).printperf(); + } + else { + System.out.println("JGFInstrumentor.printTimer: failed - timer " + name + + " does not exist"); + } + } + + public static void storeData(String name, Object obj, HashMap data){ + data.put(name,obj); + } + + public static void retrieveData(String name, Object obj, HashMap data){ + obj = data.get(name); + } + + public static void printHeader(int section, int size,int nthreads) { + + String header, base; + + header = ""; + base = "Java Grande Forum Thread Benchmark Suite - Version 1.0 - Section "; + + switch (section) { + case 1: + header = base + "1"; + break; + case 2: + switch (size) { + case 0: + header = base + "2 - Size A"; + break; + case 1: + header = base + "2 - Size B"; + break; + case 2: + header = base + "2 - Size C"; + break; + } + break; + case 3: + switch (size) { + case 0: + header = base + "3 - Size A"; + break; + case 1: + header = base + "3 - Size B"; + break; + } + break; + } + + System.out.println(header); + + if (nthreads == 1) { + System.out.println("Executing on " + nthreads + " thread"); + } + else { + System.out.println("Executing on " + nthreads + " threads"); + } + + System.out.println(""); + + } + +} diff --git a/Robust/src/Benchmarks/Prefetch/Moldyn/java/JGFMolDynBench.java b/Robust/src/Benchmarks/Prefetch/Moldyn/java/JGFMolDynBench.java new file mode 100644 index 00000000..fef7a041 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/Moldyn/java/JGFMolDynBench.java @@ -0,0 +1,672 @@ +/************************************************************************** + * * + * Java Grande Forum Benchmark Suite - Thread Version 1.0 * + * * + * produced by * + * * + * Java Grande Benchmarking Project * + * * + * at * + * * + * Edinburgh Parallel Computing Centre * + * * + * email: epcc-javagrande@epcc.ed.ac.uk * + * * + * * + * This version copyright (c) The University of Edinburgh, 2001. * + * All rights reserved. * + * * + **************************************************************************/ + +import java.io.*; + +public class JGFMolDynBench { + public int ITERS; + public double LENGTH; + public double m; + public double mu; + public double kb; + public double TSIM; + public double deltat; + + public int PARTSIZE; + + public double[] epot; + public double[] vir; + public double[] ek; + + int size,mm; + int[] datasizes; + + public int interactions; + public int[] interacts; + + public int nthreads; + public JGFInstrumentor instr; + + public JGFMolDynBench(int nthreads, JGFInstrumentor instr) { + this.nthreads=nthreads; + this.instr = instr; + } + + public void JGFsetsize(int size){ + this.size = size; + } + + public void JGFinitialise(){ + interactions = 0; + datasizes = new int[2]; + datasizes[0] = 8; + datasizes[1] = 13; + + mm = datasizes[size]; + PARTSIZE = mm*mm*mm*4; + ITERS = 100; + LENGTH = 50e-10; + m = 4.0026; + mu = 1.66056e-27; + kb = 1.38066e-23; + TSIM = 50; + deltat = 5e-16; + + //initialise(); + } + + public void JGFapplication() { + // Create new arrays + epot = new double [nthreads]; + vir = new double [nthreads]; + ek = new double [nthreads]; + + interacts = new int [nthreads]; + + double sh_force [][] = new double[3][PARTSIZE]; + double sh_force2 [][][] = new double[3][nthreads][PARTSIZE]; + + // spawn threads + Thread thobjects[] = new Thread [nthreads]; + TournamentBarrier br= new TournamentBarrier(nthreads); + //Barrier br = new Barrier(nthreads); + + for(int i=1;i 1.0e-10 ){ + System.out.println("Validation failed"); + System.out.println("Kinetic Energy = " + ek[0] + " " + dev + " " + size); + } + } +} + +class mdRunner extends Thread { + + double count; + int id,i,j,k,lg,mdsize,move,mm; + double l,rcoff,rcoffs,side,sideh,hsq,hsq2,vel,velt; + double a,r,sum,tscale,sc,ekin,ts,sp; + double den; + double tref; + double h; + double vaver,vaverh,rand; + double etot,temp,pres,rp; + double u1,u2,v1,v2,s, xx, yy, zz; + double xvelocity, yvelocity, zvelocity; + + double [][] sh_force; + double [][][] sh_force2; + + int ijk,npartm,iseed,tint; + int irep; + int istop; + int iprint; + int movemx; + + TournamentBarrier br; + //Barrier br; + random randnum; + JGFInstrumentor instr; + JGFMolDynBench mymd; + int nthreads; + + particle[] one; + + public mdRunner(int id, int mm, double [][] sh_force, double [][][] sh_force2,TournamentBarrier br, + //public mdRunner(int id, int mm, double [][] sh_force, double [][][] sh_force2,Barrier br, + JGFInstrumentor instr, int nthreads, JGFMolDynBench mymd) { + this.id=id; + this.mm=mm; + this.sh_force=sh_force; + this.sh_force2=sh_force2; + this.br=br; + this.instr = instr; + this.nthreads = nthreads; + this.mymd = mymd; + count = 0.0; + den = 0.83134; + tref = 0.722; + h = 0.064; + irep = 10; + istop = 19; + iprint = 10; + movemx = 50; + } + + public void run() { + + /* Parameter determination */ + + mdsize = mymd.PARTSIZE; + one = new particle [mdsize]; + l = mymd.LENGTH; + + side = Math.pow((mdsize/den),0.3333333); + rcoff = mm/4.0; + + a = side/mm; + sideh = side*0.5; + hsq = h*h; + hsq2 = hsq*0.5; + npartm = mdsize - 1; + rcoffs = rcoff * rcoff; + tscale = 16.0 / (1.0 * mdsize - 1.0); + vaver = 1.13 * Math.sqrt(tref / 24.0); + vaverh = vaver * h; + + /* Particle Generation */ + + xvelocity = 0.0; + yvelocity = 0.0; + zvelocity = 0.0; + + ijk = 0; + for (lg=0; lg<=1; lg++) { + for (i=0; i vaverh) { count = count + 1.0; } + vel = vel + velt; + } + + vel = vel / h; + + /* temperature scale if required */ + + if((move < istop) && (((move+1) % irep) == 0)) { + sc = Math.sqrt(tref / (tscale*ekin)); + for (i=0;i side) { xcoord = xcoord - side; } + if(ycoord < 0) { ycoord = ycoord + side; } + if(ycoord > side) { ycoord = ycoord - side; } + if(zcoord < 0) { zcoord = zcoord + side; } + if(zcoord > side) { zcoord = zcoord - side; } + + xvelocity = xvelocity + sh_force[0][part_id]; + yvelocity = yvelocity + sh_force[1][part_id]; + zvelocity = zvelocity + sh_force[2][part_id]; + + } + + public void force(double side, double rcoff,int mdsize,int x, double xx, double yy, double zz, JGFMolDynBench mymd) { + + double sideh; + double rcoffs; + + double fxi,fyi,fzi; + double rd,rrd,rrd2,rrd3,rrd4,rrd6,rrd7,r148; + double forcex,forcey,forcez; + + sideh = 0.5*side; + rcoffs = rcoff*rcoff; + + fxi = 0.0; + fyi = 0.0; + fzi = 0.0; + + for (int i=x+1;i (sideh)) { xx = xx - side; } + if(yy < (-sideh)) { yy = yy + side; } + if(yy > (sideh)) { yy = yy - side; } + if(zz < (-sideh)) { zz = zz + side; } + if(zz > (sideh)) { zz = zz - side; } + + + rd = xx*xx + yy*yy + zz*zz; + + if(rd <= rcoffs) { + rrd = 1.0/rd; + rrd2 = rrd*rrd; + rrd3 = rrd2*rrd; + rrd4 = rrd2*rrd2; + rrd6 = rrd2*rrd4; + rrd7 = rrd6*rrd; + mymd.epot[id] = mymd.epot[id] + (rrd6 - rrd3); + r148 = rrd7 - 0.5*rrd4; + mymd.vir[id] = mymd.vir[id] - rd*r148; + forcex = xx * r148; + fxi = fxi + forcex; + + sh_force2[0][id][i] = sh_force2[0][id][i] - forcex; + + forcey = yy * r148; + fyi = fyi + forcey; + + sh_force2[1][id][i] = sh_force2[1][id][i] - forcey; + + forcez = zz * r148; + fzi = fzi + forcez; + + sh_force2[2][id][i] = sh_force2[2][id][i] - forcez; + + mymd.interacts[id]++; + } + + } + + sh_force2[0][id][x] = sh_force2[0][id][x] + fxi; + sh_force2[1][id][x] = sh_force2[1][id][x] + fyi; + sh_force2[2][id][x] = sh_force2[2][id][x] + fzi; + + } + + public double mkekin(double hsq2,int part_id) { + + double sumt = 0.0; + + xvelocity = xvelocity + sh_force[0][part_id]; + yvelocity = yvelocity + sh_force[1][part_id]; + zvelocity = zvelocity + sh_force[2][part_id]; + + sumt = (xvelocity*xvelocity)+(yvelocity*yvelocity)+(zvelocity*zvelocity); + return sumt; + } + + public double velavg(double vaverh,double h) { + + double velt; + double sq; + + sq = Math.sqrt(xvelocity*xvelocity + yvelocity*yvelocity + + zvelocity*zvelocity); + + velt = sq; + return velt; + } + + public void dscal(double sc,int incx) { + + xvelocity = xvelocity * sc; + yvelocity = yvelocity * sc; + zvelocity = zvelocity * sc; + + + + } + +} + +class random { + + public int iseed; + public double v1,v2; + + public random(int iseed,double v1,double v2) { + this.iseed = iseed; + this.v1 = v1; + this.v2 = v2; + } + + public double update() { + + double rand; + double scale= 4.656612875e-10; + + int is1,is2,iss2; + int imult=16807; + int imod = 2147483647; + + if (iseed<=0) { iseed = 1; } + + is2 = iseed % 32768; + is1 = (iseed-is2)/32768; + iss2 = is2 * imult; + is2 = iss2 % 32768; + is1 = (is1*imult+(iss2-is2)/32768) % (65536); + + iseed = (is1*32768+is2) % imod; + + rand = scale * iseed; + + return rand; + + } + + public double seed() { + + double s,u1,u2,r; + s = 1.0; + do { + u1 = update(); + u2 = update(); + + v1 = 2.0 * u1 - 1.0; + v2 = 2.0 * u2 - 1.0; + s = v1*v1 + v2*v2; + + } while (s >= 1.0); + + r = Math.sqrt(-2.0*Math.log(s)/s); + + return r; + + } +} + + diff --git a/Robust/src/Benchmarks/Prefetch/Moldyn/java/JGFMolDynBenchSizeA.java b/Robust/src/Benchmarks/Prefetch/Moldyn/java/JGFMolDynBenchSizeA.java new file mode 100644 index 00000000..630ed78b --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/Moldyn/java/JGFMolDynBenchSizeA.java @@ -0,0 +1,60 @@ +/************************************************************************** + * * + * Java Grande Forum Benchmark Suite - Thread Version 1.0 * + * * + * produced by * + * * + * Java Grande Benchmarking Project * + * * + * at * + * * + * Edinburgh Parallel Computing Centre * + * * + * email: epcc-javagrande@epcc.ed.ac.uk * + * * + * * + * This version copyright (c) The University of Edinburgh, 2001. * + * All rights reserved. * + * * + **************************************************************************/ +import java.io.*; +import java.util.*; + +public class JGFMolDynBenchSizeA { + + public static void main(String argv[]){ + int nthreads; + if(argv.length != 0 ) { + nthreads = Integer.parseInt(argv[0]); + } else { + System.out.println("The no of threads has not been specified, defaulting to 1"); + System.out.println(" "); + nthreads = 1; + } + + JGFInstrumentor instr = new JGFInstrumentor(); + JGFInstrumentor.printHeader(3,0,nthreads); + + JGFMolDynBench mold = new JGFMolDynBench(nthreads, instr); + int size = 0; + JGFInstrumentor.addTimer("Section3:MolDyn:Total", "Solutions",size, instr.timers); + JGFInstrumentor.addTimer("Section3:MolDyn:Run", "Interactions",size, instr.timers); + + mold.JGFsetsize(size); + + JGFInstrumentor.startTimer("Section3:MolDyn:Total", instr.timers); + + mold.JGFinitialise(); + mold.JGFapplication(); + mold.JGFvalidate(); + + JGFInstrumentor.stopTimer("Section3:MolDyn:Total", instr.timers); + + JGFInstrumentor.addOpsToTimer("Section3:MolDyn:Run", (double) (mold.interactions), instr.timers); + JGFInstrumentor.addOpsToTimer("Section3:MolDyn:Total", 1, instr.timers); + + JGFInstrumentor.printTimer("Section3:MolDyn:Run", instr.timers); + JGFInstrumentor.printTimer("Section3:MolDyn:Total", instr.timers); + } +} + diff --git a/Robust/src/Benchmarks/Prefetch/Moldyn/java/JGFTimer.java b/Robust/src/Benchmarks/Prefetch/Moldyn/java/JGFTimer.java new file mode 100644 index 00000000..8644d2c8 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/Moldyn/java/JGFTimer.java @@ -0,0 +1,132 @@ +/************************************************************************** + * * + * Java Grande Forum Benchmark Suite - Thread Version 1.0 * + * * + * produced by * + * * + * Java Grande Benchmarking Project * + * * + * at * + * * + * Edinburgh Parallel Computing Centre * + * * + * email: epcc-javagrande@epcc.ed.ac.uk * + * * + * * + * This version copyright (c) The University of Edinburgh, 1999. * + * All rights reserved. * + * * + **************************************************************************/ + +public class JGFTimer { + + public String name; + public String opname; + public double time; + public double opcount; + public long calls; + public int size; + + private long start_time; + private boolean on; + + public JGFTimer(String name, String opname){ + this.size = -1; + this.name = name; + this.opname = opname; + reset(); + } + + public JGFTimer(String name, String opname, int size){ + this.name = name; + this.opname = opname; + this.size = size; + reset(); + } + + public JGFTimer(String name){ + this(name,""); + } + + + + public void start(){ + if (on) System.out.println("Warning timer " + name + " was already turned on"); + on = true; + start_time = System.currentTimeMillis(); + } + + + public void stop(){ + time += (double) (System.currentTimeMillis()-start_time) / 1000.; + if (!on) System.out.println("Warning timer " + name + " wasn't turned on"); + calls++; + on = false; + } + + public void addops(double count){ + opcount += count; + } + + public void addtime(double added_time){ + time += added_time; + } + + public void reset(){ + time = 0.0; + calls = 0; + opcount = 0; + on = false; + } + + public double perf(){ + return opcount / time; + } + + public void longprint(){ + System.out.println("Timer Calls Time(s) Performance("+opname+"/s)"); + System.out.println(name + " " + calls + " " + time + " " + this.perf()); + } + + public void print(){ + if (opname.equals("")) { + System.out.println(name + " " + time + " (s)"); + } + else { + + switch(size) { + case 0: + System.out.println(name + ":SizeA" + "\t" + time + " (s) \t " + (float)this.perf() + "\t" + + " ("+opname+"/s)"); + break; + case 1: + System.out.println(name + ":SizeB" + "\t" + time + " (s) \t " + (float)this.perf() + "\t" + + " ("+opname+"/s)"); + break; + case 2: + System.out.println(name + ":SizeC" + "\t" + time + " (s) \t " + (float)this.perf() + "\t" + + " ("+opname+"/s)"); + break; + default: + System.out.println(name + "\t" + time + " (s) \t " + (float)this.perf() + "\t" + + " ("+opname+"/s)"); + break; + } + + } + } + + + public void printperf(){ + + String name; + name = this.name; + + // pad name to 40 characters + while ( name.length() < 40 ) name = name + " "; + + System.out.println(name + "\t" + (float)this.perf() + "\t" + + " ("+opname+"/s)"); + } + +} diff --git a/Robust/src/Benchmarks/Prefetch/Moldyn/java/TournamentBarrier.java b/Robust/src/Benchmarks/Prefetch/Moldyn/java/TournamentBarrier.java new file mode 100755 index 00000000..96bf4f51 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/Moldyn/java/TournamentBarrier.java @@ -0,0 +1,96 @@ +/************************************************************************** + * * + * Java Grande Forum Benchmark Suite - Thread Version 1.0 * + * * + * produced by * + * * + * Java Grande Benchmarking Project * + * * + * at * + * * + * Edinburgh Parallel Computing Centre * + * * + * email: epcc-javagrande@epcc.ed.ac.uk * + * * + * * + * This version copyright (c) The University of Edinburgh, 2001. * + * All rights reserved. * + * * + **************************************************************************/ + +// This implements a simple tournament-based barrier, using entirely its +// own synchronisation. At present Yield() is called to stop busy-waiting +// processes hogging the processor(s)! + +public class TournamentBarrier { + // Array of flags indicating whether the given process and all those + // for which it is responsible have finished. The "sense" of this + // array alternates with each barrier, to prevent having to + // reinitialise. + boolean[] IsDone; + public int maxBusyIter; + int numThreads; + + public TournamentBarrier(int n) { + numThreads = n; + maxBusyIter = 1; + // Superclass constructor should record the number of threads + // and thread manager. + //super(n); + + // Initialise the IsDone array. The choice of initial value is + // arbitrary, but must be consistent! + IsDone = new boolean[numThreads]; + for(int i = 0; i < n; i++) { + IsDone[i] = false; + } + } + + // Uses the manager's debug function, so this can only be used after + // construction! + public void debug(String s) { + //System.err.println("Debug message" + s); + } + + /* + public void setMaxBusyIter(int b) { + maxBusyIter = b; + } + */ + + public void DoBarrier(int myid) { + int b; + //debug("Thread " + myid + " checking in"); + + int roundmask = 3; + boolean donevalue = !IsDone[myid]; + + while(((myid & roundmask) == 0) && (roundmask<(numThreads<<2))) { + int spacing = (roundmask+1) >> 2; + for(int i=1; i<=3 && myid+i*spacing < numThreads; i++) { + //debug("Thread " + myid + " waiting for thread " + (myid+i*spacing)); + b = maxBusyIter; + while(IsDone[myid+i*spacing] != donevalue) { + b--; + if(b==0) { + //Thread.yield(); + b = maxBusyIter; + } + } + } + roundmask = (roundmask << 2) + 3; + } + //debug("Thread " + myid + " reporting done"); + IsDone[myid] = donevalue; + b = maxBusyIter; + while(IsDone[0] != donevalue) { + b--; + if(b==0) { + //Thread.yield(); + b = maxBusyIter; + } + } + //debug("Thread " + myid + " checking out"); + + } +} diff --git a/Robust/src/Benchmarks/Prefetch/Moldyn/java/makefile b/Robust/src/Benchmarks/Prefetch/Moldyn/java/makefile new file mode 100644 index 00000000..1b029f9a --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/Moldyn/java/makefile @@ -0,0 +1,8 @@ +SRC = JGFMolDynBenchSizeA +default: + javac ${SRC}.java +run: + java ${SRC} 2 + +clean: + rm *.class