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;
30 public SORRunner(int id, double omega, double G[][], int num_iterations,int[][] sync, int nthreads) {
34 this.num_iterations=num_iterations;
36 this.nthreads = nthreads;
40 int tmpid, M, N, numthreads;
41 double omega_over_four, one_minus_omega;
46 omega_over_four = omega * 0.25;
47 one_minus_omega = 1.0 - omega;
48 numthreads = nthreads;
50 numiterations = num_iterations;
53 // update interior points
59 int ilow, iupper, slice, tslice, ttslice;
62 ttslice = (tslice + numthreads-1)/numthreads;
65 iupper = ((tmpid+1)*slice)+1;
66 if (iupper > Mm1) iupper = Mm1+1;
67 if (tmpid == (numthreads-1)) iupper = Mm1+1;
69 for (int p=-2; p<2*numiterations; p++) {
76 S=global new double[iupper-l][N];
77 for (int i=l; i<iupper; i++) {
80 for(int j=0;j<N;j++) {
87 for (int i=l; i<iupper; i++) {
94 for (int i=ilow+(p%2); i<iupper; i=i+2) {
97 double [] Gim1 = G[i-1];
100 double [] Gip1 = G[i+1];
102 for (int j=1; j<Nm1; j=j+2){
103 Gi[j] = omega_over_four * (Gim1[j] + Gip1[j] + Gi[j-1]
104 + Gi[j+1]) + one_minus_omega * Gi[j];
107 } else if (i == Mm1) {
109 double [] Gim2 = G[i-2];
111 for (int j=1; j<Nm1; j=j+2){
113 Gim1[j+1]=omega_over_four * (Gim2[j+1] + Gi[j+1] + Gim1[j]
114 + Gim1[j+2]) + one_minus_omega * Gim1[j+1];
120 double [] Gip1 = G[i+1];
121 double [] Gim2 = G[i-2];
123 for (int j=1; j<Nm1; j=j+2){
124 Gi[j] = omega_over_four * (Gim1[j] + Gip1[j] + Gi[j-1]
125 + Gi[j+1]) + one_minus_omega * Gi[j];
128 Gim1[j+1]=omega_over_four * (Gim2[j+1] + Gi[j+1] + Gim1[j]
129 + Gim1[j+2]) + one_minus_omega * Gim1[j+1];
140 // Signal this thread has done iteration
142 ourcount=sync[tmpid][0];
145 // Wait for neighbours;
148 if ((tmpid==0 || ourcount <= sync[tmpid-1][0])
149 &&((tmpid==(numthreads-1))||ourcount<=sync[tmpid+1][0]))
154 System.clearPrefetchCache();