RANDOM_SEED = 10101010;
R = global new Random(RANDOM_SEED);
Gtotal = 0.0;
- cachelinesize = 128;
+ cachelinesize = 1;
}
public void JGFsetsize(int size){
SORRunner tmp;
int[] mid = new int[4];
- mid[0] = (128<<24)|(195<<16)|(175<<8)|69;
- mid[1] = (128<<24)|(195<<16)|(175<<8)|78;
+ mid[0] = (128<<24)|(195<<16)|(175<<8)|79;
+ mid[1] = (128<<24)|(195<<16)|(175<<8)|80;
mid[2] = (128<<24)|(195<<16)|(175<<8)|73;
- mid[3] = (128<<24)|(195<<16)|(175<<8)|79;
+ mid[3] = (128<<24)|(195<<16)|(175<<8)|78;
for(int i=1;i<numthreads;i++) {
atomic {
thobjects[i] = global new SORRunner(i,omega,G,num_iterations,sor.sync,numthreads);
class SORRunner extends Thread {
- int donecount, prevvalue;
int id,num_iterations;
double G[][],omega;
long sync[][];
this.num_iterations=num_iterations;
this.sync=sync;
this.nthreads = nthreads;
- this.prevvalue = 0;
- this.donecount = 0;
}
public void run() {
if (iupper > Mm1) iupper = Mm1+1;
if (tmpid == (numthreads-1)) iupper = Mm1+1;
- atomic {
for (int p=0; p<2*numiterations; p++) {
- for (int i=ilow+(p%2); i<iupper; i=i+2) {
+ atomic {
+ for (int i=ilow+(p%2); i<iupper; i=i+2) {
- double [] Gi = G[i];
- double [] Gim1 = G[i-1];
+ double [] Gi = G[i];
+ double [] Gim1 = G[i-1];
- if(i == 1) {
- double [] Gip1 = 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];
+ 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 if (i == Mm1) {
- double [] Gim2 = G[i-2];
+ 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];
+ 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 {
+ } else {
- double [] Gip1 = G[i+1];
- double [] Gim2 = G[i-2];
+ 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];
+ 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];
+ 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
// Signal this thread has done iteration
- sync[id][0]++;
- /* My modifications */
- while (donecount < nthreads-1) {
- if (sync[id][0] > prevvalue) {
- donecount++;
- }
- }
- if (id == 0) {
- donecount = 0;
- prevvalue++;
- }
- /*
// Wait for neighbours;
- if (id > 0) {
- System.printString("id: " + id + " sync: id-1 0 " + sync[id-1][0] + " id 0" + sync[id][0] + "\n");
- while (sync[id-1][0] < sync[id][0]) ;
- System.printString("id: " + id + " sync: id-1 0 " + sync[id-1][0] + " id 0" + sync[id][0] + "\n");
+ long ourcount;
+ boolean done=true;
+
+ atomic {
+ sync[tmpid][0]++;
+ ourcount=sync[tmpid][0];
}
- if (id < nthreads -1) {
- System.printString("id: " + id + " sync: id 0 " + sync[id][0] + " id+1 0" + sync[id+1][0] + "\n");
- while (sync[id+1][0] < sync[id][0]) ;
- System.printString("id: " + id + " sync: id 0 " + sync[id][0] + " id+1 0" + sync[id+1][0] + "\n");
+
+ while(done) {
+ atomic {
+ if ((tmpid==0 || ourcount <= sync[tmpid-1][0])
+ &&((tmpid==(numthreads-1))||ourcount<=sync[tmpid+1][0]))
+ done=false;
+ }
}
- */
- }
- } //end of atomic
+
+ }//end of for
} //end of run()
}
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
+ 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} -trueprob 0.8
+FLAGS2=-dsm -nooptimize -debug -profile -mainclass ${MAINCLASS}
default:
- ../../../../buildscript ${FLAGS2} ${SRC}
- ../../../../buildscript ${FLAGS} ${SRC}
+ ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}NP ${SRC}
+ ../../../../buildscript ${FLAGS} -o ${MAINCLASS} ${SRC}
+ ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}1NP ${SRC}
+ ../../../../buildscript ${FLAGS} -o ${MAINCLASS}1 ${SRC}
+ ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}2NP ${SRC}
+ ../../../../buildscript ${FLAGS} -o ${MAINCLASS}2 ${SRC}
+ ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}4NP ${SRC}
+ ../../../../buildscript ${FLAGS} -o ${MAINCLASS}4 ${SRC}
clean:
rm -rf tmpbuilddirectory