--- /dev/null
+/**************************************************************************
+ * *
+ * 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");
+ }
+}
--- /dev/null
+/**************************************************************************
+ * *
+ * 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;
+ public double Gtotal;
+
+ public JGFSORBench(int nthreads){
+ this.nthreads = nthreads;
+ datasizes = global new int[4];
+ datasizes[0] = 1000;
+ datasizes[1] = 1500;
+ datasizes[2] = 2000;
+ datasizes[3] = 8000;
+ JACOBI_NUM_ITER = 100;
+ RANDOM_SEED = 10101010;
+ Gtotal = 0.0;
+ }
+
+ public void JGFsetsize(int size){
+ this.size = size;
+ }
+
+ public static void JGFkernel(JGFSORBench sor) {
+ int numthreads, datasize;
+ BarrierServer mybarr;
+
+ int[] mid = new int[8];
+ mid[0] = (128<<24)|(195<<16)|(136<<8)|162; //dw-10
+ mid[1] = (128<<24)|(195<<16)|(136<<8)|163; //dw-11
+ mid[2] = (128<<24)|(195<<16)|(136<<8)|164; //dw-12
+ mid[3] = (128<<24)|(195<<16)|(136<<8)|165; //dw-13
+ mid[4] = (128<<24)|(195<<16)|(136<<8)|166; //dw-14
+ mid[5] = (128<<24)|(195<<16)|(136<<8)|167; //dw-15
+ mid[6] = (128<<24)|(195<<16)|(136<<8)|168; //dw-16
+ mid[7] = (128<<24)|(195<<16)|(136<<8)|169; //dw-17
+
+ double[][] G;
+ int num_iterations;
+ long RANDOM_SEED;
+
+ atomic {
+ numthreads = sor.nthreads;
+ datasize = sor.datasizes[sor.size];
+ mybarr = global new BarrierServer(numthreads);
+ G = global new double[datasize][];
+ num_iterations = sor.JACOBI_NUM_ITER;
+ RANDOM_SEED = sor.RANDOM_SEED;
+ }
+ mybarr.start(mid[0]);
+
+ double omega = 1.25;
+ double omega_over_four = omega * 0.25;
+ double one_minus_omega = 1.0 - omega;
+
+ // update interior points
+ //
+ //spawn threads
+
+ SORWrap[] thobjects = new SORWrap[numthreads];
+
+ atomic {
+ for(int i=0;i<numthreads;i++) {
+ thobjects[i] = new SORWrap(global new SORRunner(i,omega,G,num_iterations,numthreads, RANDOM_SEED));
+ }
+ }
+
+ boolean waitfordone=true;
+ while(waitfordone) {
+ atomic {
+ if (mybarr.done)
+ waitfordone=false;
+ }
+ }
+
+ for(int i=0;i<numthreads;i++) {
+ thobjects[i].sor.start(mid[i]);
+ }
+
+ for(int i=0;i<numthreads;i++) {
+ thobjects[i].sor.join();
+ }
+
+ //JGFInstrumentor.stopTimer("Section2:SOR:Kernel", instr.timers);
+ atomic {
+ for (int i=1; i<G.length-1; i++) {
+ for (int j=1; j<G.length-1; j++) {
+ sor.Gtotal += G[i][j];
+ }
+ }
+ System.out.println("DEBUG: G.length= " + G.length+" sor.Gtotal= " + sor.Gtotal);
+ }
+ }
+
+ public int JGFvalidate(){
+
+ double refval[];
+ refval = new double[4];
+ refval[0] = 0.498574406322512;
+ refval[1] = 1.1234778980135105;
+ refval[2] = 1.9954895063582696;
+ refval[3] = 2.654895063582696;
+ double dev = Math.fabs(Gtotal - refval[size]);
+ long l = (long) refval[size] * 1000000;
+ long r = (long) Gtotal * 1000000;
+ if (l != r ){
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+}
--- /dev/null
+/**************************************************************************
+* *
+* 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 JGFSORBenchSizeD{
+
+ 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\n");
+ System.printString(" \n");
+ nthreads = 1;
+ }
+
+ JGFInstrumentor instr = new JGFInstrumentor();
+ //JGFInstrumentor.printHeader(2,0,nthreads);
+
+ JGFSORBench sor;
+ atomic {
+ sor = global new JGFSORBench(nthreads);
+ }
+
+ int size = 3;
+
+ atomic {
+ sor.JGFsetsize(size);
+ }
+ JGFSORBench.JGFkernel(sor);
+ int retval = 0;
+ /*
+ atomic {
+ retval = sor.JGFvalidate();
+ }
+ */
+ if(retval!=0) {
+ System.printString("Validation failed\n");
+ }
+
+ int jacobi;
+ atomic {
+ jacobi = sor.JACOBI_NUM_ITER;
+ }
+ System.printString("Finished\n");
+ }
+}
--- /dev/null
+/**************************************************************************
+ * *
+ * 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");
+ }
+
+}
--- /dev/null
+/**************************************************************************
+ * *
+ * 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;
+ int nthreads;
+ long RANDOM_SEED;
+
+ public SORRunner(int id, double omega, double G[][], int num_iterations, int nthreads, long RANDOM_SEED) {
+ this.id = id;
+ this.omega=omega;
+ this.G=G;
+ this.num_iterations=num_iterations;
+ this.nthreads = nthreads;
+ this.RANDOM_SEED = RANDOM_SEED;
+ }
+
+ public void run() {
+ int tmpid, M, N, numthreads;
+ double omega_over_four, one_minus_omega;
+ int numiterations;
+ Barrier barr;
+ barr = new Barrier("128.195.136.162");
+ int ilow, iupper, slice, tslice, ttslice, Mm1, Nm1;
+
+ atomic {
+ N = M = G.length;
+
+ omega_over_four = omega * 0.25;
+ one_minus_omega = 1.0 - omega;
+ numthreads = nthreads;
+ tmpid = id;
+ numiterations = num_iterations;
+ Mm1 = M-1;
+ Nm1 = N-1;
+ tslice = (Mm1) / 2;
+ ttslice = (tslice + numthreads-1)/numthreads;
+ slice = ttslice*2;
+ ilow=tmpid*slice+1;
+ iupper = ((tmpid+1)*slice)+1;
+
+ short[] offsets = new short[4];
+ offsets[0] = getoffset{SORRunner, G};
+ offsets[1] = (short) 0;
+ offsets[2] = (short) ilow;
+ offsets[3] = (short) iupper;
+ System.rangePrefetch(this, offsets);
+
+ if (iupper > Mm1) iupper = Mm1+1;
+ if (tmpid == (numthreads-1)) iupper = Mm1+1;
+ G[0]=global new double[N];
+ for(int i=ilow;i<iupper;i++) {
+ G[i]=global new double[N];
+ }
+ }
+ Barrier.enterBarrier(barr);
+
+ atomic {
+ Random rand=new Random(RANDOM_SEED);
+ double[] R = G[0];
+ for(int j=0;j<M;j++)
+ R[j]=rand.nextDouble() * 1e-6;
+ for(int i=ilow;i<iupper;i++) {
+ R=G[i];
+ for(int j=0;j<M;j++)
+ R[j]=rand.nextDouble() * 1e-6;
+ }
+ }
+ Barrier.enterBarrier(barr);
+
+ // update interior points
+ //
+
+ for (int p=0; p<2*numiterations; p++) {
+ atomic {
+ for (int i=ilow+(p%2); i<iupper; i=i+2) {
+
+ double [] Gi = G[i];
+ double [] Gim1 = G[i-1];
+
+ if(i == 1) {
+ double [] Gip1 = G[i+1];
+
+ for (int j=1; j<Nm1; j=j+2){
+ Gi[j] = omega_over_four * (Gim1[j] + Gip1[j] + Gi[j-1]
+ + Gi[j+1]) + one_minus_omega * Gi[j];
+
+ }
+ } else if (i == Mm1) {
+
+ } else {
+
+ double [] Gip1 = G[i+1];
+
+ for (int j=1; j<Nm1; j=j+2){
+ Gi[j] = omega_over_four * (Gim1[j] + Gip1[j] + Gi[j-1]
+ + Gi[j+1]) + one_minus_omega * Gi[j];
+
+ }
+ }
+ }
+ } //close atomic
+
+ Barrier.enterBarrier(barr);
+ atomic {
+ for (int i=ilow+(p%2); i<iupper; i=i+2) {
+
+ double [] Gi = G[i];
+ double [] Gim1 = G[i-1];
+
+ if(i == 1) {
+ } else if (i == Mm1) {
+
+ double [] Gim2 = G[i-2];
+
+ for (int j=1; j<Nm1; j=j+2){
+ if((j+1) != Nm1) {
+ Gim1[j+1]=omega_over_four * (Gim2[j+1] + Gi[j+1] + Gim1[j]
+ + Gim1[j+2]) + one_minus_omega * Gim1[j+1];
+ }
+ }
+
+ } else {
+
+ double [] Gim2 = G[i-2];
+
+ for (int j=1; j<Nm1; j=j+2){
+ if((j+1) != Nm1) {
+ Gim1[j+1]=omega_over_four * (Gim2[j+1] + Gi[j+1] + Gim1[j]
+ + Gim1[j+2]) + one_minus_omega * Gim1[j+1];
+ }
+ }
+ }
+ }
+ } //close atomic
+
+ Barrier.enterBarrier(barr);
+ }//end of for
+ } //end of run()
+}
--- /dev/null
+public class SORWrap {
+ public global SORRunner sor;
+ public SORWrap() {
+ }
+
+ public SORWrap(SORRunner e) {
+ sor=e;
+ }
+}
\ No newline at end of file
--- /dev/null
+MAINCLASS=JGFSORBenchSizeD
+SRC=${MAINCLASS}.java \
+ JGFSORBench.java \
+ JGFInstrumentor.java \
+ JGFTimer.java \
+ SORRunner.java \
+ SORWrap.java \
+ ../../../../ClassLibrary/JavaDSM/Barrier.java
+
+FLAGS=-dsm -transstats -rangeprefetch -dsmcaching -builddir tmpbuilddirectory2 -optimize -excprefetch JGFSORBench.JGFSORBench -excprefetch JGFSORBenchSizeA.main -excprefetch JGFSORBench.RandomMatrix -excprefetch JGFSORBench.init_sync -excprefetch JGFSORBench.JGFkernel -trueprob 0.72
+FLAGS1=-dsm -dsmcaching -transstats -optimize -builddir tmpbuilddirectory1 -mainclass ${MAINCLASS}
+FLAGS2=-dsm -optimize -transstats
+
+FLAGSP=-dsm -prefetch -dsmcaching -optimize -builddir tmpbuilddirectory2 -excprefetch JGFSORBench.JGFSORBench -excprefetch JGFSORBenchSizeA.main -excprefetch JGFSORBench.RandomMatrix -excprefetch JGFSORBench.init_sync -excprefetch JGFSORBench.JGFkernel -trueprob 0.72
+FLAGSNPC=-dsm -dsmcaching -optimize -builddir tmpbuilddirectory1 -mainclass ${MAINCLASS}
+FLAGSNPNC=-dsm -optimize
+
+default:
+# ../../../../buildscript ${FLAGSNPNC} -mainclass ${MAINCLASS} -o ${MAINCLASS}NPNC ${SRC}
+# ../../../../buildscript ${FLAGSNPC} -mainclass ${MAINCLASS} -o ${MAINCLASS}NPC ${SRC}
+# ../../../../buildscript ${FLAGSP} -mainclass ${MAINCLASS} -o ${MAINCLASS}N ${SRC}
+ ../../../../buildscript ${FLAGS} -mainclass ${MAINCLASS} -o ${MAINCLASS}RangeN ${SRC}
+ ../../../../buildscript ${FLAGS2} -mainclass ${MAINCLASS} -o ${MAINCLASS}NPNC ${SRC}
+ ../../../../buildscript ${FLAGS1} -mainclass ${MAINCLASS} -o ${MAINCLASS}NPC ${SRC}
+
+clean:
+ rm -rf tmpbuilddirectory
+ rm *.bin