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[];
27 public LinpackRunner(int id, double a[][], int lda, int n, int ipvt[],TournamentBarrier br, int nthreads) {
35 this.nthreads = nthreads;
38 double abs (double d) {
39 //return (d >= 0) ? d : -d;
45 double[] col_k, col_j;
49 int slice,ilow,iupper;
50 // gaussian elimination with partial pivoting
54 for (k = 0; k < nm1; k++) {
57 // find l = pivot index
58 l = idamax(n-k,col_k,k,1) + k;
62 // synchronise threads
64 // zero pivot implies this column already triangularized
67 // interchange if necessary
75 // synchronise threads
77 // compute multipliers
80 dscal(n-(kp1),t,col_k,kp1,1);
82 // synchronise threads
84 // row elimination with column indexing
85 slice = ((n-kp1) + nthreads-1)/nthreads;
86 ilow = (id*slice)+kp1;
87 iupper = ((id+1)*slice)+kp1;
88 if (iupper > n ) iupper=n;
89 if (ilow > n ) ilow=n;
90 for (j = ilow; j < iupper; j++) {
97 daxpy(n-(kp1),t,col_k,kp1,1,
100 // synchronise threads
112 if (a[(n-1)][(n-1)] == 0) info = n-1;
116 finds the index of element having max. absolute value.
117 jack dongarra, linpack, 3/11/78.
119 int idamax( int n, double dx[], int dx_off, int incx)
128 } else if (incx != 1) {
129 // code for increment not equal to 1
130 dmax = abs(dx[0 +dx_off]);
132 for (i = 1; i < n; i++) {
133 dtemp = abs(dx[ix + dx_off]);
141 // code for increment equal to 1
143 dmax = abs(dx[0 +dx_off]);
144 for (i = 1; i < n; i++) {
145 dtemp = abs(dx[i + dx_off]);
156 scales a vector by a constant.
157 jack dongarra, linpack, 3/11/78.
159 void dscal( int n, double da, double dx[], int dx_off, int incx)
164 // code for increment not equal to 1
166 for (i = 0; i < nincx; i += incx)
169 // code for increment equal to 1
170 for (i = 0; i < n; i++)
177 constant times a vector plus a vector.
178 jack dongarra, linpack, 3/11/78.
180 void daxpy( int n, double da, double dx[], int dx_off, int incx,
181 double dy[], int dy_off, int incy)
184 if ((n > 0) && (da != 0)) {
185 if (incx != 1 || incy != 1) {
186 // code for unequal increments or equal increments not equal to 1
189 if (incx < 0) ix = (-n+1)*incx;
190 if (incy < 0) iy = (-n+1)*incy;
191 for (i = 0;i < n; i++) {
192 dy[iy +dy_off] += da*dx[ix +dx_off];
198 // code for both increments equal to 1
199 for (i=0; i < n; i++)
200 dy[i +dy_off] += da*dx[i +dx_off];