From 04741fb6181f8cc1ebc6f527d8d22840d019eb7b Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Sat, 15 Nov 2008 03:17:35 +0000 Subject: -- Remove structs completely -- results is now a static variable in each benchmark -- added get*Score routines -- finally got rid of nmglobal.h completely -- removed more useless stuff git-svn-id: svn://mattst88.com/svn/cleanbench/trunk@53 0d43b9a7-5ab2-4d7b-af9d-f64450cef757 --- Makefile | 4 +- assignment.c | 13 ++++- bitfield.c | 13 ++++- cleanbench.c | 131 +++++++++++++++++++++++++++++++++---------- cleanbench.h | 175 +++++++++------------------------------------------------- emfloat.c | 3 +- fourier.c | 13 ++++- fpemulation.c | 15 +++-- huffman.c | 13 ++++- idea.c | 13 ++++- linear.c | 13 ++++- neural.c | 82 +++------------------------ nmglobal.h | 86 ----------------------------- numsort.c | 13 ++++- stringsort.c | 13 ++++- 15 files changed, 230 insertions(+), 370 deletions(-) delete mode 100644 nmglobal.h diff --git a/Makefile b/Makefile index ff131e2..1cdb017 100644 --- a/Makefile +++ b/Makefile @@ -25,10 +25,10 @@ sysinfo.c: Makefile hardware.o: hardware.c hardware.h Makefile $(GCC) $(GCCFLAGS) -c hardware.c -cleanbench.o: cleanbench.h cleanbench.c nmglobal.h hardware.h Makefile sysinfo.c sysinfoc.c +cleanbench.o: cleanbench.h cleanbench.c hardware.h Makefile sysinfo.c sysinfoc.c $(GCC) $(GCCFLAGS) -c cleanbench.c -emfloat.o: emfloat.h emfloat.c nmglobal.h Makefile +emfloat.o: emfloat.h emfloat.c Makefile $(GCC) $(GCCFLAGS) -c emfloat.c randnum.o: randnum.c Makefile diff --git a/assignment.c b/assignment.c index 78be3fa..2fe8b8d 100644 --- a/assignment.c +++ b/assignment.c @@ -6,7 +6,7 @@ #include #include -#include "nmglobal.h" +#include "cleanbench.h" #include "randnum.h" @@ -48,6 +48,8 @@ static int first_assignments(long tableau[][ASSIGNCOLS], static void second_assignments(long tableau[][ASSIGNCOLS], short assignedtableau[][ASSIGNCOLS]); +static double results; + /************* ** DoAssign ** ************** @@ -70,7 +72,6 @@ void DoAssign(void) { const char* context = "CPU:Assignment"; - AssignStruct* locassignstruct = &global_assignstruct; /* Local structure ptr */ long* array = NULL; clock_t total_time = 0; int iterations = 0; @@ -119,7 +120,7 @@ DoAssign(void) free(array); - locassignstruct->results = (double)(iterations * CLOCKS_PER_SEC *num_arrays) / (double)total_time; + results = (double)(iterations * CLOCKS_PER_SEC *num_arrays) / (double)total_time; } @@ -521,3 +522,9 @@ for(i=0;i #include -#include "nmglobal.h" +#include "cleanbench.h" #include "randnum.h" @@ -32,6 +32,8 @@ static void FlipBitRun(unsigned long *bitmap, unsigned long bit_addr, unsigned long nbits); +static double results; + /************* ** DoBitops ** ************** @@ -42,7 +44,6 @@ void DoBitops(void) { const char* context = "CPU:Bitfields"; - BitOpStruct* locbitopstruct = &global_bitopstruct; unsigned long* bitarray = NULL; unsigned long* bitoparray = NULL; clock_t total_time = 0; @@ -116,7 +117,7 @@ DoBitops(void) free(bitarray); free(bitoparray); - locbitopstruct->results = (double)(iterations * CLOCKS_PER_SEC) / (double)total_time; + results = (double)(iterations * CLOCKS_PER_SEC) / (double)total_time; } /************************ @@ -253,3 +254,9 @@ void ToggleBitRun(unsigned long *bitmap, /* Bitmap */ } } } + +inline double +getBitfieldScore(void) +{ + return results; +} diff --git a/cleanbench.c b/cleanbench.c index bb73b6a..f50b10a 100644 --- a/cleanbench.c +++ b/cleanbench.c @@ -47,7 +47,7 @@ #include #include #include -#include "nmglobal.h" + #include "cleanbench.h" #include "hardware.h" @@ -55,6 +55,90 @@ static int bench_with_confidence(int fid, double *mean, double *stdev, unsigned static int calc_confidence(double scores[], int num_scores, double *c_half_interval,double *smean, double *sdev); static double getscore(int fid); +/* Tests-to-do flags...must coincide with test. */ +enum { + NUMSORT, + STRINGSORT, + BITFIELD, + FPEMULATION, + FOURIER, + ASSIGNMENT, + IDEA, + HUFFMAN, + NEURAL, + LINEAR +} tests_t; + +#define NUMTESTS 10 + +/* +** Following array is a collection of flags indicating which +** tests to perform. +*/ +int tests_to_do[NUMTESTS]; + + +/* +** Test names +*/ +char *ftestnames[] = { + "NUMERIC SORT ", + "STRING SORT ", + "BITFIELD ", + "FP EMULATION ", + "FOURIER ", + "ASSIGNMENT ", + "IDEA ", + "HUFFMAN ", + "NEURAL NET ", + "LU DECOMPOSITION" }; + +/* +** Indexes -- Baseline is DELL Pentium XP90 +** 11/28/94 +*/ +double bindex[] = { + 38.993, /* Numeric sort */ + 2.238, /* String sort */ + 5829704, /* Bitfield */ + 2.084, /* FP Emulation */ + 879.278, /* Fourier */ + .2628, /* Assignment */ + 65.382, /* IDEA */ + 36.062, /* Huffman */ + .6225, /* Neural Net */ + 19.3031 }; /* LU Decomposition */ + +/* +** Indices -- Baseline is a AMD K6-233, 32MB RAM (60ns SDRAM),512k L2 cache, +** Linux kernel 2.0.32, libc-5.4.38, gcc-2.7.2.3) +** Nov/30/97 +*/ +double lx_bindex[] = { + 118.73, /* Numeric sort */ + 14.459, /* String sort */ + 27910000, /* Bitfield */ + 9.0314, /* FP Emulation */ + 1565.5, /* Fourier */ + 1.0132, /* Assignment */ + 220.21, /* IDEA */ + 112.93, /* Huffman */ + 1.4799, /* Neural Net */ + 26.732}; /* LU Decomposition */ + + +void (*funcpointer[])(void) = +{ DoNumSort, + DoStringSort, + DoBitops, + DoEmFloat, + DoFourier, + DoAssign, + DoIDEA, + DoHuffman, + DoNNET, + DoLU }; + /************* **** main **** *************/ @@ -84,7 +168,7 @@ puts("\nTEST : Iterations/sec. : Old Index : New Index"); puts(" : : Pentium 90* : AMD K6/233*"); puts("--------------------:------------------:-------------:------------"); -for(i=LINEAR;i #include -#include "nmglobal.h" + +#include "cleanbench.h" #include "randnum.h" #include "emfloat.h" diff --git a/fourier.c b/fourier.c index d45f784..a4505e0 100644 --- a/fourier.c +++ b/fourier.c @@ -6,7 +6,7 @@ #include #include -#include "nmglobal.h" +#include "cleanbench.h" #include "randnum.h" @@ -26,6 +26,8 @@ static double thefunction(double x, double omega_n, int select); +static double results; + /************** ** DoFourier ** *************** @@ -38,7 +40,6 @@ void DoFourier(void) { const char* context = "FPU:Transcendental"; - FourierStruct* locfourierstruct = &global_fourierstruct; double* abase = NULL; double* bbase = NULL; clock_t total_time = 0; @@ -105,7 +106,7 @@ DoFourier(void) free(abase); free(bbase); - locfourierstruct->results = (double)(iterations * CLOCKS_PER_SEC) / (double)total_time; + results = (double)(iterations * CLOCKS_PER_SEC) / (double)total_time; } /************************ @@ -239,3 +240,9 @@ switch(select) */ return(0.0); } + +inline double +getFourierScore(void) +{ + return results; +} diff --git a/fpemulation.c b/fpemulation.c index b0c5459..3536d77 100644 --- a/fpemulation.c +++ b/fpemulation.c @@ -6,7 +6,7 @@ #include #include -#include "nmglobal.h" +#include "cleanbench.h" #include "randnum.h" #include "emfloat.h" @@ -24,12 +24,14 @@ */ #define LOOP_MAX 500000L -#define ARRAY_SIZE 3000L +#define ARRAY_SIZE 3000 static clock_t DoEmFloatIteration(InternalFPF *abase, InternalFPF *bbase, InternalFPF *cbase, unsigned long loops); static void SetupCPUEmFloatArrays(InternalFPF *abase, InternalFPF *bbase); +static double results; + /************** ** DoEmFloat ** *************** @@ -40,7 +42,6 @@ void DoEmFloat(void) { const char* context = "CPU:Floating Emulation"; - EmFloatStruct* locemfloatstruct = &global_emfloatstruct; InternalFPF* abase = NULL; InternalFPF* bbase = NULL; InternalFPF* cbase = NULL; @@ -117,7 +118,7 @@ DoEmFloat(void) free(bbase); free(cbase); - locemfloatstruct->results = (double)(iterations * loops * CLOCKS_PER_SEC) / (double)total_time; + results = (double)(iterations * loops * CLOCKS_PER_SEC) / (double)total_time; } /*********************** @@ -205,3 +206,9 @@ SetupCPUEmFloatArrays(InternalFPF *abase, InternalFPF *bbase) DivideInternalFPF(&locFPF1,&locFPF2,bbase+i); } } + +inline double +getEmFloatScore(void) +{ + return results; +} diff --git a/huffman.c b/huffman.c index 7ebdd81..051fbbf 100644 --- a/huffman.c +++ b/huffman.c @@ -6,7 +6,7 @@ #include #include -#include "nmglobal.h" +#include "cleanbench.h" #include "randnum.h" @@ -51,6 +51,8 @@ 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 ** *************** @@ -64,7 +66,6 @@ void DoHuffman(void) { const char* context = "CPU:Huffman"; - HuffStruct* lochuffstruct = &global_huffstruct; char* comparray = NULL; char* decomparray = NULL; char* plaintext = NULL; @@ -155,7 +156,7 @@ DoHuffman(void) free(decomparray); free(hufftree); - lochuffstruct->results = (double)(iterations * CLOCKS_PER_SEC) / (double)total_time; + results = (double)(iterations * CLOCKS_PER_SEC) / (double)total_time; } /********************* @@ -499,3 +500,9 @@ bitnumb=bitoffset % 8; */ return((1< #include -#include "nmglobal.h" +#include "cleanbench.h" #include "randnum.h" @@ -52,6 +52,8 @@ 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 ** ************ @@ -62,7 +64,6 @@ void DoIDEA(void) { const char* context = "CPU:IDEA"; - IDEAStruct* locideastruct=&global_ideastruct; /* Loc pointer to global structure */ unsigned char* plain1 = NULL; /* First plaintext buffer */ unsigned char* crypt1 = NULL; /* Encryption buffer */ unsigned char* plain2 = NULL; /* Second plaintext buffer */ @@ -157,7 +158,7 @@ DoIDEA(void) free(crypt1); free(plain2); - locideastruct->results = (double)(iterations * CLOCKS_PER_SEC) / (double)total_time; + results = (double)(iterations * CLOCKS_PER_SEC) / (double)total_time; } /******************** @@ -379,3 +380,9 @@ MUL(x4,*Z); *out=x4; return; } + +inline double +getIDEAScore(void) +{ + return results; +} diff --git a/linear.c b/linear.c index 3216378..a57439c 100644 --- a/linear.c +++ b/linear.c @@ -6,7 +6,7 @@ #include #include -#include "nmglobal.h" +#include "cleanbench.h" #include "randnum.h" @@ -56,6 +56,8 @@ static void lubksb(double a[][LUARRAYCOLS], static int lusolve(double a[][LUARRAYCOLS], int n, double b[LUARRAYROWS]); +static double results; + /********* ** DoLU ** ********** @@ -65,7 +67,6 @@ void DoLU(void) { const char* context = "FPU:LU"; - LUStruct* loclustruct = &global_lustruct; clock_t total_time = 0; int iterations = 0; double* a = NULL; @@ -182,7 +183,7 @@ DoLU(void) free(bbase); free(LUtempvv); - loclustruct->results = (double)(iterations * CLOCKS_PER_SEC) / (double)total_time; + results = (double)(iterations * CLOCKS_PER_SEC) / (double)total_time; } /****************** @@ -540,3 +541,9 @@ printf("\n"); return(1); } + +inline double +getLinearScore(void) +{ + return results; +} diff --git a/neural.c b/neural.c index e3e3c46..f814dc6 100644 --- a/neural.c +++ b/neural.c @@ -6,7 +6,7 @@ #include #include -#include "nmglobal.h" +#include "cleanbench.h" #include "randnum.h" @@ -104,7 +104,8 @@ static int check_out_error(); static void zero_changes(); static void randomize_wts(); static int read_data_file(); -/* static int initialize_net(); */ + +static double results; /*********** ** DoNNet ** @@ -119,7 +120,6 @@ void DoNNET(void) { /* const char* context="CPU:NNET"; */ /* Since we never fprintf errors here, we don't need this */ - NNetStruct* locnnetstruct = &global_nnetstruct; clock_t total_time = 0; int iterations = 0; static int is_adjusted = FALSE; @@ -168,7 +168,7 @@ DoNNET(void) iterations += loops; } while (total_time < MINIMUM_SECONDS * CLOCKS_PER_SEC); - locnnetstruct->results = (double)(iterations * CLOCKS_PER_SEC) / total_time; + results = (double)(iterations * CLOCKS_PER_SEC) / total_time; } /******************** @@ -778,80 +778,12 @@ for (patt=0; patt -#define TRUE 1 -#define FALSE 0 - -#define MINIMUM_TICKS 60 -#define MINIMUM_SECONDS 5 /* Minimum number of seconds to run each test */ - -typedef struct { - double results; /* # of sort iterations per sec */ -} SortStruct; - -typedef struct { - double results; /* # of bitfield ops per sec */ -} BitOpStruct; - -/* -** TYPEDEFS -*/ -typedef struct { - double results; /* Results */ -} EmFloatStruct; - -typedef struct { - double results; /* Results */ -} FourierStruct; - -typedef struct { - double results; /* Results */ -} AssignStruct; - -typedef struct { - double results; /* Results */ -} IDEAStruct; - -typedef struct { - double results; /* Results */ -} HuffStruct; - -typedef struct { - double results; /* Results */ -} NNetStruct; - -typedef struct { - double results; /* Results */ -} LUStruct; - -extern SortStruct global_numsortstruct; -extern SortStruct global_strsortstruct; -extern BitOpStruct global_bitopstruct; -extern EmFloatStruct global_emfloatstruct; -extern FourierStruct global_fourierstruct; -extern AssignStruct global_assignstruct; -extern IDEAStruct global_ideastruct; -extern HuffStruct global_huffstruct; -extern NNetStruct global_nnetstruct; -extern LUStruct global_lustruct; diff --git a/numsort.c b/numsort.c index b9765cf..e05c742 100644 --- a/numsort.c +++ b/numsort.c @@ -6,7 +6,7 @@ #include #include -#include "nmglobal.h" +#include "cleanbench.h" #include "randnum.h" @@ -28,6 +28,8 @@ 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 ** *************** @@ -38,7 +40,6 @@ void DoNumSort (void) { const char* context = "CPU:Numeric Sort"; - SortStruct* numsortstruct = &global_numsortstruct; long* array = NULL; clock_t total_time = 0; int iterations = 0; @@ -93,7 +94,7 @@ DoNumSort (void) free(array); - numsortstruct->results = (double)(iterations * num_arrays * CLOCKS_PER_SEC) / (double)total_time; + results = (double)(iterations * num_arrays * CLOCKS_PER_SEC) / (double)total_time; } /*********************** @@ -219,3 +220,9 @@ NumSift(long *array, unsigned long min, unsigned long max) } } } + +inline double +getNumSortScore(void) +{ + return results; +} diff --git a/stringsort.c b/stringsort.c index 71e6045..b1659b3 100644 --- a/stringsort.c +++ b/stringsort.c @@ -6,7 +6,7 @@ #include #include -#include "nmglobal.h" +#include "cleanbench.h" #include "randnum.h" @@ -47,13 +47,14 @@ static void strsift(unsigned long *optrarray, unsigned long i, unsigned long j); +static double results; + /***************** ** DoStringSort ** *****************/ void DoStringSort(void) { const char* context = "CPU:String Sort"; - SortStruct* strsortstruct = &global_strsortstruct; unsigned char* array = NULL; clock_t total_time = 0; int iterations = 0; @@ -108,7 +109,7 @@ void DoStringSort(void) free(array); - strsortstruct->results = (double)(iterations * CLOCKS_PER_SEC) / (double)total_time; + results = (double)(iterations * CLOCKS_PER_SEC) / (double)total_time; } /************************** @@ -507,3 +508,9 @@ while((i+i)<=j) i=j+1; } } + +inline double +getStringSortScore(void) +{ + return results; +} -- cgit v1.2.3