1 /**************************************************************************
3 * Java Grande Forum Benchmark Suite - Thread Version 1.0 *
7 * Java Grande Benchmarking Project *
11 * Edinburgh Parallel Computing Centre *
13 * email: epcc-javagrande@epcc.ed.ac.uk *
15 * adapted from SciMark 2.0, author Roldan Pozo (pozo@cam.nist.gov) *
17 * This version copyright (c) The University of Edinburgh, 2001. *
18 * All rights reserved. *
20 **************************************************************************/
22 class SORRunner extends Thread {
24 int id,num_iterations;
29 public SORRunner(int id, double omega, double G[][], int num_iterations,long[][] sync, int nthreads) {
33 this.num_iterations=num_iterations;
35 this.nthreads = nthreads;
40 int tmpid, M, N, numthreads;
41 double omega_over_four, one_minus_omega;
45 omega_over_four = omega * 0.25;
46 one_minus_omega = 1.0 - omega;
47 numthreads = nthreads;
51 // update interior points
57 int ilow, iupper, slice, tslice, ttslice;
60 ttslice = (tslice + numthreads-1)/numthreads;
63 iupper = ((tmpid+1)*slice)+1;
64 if (iupper > Mm1) iupper = Mm1+1;
65 if (tmpid == (numthreads-1)) iupper = Mm1+1;
68 for (int p=0; p<2*num_iterations; p++) {
69 for (int i=ilow+(p%2); i<iupper; i=i+2) {
72 double [] Gim1 = G[i-1];
75 double [] Gip1 = G[i+1];
77 for (int j=1; j<Nm1; j=j+2){
78 Gi[j] = omega_over_four * (Gim1[j] + Gip1[j] + Gi[j-1]
79 + Gi[j+1]) + one_minus_omega * Gi[j];
82 } else if (i == Mm1) {
84 double [] Gim2 = G[i-2];
86 for (int j=1; j<Nm1; j=j+2){
88 Gim1[j+1]=omega_over_four * (Gim2[j+1] + Gi[j+1] + Gim1[j]
89 + Gim1[j+2]) + one_minus_omega * Gim1[j+1];
95 double [] Gip1 = G[i+1];
96 double [] Gim2 = G[i-2];
98 for (int j=1; j<Nm1; j=j+2){
99 Gi[j] = omega_over_four * (Gim1[j] + Gip1[j] + Gi[j-1]
100 + Gi[j+1]) + one_minus_omega * Gi[j];
103 Gim1[j+1]=omega_over_four * (Gim2[j+1] + Gi[j+1] + Gim1[j]
104 + Gim1[j+2]) + one_minus_omega * Gim1[j+1];
111 // Signal this thread has done iteration
114 // Wait for neighbours;
116 while (sync[id-1][0] < sync[id][0]) ;
118 if (id < nthreads -1) {
119 while (sync[id+1][0] < sync[id][0]) ;