public static void JGFkernel(JGFSORBench sor) {
int numthreads, datasize;
-
double[][] G;
int num_iterations;
+ long RANDOM_SEED;
numthreads = sor.nthreads;
datasize = sor.datasizes[sor.size];
G = new double[datasize][];
num_iterations = sor.JACOBI_NUM_ITER;
+ RANDOM_SEED = sor.RANDOM_SEED;
double omega = 1.25;
double omega_over_four = omega * 0.25;
SORWrap[] thobjects = new SORWrap[numthreads];
- for(int i=0;i<numthreads;i++) {
- thobjects[i] = new SORWrap( new SORRunner(i,omega,G,num_iterations,numthreads));
- }
+ for(int i=0;i<numthreads;i++) {
+ thobjects[i] = new SORWrap(new SORRunner(i,omega,G,num_iterations,numthreads, RANDOM_SEED));
+ }
for(int i=0;i<numthreads;i++) {
thobjects[i].sor.run();
}
//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];
- }
- }
+ 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(){
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) {
+ 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() {
iupper = ((tmpid+1)*slice)+1;
if (iupper > Mm1) iupper = Mm1+1;
if (tmpid == (numthreads-1)) iupper = Mm1+1;
- G[0]= new double[N];
+ G[0]=new double[N];
for(int i=ilow;i<iupper;i++) {
- G[i]= new double[N];
+ G[i]=new double[N];
}
- Random rand=new Random();
+ Random rand=new Random(RANDOM_SEED);
double[] R = G[0];
for(int j=0;j<M;j++)
R[j]=rand.nextDouble() * 1e-6;
}
}
}
-
}//end of for
} //end of run()
}