summaryrefslogtreecommitdiff
path: root/linear.c
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2008-11-14 22:27:04 +0000
committerMatt Turner <mattst88@gmail.com>2008-11-14 22:27:04 +0000
commit7225b0865e8c7697fce69224640142374b22364d (patch)
tree27fb27187a9f6010485a2f5bc0716ce1e0af7acd /linear.c
parent341997c711b8d0ba7edf70cced84762e2a82d996 (diff)
-- Remove numarrays member from structs in favor of a local variable
git-svn-id: svn://mattst88.com/svn/cleanbench/trunk@43 0d43b9a7-5ab2-4d7b-af9d-f64450cef757
Diffstat (limited to 'linear.c')
-rw-r--r--linear.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/linear.c b/linear.c
index 6cb7923..d743f97 100644
--- a/linear.c
+++ b/linear.c
@@ -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;