From: adash Date: Tue, 12 Feb 2008 23:53:16 +0000 (+0000) Subject: Add SOR benchmark X-Git-Tag: preEdgeChange~282 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=caac57be7a28bcd3ef5da2d0b4f36a67aeb9a340;p=IRC.git Add SOR benchmark --- diff --git a/Robust/src/Benchmarks/Prefetch/SOR/JGFInstrumentor.java b/Robust/src/Benchmarks/Prefetch/SOR/JGFInstrumentor.java new file mode 100644 index 00000000..b48928d6 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/SOR/JGFInstrumentor.java @@ -0,0 +1,178 @@ +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 new file mode 100644 index 00000000..28a65fdc --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/SOR/JGFSORBench.java @@ -0,0 +1,88 @@ +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/makefile b/Robust/src/Benchmarks/Prefetch/SOR/makefile new file mode 100644 index 00000000..01022f32 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/SOR/makefile @@ -0,0 +1,5 @@ +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}