diff options
Diffstat (limited to 'linear.c')
-rw-r--r-- | linear.c | 24 |
1 files changed, 13 insertions, 11 deletions
@@ -48,7 +48,7 @@ double *LUtempvv; */ static clock_t DoLUIteration(double *a, double *b, double *abase, double *bbase, - unsigned long numarrays); + unsigned long num_arrays); static void build_problem( double a[][LUARRAYCOLS], int n, double b[LUARRAYROWS]); static int ludcmp(double a[][LUARRAYCOLS], @@ -79,6 +79,8 @@ DoLU(void) int n; int i; + int num_arrays; + /* ** Our first step is to build a "solvable" problem. This ** will become the "seed" set that all others will be @@ -110,7 +112,7 @@ DoLU(void) if (loclustruct->adjust == FALSE) { loclustruct->adjust = TRUE; - loclustruct->numarrays=0; + num_arrays=0; for(i=1;i<=MAXLUARRAYS;i++) { abase = realloc(abase, sizeof(double) * LUARRAYCOLS*LUARRAYROWS*(i+1)); @@ -132,14 +134,14 @@ DoLU(void) exit(1); } if(DoLUIteration(a,b,abase,bbase,i)>MINIMUM_TICKS) - { loclustruct->numarrays=i; + { num_arrays=i; break; } } /* ** Were we able to do it? */ - if (loclustruct->numarrays==0) { + if (num_arrays==0) { fprintf(stderr, "FPU:LU -- Array limit reached\n"); free(a); free(b); @@ -153,7 +155,7 @@ DoLU(void) ** Don't need to adjust -- just allocate the proper ** number of arrays and proceed. */ - abase = malloc(sizeof(double) * LUARRAYCOLS*LUARRAYROWS*loclustruct->numarrays); + abase = malloc(sizeof(double) * LUARRAYCOLS*LUARRAYROWS*num_arrays); if (!abase) { fprintf(stderr, "Error in %s, could not allocate memory. Exitting...\n", context); free(a); @@ -162,7 +164,7 @@ DoLU(void) exit(1); } - bbase = malloc(sizeof(double) * LUARRAYROWS*loclustruct->numarrays); + bbase = malloc(sizeof(double) * LUARRAYROWS*num_arrays); if (!bbase) { fprintf(stderr, "Error in %s, could not allocate memory. Exitting...\n", context); free(a); @@ -174,8 +176,8 @@ DoLU(void) } do { - total_time += DoLUIteration(a, b, abase, bbase, loclustruct->numarrays); - iterations += loclustruct->numarrays; + total_time += DoLUIteration(a, b, abase, bbase, num_arrays); + iterations += num_arrays; } while(total_time < MINIMUM_SECONDS * CLOCKS_PER_SEC); free(a); @@ -195,7 +197,7 @@ DoLU(void) ** identical matrices. */ static clock_t -DoLUIteration(double *a,double *b, double *abase, double *bbase, unsigned long numarrays) +DoLUIteration(double *a,double *b, double *abase, double *bbase, unsigned long num_arrays) { clock_t start, stop; double *locabase; @@ -208,7 +210,7 @@ unsigned long j,i; /* Indexes */ ** Move the seed arrays (a & b) into the destination ** arrays; */ -for(j=0;j<numarrays;j++) +for(j=0;j<num_arrays;j++) { locabase=abase+j*LUARRAYROWS*LUARRAYCOLS; locbbase=bbase+j*LUARRAYROWS; for(i=0;i<LUARRAYROWS*LUARRAYCOLS;i++) @@ -219,7 +221,7 @@ for(j=0;j<numarrays;j++) start = clock(); -for(i=0;i<numarrays;i++) +for(i=0;i<num_arrays;i++) { locabase=abase+i*LUARRAYROWS*LUARRAYCOLS; locbbase=bbase+i*LUARRAYROWS; ptra.ptrs.p=locabase; |