AStarPathFinder.java
FLAGS1=-dsm -optimize -mainclass ${MAINCLASS}
-FLAGS2=-dsm -dsmcaching -transstats -abortreaders -optimize -mainclass ${MAINCLASS}
-FLAGS3=-dsm -dsmcaching -transstats -abortreaders -prefetch -optimize -mainclass ${MAINCLASS} -excprefetch BarrierServer.updateAge -excprefetch RainForest.main -excprefetch GameMap.hasRock -excprefetch GameMap.hasTree -trueprob 0.90
+FLAGS2=-dsm -dsmcaching -abortreaders -optimize -mainclass ${MAINCLASS}
+FLAGS3=-dsm -dsmcaching -abortreaders -prefetch -optimize -mainclass ${MAINCLASS} -excprefetch BarrierServer.updateAge -excprefetch RainForest.main -excprefetch GameMap.hasRock -excprefetch GameMap.hasTree -trueprob 0.90
default:
cpp ${MAINCLASS}.java > tmp1${MAINCLASS}.java
-#define ROW 100 /* columns in the map */
+#define ROW 400 /* columns in the map */
#define COLUMN 100 /* rows of in the map */
-#define ROUNDS 256 /* Number of moves by each player */
+#define ROUNDS 512 /* Number of moves by each player */
#define PLAYERS 20 /* Number of Players when num Players != num of client machines */
#define RATI0 0.5 /* Number of lumberjacks to number of planters */
#define BLOCK 3 /* Area around the gamer to consider */
-#define ROW 100 /* columns in the map */
+#define ROW 400 /* columns in the map */
#define COLUMN 100 /* rows of in the map */
public class RainForestServerExample {
${MAINCLASS}Wrap.java \
BiGraph2.java \
Node2.java \
- EVector.java
+ EVector.java \
+ ../../../../ClassLibrary/JavaDSM/Barrier.java
FLAGS=-dsm -prefetch -optimize -excprefetch Em3d.main -excprefetch BiGraph.create -excprefetch Node.Node -excprefetch Node.fillTable -excprefetch Node.makeUniqueNeighbors -excprefetch Node.makeFromNodes -excprefetch Node.updateFromNodes -debug -mainclass ${MAINCLASS} -trueprob 0.85
-FLAGS1=-dsm -prefetch -dsmcaching -optimize -excprefetch Node.makeUniqueNeighbors -excprefetch EVector.ensureCapacity -excprefetch EVector.addElement -excprefetch BiGraph.makeFromNodes -excprefetch EVector.elementAt -excprefetch BiGraph.initializeNodes -excprefetch BiGraph.allocateNodes -mainclass ${MAINCLASS} -trueprob 0.85
+FLAGS1=-dsm -prefetch -transstats -dsmcaching -optimize -excprefetch Node.makeUniqueNeighbors -excprefetch EVector.ensureCapacity -excprefetch EVector.addElement -excprefetch BiGraph.makeFromNodes -excprefetch EVector.elementAt -excprefetch BiGraph.initializeNodes -excprefetch BiGraph.allocateNodes -mainclass ${MAINCLASS} -trueprob 0.85
FLAGS2=-dsm -dsmcaching -optimize -mainclass ${MAINCLASS} -trueprob 0.85
FLAGS3=-dsm -optimize -mainclass ${MAINCLASS} -trueprob 0.85
SORWrap.java \
../../../../ClassLibrary/JavaDSM/Barrier.java
-FLAGS=-dsm -prefetch -transstats -dsmcaching -optimize -excprefetch JGFSORBench.JGFSORBench -excprefetch JGFSORBenchSizeA.main -excprefetch JGFSORBench.RandomMatrix -excprefetch JGFSORBench.init_sync -excprefetch JGFSORBench.JGFkernel -trueprob 0.72
-FLAGS1=-dsm -dsmcaching -optimize -debug -mainclass ${MAINCLASS}
+FLAGS=-dsm -prefetch -dsmcaching -optimize -excprefetch JGFSORBench.JGFSORBench -excprefetch JGFSORBenchSizeA.main -excprefetch JGFSORBench.RandomMatrix -excprefetch JGFSORBench.init_sync -excprefetch JGFSORBench.JGFkernel -trueprob 0.72
+FLAGS1=-dsm -dsmcaching -optimize -mainclass ${MAINCLASS}
FLAGS2=-dsm -optimize
default:
../../../../buildscript ${FLAGS2} -mainclass ${MAINCLASS} -o ${MAINCLASS}NPNC ${SRC}
../../../../buildscript ${FLAGS} -mainclass ${MAINCLASS} -o ${MAINCLASS}N ${SRC}
- ../../../../buildscript ${FLAGS2} -mainclass ${MAINCLASS1} -o ${MAINCLASS1}NPNC ${SRC1}
- ../../../../buildscript ${FLAGS} -mainclass ${MAINCLASS1} -o ${MAINCLASS1}N ${SRC1}
+# ../../../../buildscript ${FLAGS2} -mainclass ${MAINCLASS1} -o ${MAINCLASS1}NPNC ${SRC1}
+# ../../../../buildscript ${FLAGS} -mainclass ${MAINCLASS1} -o ${MAINCLASS1}N ${SRC1}
clean:
rm -rf tmpbuilddirectory
* All rights reserved. *
* *
**************************************************************************/
-
-import java.util.Random;
-
public class JGFSORBench {
int size;
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){
+ public JGFSORBench(int nthreads){
this.nthreads = nthreads;
- this.instr = instr;
datasizes = new int[4];
datasizes[0] = 1000;
datasizes[1] = 1500;
datasizes[3] = 8000;
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;
+ public static void JGFkernel(JGFSORBench sor) {
+ int numthreads, datasize;
- 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[][] G;
+ int num_iterations;
+ numthreads = sor.nthreads;
+ datasize = sor.datasizes[sor.size];
+ G = new double[datasize][];
+ num_iterations = sor.JACOBI_NUM_ITER;
+ double omega = 1.25;
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);
+ SORWrap[] thobjects = new SORWrap[numthreads];
- JGFInstrumentor.startTimer("Section2:SOR:Kernel", instr.timers);
+ for(int i=0;i<numthreads;i++) {
+ thobjects[i] = new SORWrap( new SORRunner(i,omega,G,num_iterations,numthreads));
+ }
- for(int i=1;i<numthreads;i++) {
- thobjects[i] = new SORRunner(i,omega,G,num_iterations,sor.sync,numthreads);
- thobjects[i].start();
+ for(int i=0;i<numthreads;i++) {
+ thobjects[i].sor.run();
}
- thobjects[0] = new SORRunner(0,omega,G,num_iterations,sor.sync,numthreads);
- thobjects[0].start();
- thobjects[0].join();
-
-
- for(int i=1;i<numthreads;i++) {
- thobjects[i].join();
- }
-
- JGFInstrumentor.stopTimer("Section2:SOR:Kernel", instr.timers);
-
- for (int i=1; i<Nm1; i++) {
- for (int j=1; j<Nm1; j++) {
- sor.Gtotal += G[i][j];
- }
- }
-
- }
-
- private long[][] init_sync(int nthreads, int cachelinesize) {
- long sync[][] = new long [nthreads][cachelinesize];
- for (int i = 0; i<nthreads; i++)
- sync[i][0] = 0;
- return sync;
+ //JGFInstrumentor.stopTimer("Section2:SOR:Kernel", instr.timers);
+ for (int i=1; i<G.length-1; i++) {
+ for (int j=1; j<G.length-1; j++) {
+ sor.Gtotal += G[i][j];
+ }
+ }
}
- 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.printString("Validation failed");
- System.printString("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<N; i++)
- for (int j=0; j<N; j++)
- {
- A[i][j] = R.nextDouble() * 1e-6;
- }
- return A;
+ 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;
+ }
}
-
-
}
/**************************************************************************
-* *
-* 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. *
-* *
-**************************************************************************/
+ * *
+ * 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;
+ 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) {
+ public SORRunner(int id, double omega, double G[][], int num_iterations, 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;
+ int numiterations;
+ int ilow, iupper, slice, tslice, ttslice, Mm1, Nm1;
+
+ 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;
+ if (iupper > Mm1) iupper = Mm1+1;
+ if (tmpid == (numthreads-1)) iupper = Mm1+1;
+ G[0]= new double[N];
+ for(int i=ilow;i<iupper;i++) {
+ G[i]= new double[N];
+ }
- int M = G.length;
- int N = G[0].length;
-
- double omega_over_four = omega * 0.25;
- double one_minus_omega = 1.0 - omega;
+ Random rand=new Random();
+ 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;
+ }
// update interior points
//
- int Mm1 = M-1;
- int Nm1 = N-1;
-
-
- int ilow, iupper, slice, tslice, ttslice;
-
- tslice = (Mm1) / 2;
- ttslice = (tslice + nthreads-1)/nthreads;
- slice = ttslice*2;
- ilow=id*slice+1;
- iupper = ((id+1)*slice)+1;
- if (iupper > Mm1) iupper = Mm1+1;
- if (id == (nthreads-1)) iupper = Mm1+1;
- for (int p=0; p<2*num_iterations; p++) {
+ for (int p=0; p<2*numiterations; p++) {
for (int i=ilow+(p%2); i<iupper; i=i+2) {
double [] Gi = G[i];
}
} 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];
+
+ }
+ }
+ }
+
+ 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){
} else {
- double [] Gip1 = G[i+1];
double [] Gim2 = G[i-2];
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];
-
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];
}
}
}
-
- }
-
- // Signal this thread has done iteration
- sync[id][0]++;
-
- // Wait for neighbours;
- if (id > 0) {
- while (sync[id-1][0] < sync[id][0]) ;
- }
- if (id < nthreads -1) {
- while (sync[id+1][0] < sync[id][0]) ;
}
- }
- }
+ }//end of for
+ } //end of run()
}
FLAGS=-thread -optimize -mainclass ${MAINCLASS} -o ${MAINCLASS}
default:
- ../../../../buildscript ${FLAGS} ${SRC1}
+# ../../../../buildscript ${FLAGS} ${SRC1}
../../../../buildscript ${FLAGS2} ${SRC2}
clean:
TreeT t;
atomic {
t=global new TreeT();
- t.numTrees=5000;
- t.TreeDepth=10;
+ t.numTrees=20000;
+ t.TreeDepth=5;
}
t.start((128<<24)|(195<<16)|(136<<8)|162);
t.join();
tt = global new Tree[numTrees];
for(int i =0; i<numTrees; i++) {
tt[i] = global new Tree(TreeDepth);
- tt[i].Populate(tt[i].root);
+ int depth = tt[i].iDepth;
+ tt[i].Populate(tt[i].root, depth);
}
}
}
+ public void exec() {
+ Random r = new Random(241);
+ for (int i=0; i <numTrees; i++) {
+ Node n = tt[i].root;
+ while (n != null) {
+ int choice = r.nextInt(2);
+ if (choice == 0) {
+ //System.out.println("i= " + i + " n.data= " +n.element);
+ n = n.left;
+ } else {
+ //System.out.println("i= " + i + " n.data= " +n.element);
+ n = n.right;
+ }
+ }
+ }
+ }
+ /*
public void exec() {
Random r = new Random(241);
for(int i=0; i<numTrees; i++) {
}
}
}
+ */
}
class Tree {
}
// Build tree top down, assigning to older objects.
- public void Populate(Node n) {
+ public void Populate(Node n, int depth) {
Random r = new Random(0);
//pick a random seed
- if (iDepth<=0) {
+ if (depth<=0) {
return;
} else {
- iDepth--;
+ depth--;
//n.left = global new Node(r.nextInt(100));
//n.right = global new Node(r.nextInt(100));
- n.left = global new Node(iDepth);
+ n.left = global new Node(depth);
n.left.parent = n;
- n.right = global new Node(iDepth+100);
+ n.right = global new Node(depth+100);
n.right.parent = n;
- this.Populate(n.left);
- this.Populate(n.right);
+ Populate(n.left, depth);
+ Populate(n.right, depth);
}
}
-
-
}
// Basic node stored in unbalanced binary search trees
MAINCLASS=TreeT
SRC1=Tree.java
-FLAGS=-dsm -transstats -debug -prefetch -dsmcaching -optimize -excprefetch Tree.Populate -excprefetch Node.Inorder -excprefetch Node.Postorder -excprefetch TreeT.run -excprefetch TreeT.main -mainclass ${MAINCLASS} -trueprob 0.90
+FLAGS=-dsm -prefetch -dsmcaching -optimize -excprefetch Tree.Populate -excprefetch Node.Inorder -excprefetch Node.Postorder -excprefetch TreeT.run -excprefetch TreeT.main -mainclass ${MAINCLASS} -trueprob 0.98
FLAGS1=-dsm -dsmcaching -optimize -mainclass ${MAINCLASS} -trueprob 0.98
FLAGS2=-dsm -optimize -mainclass ${MAINCLASS}
default: