From ca9b92ec3e92dd32bec21878808e4898194df996 Mon Sep 17 00:00:00 2001 From: adash Date: Sat, 26 Apr 2008 20:08:44 +0000 Subject: [PATCH] New benchmark --- .../Prefetch/LUFact/dsm/JGFInstrumentor.java | 199 ++++++++ .../Prefetch/LUFact/dsm/JGFLUFactBench.java | 453 ++++++++++++++++++ .../LUFact/dsm/JGFLUFactBenchSizeA.java | 68 +++ .../Prefetch/LUFact/dsm/JGFTimer.java | 123 +++++ .../Prefetch/LUFact/dsm/Linpack.java | 327 +++++++++++++ .../Prefetch/LUFact/dsm/LinpackRunner.java | 205 ++++++++ .../LUFact/dsm/TournamentBarrier.java | 94 ++++ .../Benchmarks/Prefetch/LUFact/dsm/makefile | 18 + .../Prefetch/LUFact/java/JGFInstrumentor.java | 200 ++++++++ .../Prefetch/LUFact/java/JGFLUFactBench.java | 442 +++++++++++++++++ .../LUFact/java/JGFLUFactBenchSizeA.java | 50 ++ .../Prefetch/LUFact/java/JGFTimer.java | 124 +++++ .../Prefetch/LUFact/java/Linpack.java | 327 +++++++++++++ .../Prefetch/LUFact/java/LinpackRunner.java | 205 ++++++++ .../LUFact/java/TournamentBarrier.java | 96 ++++ .../Benchmarks/Prefetch/LUFact/java/makefile | 8 + 16 files changed, 2939 insertions(+) create mode 100644 Robust/src/Benchmarks/Prefetch/LUFact/dsm/JGFInstrumentor.java create mode 100644 Robust/src/Benchmarks/Prefetch/LUFact/dsm/JGFLUFactBench.java create mode 100644 Robust/src/Benchmarks/Prefetch/LUFact/dsm/JGFLUFactBenchSizeA.java create mode 100644 Robust/src/Benchmarks/Prefetch/LUFact/dsm/JGFTimer.java create mode 100644 Robust/src/Benchmarks/Prefetch/LUFact/dsm/Linpack.java create mode 100644 Robust/src/Benchmarks/Prefetch/LUFact/dsm/LinpackRunner.java create mode 100755 Robust/src/Benchmarks/Prefetch/LUFact/dsm/TournamentBarrier.java create mode 100644 Robust/src/Benchmarks/Prefetch/LUFact/dsm/makefile create mode 100644 Robust/src/Benchmarks/Prefetch/LUFact/java/JGFInstrumentor.java create mode 100644 Robust/src/Benchmarks/Prefetch/LUFact/java/JGFLUFactBench.java create mode 100644 Robust/src/Benchmarks/Prefetch/LUFact/java/JGFLUFactBenchSizeA.java create mode 100644 Robust/src/Benchmarks/Prefetch/LUFact/java/JGFTimer.java create mode 100644 Robust/src/Benchmarks/Prefetch/LUFact/java/Linpack.java create mode 100644 Robust/src/Benchmarks/Prefetch/LUFact/java/LinpackRunner.java create mode 100755 Robust/src/Benchmarks/Prefetch/LUFact/java/TournamentBarrier.java create mode 100644 Robust/src/Benchmarks/Prefetch/LUFact/java/makefile diff --git a/Robust/src/Benchmarks/Prefetch/LUFact/dsm/JGFInstrumentor.java b/Robust/src/Benchmarks/Prefetch/LUFact/dsm/JGFInstrumentor.java new file mode 100644 index 00000000..fc737bec --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/LUFact/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/LUFact/dsm/JGFLUFactBench.java b/Robust/src/Benchmarks/Prefetch/LUFact/dsm/JGFLUFactBench.java new file mode 100644 index 00000000..3dea7eb6 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/LUFact/dsm/JGFLUFactBench.java @@ -0,0 +1,453 @@ +/************************************************************************** + * * + * 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 JGFLUFactBench { + public int nthreads; + private int size; + private int[] datasizes; + public int cachelinesize; + double a[][]; + double b[]; + double x[]; + double ops,total,norma,normx; + double resid,time; + double kf; + int n,i,ntimes,info,lda,ldaa,kflops; + int ipvt[]; + + public JGFLUFactBench(int nthreads) { + this.nthreads=nthreads; + datasizes = global new int[3]; + datasizes[0] = 500; + datasizes[1] = 1000; + datasizes[2] = 2000; + cachelinesize = 128; + } + + public void JGFsetsize(int size) { + this.size = size; + } + + public void JGFinitialise() { + n = datasizes[size]; + ldaa = n; + lda = ldaa + 1; + + a = global new double[ldaa][lda]; + b = global new double [ldaa]; + x = global new double [ldaa]; + ipvt = global new int [ldaa]; + + long nl = (long) n; //avoid integer overflow + ops = (2.0*(nl*nl*nl))/3.0 + 2.0*(nl*nl); + norma = matgen(a,lda,n,b); + } + + public static void JGFkernel(JGFLUFactBench lub) { + int numthreads; + atomic { + numthreads = lub.nthreads; + } + + /* spawn threads */ + LinpackRunner[] thobjects; + TournamentBarrier br; + atomic { + thobjects = global new LinpackRunner[numthreads]; + br = global new TournamentBarrier(numthreads); + } + + //JGFInstrumentor.startTimer("Section2:LUFact:Kernel", instr.timers); + + LinpackRunner tmp; + int mid = (128<<24)|(195<<16)|(175<<8)|73; + for(int i=1;i abs(b[i])) ? resid : abs(b[i]); + //normx = (normx > abs(x[i])) ? normx : abs(x[i]); + if (resid <= abs(b[i])) resid = abs(b[i]); + if (normx <= abs(x[i])) normx = abs(x[i]); + } + eps = epslon((double)1.0); + residn = resid/( n*norma*normx*eps ); + + /*******************Compare longs ***********/ + long lresidn, lref; + lresidn = (long) residn * 1000000; + lref = (long) ref[size] * 1000000; + + if (lresidn > lref) { + //System.printString("Validation failed"); + System.printString("Computed Norm Res = " + (long) residn * 1000000); + System.printString("Reference Norm Res = " + (long) ref[size] * 1000000); + return 1; + } else { + return 0; + } + } + + double abs (double d) { + if (d >= 0) return d; + else return -d; + } + + double matgen (double a[][], int lda, int n, double b[]) + { + double norma; + int init, i, j; + + init = 1325; + norma = 0.0; + /* Next two for() statements switched. Solver wants + matrix in column order. --dmd 3/3/97 + */ + for (i = 0; i < n; i++) { + for (j = 0; j < n; j++) { + init = 3125*init % 65536; + a[j][i] = (init - 32768.0)/16384.0; + if (a[j][i] > norma) { + norma = a[j][i]; + } + } + } + for (i = 0; i < n; i++) { + b[i] = 0.0; + } + for (j = 0; j < n; j++) { + for (i = 0; i < n; i++) { + b[i] += a[j][i]; + } + } + return norma; + } + + void dgesl( double a[][], int lda, int n, int ipvt[], double b[], int job) + { + double t; + int k,kb,l,nm1,kp1; + + nm1 = n - 1; + if (job == 0) { + // job = 0 , solve a * x = b. first solve l*y = b + if (nm1 >= 1) { + for (k = 0; k < nm1; k++) { + l = ipvt[k]; + t = b[l]; + if (l != k){ + b[l] = b[k]; + b[k] = t; + } + kp1 = k + 1; + daxpy(n-(kp1),t,a[k],kp1,1,b,kp1,1); + } + } + // now solve u*x = y + for (kb = 0; kb < n; kb++) { + k = n - (kb + 1); + b[k] /= a[k][k]; + t = -b[k]; + daxpy(k,t,a[k],0,1,b,0,1); + } + } else { + // job = nonzero, solve trans(a) * x = b. first solve trans(u)*y = b + for (k = 0; k < n; k++) { + t = ddot(k,a[k],0,1,b,0,1); + b[k] = (b[k] - t)/a[k][k]; + } + // now solve trans(l)*x = y + if (nm1 >= 1) { + for (kb = 1; kb < nm1; kb++) { + k = n - (kb+1); + kp1 = k + 1; + b[k] += ddot(n-(kp1),a[k],kp1,1,b,kp1,1); + l = ipvt[k]; + if (l != k) { + t = b[l]; + b[l] = b[k]; + b[k] = t; + } + } + } + } + } + + /* + constant times a vector plus a vector. + jack dongarra, linpack, 3/11/78. + */ + void daxpy( int n, double da, double dx[], int dx_off, int incx, + double dy[], int dy_off, int incy) + { + int i,ix,iy; + + if ((n > 0) && (da != 0)) { + if (incx != 1 || incy != 1) { + // code for unequal increments or equal increments not equal to 1 + ix = 0; + iy = 0; + if (incx < 0) ix = (-n+1)*incx; + if (incy < 0) iy = (-n+1)*incy; + for (i = 0;i < n; i++) { + dy[iy +dy_off] += da*dx[ix +dx_off]; + ix += incx; + iy += incy; + } + return; + } else { + // code for both increments equal to 1 + for (i=0; i < n; i++) + dy[i +dy_off] += da*dx[i +dx_off]; + } + } + } + + /* + forms the dot product of two vectors. + jack dongarra, linpack, 3/11/78. + */ + double ddot( int n, double dx[], int dx_off, int incx, double dy[], + int dy_off, int incy) + { + double dtemp; + int i,ix,iy; + dtemp = 0; + if (n > 0) { + if (incx != 1 || incy != 1) { + // code for unequal increments or equal increments not equal to 1 + ix = 0; + iy = 0; + if (incx < 0) ix = (-n+1)*incx; + if (incy < 0) iy = (-n+1)*incy; + for (i = 0;i < n; i++) { + dtemp += dx[ix +dx_off]*dy[iy +dy_off]; + ix += incx; + iy += incy; + } + } else { + // code for both increments equal to 1 + for (i=0;i < n; i++) + dtemp += dx[i +dx_off]*dy[i +dy_off]; + } + } + return(dtemp); + } + + /* + scales a vector by a constant. + jack dongarra, linpack, 3/11/78. + */ + void dscal( int n, double da, double dx[], int dx_off, int incx) + { + int i,nincx; + if (n > 0) { + if (incx != 1) { + // code for increment not equal to 1 + nincx = n*incx; + for (i = 0; i < nincx; i += incx) + dx[i +dx_off] *= da; + } else { + // code for increment equal to 1 + for (i = 0; i < n; i++) + dx[i +dx_off] *= da; + } + } + } + + /* + finds the index of element having max. absolute value. + jack dongarra, linpack, 3/11/78. + */ + int idamax( int n, double dx[], int dx_off, int incx) + { + double dmax, dtemp; + int i, ix, itemp=0; + + if (n < 1) { + itemp = -1; + } else if (n ==1) { + itemp = 0; + } else if (incx != 1) { + // code for increment not equal to 1 + dmax = abs(dx[0 +dx_off]); + ix = 1 + incx; + for (i = 1; i < n; i++) { + dtemp = abs(dx[ix + dx_off]); + if (dtemp > dmax) { + itemp = i; + dmax = dtemp; + } + ix += incx; + } + } else { + // code for increment equal to 1 + itemp = 0; + dmax = abs(dx[0 +dx_off]); + for (i = 1; i < n; i++) { + dtemp = abs(dx[i + dx_off]); + if (dtemp > dmax) { + itemp = i; + dmax = dtemp; + } + } + } + return (itemp); + } + + /* + estimate unit roundoff in quantities of size x. + this program should function properly on all systems + satisfying the following two assumptions, + 1. the base used in representing dfloating point + numbers is not a power of three. + 2. the quantity a in statement 10 is represented to + the accuracy used in dfloating point variables + that are stored in memory. + the statement number 10 and the go to 10 are intended to + force optimizing compilers to generate code satisfying + assumption 2. + under these assumptions, it should be true that, + a is not exactly equal to four-thirds, + b has a zero for its last bit or digit, + c is not exactly equal to one, + eps measures the separation of 1.0 from + the next larger dfloating point number. + the developers of eispack would appreciate being informed + about any systems where these assumptions do not hold. + + ***************************************************************** + this routine is one of the auxiliary routines used by eispack iii + to avoid machine dependencies. + ***************************************************************** + + this version dated 4/6/83. + */ + double epslon (double x) + { + double a,b,c,eps; + + a = 4.0e0/3.0e0; + eps = 0; + while (eps == 0) { + b = a - 1.0; + c = b + b + b; + eps = abs(c-1.0); + } + return(eps*abs(x)); + } + + void dmxpy ( int n1, double y[], int n2, int ldm, double x[], double m[][]) + { + int j,i; + // cleanup odd vector + for (j = 0; j < n2; j++) { + for (i = 0; i < n1; i++) { + y[i] += x[j]*m[j][i]; + } + } + } + /* + public static void JGFvalidate(JGFLUFactBench lub) { + int i; + double eps,residn; + double[] ref; + + ref = new double[3]; + ref[0] = 6.0; + ref[1] = 12.0; + ref[2] = 20.0; + + atomic { + for (i = 0; i < lub.n; i++) { + lub.x[i] = lub.b[i]; + } + lub.norma = lub.matgen(lub.a,lub.lda,lub.n,lub.b); + for (i = 0; i < lub.n; i++) { + lub.b[i] = -(lub.b[i]); + } + + lub.dmxpy(lub.n,lub.b,lub.n,lub.lda,lub.x,lub.a); + lub.resid = 0.0; + lub.normx = 0.0; + for (i = 0; i < lub.n; i++) { +//resid = (resid > abs(b[i])) ? resid : abs(b[i]); +//normx = (normx > abs(x[i])) ? normx : abs(x[i]); +if (lub.resid <= abs(lub.b[i])) lub.resid = lub.abs(lub.b[i]); +if (lub.normx <= abs(lub.x[i])) lub.normx = lub.abs(lub.x[i]); +} +eps = lub.epslon((double)1.0); +residn = lub.resid/( lub.n*lub.norma*lub.normx*eps ); +} + +if (residn > ref[size]) { +System.printString("Validation failed"); +System.printString("Computed Norm Res = " + (long) residn); +System.printString("Reference Norm Res = " + (long) ref[size]); +} +} +*/ + +} diff --git a/Robust/src/Benchmarks/Prefetch/LUFact/dsm/JGFLUFactBenchSizeA.java b/Robust/src/Benchmarks/Prefetch/LUFact/dsm/JGFLUFactBenchSizeA.java new file mode 100644 index 00000000..e71f57fe --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/LUFact/dsm/JGFLUFactBenchSizeA.java @@ -0,0 +1,68 @@ +/************************************************************************** + * * + * 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 JGFLUFactBenchSizeA { + + 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(2,0,nthreads); + JGFLUFactBench lub; + atomic { + //lub = global new JGFLUFactBench(nthreads, instr); + lub = global new JGFLUFactBench(nthreads); + } + + int size = 0; + //lub.JGFrun(0); + JGFInstrumentor.addTimer("Section2:LUFact:Kernel", "Mflops", size, instr.timers); + atomic { + lub.JGFsetsize(size); + lub.JGFinitialise(); + } + JGFLUFactBench.JGFkernel(lub); + int retval; + atomic { + retval = lub.JGFvalidate(); + } + if(retval == 1) { + System.printString("Validation failed"); + } + //JGFLUFactBench.JGFvalidate(lub); + + // atomic { + // lub.JGFvalidate(); + //} + double ops; + atomic { + ops = lub.ops; + } + JGFInstrumentor.addOpsToTimer("Section2:LUFact:Kernel", ((long)ops)/1.0e06, instr.timers); + JGFInstrumentor.printTimer("Section2:LUFact:Kernel", instr.timers); + } +} + diff --git a/Robust/src/Benchmarks/Prefetch/LUFact/dsm/JGFTimer.java b/Robust/src/Benchmarks/Prefetch/LUFact/dsm/JGFTimer.java new file mode 100644 index 00000000..d65f4010 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/LUFact/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 " + " 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 " + " 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/LUFact/dsm/Linpack.java b/Robust/src/Benchmarks/Prefetch/LUFact/dsm/Linpack.java new file mode 100644 index 00000000..1c21cb08 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/LUFact/dsm/Linpack.java @@ -0,0 +1,327 @@ +/************************************************************************** + * * + * 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 * + * * + * See below for the previous history of this code * + * * + * This version copyright (c) The University of Edinburgh, 2001. * + * All rights reserved. * + * * + **************************************************************************/ + +/* + + Modified 3/3/97 by David M. Doolin (dmd) doolin@cs.utk.edu + Fixed error in matgen() method. Added some comments. + + Modified 1/22/97 by Paul McMahan mcmahan@cs.utk.edu + Added more MacOS options to form. + + Optimized by Jonathan Hardwick (jch@cs.cmu.edu), 3/28/96 + Compare to Linkpack.java. + Optimizations performed: + - added "final" modifier to performance-critical methods. + - changed lines of the form "a[i] = a[i] + x" to "a[i] += x". + - minimized array references using common subexpression elimination. + - eliminated unused variables. + - undid an unrolled loop. + - added temporary 1D arrays to hold frequently-used columns of 2D arrays. + - wrote my own abs() method + See http://www.cs.cmu.edu/~jch/java/linpack.html for more details. + + + Ported to Java by Reed Wade (wade@cs.utk.edu) 2/96 + built using JDK 1.0 on solaris + using "javac -O Linpack.java" + + + Translated to C by Bonnie Toy 5/88 + (modified on 2/25/94 to fix a problem with daxpy for + unequal increments or equal increments not equal to 1. + Jack Dongarra) + +*/ + +public class Linpack { + double a[][]; + double b[]; + double x[]; + double ops,total,norma,normx; + double resid,time; + double kf; + int n,i,ntimes,info,lda,ldaa,kflops; + int ipvt[]; + + double abs (double d) { + if (d >= 0) return d; + else return -d; + //return (d >= 0) ? d : -d; + } + + double matgen (double a[][], int lda, int n, double b[]) + { + double norma; + int init, i, j; + + init = 1325; + norma = 0.0; + /* Next two for() statements switched. Solver wants + matrix in column order. --dmd 3/3/97 + */ + for (i = 0; i < n; i++) { + for (j = 0; j < n; j++) { + init = 3125*init % 65536; + a[j][i] = (init - 32768.0)/16384.0; + //norma = (a[j][i] > norma) ? a[j][i] : norma; + if (a[j][i] > norma) { + norma = a[j][i]; + } + } + } + for (i = 0; i < n; i++) { + b[i] = 0.0; + } + for (j = 0; j < n; j++) { + for (i = 0; i < n; i++) { + b[i] += a[j][i]; + } + } + return norma; + } + + void dgesl( double a[][], int lda, int n, int ipvt[], double b[], int job) + { + double t; + int k,kb,l,nm1,kp1; + + nm1 = n - 1; + if (job == 0) { + // job = 0 , solve a * x = b. first solve l*y = b + if (nm1 >= 1) { + for (k = 0; k < nm1; k++) { + l = ipvt[k]; + t = b[l]; + if (l != k){ + b[l] = b[k]; + b[k] = t; + } + kp1 = k + 1; + daxpy(n-(kp1),t,a[k],kp1,1,b,kp1,1); + } + } + // now solve u*x = y + for (kb = 0; kb < n; kb++) { + k = n - (kb + 1); + b[k] /= a[k][k]; + t = -b[k]; + daxpy(k,t,a[k],0,1,b,0,1); + } + } else { + // job = nonzero, solve trans(a) * x = b. first solve trans(u)*y = b + for (k = 0; k < n; k++) { + t = ddot(k,a[k],0,1,b,0,1); + b[k] = (b[k] - t)/a[k][k]; + } + // now solve trans(l)*x = y + if (nm1 >= 1) { + for (kb = 1; kb < nm1; kb++) { + k = n - (kb+1); + kp1 = k + 1; + b[k] += ddot(n-(kp1),a[k],kp1,1,b,kp1,1); + l = ipvt[k]; + if (l != k) { + t = b[l]; + b[l] = b[k]; + b[k] = t; + } + } + } + } + } + + /* + constant times a vector plus a vector. + jack dongarra, linpack, 3/11/78. + */ + void daxpy( int n, double da, double dx[], int dx_off, int incx, + double dy[], int dy_off, int incy) + { + int i,ix,iy; + + if ((n > 0) && (da != 0)) { + if (incx != 1 || incy != 1) { + // code for unequal increments or equal increments not equal to 1 + ix = 0; + iy = 0; + if (incx < 0) ix = (-n+1)*incx; + if (incy < 0) iy = (-n+1)*incy; + for (i = 0;i < n; i++) { + dy[iy +dy_off] += da*dx[ix +dx_off]; + ix += incx; + iy += incy; + } + return; + } else { + // code for both increments equal to 1 + for (i=0; i < n; i++) + dy[i +dy_off] += da*dx[i +dx_off]; + } + } + } + + /* + forms the dot product of two vectors. + jack dongarra, linpack, 3/11/78. + */ + double ddot( int n, double dx[], int dx_off, int incx, double dy[], + int dy_off, int incy) + { + double dtemp; + int i,ix,iy; + dtemp = 0; + if (n > 0) { + if (incx != 1 || incy != 1) { + // code for unequal increments or equal increments not equal to 1 + ix = 0; + iy = 0; + if (incx < 0) ix = (-n+1)*incx; + if (incy < 0) iy = (-n+1)*incy; + for (i = 0;i < n; i++) { + dtemp += dx[ix +dx_off]*dy[iy +dy_off]; + ix += incx; + iy += incy; + } + } else { + // code for both increments equal to 1 + for (i=0;i < n; i++) + dtemp += dx[i +dx_off]*dy[i +dy_off]; + } + } + return(dtemp); + } + + /* + scales a vector by a constant. + jack dongarra, linpack, 3/11/78. + */ + void dscal( int n, double da, double dx[], int dx_off, int incx) + { + int i,nincx; + if (n > 0) { + if (incx != 1) { + // code for increment not equal to 1 + nincx = n*incx; + for (i = 0; i < nincx; i += incx) + dx[i +dx_off] *= da; + } else { + // code for increment equal to 1 + for (i = 0; i < n; i++) + dx[i +dx_off] *= da; + } + } + } + + /* + finds the index of element having max. absolute value. + jack dongarra, linpack, 3/11/78. + */ + int idamax( int n, double dx[], int dx_off, int incx) + { + double dmax, dtemp; + int i, ix, itemp=0; + + if (n < 1) { + itemp = -1; + } else if (n ==1) { + itemp = 0; + } else if (incx != 1) { + // code for increment not equal to 1 + dmax = abs(dx[0 +dx_off]); + ix = 1 + incx; + for (i = 1; i < n; i++) { + dtemp = abs(dx[ix + dx_off]); + if (dtemp > dmax) { + itemp = i; + dmax = dtemp; + } + ix += incx; + } + } else { + // code for increment equal to 1 + itemp = 0; + dmax = abs(dx[0 +dx_off]); + for (i = 1; i < n; i++) { + dtemp = abs(dx[i + dx_off]); + if (dtemp > dmax) { + itemp = i; + dmax = dtemp; + } + } + } + return (itemp); + } + + /* + estimate unit roundoff in quantities of size x. + this program should function properly on all systems + satisfying the following two assumptions, + 1. the base used in representing dfloating point + numbers is not a power of three. + 2. the quantity a in statement 10 is represented to + the accuracy used in dfloating point variables + that are stored in memory. + the statement number 10 and the go to 10 are intended to + force optimizing compilers to generate code satisfying + assumption 2. + under these assumptions, it should be true that, + a is not exactly equal to four-thirds, + b has a zero for its last bit or digit, + c is not exactly equal to one, + eps measures the separation of 1.0 from + the next larger dfloating point number. + the developers of eispack would appreciate being informed + about any systems where these assumptions do not hold. + + ***************************************************************** + this routine is one of the auxiliary routines used by eispack iii + to avoid machine dependencies. + ***************************************************************** + + this version dated 4/6/83. + */ + double epslon (double x) + { + double a,b,c,eps; + + a = 4.0e0/3.0e0; + eps = 0; + while (eps == 0) { + b = a - 1.0; + c = b + b + b; + eps = abs(c-1.0); + } + return(eps*abs(x)); + } + + void dmxpy ( int n1, double y[], int n2, int ldm, double x[], double m[][]) + { + int j,i; + // cleanup odd vector + for (j = 0; j < n2; j++) { + for (i = 0; i < n1; i++) { + y[i] += x[j]*m[j][i]; + } + } + } +} + diff --git a/Robust/src/Benchmarks/Prefetch/LUFact/dsm/LinpackRunner.java b/Robust/src/Benchmarks/Prefetch/LUFact/dsm/LinpackRunner.java new file mode 100644 index 00000000..73b2a1ef --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/LUFact/dsm/LinpackRunner.java @@ -0,0 +1,205 @@ +/************************************************************************** +* * +* 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. * +* * +**************************************************************************/ + +class LinpackRunner extends Thread { + int id,lda,n,info,ipvt[]; + double a[][]; + TournamentBarrier br; + int nthreads; + + public LinpackRunner(int id, double a[][], int lda, int n, int ipvt[],TournamentBarrier br, int nthreads) { + this.id = id; + this.a=a; + this.lda=lda; + this.n=n; + this.ipvt=ipvt; + this.br=br; + this.nthreads = nthreads; + } + + double abs (double d) { + if (d >= 0) return d; + else return -d; + } + + public void run() { + double[] col_k, col_j; + double t; + int j,k,kp1,l,nm1; + int info; + int slice,ilow,iupper; + // gaussian elimination with partial pivoting + atomic { + info = 0; + nm1 = n - 1; + if (nm1 >= 0) { + for (k = 0; k < nm1; k++) { + col_k = a[k]; + kp1 = k + 1; + // find l = pivot index + l = idamax(n-k,col_k,k,1) + k; + if(id==0) { + ipvt[k] = l; + } + // synchronise threads + br.DoBarrier(id); + // zero pivot implies this column already triangularized + if (col_k[l] != 0) { + br.DoBarrier(id); + // interchange if necessary + if(id == 0 ) { + if (l != k) { + t = col_k[l]; + col_k[l] = col_k[k]; + col_k[k] = t; + } + } + // synchronise threads + br.DoBarrier(id); + // compute multipliers + t = -1.0/col_k[k]; + if(id == 0) { + dscal(n-(kp1),t,col_k,kp1,1); + } + // synchronise threads + br.DoBarrier(id); + // row elimination with column indexing + slice = ((n-kp1) + nthreads-1)/nthreads; + ilow = (id*slice)+kp1; + iupper = ((id+1)*slice)+kp1; + if (iupper > n ) iupper=n; + if (ilow > n ) ilow=n; + for (j = ilow; j < iupper; j++) { + col_j = a[j]; + t = col_j[l]; + if (l != k) { + col_j[l] = col_j[k]; + col_j[k] = t; + } + daxpy(n-(kp1),t,col_k,kp1,1, + col_j,kp1,1); + } + // synchronise threads + br.DoBarrier(id); + } else { + info = k; + } + br.DoBarrier(id); + } + } + + if(id==0) { + ipvt[n-1] = n-1; + } + if (a[(n-1)][(n-1)] == 0) info = n-1; + } + } + + /* + finds the index of element having max. absolute value. + jack dongarra, linpack, 3/11/78. + */ + int idamax( int n, double dx[], int dx_off, int incx) + { + double dmax, dtemp; + int i, ix, itemp=0; + + if (n < 1) { + itemp = -1; + } else if (n ==1) { + itemp = 0; + } else if (incx != 1) { + // code for increment not equal to 1 + dmax = abs(dx[0 +dx_off]); + ix = 1 + incx; + for (i = 1; i < n; i++) { + dtemp = abs(dx[ix + dx_off]); + if (dtemp > dmax) { + itemp = i; + dmax = dtemp; + } + ix += incx; + } + } else { + // code for increment equal to 1 + itemp = 0; + dmax = abs(dx[0 +dx_off]); + for (i = 1; i < n; i++) { + dtemp = abs(dx[i + dx_off]); + if (dtemp > dmax) { + itemp = i; + dmax = dtemp; + } + } + } + return (itemp); + } + + /* + scales a vector by a constant. + jack dongarra, linpack, 3/11/78. + */ + void dscal( int n, double da, double dx[], int dx_off, int incx) + { + int i,nincx; + if (n > 0) { + if (incx != 1) { + // code for increment not equal to 1 + nincx = n*incx; + for (i = 0; i < nincx; i += incx) + dx[i +dx_off] *= da; + } else { + // code for increment equal to 1 + for (i = 0; i < n; i++) + dx[i +dx_off] *= da; + } + } + } + + /* + constant times a vector plus a vector. + jack dongarra, linpack, 3/11/78. + */ + void daxpy( int n, double da, double dx[], int dx_off, int incx, + double dy[], int dy_off, int incy) + { + int i,ix,iy; + if ((n > 0) && (da != 0)) { + if (incx != 1 || incy != 1) { + // code for unequal increments or equal increments not equal to 1 + ix = 0; + iy = 0; + if (incx < 0) ix = (-n+1)*incx; + if (incy < 0) iy = (-n+1)*incy; + for (i = 0;i < n; i++) { + dy[iy +dy_off] += da*dx[ix +dx_off]; + ix += incx; + iy += incy; + } + return; + } else { + // code for both increments equal to 1 + for (i=0; i < n; i++) + dy[i +dy_off] += da*dx[i +dx_off]; + } + } + } +} + diff --git a/Robust/src/Benchmarks/Prefetch/LUFact/dsm/TournamentBarrier.java b/Robust/src/Benchmarks/Prefetch/LUFact/dsm/TournamentBarrier.java new file mode 100755 index 00000000..56259b45 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/LUFact/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 = global 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/LUFact/dsm/makefile b/Robust/src/Benchmarks/Prefetch/LUFact/dsm/makefile new file mode 100644 index 00000000..5f73b9f6 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/LUFact/dsm/makefile @@ -0,0 +1,18 @@ +MAINCLASS=JGFLUFactBenchSizeA +SRC=${MAINCLASS}.java \ +JGFLUFactBench.java \ +JGFInstrumentor.java \ +JGFTimer.java \ +TournamentBarrier.java \ +Linpack.java \ +LinpackRunner.java +FLAGS=-dsm -prefetch -optimize -debug -profile -excprefetch JGFLUFactBench.JGFkernel -excprefetch JGFLUFactBench.dmxpy -excprefetch JGFLUFactBench.JGFvalidate -excprefetch JGFLUFactBench.JGFinitialise -excprefetch JGFLUFactBench.matgen -excprefetch JGFLUFactBench.dgesl -mainclass ${MAINCLASS} -o ${MAINCLASS} -trueprob 0.8 +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/LUFact/java/JGFInstrumentor.java b/Robust/src/Benchmarks/Prefetch/LUFact/java/JGFInstrumentor.java new file mode 100644 index 00000000..69baf77f --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/LUFact/java/JGFInstrumentor.java @@ -0,0 +1,200 @@ +/************************************************************************** + * * + * 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 "; + + 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.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/LUFact/java/JGFLUFactBench.java b/Robust/src/Benchmarks/Prefetch/LUFact/java/JGFLUFactBench.java new file mode 100644 index 00000000..71caa044 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/LUFact/java/JGFLUFactBench.java @@ -0,0 +1,442 @@ +/************************************************************************** + * * + * 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 JGFLUFactBench { + public int nthreads; + private int size; + private int[] datasizes; + public int cachelinesize; + public JGFInstrumentor instr; + double a[][]; + double b[]; + double x[]; + double ops,total,norma,normx; + double resid,time; + double kf; + int n,i,ntimes,info,lda,ldaa,kflops; + int ipvt[]; + + public JGFLUFactBench(int nthreads, JGFInstrumentor instr) { + //public JGFLUFactBench(int nthreads) { + this.nthreads=nthreads; + this.instr = instr; + datasizes = new int[3]; + datasizes[0] = 500; + datasizes[1] = 1000; + datasizes[2] = 2000; + cachelinesize = 128; + } + + public void JGFsetsize(int size) { + this.size = size; + } + + public void JGFinitialise() { + n = datasizes[size]; + ldaa = n; + lda = ldaa + 1; + + a = new double[ldaa][lda]; + b = new double [ldaa]; + x = new double [ldaa]; + ipvt = new int [ldaa]; + + long nl = (long) n; //avoid integer overflow + ops = (2.0*(nl*nl*nl))/3.0 + 2.0*(nl*nl); + norma = matgen(a,lda,n,b); + } + + public static void JGFkernel(JGFLUFactBench lub, JGFInstrumentor instr) { + int numthreads; + numthreads = lub.nthreads; + + /* spawn threads */ + LinpackRunner[] thobjects; + TournamentBarrier br; + thobjects = new LinpackRunner[numthreads]; + br = new TournamentBarrier(numthreads); + + instr.startTimer("Section2:LUFact:Kernel", instr.timers); + + LinpackRunner tmp; + int mid = (128<<24)|(195<<16)|(175<<8)|73; + for(int i=1;i abs(b[i])) ? resid : abs(b[i]); + //normx = (normx > abs(x[i])) ? normx : abs(x[i]); + if (resid <= abs(b[i])) resid = abs(b[i]); + if (normx <= abs(x[i])) normx = abs(x[i]); + } + eps = epslon((double)1.0); + residn = resid/( n*norma*normx*eps ); + + if (residn > ref[size]) { + System.out.println("Validation failed"); + System.out.println("Computed Norm Res = " + (long) residn * 1000000); + System.out.println("Reference Norm Res = " + (long) ref[size] * 1000000); + } + } + + double abs (double d) { + if (d >= 0) return d; + else return -d; + //return (d >= 0) ? d : -d; + } + + double matgen (double a[][], int lda, int n, double b[]) + { + double norma; + int init, i, j; + + init = 1325; + norma = 0.0; + /* Next two for() statements switched. Solver wants + matrix in column order. --dmd 3/3/97 + */ + for (i = 0; i < n; i++) { + for (j = 0; j < n; j++) { + init = 3125*init % 65536; + a[j][i] = (init - 32768.0)/16384.0; + //norma = (a[j][i] > norma) ? a[j][i] : norma; + if (a[j][i] > norma) { + norma = a[j][i]; + } + } + } + for (i = 0; i < n; i++) { + b[i] = 0.0; + } + for (j = 0; j < n; j++) { + for (i = 0; i < n; i++) { + b[i] += a[j][i]; + } + } + return norma; + } + + void dgesl( double a[][], int lda, int n, int ipvt[], double b[], int job) + { + double t; + int k,kb,l,nm1,kp1; + + nm1 = n - 1; + if (job == 0) { + // job = 0 , solve a * x = b. first solve l*y = b + if (nm1 >= 1) { + for (k = 0; k < nm1; k++) { + l = ipvt[k]; + t = b[l]; + if (l != k){ + b[l] = b[k]; + b[k] = t; + } + kp1 = k + 1; + daxpy(n-(kp1),t,a[k],kp1,1,b,kp1,1); + } + } + // now solve u*x = y + for (kb = 0; kb < n; kb++) { + k = n - (kb + 1); + b[k] /= a[k][k]; + t = -b[k]; + daxpy(k,t,a[k],0,1,b,0,1); + } + } else { + // job = nonzero, solve trans(a) * x = b. first solve trans(u)*y = b + for (k = 0; k < n; k++) { + t = ddot(k,a[k],0,1,b,0,1); + b[k] = (b[k] - t)/a[k][k]; + } + // now solve trans(l)*x = y + if (nm1 >= 1) { + for (kb = 1; kb < nm1; kb++) { + k = n - (kb+1); + kp1 = k + 1; + b[k] += ddot(n-(kp1),a[k],kp1,1,b,kp1,1); + l = ipvt[k]; + if (l != k) { + t = b[l]; + b[l] = b[k]; + b[k] = t; + } + } + } + } + } + + /* + constant times a vector plus a vector. + jack dongarra, linpack, 3/11/78. + */ + void daxpy( int n, double da, double dx[], int dx_off, int incx, + double dy[], int dy_off, int incy) + { + int i,ix,iy; + + if ((n > 0) && (da != 0)) { + if (incx != 1 || incy != 1) { + // code for unequal increments or equal increments not equal to 1 + ix = 0; + iy = 0; + if (incx < 0) ix = (-n+1)*incx; + if (incy < 0) iy = (-n+1)*incy; + for (i = 0;i < n; i++) { + dy[iy +dy_off] += da*dx[ix +dx_off]; + ix += incx; + iy += incy; + } + return; + } else { + // code for both increments equal to 1 + for (i=0; i < n; i++) + dy[i +dy_off] += da*dx[i +dx_off]; + } + } + } + + /* + forms the dot product of two vectors. + jack dongarra, linpack, 3/11/78. + */ + double ddot( int n, double dx[], int dx_off, int incx, double dy[], + int dy_off, int incy) + { + double dtemp; + int i,ix,iy; + dtemp = 0; + if (n > 0) { + if (incx != 1 || incy != 1) { + // code for unequal increments or equal increments not equal to 1 + ix = 0; + iy = 0; + if (incx < 0) ix = (-n+1)*incx; + if (incy < 0) iy = (-n+1)*incy; + for (i = 0;i < n; i++) { + dtemp += dx[ix +dx_off]*dy[iy +dy_off]; + ix += incx; + iy += incy; + } + } else { + // code for both increments equal to 1 + for (i=0;i < n; i++) + dtemp += dx[i +dx_off]*dy[i +dy_off]; + } + } + return(dtemp); + } + + /* + scales a vector by a constant. + jack dongarra, linpack, 3/11/78. + */ + void dscal( int n, double da, double dx[], int dx_off, int incx) + { + int i,nincx; + if (n > 0) { + if (incx != 1) { + // code for increment not equal to 1 + nincx = n*incx; + for (i = 0; i < nincx; i += incx) + dx[i +dx_off] *= da; + } else { + // code for increment equal to 1 + for (i = 0; i < n; i++) + dx[i +dx_off] *= da; + } + } + } + + /* + finds the index of element having max. absolute value. + jack dongarra, linpack, 3/11/78. + */ + int idamax( int n, double dx[], int dx_off, int incx) + { + double dmax, dtemp; + int i, ix, itemp=0; + + if (n < 1) { + itemp = -1; + } else if (n ==1) { + itemp = 0; + } else if (incx != 1) { + // code for increment not equal to 1 + dmax = abs(dx[0 +dx_off]); + ix = 1 + incx; + for (i = 1; i < n; i++) { + dtemp = abs(dx[ix + dx_off]); + if (dtemp > dmax) { + itemp = i; + dmax = dtemp; + } + ix += incx; + } + } else { + // code for increment equal to 1 + itemp = 0; + dmax = abs(dx[0 +dx_off]); + for (i = 1; i < n; i++) { + dtemp = abs(dx[i + dx_off]); + if (dtemp > dmax) { + itemp = i; + dmax = dtemp; + } + } + } + return (itemp); + } + + /* + estimate unit roundoff in quantities of size x. + this program should function properly on all systems + satisfying the following two assumptions, + 1. the base used in representing dfloating point + numbers is not a power of three. + 2. the quantity a in statement 10 is represented to + the accuracy used in dfloating point variables + that are stored in memory. + the statement number 10 and the go to 10 are intended to + force optimizing compilers to generate code satisfying + assumption 2. + under these assumptions, it should be true that, + a is not exactly equal to four-thirds, + b has a zero for its last bit or digit, + c is not exactly equal to one, + eps measures the separation of 1.0 from + the next larger dfloating point number. + the developers of eispack would appreciate being informed + about any systems where these assumptions do not hold. + + ***************************************************************** + this routine is one of the auxiliary routines used by eispack iii + to avoid machine dependencies. + ***************************************************************** + + this version dated 4/6/83. + */ + double epslon (double x) + { + double a,b,c,eps; + + a = 4.0e0/3.0e0; + eps = 0; + while (eps == 0) { + b = a - 1.0; + c = b + b + b; + eps = abs(c-1.0); + } + return(eps*abs(x)); + } + + void dmxpy ( int n1, double y[], int n2, int ldm, double x[], double m[][]) + { + int j,i; + // cleanup odd vector + for (j = 0; j < n2; j++) { + for (i = 0; i < n1; i++) { + y[i] += x[j]*m[j][i]; + } + } + } + /* + public static void JGFvalidate(JGFLUFactBench lub) { + int i; + double eps,residn; + double[] ref; + + ref = new double[3]; + ref[0] = 6.0; + ref[1] = 12.0; + ref[2] = 20.0; + + atomic { + for (i = 0; i < lub.n; i++) { + lub.x[i] = lub.b[i]; + } + lub.norma = lub.matgen(lub.a,lub.lda,lub.n,lub.b); + for (i = 0; i < lub.n; i++) { + lub.b[i] = -(lub.b[i]); + } + + lub.dmxpy(lub.n,lub.b,lub.n,lub.lda,lub.x,lub.a); + lub.resid = 0.0; + lub.normx = 0.0; + for (i = 0; i < lub.n; i++) { +//resid = (resid > abs(b[i])) ? resid : abs(b[i]); +//normx = (normx > abs(x[i])) ? normx : abs(x[i]); +if (lub.resid <= abs(lub.b[i])) lub.resid = lub.abs(lub.b[i]); +if (lub.normx <= abs(lub.x[i])) lub.normx = lub.abs(lub.x[i]); +} +eps = lub.epslon((double)1.0); +residn = lub.resid/( lub.n*lub.norma*lub.normx*eps ); +} + +if (residn > ref[size]) { +System.out.println("Validation failed"); +System.out.println("Computed Norm Res = " + (long) residn); +System.out.println("Reference Norm Res = " + (long) ref[size]); +} +} +*/ + +} diff --git a/Robust/src/Benchmarks/Prefetch/LUFact/java/JGFLUFactBenchSizeA.java b/Robust/src/Benchmarks/Prefetch/LUFact/java/JGFLUFactBenchSizeA.java new file mode 100644 index 00000000..766a147c --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/LUFact/java/JGFLUFactBenchSizeA.java @@ -0,0 +1,50 @@ +/************************************************************************** + * * + * 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 JGFLUFactBenchSizeA { + + 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(2,0,nthreads); + JGFLUFactBench lub; + lub = new JGFLUFactBench(nthreads, instr); + //lub = new JGFLUFactBench(nthreads); + + int size = 0; + JGFInstrumentor.addTimer("Section2:LUFact:Kernel", "Mflops", size, instr.timers); + lub.JGFsetsize(size); + lub.JGFinitialise(); + JGFLUFactBench.JGFkernel(lub,instr); + lub.JGFvalidate(); + double ops; + ops = lub.ops; + JGFInstrumentor.addOpsToTimer("Section2:LUFact:Kernel", ((long)ops)/1.0e06, instr.timers); + JGFInstrumentor.printTimer("Section2:LUFact:Kernel", instr.timers); + } +} + diff --git a/Robust/src/Benchmarks/Prefetch/LUFact/java/JGFTimer.java b/Robust/src/Benchmarks/Prefetch/LUFact/java/JGFTimer.java new file mode 100644 index 00000000..cf4daf57 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/LUFact/java/JGFTimer.java @@ -0,0 +1,124 @@ +/************************************************************************** + * * + * 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 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.out.println("Warning timer " + " 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 " + " 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 { + if(size == 0) { + System.out.println(name + ":SizeA" + "\t" + time + " (s) \t " + this.perf() + "\t" + " ("+opname+"/s)"); + } else if (size == 1) { + System.out.println(name + ":SizeB" + "\t" + time + " (s) \t " + this.perf() + "\t" + " ("+opname+"/s)"); + } else if (size == 2) { + System.out.println(name + ":SizeC" + "\t" + time + " (s) \t " + this.perf() + "\t" + " ("+opname+"/s)"); + } else{ + System.out.println(name + "\t" + time + " (s) \t " + 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.out.println(name + "\t" + this.perf() + "\t" + + " ("+opname+"/s)"); + } + +} diff --git a/Robust/src/Benchmarks/Prefetch/LUFact/java/Linpack.java b/Robust/src/Benchmarks/Prefetch/LUFact/java/Linpack.java new file mode 100644 index 00000000..1c21cb08 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/LUFact/java/Linpack.java @@ -0,0 +1,327 @@ +/************************************************************************** + * * + * 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 * + * * + * See below for the previous history of this code * + * * + * This version copyright (c) The University of Edinburgh, 2001. * + * All rights reserved. * + * * + **************************************************************************/ + +/* + + Modified 3/3/97 by David M. Doolin (dmd) doolin@cs.utk.edu + Fixed error in matgen() method. Added some comments. + + Modified 1/22/97 by Paul McMahan mcmahan@cs.utk.edu + Added more MacOS options to form. + + Optimized by Jonathan Hardwick (jch@cs.cmu.edu), 3/28/96 + Compare to Linkpack.java. + Optimizations performed: + - added "final" modifier to performance-critical methods. + - changed lines of the form "a[i] = a[i] + x" to "a[i] += x". + - minimized array references using common subexpression elimination. + - eliminated unused variables. + - undid an unrolled loop. + - added temporary 1D arrays to hold frequently-used columns of 2D arrays. + - wrote my own abs() method + See http://www.cs.cmu.edu/~jch/java/linpack.html for more details. + + + Ported to Java by Reed Wade (wade@cs.utk.edu) 2/96 + built using JDK 1.0 on solaris + using "javac -O Linpack.java" + + + Translated to C by Bonnie Toy 5/88 + (modified on 2/25/94 to fix a problem with daxpy for + unequal increments or equal increments not equal to 1. + Jack Dongarra) + +*/ + +public class Linpack { + double a[][]; + double b[]; + double x[]; + double ops,total,norma,normx; + double resid,time; + double kf; + int n,i,ntimes,info,lda,ldaa,kflops; + int ipvt[]; + + double abs (double d) { + if (d >= 0) return d; + else return -d; + //return (d >= 0) ? d : -d; + } + + double matgen (double a[][], int lda, int n, double b[]) + { + double norma; + int init, i, j; + + init = 1325; + norma = 0.0; + /* Next two for() statements switched. Solver wants + matrix in column order. --dmd 3/3/97 + */ + for (i = 0; i < n; i++) { + for (j = 0; j < n; j++) { + init = 3125*init % 65536; + a[j][i] = (init - 32768.0)/16384.0; + //norma = (a[j][i] > norma) ? a[j][i] : norma; + if (a[j][i] > norma) { + norma = a[j][i]; + } + } + } + for (i = 0; i < n; i++) { + b[i] = 0.0; + } + for (j = 0; j < n; j++) { + for (i = 0; i < n; i++) { + b[i] += a[j][i]; + } + } + return norma; + } + + void dgesl( double a[][], int lda, int n, int ipvt[], double b[], int job) + { + double t; + int k,kb,l,nm1,kp1; + + nm1 = n - 1; + if (job == 0) { + // job = 0 , solve a * x = b. first solve l*y = b + if (nm1 >= 1) { + for (k = 0; k < nm1; k++) { + l = ipvt[k]; + t = b[l]; + if (l != k){ + b[l] = b[k]; + b[k] = t; + } + kp1 = k + 1; + daxpy(n-(kp1),t,a[k],kp1,1,b,kp1,1); + } + } + // now solve u*x = y + for (kb = 0; kb < n; kb++) { + k = n - (kb + 1); + b[k] /= a[k][k]; + t = -b[k]; + daxpy(k,t,a[k],0,1,b,0,1); + } + } else { + // job = nonzero, solve trans(a) * x = b. first solve trans(u)*y = b + for (k = 0; k < n; k++) { + t = ddot(k,a[k],0,1,b,0,1); + b[k] = (b[k] - t)/a[k][k]; + } + // now solve trans(l)*x = y + if (nm1 >= 1) { + for (kb = 1; kb < nm1; kb++) { + k = n - (kb+1); + kp1 = k + 1; + b[k] += ddot(n-(kp1),a[k],kp1,1,b,kp1,1); + l = ipvt[k]; + if (l != k) { + t = b[l]; + b[l] = b[k]; + b[k] = t; + } + } + } + } + } + + /* + constant times a vector plus a vector. + jack dongarra, linpack, 3/11/78. + */ + void daxpy( int n, double da, double dx[], int dx_off, int incx, + double dy[], int dy_off, int incy) + { + int i,ix,iy; + + if ((n > 0) && (da != 0)) { + if (incx != 1 || incy != 1) { + // code for unequal increments or equal increments not equal to 1 + ix = 0; + iy = 0; + if (incx < 0) ix = (-n+1)*incx; + if (incy < 0) iy = (-n+1)*incy; + for (i = 0;i < n; i++) { + dy[iy +dy_off] += da*dx[ix +dx_off]; + ix += incx; + iy += incy; + } + return; + } else { + // code for both increments equal to 1 + for (i=0; i < n; i++) + dy[i +dy_off] += da*dx[i +dx_off]; + } + } + } + + /* + forms the dot product of two vectors. + jack dongarra, linpack, 3/11/78. + */ + double ddot( int n, double dx[], int dx_off, int incx, double dy[], + int dy_off, int incy) + { + double dtemp; + int i,ix,iy; + dtemp = 0; + if (n > 0) { + if (incx != 1 || incy != 1) { + // code for unequal increments or equal increments not equal to 1 + ix = 0; + iy = 0; + if (incx < 0) ix = (-n+1)*incx; + if (incy < 0) iy = (-n+1)*incy; + for (i = 0;i < n; i++) { + dtemp += dx[ix +dx_off]*dy[iy +dy_off]; + ix += incx; + iy += incy; + } + } else { + // code for both increments equal to 1 + for (i=0;i < n; i++) + dtemp += dx[i +dx_off]*dy[i +dy_off]; + } + } + return(dtemp); + } + + /* + scales a vector by a constant. + jack dongarra, linpack, 3/11/78. + */ + void dscal( int n, double da, double dx[], int dx_off, int incx) + { + int i,nincx; + if (n > 0) { + if (incx != 1) { + // code for increment not equal to 1 + nincx = n*incx; + for (i = 0; i < nincx; i += incx) + dx[i +dx_off] *= da; + } else { + // code for increment equal to 1 + for (i = 0; i < n; i++) + dx[i +dx_off] *= da; + } + } + } + + /* + finds the index of element having max. absolute value. + jack dongarra, linpack, 3/11/78. + */ + int idamax( int n, double dx[], int dx_off, int incx) + { + double dmax, dtemp; + int i, ix, itemp=0; + + if (n < 1) { + itemp = -1; + } else if (n ==1) { + itemp = 0; + } else if (incx != 1) { + // code for increment not equal to 1 + dmax = abs(dx[0 +dx_off]); + ix = 1 + incx; + for (i = 1; i < n; i++) { + dtemp = abs(dx[ix + dx_off]); + if (dtemp > dmax) { + itemp = i; + dmax = dtemp; + } + ix += incx; + } + } else { + // code for increment equal to 1 + itemp = 0; + dmax = abs(dx[0 +dx_off]); + for (i = 1; i < n; i++) { + dtemp = abs(dx[i + dx_off]); + if (dtemp > dmax) { + itemp = i; + dmax = dtemp; + } + } + } + return (itemp); + } + + /* + estimate unit roundoff in quantities of size x. + this program should function properly on all systems + satisfying the following two assumptions, + 1. the base used in representing dfloating point + numbers is not a power of three. + 2. the quantity a in statement 10 is represented to + the accuracy used in dfloating point variables + that are stored in memory. + the statement number 10 and the go to 10 are intended to + force optimizing compilers to generate code satisfying + assumption 2. + under these assumptions, it should be true that, + a is not exactly equal to four-thirds, + b has a zero for its last bit or digit, + c is not exactly equal to one, + eps measures the separation of 1.0 from + the next larger dfloating point number. + the developers of eispack would appreciate being informed + about any systems where these assumptions do not hold. + + ***************************************************************** + this routine is one of the auxiliary routines used by eispack iii + to avoid machine dependencies. + ***************************************************************** + + this version dated 4/6/83. + */ + double epslon (double x) + { + double a,b,c,eps; + + a = 4.0e0/3.0e0; + eps = 0; + while (eps == 0) { + b = a - 1.0; + c = b + b + b; + eps = abs(c-1.0); + } + return(eps*abs(x)); + } + + void dmxpy ( int n1, double y[], int n2, int ldm, double x[], double m[][]) + { + int j,i; + // cleanup odd vector + for (j = 0; j < n2; j++) { + for (i = 0; i < n1; i++) { + y[i] += x[j]*m[j][i]; + } + } + } +} + diff --git a/Robust/src/Benchmarks/Prefetch/LUFact/java/LinpackRunner.java b/Robust/src/Benchmarks/Prefetch/LUFact/java/LinpackRunner.java new file mode 100644 index 00000000..a9764f50 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/LUFact/java/LinpackRunner.java @@ -0,0 +1,205 @@ +/************************************************************************** +* * +* 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. * +* * +**************************************************************************/ + +class LinpackRunner extends Thread { + int id,lda,n,info,ipvt[]; + double a[][]; + TournamentBarrier br; + int nthreads; + + public LinpackRunner(int id, double a[][], int lda, int n, int ipvt[],TournamentBarrier br, int nthreads) { + this.id = id; + this.a=a; + this.lda=lda; + this.n=n; + this.ipvt=ipvt; + this.br=br; + //this.instr = instr; + this.nthreads = nthreads; + } + + double abs (double d) { + //return (d >= 0) ? d : -d; + if (d >= 0) return d; + else return -d; + } + + public void run() { + double[] col_k, col_j; + double t; + int j,k,kp1,l,nm1; + int info; + int slice,ilow,iupper; + // gaussian elimination with partial pivoting + info = 0; + nm1 = n - 1; + if (nm1 >= 0) { + for (k = 0; k < nm1; k++) { + col_k = a[k]; + kp1 = k + 1; + // find l = pivot index + l = idamax(n-k,col_k,k,1) + k; + if(id==0) { + ipvt[k] = l; + } + // synchronise threads + br.DoBarrier(id); + // zero pivot implies this column already triangularized + if (col_k[l] != 0) { + br.DoBarrier(id); + // interchange if necessary + if(id == 0 ) { + if (l != k) { + t = col_k[l]; + col_k[l] = col_k[k]; + col_k[k] = t; + } + } + // synchronise threads + br.DoBarrier(id); + // compute multipliers + t = -1.0/col_k[k]; + if(id == 0) { + dscal(n-(kp1),t,col_k,kp1,1); + } + // synchronise threads + br.DoBarrier(id); + // row elimination with column indexing + slice = ((n-kp1) + nthreads-1)/nthreads; + ilow = (id*slice)+kp1; + iupper = ((id+1)*slice)+kp1; + if (iupper > n ) iupper=n; + if (ilow > n ) ilow=n; + for (j = ilow; j < iupper; j++) { + col_j = a[j]; + t = col_j[l]; + if (l != k) { + col_j[l] = col_j[k]; + col_j[k] = t; + } + daxpy(n-(kp1),t,col_k,kp1,1, + col_j,kp1,1); + } + // synchronise threads + br.DoBarrier(id); + } else { + info = k; + } + br.DoBarrier(id); + } + } + + if(id==0) { + ipvt[n-1] = n-1; + } + if (a[(n-1)][(n-1)] == 0) info = n-1; + } + + /* + finds the index of element having max. absolute value. + jack dongarra, linpack, 3/11/78. + */ + int idamax( int n, double dx[], int dx_off, int incx) + { + double dmax, dtemp; + int i, ix, itemp=0; + + if (n < 1) { + itemp = -1; + } else if (n ==1) { + itemp = 0; + } else if (incx != 1) { + // code for increment not equal to 1 + dmax = abs(dx[0 +dx_off]); + ix = 1 + incx; + for (i = 1; i < n; i++) { + dtemp = abs(dx[ix + dx_off]); + if (dtemp > dmax) { + itemp = i; + dmax = dtemp; + } + ix += incx; + } + } else { + // code for increment equal to 1 + itemp = 0; + dmax = abs(dx[0 +dx_off]); + for (i = 1; i < n; i++) { + dtemp = abs(dx[i + dx_off]); + if (dtemp > dmax) { + itemp = i; + dmax = dtemp; + } + } + } + return (itemp); + } + + /* + scales a vector by a constant. + jack dongarra, linpack, 3/11/78. + */ + void dscal( int n, double da, double dx[], int dx_off, int incx) + { + int i,nincx; + if (n > 0) { + if (incx != 1) { + // code for increment not equal to 1 + nincx = n*incx; + for (i = 0; i < nincx; i += incx) + dx[i +dx_off] *= da; + } else { + // code for increment equal to 1 + for (i = 0; i < n; i++) + dx[i +dx_off] *= da; + } + } + } + + /* + constant times a vector plus a vector. + jack dongarra, linpack, 3/11/78. + */ + void daxpy( int n, double da, double dx[], int dx_off, int incx, + double dy[], int dy_off, int incy) + { + int i,ix,iy; + if ((n > 0) && (da != 0)) { + if (incx != 1 || incy != 1) { + // code for unequal increments or equal increments not equal to 1 + ix = 0; + iy = 0; + if (incx < 0) ix = (-n+1)*incx; + if (incy < 0) iy = (-n+1)*incy; + for (i = 0;i < n; i++) { + dy[iy +dy_off] += da*dx[ix +dx_off]; + ix += incx; + iy += incy; + } + return; + } else { + // code for both increments equal to 1 + for (i=0; i < n; i++) + dy[i +dy_off] += da*dx[i +dx_off]; + } + } + } +} + diff --git a/Robust/src/Benchmarks/Prefetch/LUFact/java/TournamentBarrier.java b/Robust/src/Benchmarks/Prefetch/LUFact/java/TournamentBarrier.java new file mode 100755 index 00000000..99ff768a --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/LUFact/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)! + +import java.util.*; + +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/LUFact/java/makefile b/Robust/src/Benchmarks/Prefetch/LUFact/java/makefile new file mode 100644 index 00000000..1103d192 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/LUFact/java/makefile @@ -0,0 +1,8 @@ +SRC = JGFLUFactBenchSizeA +default: + javac ${SRC}.java +run: + java ${SRC} 2 + +clean: + rm *.class -- 2.34.1