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 *
16 * This version copyright (c) The University of Edinburgh, 2001. *
17 * All rights reserved. *
19 **************************************************************************/
21 class LinpackRunner extends Thread {
22 int id,lda,n,info,ipvt[];
26 public LinpackRunner(int id, double a[][], int lda, int n, int ipvt[], int nthreads) {
32 this.nthreads = nthreads;
35 double abs (double d) {
42 barr = new Barrier("128.195.175.84");
43 double[] col_k, col_j;
47 int slice,ilow,iupper;
48 // gaussian elimination with partial pivoting
53 //System.printString("Atomic #1\t");
61 //System.printString("nm1 = " +nm1+ "\n");
62 for (k = 0; k < nm1; k++) {
64 //System.printString("Atomic #2\t");
67 // find l = pivot index
68 l = idamax(nlocal-k,col_k,k,1) + k;
73 // synchronise threads
74 Barrier.enterBarrier(barr);
76 // zero pivot implies this column already triangularized
79 //System.printString("Atomic #3\t");
83 Barrier.enterBarrier(barr);
84 // interchange if necessary
94 // synchronise threads
95 Barrier.enterBarrier(barr);
96 // compute multipliers
101 dscal(nlocal-(kp1),t,col_k,kp1,1);
105 // synchronise threads
106 Barrier.enterBarrier(barr);
108 // row elimination with column indexing
110 //System.printString("Atomic #4\t");
111 slice = ((nlocal-kp1) + nthreads-1)/nthreads;
112 ilow = (lid*slice)+kp1;
113 iupper = ((lid+1)*slice)+kp1;
114 if (iupper > nlocal ) iupper=nlocal;
115 if (ilow > nlocal ) ilow=nlocal;
116 //System.printString("ilow= " + ilow + " iupper= " + iupper + "\n");
117 for (j = ilow; j < iupper; j++) {
124 daxpy(nlocal-(kp1),t,col_k,kp1,1,
129 // synchronise threads
130 Barrier.enterBarrier(barr);
134 Barrier.enterBarrier(barr);
139 //System.printString("Atomic #5\t");
142 ipvt[nlocal-1] = nlocal-1;
146 if (a[(nlocal-1)][(nlocal-1)] == 0) info = nlocal-1;
152 finds the index of element having max. absolute value.
153 jack dongarra, linpack, 3/11/78.
155 int idamax( int n, double dx[], int dx_off, int incx)
164 } else if (incx != 1) {
165 // code for increment not equal to 1
166 dmax = abs(dx[0 +dx_off]);
168 for (i = 1; i < n; i++) {
169 dtemp = abs(dx[ix + dx_off]);
177 // code for increment equal to 1
179 dmax = abs(dx[0 +dx_off]);
180 for (i = 1; i < n; i++) {
181 dtemp = abs(dx[i + dx_off]);
192 scales a vector by a constant.
193 jack dongarra, linpack, 3/11/78.
195 void dscal( int n, double da, double dx[], int dx_off, int incx)
200 // code for increment not equal to 1
202 for (i = 0; i < nincx; i += incx)
205 // code for increment equal to 1
206 for (i = 0; i < n; i++)
213 constant times a vector plus a vector.
214 jack dongarra, linpack, 3/11/78.
216 void daxpy( int n, double da, double dx[], int dx_off, int incx,
217 double dy[], int dy_off, int incy)
220 if ((n > 0) && (da != 0)) {
221 if (incx != 1 || incy != 1) {
222 // code for unequal increments or equal increments not equal to 1
225 if (incx < 0) ix = (-n+1)*incx;
226 if (incy < 0) iy = (-n+1)*incy;
227 for (i = 0;i < n; i++) {
228 dy[iy +dy_off] += da*dx[ix +dx_off];
234 // code for both increments equal to 1
235 for (i=0; i < n; i++)
236 dy[i +dy_off] += da*dx[i +dx_off];