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[],Barrier br, int nthreads) {
34 this.nthreads = nthreads;
37 double abs (double d) {
43 double[] col_k, col_j;
47 int slice,ilow,iupper;
48 // gaussian elimination with partial pivoting
61 for (k = 0; k < nm1; k++) {
65 // find l = pivot index
66 l = idamax(nlocal-k,col_k,k,1) + k;
71 // synchronise threads
72 Barrier.enterBarrier(tmpbr);
73 System.clearPrefetchCache();
75 // zero pivot implies this column already triangularized
81 Barrier.enterBarrier(tmpbr);
82 System.clearPrefetchCache();
83 // interchange if necessary
93 // synchronise threads
94 Barrier.enterBarrier(tmpbr);
95 System.clearPrefetchCache();
96 // compute multipliers
100 dscal(nlocal-(kp1),t,col_k,kp1,1);
103 // synchronise threads
104 Barrier.enterBarrier(tmpbr);
105 System.clearPrefetchCache();
106 // row elimination with column indexing
108 slice = ((nlocal-kp1) + nthreads-1)/nthreads;
109 ilow = (lid*slice)+kp1;
110 iupper = ((lid+1)*slice)+kp1;
111 if (iupper > nlocal ) iupper=nlocal;
112 if (ilow > nlocal ) ilow=nlocal;
113 for (j = ilow; j < iupper; j++) {
120 daxpy(nlocal-(kp1),t,col_k,kp1,1,
124 // synchronise threads
125 Barrier.enterBarrier(tmpbr);
126 System.clearPrefetchCache();
130 Barrier.enterBarrier(tmpbr);
131 System.clearPrefetchCache();
137 ipvt[nlocal-1] = nlocal-1;
139 if (a[(nlocal-1)][(nlocal-1)] == 0) info = nlocal-1;
144 finds the index of element having max. absolute value.
145 jack dongarra, linpack, 3/11/78.
147 int idamax( int n, double dx[], int dx_off, int incx)
156 } else if (incx != 1) {
157 // code for increment not equal to 1
158 dmax = abs(dx[0 +dx_off]);
160 for (i = 1; i < n; i++) {
161 dtemp = abs(dx[ix + dx_off]);
169 // code for increment equal to 1
171 dmax = abs(dx[0 +dx_off]);
172 for (i = 1; i < n; i++) {
173 dtemp = abs(dx[i + dx_off]);
184 scales a vector by a constant.
185 jack dongarra, linpack, 3/11/78.
187 void dscal( int n, double da, double dx[], int dx_off, int incx)
192 // code for increment not equal to 1
194 for (i = 0; i < nincx; i += incx)
197 // code for increment equal to 1
198 for (i = 0; i < n; i++)
205 constant times a vector plus a vector.
206 jack dongarra, linpack, 3/11/78.
208 void daxpy( int n, double da, double dx[], int dx_off, int incx,
209 double dy[], int dy_off, int incy)
212 if ((n > 0) && (da != 0)) {
213 if (incx != 1 || incy != 1) {
214 // code for unequal increments or equal increments not equal to 1
217 if (incx < 0) ix = (-n+1)*incx;
218 if (incy < 0) iy = (-n+1)*incy;
219 for (i = 0;i < n; i++) {
220 dy[iy +dy_off] += da*dx[ix +dx_off];
226 // code for both increments equal to 1
227 for (i=0; i < n; i++)
228 dy[i +dy_off] += da*dx[i +dx_off];