diff options
-rw-r--r-- | assignment.c | 13 | ||||
-rw-r--r-- | bitfield.c | 17 | ||||
-rw-r--r-- | cleanbench.c | 190 | ||||
-rw-r--r-- | fourier.c | 12 | ||||
-rw-r--r-- | fpemulation.c | 12 | ||||
-rw-r--r-- | huffman.c | 12 | ||||
-rw-r--r-- | idea.c | 13 | ||||
-rw-r--r-- | linear.c | 12 | ||||
-rw-r--r-- | neural.c | 13 | ||||
-rw-r--r-- | numsort.c | 12 | ||||
-rw-r--r-- | stringsort.c | 13 |
11 files changed, 96 insertions, 223 deletions
diff --git a/assignment.c b/assignment.c index a4f4d03..6d653ca 100644 --- a/assignment.c +++ b/assignment.c @@ -49,8 +49,6 @@ static int first_assignments(long tableau[][ASSIGNCOLS], static void second_assignments(long tableau[][ASSIGNCOLS], short assignedtableau[][ASSIGNCOLS]); -static double results; - /************* ** DoAssign ** ************** @@ -69,7 +67,7 @@ static double results; ** probably non-optimal constructs. ** */ -void +double DoAssign(void) { const char* context = "CPU:Assignment"; @@ -121,7 +119,7 @@ DoAssign(void) free(array); - results = (double)(iterations * CLOCKS_PER_SEC *num_arrays) / (double)total_time; + return (double)(iterations * CLOCKS_PER_SEC *num_arrays) / (double)total_time; } @@ -521,11 +519,4 @@ for(i=0;i<ASSIGNROWS;i++) if(linescol[j]==1) tableau[i][j]+=smallest; -return; -} - -double -getAssignmentScore(void) -{ - return results; } @@ -33,15 +33,13 @@ static void FlipBitRun(unsigned long *bitmap, unsigned long bit_addr, unsigned long nbits); -static double results; - /************* ** DoBitops ** ************** ** Perform the bit operations test portion of the CPU ** benchmark. Returns the iterations per second. */ -void +double DoBitops(void) { const char* context = "CPU:Bitfields"; @@ -110,15 +108,10 @@ DoBitops(void) iterations += nbitops; } while (total_time < MINIMUM_SECONDS * CLOCKS_PER_SEC); - /* - ** Clean up, calculate results, and go home. - ** Also, set adjustment flag to show that we don't have - ** to do self adjusting in the future. - */ free(bitarray); free(bitoparray); - results = (double)(iterations * CLOCKS_PER_SEC) / (double)total_time; + return (double)(iterations * CLOCKS_PER_SEC) / (double)total_time; } /************************ @@ -255,9 +248,3 @@ void ToggleBitRun(unsigned long *bitmap, /* Bitmap */ } } } - -double -getBitfieldScore(void) -{ - return results; -} diff --git a/cleanbench.c b/cleanbench.c index 6792bce..c5245f2 100644 --- a/cleanbench.c +++ b/cleanbench.c @@ -10,31 +10,19 @@ #include "cleanbench.h" #include "randnum.h" -void DoNumSort(void); -void DoStringSort(void); -void DoBitops(void); -void DoEmFloat(void); -void DoFourier(void); -void DoAssign(void); -void DoIDEA(void); -void DoHuffman(void); -void DoNNET(void); -void DoLU(void); +double DoNumSort(void); +double DoStringSort(void); +double DoBitops(void); +double DoEmFloat(void); +double DoFourier(void); +double DoAssign(void); +double DoIDEA(void); +double DoHuffman(void); +double DoNNET(void); +double DoLU(void); -double getNumSortScore(void); -double getStringSortScore(void); -double getBitfieldScore(void); -double getEmFloatScore(void); -double getFourierScore(void); -double getAssignmentScore(void); -double getIDEAScore(void); -double getHuffmanScore(void); -double getNNETScore(void); -double getLinearScore(void); - -static int bench_with_confidence(int fid, double *mean, double *stdev, unsigned long *numtries); -static int calc_confidence(double scores[], int num_scores, double *c_half_interval,double *smean, double *sdev); -static double getScore(int fid); +static int bench_with_confidence(int benchmark, double* average, double* std_dev, int* runs); +static int calc_confidence(double scores[], int num_scores, double *c_half_interval,double* average, double* std_dev); #define NUMTESTS 10 @@ -109,7 +97,7 @@ main(int argc, char *argv[]) double fpindex = 1.0; /* Old Floating-point index */ double average; /* Average of benchmark results */ double std_dev; /* Standard deviation of benchmark results */ - unsigned long runs; /* # of runs */ + int runs; /* # of runs */ int benchmark = 0; puts( "TEST : Iterations/sec. : Old Index : New Index\n" @@ -142,7 +130,7 @@ main(int argc, char *argv[]) "INTEGER INDEX : %.3f\n" "FLOATING-POINT INDEX: %.3f\n" "Baseline (MSDOS) : Pentium 90, 256 KB L2-cache, Watcom compiler 10.0\n" - "==============================LINUX DATA BELOW===============================\n", + "===========================LINUX BENCHMARK RESULTS===========================\n", pow(intindex, .142857), pow(fpindex, .33333)); hardware(); #include "sysinfo.c" @@ -169,73 +157,67 @@ main(int argc, char *argv[]) ** along. We simply do more runs and hope to get a big enough sample ** size so that things stabilize. Uwe F. Mayer ** -** Return true; false on failure. Returns mean +** Return true; false on failure. Returns average ** and standard deviation through argument list if successful. */ -static int bench_with_confidence(int benchmark, - double *mean, /* Mean of scores */ - double *stdev, /* Standard deviation */ - unsigned long *numtries) /* # of attempts */ +static int +bench_with_confidence(int benchmark, double* average, double* std_dev, int* runs) { -void (*funcpointer[])(void) = -{ DoNumSort, - DoEmFloat, - DoIDEA, - DoHuffman, - DoStringSort, - DoBitops, - DoAssign, - DoFourier, - DoNNET, - DoLU }; - -double myscores[30]; /* Need at least 5 scores, use at most 30 */ -double c_half_interval; /* Confidence half interval */ -int i; /* Index */ -/* double newscore; */ /* For improving confidence interval */ + double (*funcpointer[])(void) = { + DoNumSort, + DoEmFloat, + DoIDEA, + DoHuffman, + DoStringSort, + DoBitops, + DoAssign, + DoFourier, + DoNNET, + DoLU + }; -/* -** Get first 5 scores. Then begin confidence testing. -*/ -for (i=0;i<5;i++) -{ (*funcpointer[benchmark])(); - myscores[i]=getScore(benchmark); -} -*numtries=5; /* Show 5 attempts */ + double myscores[30]; /* Need at least 5 scores, use at most 30 */ + double c_half_interval; /* Confidence half interval */ + int i; /* Index */ -/* -** The system allows a maximum of 30 tries before it gives -** up. Since we've done 5 already, we'll allow 25 more. -*/ + /* + ** Get first 5 scores. Then begin confidence testing. + */ + for (i = 0; i < 5; i++) { + myscores[i] = (*funcpointer[benchmark])(); + } + *runs = 5; /* Show 5 attempts */ -/* -** Enter loop to test for confidence criteria. -*/ -while(1) -{ /* - ** Calculate confidence. Should always return true + ** The system allows a maximum of 30 tries before it gives + ** up. Since we've done 5 already, we'll allow 25 more. */ - if (0!=calc_confidence(myscores, - *numtries, - &c_half_interval, - mean, - stdev)) return false; /* - ** Is the length of the half interval 5% or less of mean? - ** If so, we can go home. Otherwise, we have to continue. + ** Enter loop to test for confidence criteria. */ - if(c_half_interval/ (*mean) <= (double)0.05) - break; + while(1) { + /* Calculate confidence. Should always return true */ + if (0!=calc_confidence(myscores, + *runs, + &c_half_interval, + average, + std_dev)) return false; - /* We now simply add a new test run and hope that the runs - finally stabilize, Uwe F. Mayer */ - if(*numtries==30) return false; - (*funcpointer[benchmark])(); - myscores[*numtries]=getScore(benchmark); - *numtries+=1; -} + /* + ** Is the length of the half interval 5% or less of average? + ** If so, we can go home. Otherwise, we have to continue. + */ + if (c_half_interval / (*average) <= 0.05) { + break; + } + + /* We now simply add a new test run and hope that the runs + finally stabilize, Uwe F. Mayer */ + if(*runs == 30) return false; + myscores[*runs] = (*funcpointer[benchmark])(); + *runs += 1; + } return true; } @@ -244,7 +226,7 @@ while(1) ** calc_confidence ** ********************* ** Given a set of numtries scores, calculate the confidence -** half-interval. We'll also return the sample mean and sample +** half-interval. We'll also return the sample average and sample ** standard deviation. ** NOTE: This routines presumes a confidence of 95% and ** a confidence coefficient of .95 @@ -253,8 +235,8 @@ while(1) static int calc_confidence(double scores[], /* Array of scores */ int num_scores, /* number of scores in array */ double *c_half_interval, /* Confidence half-int */ - double *smean, /* Standard mean */ - double *sdev) /* Sample stand dev */ + double *average, /* Standard average */ + double *std_dev) /* Sample stand dev */ { /* Here is a list of the student-t distribution up to 29 degrees of freedom. The value at 0 is bogus, as there is no value for zero @@ -271,21 +253,21 @@ if ((num_scores<2) || (num_scores>30)) { return true; } /* -** First calculate mean. +** First calculate average. */ -*smean=(double)0.0; +*average=(double)0.0; for(i=0;i<num_scores;i++){ - *smean+=scores[i]; + *average+=scores[i]; } -*smean/=(double)num_scores; +*average/=(double)num_scores; /* Get standard deviation */ -*sdev=(double)0.0; +*std_dev=(double)0.0; for(i=0;i<num_scores;i++) { - *sdev+=(scores[i]-(*smean))*(scores[i]-(*smean)); + *std_dev+=(scores[i]-(*average))*(scores[i]-(*average)); } -*sdev/=(double)(num_scores-1); -*sdev=sqrt(*sdev); +*std_dev/=(double)(num_scores-1); +*std_dev=sqrt(*std_dev); /* Now calculate the length of the confidence half-interval. For a ** confidence level of 95% our confidence coefficient gives us a @@ -293,28 +275,6 @@ for(i=0;i<num_scores;i++) { ** with num_scores-1 degrees of freedom, and dividing by sqrt(number of ** observations). See any introduction to statistics. */ -*c_half_interval=student_t[num_scores-1] * (*sdev) / sqrt((double)num_scores); +*c_half_interval=student_t[num_scores-1] * (*std_dev) / sqrt((double)num_scores); return false; } - -/************* -** getScore ** -************** -** Return the score for a particular benchmark. -*/ -static double getScore(int benchmark) { - double (*getScore[])(void) = { - getNumSortScore, - getEmFloatScore, - getIDEAScore, - getHuffmanScore, - getStringSortScore, - getBitfieldScore, - getAssignmentScore, - getFourierScore, - getNNETScore, - getLinearScore - }; - - return (*getScore[benchmark])(); -} @@ -27,8 +27,6 @@ static double thefunction(double x, double omega_n, int select); -static double results; - /************** ** DoFourier ** *************** @@ -37,7 +35,7 @@ static double results; ** fourier coefficients of the function (x+1)^x defined ** on the interval 0,2. */ -void +double DoFourier(void) { const char* context = "FPU:Transcendental"; @@ -107,7 +105,7 @@ DoFourier(void) free(abase); free(bbase); - results = (double)(iterations * CLOCKS_PER_SEC) / (double)total_time; + return (double)(iterations * CLOCKS_PER_SEC) / (double)total_time; } /************************ @@ -241,9 +239,3 @@ switch(select) */ return(0.0); } - -double -getFourierScore(void) -{ - return results; -} diff --git a/fpemulation.c b/fpemulation.c index bd4b320..a99949d 100644 --- a/fpemulation.c +++ b/fpemulation.c @@ -31,15 +31,13 @@ static clock_t DoEmFloatIteration(InternalFPF *abase, InternalFPF *bbase, Intern unsigned long loops); static void SetupCPUEmFloatArrays(InternalFPF *abase, InternalFPF *bbase); -static double results; - /************** ** DoEmFloat ** *************** ** Perform the floating-point emulation routines portion of the ** CPU benchmark. Returns the operations per second. */ -void +double DoEmFloat(void) { const char* context = "CPU:Floating Emulation"; @@ -119,7 +117,7 @@ DoEmFloat(void) free(bbase); free(cbase); - results = (double)(iterations * loops * CLOCKS_PER_SEC) / (double)total_time; + return (double)(iterations * loops * CLOCKS_PER_SEC) / (double)total_time; } /*********************** @@ -207,9 +205,3 @@ SetupCPUEmFloatArrays(InternalFPF *abase, InternalFPF *bbase) DivideInternalFPF(&locFPF1,&locFPF2,bbase+i); } } - -double -getEmFloatScore(void) -{ - return results; -} @@ -52,8 +52,6 @@ static clock_t DoHuffIteration(char *plaintext, char *comparray, char *decomparr static void SetCompBit(uint8_t *comparray, uint32_t bitoffset, char bitchar); static int GetCompBit(uint8_t *comparray, uint32_t bitoffset); -static double results; - /************** ** DoHuffman ** *************** @@ -63,7 +61,7 @@ static double results; ** Also, the compression cycle includes building the ** Huffman tree. */ -void +double DoHuffman(void) { const char* context = "CPU:Huffman"; @@ -157,7 +155,7 @@ DoHuffman(void) free(decomparray); free(hufftree); - results = (double)(iterations * CLOCKS_PER_SEC) / (double)total_time; + return (double)(iterations * CLOCKS_PER_SEC) / (double)total_time; } /********************* @@ -501,9 +499,3 @@ bitnumb=bitoffset % 8; */ return((1<<bitnumb) & comparray[byteoffset] ); } - -double -getHuffmanScore(void) -{ - return results; -} @@ -53,15 +53,13 @@ static void en_key_idea(uint16_t userkey[8], IDEAkey Z); static void de_key_idea(IDEAkey Z, IDEAkey DK); static void cipher_idea(uint16_t in[4], uint16_t out[4], IDEAkey Z); -static double results; - /*********** ** DoIDEA ** ************ ** Perform IDEA encryption. Note that we time encryption & decryption ** time as being a single loop. */ -void +double DoIDEA(void) { const char* context = "CPU:IDEA"; @@ -159,7 +157,7 @@ DoIDEA(void) free(crypt1); free(plain2); - results = (double)(iterations * CLOCKS_PER_SEC) / (double)total_time; + return (double)(iterations * CLOCKS_PER_SEC) / (double)total_time; } /******************** @@ -379,11 +377,4 @@ MUL(x1,*Z++); *out++=x2+*Z++; MUL(x4,*Z); *out=x4; -return; -} - -double -getIDEAScore(void) -{ - return results; } @@ -57,14 +57,12 @@ static void lubksb(double a[][LUARRAYCOLS], static int lusolve(double a[][LUARRAYCOLS], int n, double b[LUARRAYROWS]); -static double results; - /********* ** DoLU ** ********** ** Perform the LU decomposition benchmark. */ -void +double DoLU(void) { const char* context = "FPU:LU"; @@ -184,7 +182,7 @@ DoLU(void) free(bbase); free(LUtempvv); - results = (double)(iterations * CLOCKS_PER_SEC) / (double)total_time; + return (double)(iterations * CLOCKS_PER_SEC) / (double)total_time; } /****************** @@ -542,9 +540,3 @@ printf("\n"); return(1); } - -double -getLinearScore(void) -{ - return results; -} @@ -104,8 +104,6 @@ static void zero_changes(); static void randomize_wts(); static int read_data_file(); -static double results; - /*********** ** DoNNet ** ************ @@ -115,7 +113,7 @@ static double results; ** should be on the local directory (from which the ** benchmark program in launched). */ -void +double DoNNET(void) { /* const char* context="CPU:NNET"; */ /* Since we never fprintf errors here, we don't need this */ @@ -167,7 +165,7 @@ DoNNET(void) iterations += loops; } while (total_time < MINIMUM_SECONDS * CLOCKS_PER_SEC); - results = (double)(iterations * CLOCKS_PER_SEC) / total_time; + return (double)(iterations * CLOCKS_PER_SEC) / total_time; } /******************** @@ -323,7 +321,6 @@ static void do_forward_pass(int patt) do_mid_forward(patt); /* process forward pass, middle layer */ do_out_forward(); /* process forward pass, output layer */ /* display_output(patt); ** display results of forward pass */ -return; } /*********************** @@ -779,9 +776,3 @@ for (patt=0; patt<numpats; patt++) fclose(infile); return(0); } - -double -getNNETScore(void) -{ - return results; -} @@ -29,15 +29,13 @@ static void LoadNumArrayWithRand(long *array, unsigned int num_arrays); static inline void NumHeapSort(long *array, unsigned long bottom, unsigned long top); static inline void NumSift(long *array, unsigned long min, unsigned long max); -static double results; - /************** ** DoNumSort ** *************** ** This routine performs the CPU numeric sort test. */ -void +double DoNumSort (void) { const char* context = "CPU:Numeric Sort"; @@ -95,7 +93,7 @@ DoNumSort (void) free(array); - results = (double)(iterations * num_arrays * CLOCKS_PER_SEC) / (double)total_time; + return (double)(iterations * num_arrays * CLOCKS_PER_SEC) / (double)total_time; } /*********************** @@ -221,9 +219,3 @@ NumSift(long *array, unsigned long min, unsigned long max) } } } - -double -getNumSortScore(void) -{ - return results; -} diff --git a/stringsort.c b/stringsort.c index a8ff4f3..28fa155 100644 --- a/stringsort.c +++ b/stringsort.c @@ -48,12 +48,11 @@ static void strsift(unsigned long *optrarray, unsigned long i, unsigned long j); -static double results; - /***************** ** DoStringSort ** *****************/ -void DoStringSort(void) +double +DoStringSort(void) { const char* context = "CPU:String Sort"; unsigned char* array = NULL; @@ -110,7 +109,7 @@ void DoStringSort(void) free(array); - results = (double)(iterations * CLOCKS_PER_SEC) / (double)total_time; + return (double)(iterations * CLOCKS_PER_SEC) / (double)total_time; } /************************** @@ -509,9 +508,3 @@ while((i+i)<=j) i=j+1; } } - -double -getStringSortScore(void) -{ - return results; -} |