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;
28 public SORRunner(int id, double omega, double G[][], int num_iterations, int nthreads) {
32 this.num_iterations=num_iterations;
33 this.nthreads = nthreads;
37 int tmpid, M, N, numthreads;
38 double omega_over_four, one_minus_omega;
41 barr = new Barrier("128.195.175.79");
43 System.printString("Inside atomic 1\n");
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=0; p<2*numiterations; p++) {
71 for (int i=ilow+(p%2); i<iupper; i=i+2) {
74 double [] Gim1 = G[i-1];
77 double [] Gip1 = G[i+1];
79 for (int j=1; j<Nm1; j=j+2){
80 Gi[j] = omega_over_four * (Gim1[j] + Gip1[j] + Gi[j-1]
81 + Gi[j+1]) + one_minus_omega * Gi[j];
84 } else if (i == Mm1) {
86 double [] Gim2 = G[i-2];
88 for (int j=1; j<Nm1; j=j+2){
90 Gim1[j+1]=omega_over_four * (Gim2[j+1] + Gi[j+1] + Gim1[j]
91 + Gim1[j+2]) + one_minus_omega * Gim1[j+1];
97 double [] Gip1 = G[i+1];
98 double [] Gim2 = G[i-2];
100 for (int j=1; j<Nm1; j=j+2){
101 Gi[j] = omega_over_four * (Gim1[j] + Gip1[j] + Gi[j-1]
102 + Gi[j+1]) + one_minus_omega * Gi[j];
105 Gim1[j+1]=omega_over_four * (Gim2[j+1] + Gi[j+1] + Gim1[j]
106 + Gim1[j+2]) + one_minus_omega * Gim1[j+1];
113 Barrier.enterBarrier(barr);