From 332747f6df0cd2af6535d81ccde00ade374563fa Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Sat, 15 Nov 2008 02:19:34 +0000 Subject: Clean out fpemulation struct. Replace members with local static variables git-svn-id: svn://mattst88.com/svn/cleanbench/trunk@48 0d43b9a7-5ab2-4d7b-af9d-f64450cef757 --- cleanbench.c | 3 +-- emfloat.h | 11 ----------- fpemulation.c | 60 ++++++++++++++++++++++++++++++++++------------------------- nmglobal.h | 25 ------------------------- 4 files changed, 36 insertions(+), 63 deletions(-) diff --git a/cleanbench.c b/cleanbench.c index 93a6c82..abb9994 100644 --- a/cleanbench.c +++ b/cleanbench.c @@ -81,7 +81,6 @@ for (i = 0; i < NUMTESTS; i++) { ** Initialize test data structures to default ** values. */ -global_emfloatstruct.arraysize=EMFARRAYSIZE; global_ideastruct.arraysize=IDEAARRAYSIZE; global_huffstruct.arraysize=HUFFARRAYSIZE; @@ -92,7 +91,7 @@ puts("\nTEST : Iterations/sec. : Old Index : New Index"); puts(" : : Pentium 90* : AMD K6/233*"); puts("--------------------:------------------:-------------:------------"); -for(i=0;iarraysize * sizeof(InternalFPF)); + abase = malloc(ARRAY_SIZE * sizeof(InternalFPF)); if (!abase) { - printf("ERROR CONDITION\nContext: %s\n", errorcontext); + printf("ERROR CONDITION\nContext: %s\n", context); exit(1); } - bbase = malloc(locemfloatstruct->arraysize * sizeof(InternalFPF)); + bbase = malloc(ARRAY_SIZE * sizeof(InternalFPF)); if (!bbase) { - printf("ERROR CONDITION\nContext: %s\n", errorcontext); + printf("ERROR CONDITION\nContext: %s\n", context); free(abase); exit(1); } - cbase = malloc(locemfloatstruct->arraysize * sizeof(InternalFPF)); + cbase = malloc(ARRAY_SIZE * sizeof(InternalFPF)); if (!cbase) { - printf("ERROR CONDITION\nContext: %s\n", errorcontext); + printf("ERROR CONDITION\nContext: %s\n", context); free(abase); free(bbase); exit(1); } - SetupCPUEmFloatArrays(abase, bbase, locemfloatstruct->arraysize); /* FIXME: ugly */ + SetupCPUEmFloatArrays(abase, bbase); /* FIXME: ugly */ /* See if we need to do self-adjusting code.*/ if (is_adjusted == FALSE) { is_adjusted = TRUE; - locemfloatstruct->loops = 0; - /* ** Do an iteration of the tests. If the elapsed time is ** less than minimum, increase the loop count and try ** again. */ - for (; loops < CPUEMFLOATLOOPMAX; loops += loops) { - if (DoEmFloatIteration(abase, bbase, cbase, locemfloatstruct->arraysize, loops) > MINIMUM_TICKS) { - locemfloatstruct->loops = loops; + for (; i < LOOP_MAX; i += i) { + if (DoEmFloatIteration(abase, bbase, cbase, i) > MINIMUM_TICKS) { + loops = i; break; } } @@ -84,8 +94,8 @@ DoEmFloat(void) /* ** Verify that selft adjustment code worked. */ - if (locemfloatstruct->loops == 0) { - puts("CPU:EMFPU -- CMPUEMFLOATLOOPMAX limit hit"); + if (loops == 0) { + fputs("CPU:EMFPU -- CMPUEMFLOATLOOPMAX limit hit", stderr); free(abase); free(bbase); free(cbase); @@ -96,10 +106,10 @@ DoEmFloat(void) ** All's well if we get here. Repeatedly perform floating ** tests until the accumulated time is greater than the ** # of seconds requested. - ** Each iteration performs arraysize * 3 operations. + ** Each iteration performs ARRAY_SIZE * 3 operations. */ do { - total_time += DoEmFloatIteration(abase, bbase, cbase, locemfloatstruct->arraysize, locemfloatstruct->loops); + total_time += DoEmFloatIteration(abase, bbase, cbase, loops); ++iterations; } while (total_time < MINIMUM_SECONDS * CLOCKS_PER_SEC); @@ -107,7 +117,7 @@ DoEmFloat(void) free(bbase); free(cbase); - locemfloatstruct->results = (double)(iterations * locemfloatstruct->loops * CLOCKS_PER_SEC) / (double)total_time; + locemfloatstruct->results = (double)(iterations * loops * CLOCKS_PER_SEC) / (double)total_time; } /*********************** @@ -121,7 +131,7 @@ static clock_t DoEmFloatIteration(InternalFPF *abase, InternalFPF *bbase, InternalFPF *cbase, - unsigned long arraysize, unsigned long loops) + unsigned long loops) { clock_t start, stop; static unsigned char jtable[16] = {0,0,0,0,1,1,1,1,2,2,2,2,2,3,3,3}; @@ -137,7 +147,7 @@ unsigned long i; */ while(loops--) { - for(i=0;i