From: adash Date: Wed, 30 Apr 2008 01:48:58 +0000 (+0000) Subject: SOR benchmark X-Git-Tag: preEdgeChange~127 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7178afa2ae6ed43ab4ea8107ea4a4f87c374f8a1;p=IRC.git SOR benchmark --- diff --git a/Robust/src/Benchmarks/Prefetch/SOR/JGFInstrumentor.java b/Robust/src/Benchmarks/Prefetch/SOR/JGFInstrumentor.java deleted file mode 100644 index b48928d6..00000000 --- a/Robust/src/Benchmarks/Prefetch/SOR/JGFInstrumentor.java +++ /dev/null @@ -1,178 +0,0 @@ -public class JGFInstrumentor{ - - private HashMap timers; - private HashMap data; - - public JGFInstrumentor() { - timers = new HashMap(); - data = new HashMap(); - } - public static void addTimer (String name, String opname, int size){ - - 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){ - 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){ - 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){ - if (timers.containsKey(name)) { - ((JGFTimer) timers.get(name)).addops(count); - } - else { - System.printString("JGFInstrumentor.addOpsToTimer: failed - timer " + name + - " does not exist"); - } - } - - public static void printTimer(String name){ - if (timers.containsKey(name)) { - ((JGFTimer) timers.get(name)).print(); - } - else { - System.printString("JGFInstrumentor.printTimer: failed - timer " + name + - " does not exist"); - } - } - - public static void printHeader(int section, int size,int nthreads) { - - String header = new String(""); - String base = new String("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"; - } - } else { - System.printString("Error\n"); - } - - System.printString(header); - - if (nthreads == 1) { - System.printString("Executing on " + nthreads + " thread"); - } - else { - System.printString("Executing on " + nthreads + " threads"); - } - - System.printString(""); - - } - - /* - public static void addTimeToTimer(String name, double added_time){ - 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){ - 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){ - if (timers.containsKey(name)) { - ((JGFTimer) timers.get(name)).reset(); - } - else { - System.printString("JGFInstrumentor.resetTimer: failed - timer " + name + - " does not exist"); - } - } - - - public static void printperfTimer(String name){ - 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){ - data.put(name,obj); - } - - public static void retrieveData(String name, Object obj){ - obj = data.get(name); - } - public static void addTimer (String name){ - - 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){ - if (timers.containsKey(name)) { - System.printString("JGFInstrumentor.addTimer: warning - timer " + name + - " already exists"); - } - else { - timers.put(name, new JGFTimer(name,opname)); - } - - } - */ -} diff --git a/Robust/src/Benchmarks/Prefetch/SOR/JGFSORBench.java b/Robust/src/Benchmarks/Prefetch/SOR/JGFSORBench.java deleted file mode 100644 index 28a65fdc..00000000 --- a/Robust/src/Benchmarks/Prefetch/SOR/JGFSORBench.java +++ /dev/null @@ -1,88 +0,0 @@ -public class JGFSORBench extends SOR{ - - private int size; - private int[] datasize; - private final int JACOBI_NUM_ITER; - private final long RANDOM_SEED; - public int nthreads; - Random R; - - public JGFSORBench() { - JACOBI_NUM_ITER = 100; - RANDOM_SEED = 10101010; - R = new Random(RANDOM_SEED); - } - - public JGFSORBench(int nthreads){ - this.nthreads = nthreads; - int datasizes[] = new int[3]; - datasizes[0]= 1000; - datasizes[1]= 1500; - datasizes[2]= 2000; - } - - public void JGFsetsize(int size){ - this.size = size; - } - - public void JGFinitialise(){ - - } - - public void JGFkernel(){ - - double G[][] = RandomMatrix(datasizes[size], datasizes[size],R); - - SORrun(1.25, G, JACOBI_NUM_ITER, nthreads); - - - } - - public void JGFvalidate(){ - - double refval[] = new double[3]; - refval[0] = 0.498574406322512; - refval[1] = 1.1234778980135105; - refval[2] = 1.9954895063582696; - double dev = Math.abs(Gtotal - refval[size]); - if (dev > 1.0e-12 ){ - System.out.println("Validation failed"); - System.out.println("Gtotal = " + Gtotal + " " + dev + " " + size); - } - } - - public void JGFtidyup(){ - //System.gc(); - } - - public void JGFrun(int size){ - - - JGFInstrumentor.addTimer("Section2:SOR:Kernel", "Iterations",size); - - JGFsetsize(size); - JGFinitialise(); - JGFkernel(); - JGFvalidate(); - JGFtidyup(); - - - JGFInstrumentor.addOpsToTimer("Section2:SOR:Kernel", (double) (JACOBI_NUM_ITER)); - - JGFInstrumentor.printTimer("Section2:SOR:Kernel"); - } - - private static double[][] RandomMatrix(int M, int N, java.util.Random R) - { - double A[][] = new double[M][N]; - - for (int i=0; i Mm1) iupper = Mm1+1; - if (id == (JGFSORBench.nthreads-1)) iupper = Mm1+1; - - for (int p=0; p<2*num_iterations; p++) { - for (int i=ilow+(p%2); i 0) { - while (sync[id-1][0] < sync[id][0]) ; - } - if (id < JGFSORBench.nthreads -1) { - while (sync[id+1][0] < sync[id][0]) ; - } - } - - } -} diff --git a/Robust/src/Benchmarks/Prefetch/SOR/dsm/JGFInstrumentor.java b/Robust/src/Benchmarks/Prefetch/SOR/dsm/JGFInstrumentor.java new file mode 100644 index 00000000..5e89ddb9 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/SOR/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\n"); + } + 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\n"); + } + 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\n"); + } + 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\n"); + } + + } + + 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\n"); + } + } + + 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\n"); + } + } + + 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\n"); + } + + + + } + + 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\n"); + 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\n"); + } + } + + 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\n"); + } + } + + 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\n"); + } + } + + 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+"\n"); + + if (nthreads == 1) { + System.printString("Executing on " + nthreads + " thread\n"); + } + else { + System.printString("Executing on " + nthreads + " threads\n"); + } + + System.printString("\n"); + } +} diff --git a/Robust/src/Benchmarks/Prefetch/SOR/dsm/JGFSORBench.java b/Robust/src/Benchmarks/Prefetch/SOR/dsm/JGFSORBench.java new file mode 100644 index 00000000..4e947197 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/SOR/dsm/JGFSORBench.java @@ -0,0 +1,189 @@ +/************************************************************************** + * * + * 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 JGFSORBench { + + int size; + int[] datasizes; + int JACOBI_NUM_ITER; + long RANDOM_SEED; + public int nthreads; + Random R; + public double Gtotal; + public int cachelinesize; + public long sync[][]; + + public JGFSORBench(int nthreads){ + this.nthreads = nthreads; + datasizes = global new int[3]; + datasizes[0] = 1000; + datasizes[1] = 1500; + datasizes[2] = 2000; + JACOBI_NUM_ITER = 100; + RANDOM_SEED = 10101010; + R = global new Random(RANDOM_SEED); + Gtotal = 0.0; + cachelinesize = 128; + } + + public void JGFsetsize(int size){ + this.size = size; + } + + public static void JGFkernel(JGFSORBench sor) { + int numthreads, datasize; + Random rand; + atomic { + numthreads = sor.nthreads; + rand = sor.R; + datasize = sor.datasizes[sor.size]; + } + + double[][] G; + int M, N; + atomic { + //G = global new double[datasize][datasize]; + G = sor.RandomMatrix(datasize, datasize, rand); + M = G.length; + N = G[0].length; + } + double omega = 1.25; + int num_iterations; + atomic { + num_iterations = sor.JACOBI_NUM_ITER; + } + + double omega_over_four = omega * 0.25; + double one_minus_omega = 1.0 - omega; + + // update interior points + // + int Mm1 = M-1; + int Nm1 = N-1; + + //spawn threads + int tmpcachelinesize; + atomic { + tmpcachelinesize = sor.cachelinesize; + } + + SORRunner[] thobjects; + atomic { + thobjects = global new SORRunner[numthreads]; + sor.sync = sor.init_sync(numthreads, tmpcachelinesize); + } + + //JGFInstrumentor.startTimer("Section2:SOR:Kernel", instr.timers); + + SORRunner tmp; + int mid = (128<<24)|(195<<16)|(175<<8)|73; + for(int i=1;i 1.0e-12 ){ + //System.printString("Validation failed"); + //System.printString("Gtotal = " + (long) Gtotal * 1000000 + " " +(long) dev * 1000000 + " " + size); + return 1; + } else { + return 0; + } + } + + /* + public void JGFtidyup(){ + System.gc(); + } + + public void JGFrun(int size){ + + + JGFInstrumentor.addTimer("Section2:SOR:Kernel", "Iterations",size); + + JGFsetsize(size); + JGFinitialise(); + JGFkernel(); + JGFvalidate(); + JGFtidyup(); + + + JGFInstrumentor.addOpsToTimer("Section2:SOR:Kernel", (double) (JACOBI_NUM_ITER)); + + JGFInstrumentor.printTimer("Section2:SOR:Kernel"); + } + */ + + +} diff --git a/Robust/src/Benchmarks/Prefetch/SOR/dsm/JGFSORBenchSizeA.java b/Robust/src/Benchmarks/Prefetch/SOR/dsm/JGFSORBenchSizeA.java new file mode 100644 index 00000000..dd9fd607 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/SOR/dsm/JGFSORBenchSizeA.java @@ -0,0 +1,67 @@ +/************************************************************************** +* * +* 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 JGFSORBenchSizeA{ + + 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); + + JGFSORBench sor; + atomic { + sor = global new JGFSORBench(nthreads); + } + + int size = 0; + JGFInstrumentor.addTimer("Section2:SOR:Kernel", "Iterations",size, instr.timers); + + atomic { + sor.JGFsetsize(size); + } + JGFSORBench.JGFkernel(sor); + System.printString("End of JGFkernel\n"); + int retval; + atomic { + retval = sor.JGFvalidate(); + } + if(retval!=0) { + System.printString("Validation failed"); + } + + int jacobi; + atomic { + jacobi = sor.JACOBI_NUM_ITER; + } + + JGFInstrumentor.addOpsToTimer("Section2:SOR:Kernel", (double) jacobi, instr.timers); + JGFInstrumentor.printTimer("Section2:SOR:Kernel", instr.timers); + } +} diff --git a/Robust/src/Benchmarks/Prefetch/SOR/dsm/JGFSORBenchSizeB.java b/Robust/src/Benchmarks/Prefetch/SOR/dsm/JGFSORBenchSizeB.java new file mode 100644 index 00000000..d6f08f65 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/SOR/dsm/JGFSORBenchSizeB.java @@ -0,0 +1,66 @@ +/************************************************************************** +* * +* 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 JGFSORBenchSizeB{ + + 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,1,nthreads); + + JGFSORBench sor; + atomic { + sor = global new JGFSORBench(nthreads); + } + + int size = 1; + JGFInstrumentor.addTimer("Section2:SOR:Kernel", "Iterations",size, instr.timers); + + atomic { + sor.JGFsetsize(size); + } + JGFSORBench.JGFkernel(sor); + System.printString("End of JGFkernel\n"); + int retval; + atomic { + retval = sor.JGFvalidate(); + } + if(retval!=0) { + System.printString("Validation failed"); + } + + int jacobi; + atomic { + jacobi = sor.JACOBI_NUM_ITER; + } + + JGFInstrumentor.addOpsToTimer("Section2:SOR:Kernel", (double) jacobi, instr.timers); + JGFInstrumentor.printTimer("Section2:SOR:Kernel", instr.timers); + } +} diff --git a/Robust/src/Benchmarks/Prefetch/SOR/dsm/JGFSORBenchSizeC.java b/Robust/src/Benchmarks/Prefetch/SOR/dsm/JGFSORBenchSizeC.java new file mode 100644 index 00000000..ce1c4193 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/SOR/dsm/JGFSORBenchSizeC.java @@ -0,0 +1,66 @@ +/************************************************************************** +* * +* 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 JGFSORBenchSizeC{ + + 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,2,nthreads); + + JGFSORBench sor; + atomic { + sor = global new JGFSORBench(nthreads); + } + + int size = 2; + JGFInstrumentor.addTimer("Section2:SOR:Kernel", "Iterations",size, instr.timers); + + atomic { + sor.JGFsetsize(size); + } + JGFSORBench.JGFkernel(sor); + System.printString("End of JGFkernel\n"); + int retval; + atomic { + retval = sor.JGFvalidate(); + } + if(retval!=0) { + System.printString("Validation failed"); + } + + int jacobi; + atomic { + jacobi = sor.JACOBI_NUM_ITER; + } + + JGFInstrumentor.addOpsToTimer("Section2:SOR:Kernel", (double) jacobi, instr.timers); + JGFInstrumentor.printTimer("Section2:SOR:Kernel", instr.timers); + } +} diff --git a/Robust/src/Benchmarks/Prefetch/SOR/dsm/JGFTimer.java b/Robust/src/Benchmarks/Prefetch/SOR/dsm/JGFTimer.java new file mode 100644 index 00000000..4e1d168f --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/SOR/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\n"); + 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\n"); + 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)\n"); + System.printString(name + " " + calls + " " + (long)time + " " + (long)this.perf() + "\n"); + } + + public void print(){ + if (opname.equals("")) { + System.printString(name + " " + (long)time + " (s)\n"); + } + else { + if(size == 0) { + System.printString(name + ":SizeA" + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)\n"); + } else if (size == 1) { + System.printString(name + ":SizeB" + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)\n"); + } else if (size == 2) { + System.printString(name + ":SizeC" + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)\n"); + } else{ + System.printString(name + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)\n"); + } + } + } + + + 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)\n"); + } + +} diff --git a/Robust/src/Benchmarks/Prefetch/SOR/dsm/SORRunner.java b/Robust/src/Benchmarks/Prefetch/SOR/dsm/SORRunner.java new file mode 100644 index 00000000..a4d00872 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/SOR/dsm/SORRunner.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 * + * * + * adapted from SciMark 2.0, author Roldan Pozo (pozo@cam.nist.gov) * + * * + * This version copyright (c) The University of Edinburgh, 2001. * + * All rights reserved. * + * * + **************************************************************************/ + +class SORRunner extends Thread { + + int id,num_iterations; + double G[][],omega; + long sync[][]; + int nthreads; + + public SORRunner(int id, double omega, double G[][], int num_iterations,long[][] sync, int nthreads) { + this.id = id; + this.omega=omega; + this.G=G; + this.num_iterations=num_iterations; + this.sync=sync; + this.nthreads = nthreads; + } + + public void run() { + + int tmpid, M, N, numthreads; + double omega_over_four, one_minus_omega; + atomic { + M = G.length; + N = G[0].length; + omega_over_four = omega * 0.25; + one_minus_omega = 1.0 - omega; + numthreads = nthreads; + tmpid = id; + } + + // update interior points + // + int Mm1 = M-1; + int Nm1 = N-1; + + + int ilow, iupper, slice, tslice, ttslice; + + tslice = (Mm1) / 2; + ttslice = (tslice + numthreads-1)/numthreads; + slice = ttslice*2; + ilow=tmpid*slice+1; + iupper = ((tmpid+1)*slice)+1; + if (iupper > Mm1) iupper = Mm1+1; + if (tmpid == (numthreads-1)) iupper = Mm1+1; + + atomic { + for (int p=0; p<2*num_iterations; p++) { + for (int i=ilow+(p%2); i 0) { + while (sync[id-1][0] < sync[id][0]) ; + } + if (id < nthreads -1) { + while (sync[id+1][0] < sync[id][0]) ; + } + }//end of outer for + }//end of atomic + }//end of run +} diff --git a/Robust/src/Benchmarks/Prefetch/SOR/dsm/makefile b/Robust/src/Benchmarks/Prefetch/SOR/dsm/makefile new file mode 100644 index 00000000..375d7099 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/SOR/dsm/makefile @@ -0,0 +1,16 @@ +MAINCLASS=JGFSORBenchSizeA +SRC=${MAINCLASS}.java \ +JGFSORBench.java \ +JGFInstrumentor.java \ +JGFTimer.java \ +SORRunner.java +FLAGS=-dsm -prefetch -nooptimize -debug -profile -excprefetch JGFSORBench.RandomMatrix -excprefetch JGFSORBench.init_sync -excprefetch JGFSORBench.JGFkernel -mainclass ${MAINCLASS} -o ${MAINCLASS} -trueprob 0.8 +FLAGS2=-dsm -nooptimize -debug -profile -mainclass ${MAINCLASS} -o ${MAINCLASS}NP + +default: + ../../../../buildscript ${FLAGS2} ${SRC} + ../../../../buildscript ${FLAGS} ${SRC} + +clean: + rm -rf tmpbuilddirectory + rm *.bin diff --git a/Robust/src/Benchmarks/Prefetch/SOR/java/JGFInstrumentor.java b/Robust/src/Benchmarks/Prefetch/SOR/java/JGFInstrumentor.java new file mode 100644 index 00000000..69baf77f --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/SOR/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/SOR/java/JGFSORBench.java b/Robust/src/Benchmarks/Prefetch/SOR/java/JGFSORBench.java new file mode 100644 index 00000000..b0d6c4b4 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/SOR/java/JGFSORBench.java @@ -0,0 +1,165 @@ +/************************************************************************** + * * + * 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.util.Random; + +public class JGFSORBench { + + int size; + int[] datasizes; + int JACOBI_NUM_ITER; + long RANDOM_SEED; + public int nthreads; + Random R; + public double Gtotal; + public int cachelinesize; + public long sync[][]; + + public JGFInstrumentor instr; + + public JGFSORBench(int nthreads, JGFInstrumentor instr){ + this.nthreads = nthreads; + this.instr = instr; + datasizes = new int[3]; + datasizes[0] = 1000; + datasizes[1] = 1500; + datasizes[2] = 2000; + JACOBI_NUM_ITER = 100; + RANDOM_SEED = 10101010; + R = new Random(RANDOM_SEED); + Gtotal = 0.0; + cachelinesize = 128; + } + + public void JGFsetsize(int size){ + this.size = size; + } + + public static void JGFkernel(JGFSORBench sor, JGFInstrumentor instr) { + int numthreads; + numthreads = sor.nthreads; + + double G[][] = sor.RandomMatrix(sor.datasizes[sor.size], sor.datasizes[sor.size], sor.R); + int M = G.length; + int N = G[0].length; + double omega = 1.25; + int num_iterations = sor.JACOBI_NUM_ITER; + + + double omega_over_four = omega * 0.25; + double one_minus_omega = 1.0 - omega; + + // update interior points + // + int Mm1 = M-1; + int Nm1 = N-1; + + //spawn threads + int cachelinesize = sor.cachelinesize; + + SORRunner thobjects[] = new SORRunner[numthreads]; + sor.sync = sor.init_sync(numthreads, cachelinesize); + + JGFInstrumentor.startTimer("Section2:SOR:Kernel", instr.timers); + + for(int i=1;i 1.0e-12 ){ + System.out.println("Validation failed"); + System.out.println("Gtotal = " + Gtotal + " " + dev + " " + size); + } + } + + /* + public void JGFtidyup(){ + System.gc(); + } + + public void JGFrun(int size){ + + + JGFInstrumentor.addTimer("Section2:SOR:Kernel", "Iterations",size); + + JGFsetsize(size); + JGFinitialise(); + JGFkernel(); + JGFvalidate(); + JGFtidyup(); + + + JGFInstrumentor.addOpsToTimer("Section2:SOR:Kernel", (double) (JACOBI_NUM_ITER)); + + JGFInstrumentor.printTimer("Section2:SOR:Kernel"); + } + */ + + public double[][] RandomMatrix(int M, int N, Random R) + { + double A[][] = new double[M][N]; + + for (int i=0; i Mm1) iupper = Mm1+1; + if (id == (nthreads-1)) iupper = Mm1+1; + + for (int p=0; p<2*num_iterations; p++) { + for (int i=ilow+(p%2); i 0) { + while (sync[id-1][0] < sync[id][0]) ; + } + if (id < nthreads -1) { + while (sync[id+1][0] < sync[id][0]) ; + } + } + + } +} diff --git a/Robust/src/Benchmarks/Prefetch/SOR/java/makefile b/Robust/src/Benchmarks/Prefetch/SOR/java/makefile new file mode 100644 index 00000000..ce11392a --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/SOR/java/makefile @@ -0,0 +1,8 @@ +SRC = JGFSORBenchSizeA +default: + javac ${SRC}.java +run: + java ${SRC} 2 + +clean: + rm *.class diff --git a/Robust/src/Benchmarks/Prefetch/SOR/makefile b/Robust/src/Benchmarks/Prefetch/SOR/makefile deleted file mode 100644 index 01022f32..00000000 --- a/Robust/src/Benchmarks/Prefetch/SOR/makefile +++ /dev/null @@ -1,5 +0,0 @@ -MAINCLASS=JGFSORBenchSizeA -SRC=${MAINCLASS}.java JGFInstrumentor.java JGFTimer.java JGFSORBench.java SOR.java Random.java -FLAGS=-dsm -prefetch -nooptimize -debug -mainclass ${MAINCLASS} -o ${MAINCLASS} -default: - ../../../buildscript ${FLAGS} ${SRC}