summaryrefslogtreecommitdiff
path: root/cleanbench.h
blob: 278de90a9cf6ed1b6309f8e7ca676e5df0972f14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
/*
** cleanbench.h
** Header for cleanbench.c
** BYTEmark (tm)
** BYTE's Native Mode Benchmarks
** Rick Grehan, BYTE Magazine
**
** Creation:
** Revision: 3/95;10/95
**  10/95 - Added memory array & alignment -- RG
**
** DISCLAIMER
** The source, executable, and documentation files that comprise
** the BYTEmark benchmarks are made available on an "as is" basis.
** This means that we at BYTE Magazine have made every reasonable
** effort to verify that the there are no errors in the source and
** executable code.  We cannot, however, guarantee that the programs
** are error-free.  Consequently, McGraw-HIll and BYTE Magazine make
** no claims in regard to the fitness of the source code, executable
** code, and documentation of the BYTEmark.
**  Furthermore, BYTE Magazine, McGraw-Hill, and all employees
** of McGraw-Hill cannot be held responsible for any damages resulting
** from the use of this code or the results obtained from using
** this code.
*/

/*
** Following should be modified accordingly per each
** compilation.
*/
char *sysname="You can enter your system description in cleanbench.h";
char *compilername="It then will be printed here after you recompile";
char *compilerversion="Have a nice day";

/*  Parameter flags.  Must coincide with parameter names array
** which appears below. */
#define PF_GMTICKS 0            /* GLOBALMINTICKS */
#define PF_MINSECONDS 1         /* MINSECONDS */
#define PF_ALLSTATS 2           /* ALLSTATS */
#define PF_OUTFILE 3            /* OUTFILE */
#define PF_CUSTOMRUN 4          /* CUSTOMRUN */
#define PF_DONUM 5              /* DONUMSORT */
#define PF_NUMNUMA 6            /* NUMNUMARRAYS */
#define PF_NUMASIZE 7           /* NUMARRAYSIZE */
#define PF_NUMMINS 8            /* NUMMINSECONDS */
#define PF_DOSTR 9              /* DOSTRINGSORT */
#define PF_STRASIZE 10          /* STRARRAYSIZE */
#define PF_NUMSTRA 11           /* NUMSTRARRAYS */
#define PF_STRMINS 12           /* STRMINSECONDS */
#define PF_DOBITF 13            /* DOBITFIELD */
#define PF_NUMBITOPS 14         /* NUMBITOPS */
#define PF_BITFSIZE 15          /* BITFIELDSIZE */
#define PF_BITMINS 16           /* BITMINSECONDS */
#define PF_DOEMF 17             /* DOEMF */
#define PF_EMFASIZE 18          /* EMFARRAYSIZE */
#define PF_EMFLOOPS 19          /* EMFLOOPS */
#define PF_EMFMINS 20           /* EMFMINSECOND */
#define PF_DOFOUR 21            /* DOFOUR */
#define PF_FOURASIZE 22         /* FOURASIZE */
#define PF_FOURMINS 23          /* FOURMINSECONDS */
#define PF_DOASSIGN 24          /* DOASSIGN */
#define PF_AARRAYS 25           /* ASSIGNARRAYS */
#define PF_ASSIGNMINS 26        /* ASSIGNMINSECONDS */
#define PF_DOIDEA 27            /* DOIDEA */
#define PF_IDEAASIZE 28         /* IDEAARRAYSIZE */
#define PF_IDEALOOPS 29         /* IDEALOOPS */
#define PF_IDEAMINS 30          /* IDEAMINSECONDS */
#define PF_DOHUFF 31            /* DOHUFF */
#define PF_HUFFASIZE 32         /* HUFFARRAYSIZE */
#define PF_HUFFLOOPS 33         /* HUFFLOOPS */
#define PF_HUFFMINS 34          /* HUFFMINSECONDS */
#define PF_DONNET 35            /* DONNET */
#define PF_NNETLOOPS 36         /* NNETLOOPS */
#define PF_NNETMINS 37          /* NNETMINSECONDS */
#define PF_DOLU 38              /* DOLU */
#define PF_LUNARRAYS 39         /* LUNUMARRAYS */
#define PF_LUMINS 40            /* LUMINSECONDS */
#define PF_ALIGN 41		        /* ALIGN */

#define MAXPARAM 41

/* Tests-to-do flags...must coincide with test. */
#define TF_NUMSORT 0
#define TF_SSORT 1
#define TF_BITOP 2
#define TF_FPEMU 3
#define TF_FFPU 4
#define TF_ASSIGN 5
#define TF_IDEA 6
#define TF_HUFF 7
#define TF_NNET 8
#define TF_LU 9

#define NUMTESTS 10

/*
** GLOBALS
*/

#define BUF_SIZ 1024

/*
** 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 */

/* Parameter names */
char *paramnames[]= {
        "GLOBALMINTICKS",
        "MINSECONDS",
        "ALLSTATS",
        "OUTFILE",
        "CUSTOMRUN",
        "DONUMSORT",
        "NUMNUMARRAYS",
        "NUMARRAYSIZE",
        "NUMMINSECONDS",
        "DOSTRINGSORT",
        "STRARRAYSIZE",
        "NUMSTRARRAYS",
        "STRMINSECONDS",
        "DOBITFIELD",
        "NUMBITOPS",
        "BITFIELDSIZE",
        "BITMINSECONDS",
        "DOEMF",
        "EMFARRAYSIZE",
        "EMFLOOPS",
        "EMFMINSECONDS",
        "DOFOUR",
        "FOURSIZE",
        "FOURMINSECONDS",
        "DOASSIGN",
        "ASSIGNARRAYS",
        "ASSIGNMINSECONDS",
        "DOIDEA",
        "IDEARRAYSIZE",
        "IDEALOOPS",
        "IDEAMINSECONDS",
        "DOHUFF",
        "HUFARRAYSIZE",
        "HUFFLOOPS",
        "HUFFMINSECONDS",
        "DONNET",
        "NNETLOOPS",
        "NNETMINSECONDS",
        "DOLU",
        "LUNUMARRAYS",
        "LUMINSECONDS",
	"ALIGN" };

/*
** Following array is a collection of flags indicating which
** tests to perform.
*/
int tests_to_do[NUMTESTS];

/*
** Buffer for holding output text.
*/
char buffer[BUF_SIZ];

/*
** Global parameters.
*/
unsigned long global_min_ticks;         /* Minimum ticks */
unsigned long global_min_seconds;       /* Minimum seconds tests run */
int global_allstats;            /* Statistics dump flag */
char global_ofile_name[BUF_SIZ];/* Output file name */
FILE *global_ofile;             /* Output file */
int global_custrun;             /* Custom run flag */
int write_to_file;              /* Write output to file */
int global_align;		/* Memory alignment */

/*
** Following are global structures, one built for
** each of the tests.
*/
SortStruct global_numsortstruct;        /* For numeric sort */
SortStruct global_strsortstruct;        /* For string sort */
BitOpStruct global_bitopstruct;         /* For bitfield operations */
EmFloatStruct global_emfloatstruct;     /* For emul. float. point */
FourierStruct global_fourierstruct;     /* For fourier test */
AssignStruct global_assignstruct;       /* For assignment algorithm */
IDEAStruct global_ideastruct;           /* For IDEA encryption */
HuffStruct global_huffstruct;           /* For Huffman compression */
NNetStruct global_nnetstruct;           /* For Neural Net */
LUStruct global_lustruct;               /* For LU decomposition */

/*
** The following array of function struct pointers lets
** us very rapidly map a function to its controlling
** data structure. NOTE: These must match the "TF_xxx"
** constants above.
*/
void *global_fstruct[] =
{       (void *)&global_numsortstruct,
        (void *)&global_strsortstruct,
        (void *)&global_bitopstruct,
        (void *)&global_emfloatstruct,
        (void *)&global_fourierstruct,
        (void *)&global_assignstruct,
        (void *)&global_ideastruct,
        (void *)&global_huffstruct,
        (void *)&global_nnetstruct,
        (void *)&global_lustruct };

/*
** PROTOTYPES
*/
static int parse_arg(char *argptr);
static void display_help(char *progname);
static void read_comfile(FILE *cfile);
static int getflag(char *cptr);
static void strtoupper(char *s);
static void set_request_secs(void);
static int bench_with_confidence(int fid,
        double *mean, double *stdev, unsigned long *numtries);
/*
static int seek_confidence(double scores[5],
        double *newscore, double *c_half_interval,
        double *smean,double *sdev);
*/
static int calc_confidence(double scores[],
        int num_scores,
        double *c_half_interval,double *smean,
        double *sdev);
static double getscore(int fid);
static void show_stats(int bid);

/*
** EXTERNAL PROTOTYPES
*/
extern void DoNumSort(void);
extern void DoStringSort(void);
extern void DoBitops(void);
extern void DoEmFloat(void);
extern void DoFourier(void);
extern void DoAssign(void);
extern void DoIDEA(void);
extern void DoHuffman(void);
extern void DoNNET(void);
extern void DoLU(void);

/*
** Array of pointers to the benchmark functions.
*/
void (*funcpointer[])(void) =
{       DoNumSort,
        DoStringSort,
        DoBitops,
        DoEmFloat,
        DoFourier,
        DoAssign,
        DoIDEA,
        DoHuffman,
        DoNNET,
        DoLU };