3 ** Header for nbench0.c
5 ** BYTE's Native Mode Benchmarks
6 ** Rick Grehan, BYTE Magazine
9 ** Revision: 3/95;10/95
10 ** 10/95 - Added memory array & alignment -- RG
13 ** The source, executable, and documentation files that comprise
14 ** the BYTEmark benchmarks are made available on an "as is" basis.
15 ** This means that we at BYTE Magazine have made every reasonable
16 ** effort to verify that the there are no errors in the source and
17 ** executable code. We cannot, however, guarantee that the programs
18 ** are error-free. Consequently, McGraw-HIll and BYTE Magazine make
19 ** no claims in regard to the fitness of the source code, executable
20 ** code, and documentation of the BYTEmark.
21 ** Furthermore, BYTE Magazine, McGraw-Hill, and all employees
22 ** of McGraw-Hill cannot be held responsible for any damages resulting
23 ** from the use of this code or the results obtained from using
28 ** Following should be modified accordingly per each
31 char *sysname="You can enter your system description in nbench0.h";
32 char *compilername="It then will be printed here after you recompile";
33 char *compilerversion="Have a nice day";
35 /* Parameter flags. Must coincide with parameter names array
36 ** which appears below. */
37 #define PF_GMTICKS 0 /* GLOBALMINTICKS */
38 #define PF_MINSECONDS 1 /* MINSECONDS */
39 #define PF_ALLSTATS 2 /* ALLSTATS */
40 #define PF_OUTFILE 3 /* OUTFILE */
41 #define PF_CUSTOMRUN 4 /* CUSTOMRUN */
42 #define PF_DONUM 5 /* DONUMSORT */
43 #define PF_NUMNUMA 6 /* NUMNUMARRAYS */
44 #define PF_NUMASIZE 7 /* NUMARRAYSIZE */
45 #define PF_NUMMINS 8 /* NUMMINSECONDS */
46 #define PF_DOSTR 9 /* DOSTRINGSORT */
47 #define PF_STRASIZE 10 /* STRARRAYSIZE */
48 #define PF_NUMSTRA 11 /* NUMSTRARRAYS */
49 #define PF_STRMINS 12 /* STRMINSECONDS */
50 #define PF_DOBITF 13 /* DOBITFIELD */
51 #define PF_NUMBITOPS 14 /* NUMBITOPS */
52 #define PF_BITFSIZE 15 /* BITFIELDSIZE */
53 #define PF_BITMINS 16 /* BITMINSECONDS */
54 #define PF_DOEMF 17 /* DOEMF */
55 #define PF_EMFASIZE 18 /* EMFARRAYSIZE */
56 #define PF_EMFLOOPS 19 /* EMFLOOPS */
57 #define PF_EMFMINS 20 /* EMFMINSECOND */
58 #define PF_DOFOUR 21 /* DOFOUR */
59 #define PF_FOURASIZE 22 /* FOURASIZE */
60 #define PF_FOURMINS 23 /* FOURMINSECONDS */
61 #define PF_DOASSIGN 24 /* DOASSIGN */
62 #define PF_AARRAYS 25 /* ASSIGNARRAYS */
63 #define PF_ASSIGNMINS 26 /* ASSIGNMINSECONDS */
64 #define PF_DOIDEA 27 /* DOIDEA */
65 #define PF_IDEAASIZE 28 /* IDEAARRAYSIZE */
66 #define PF_IDEALOOPS 29 /* IDEALOOPS */
67 #define PF_IDEAMINS 30 /* IDEAMINSECONDS */
68 #define PF_DOHUFF 31 /* DOHUFF */
69 #define PF_HUFFASIZE 32 /* HUFFARRAYSIZE */
70 #define PF_HUFFLOOPS 33 /* HUFFLOOPS */
71 #define PF_HUFFMINS 34 /* HUFFMINSECONDS */
72 #define PF_DONNET 35 /* DONNET */
73 #define PF_NNETLOOPS 36 /* NNETLOOPS */
74 #define PF_NNETMINS 37 /* NNETMINSECONDS */
75 #define PF_DOLU 38 /* DOLU */
76 #define PF_LUNARRAYS 39 /* LUNUMARRAYS */
77 #define PF_LUMINS 40 /* LUMINSECONDS */
78 #define PF_ALIGN 41 /* ALIGN */
82 /* Tests-to-do flags...must coincide with test. */
105 char *ftestnames[] = {
115 "LU DECOMPOSITION" };
118 ** Indexes -- Baseline is DELL Pentium XP90
122 38.993, /* Numeric sort */
123 2.238, /* String sort */
124 5829704, /* Bitfield */
125 2.084, /* FP Emulation */
126 879.278, /* Fourier */
127 .2628, /* Assignment */
129 36.062, /* Huffman */
130 .6225, /* Neural Net */
131 19.3031 }; /* LU Decomposition */
134 ** Indices -- Baseline is a AMD K6-233, 32MB RAM (60ns SDRAM),512k L2 cache,
135 ** Linux kernel 2.0.32, libc-5.4.38, gcc-2.7.2.3)
138 double lx_bindex[] = {
139 118.73, /* Numeric sort */
140 14.459, /* String sort */
141 27910000, /* Bitfield */
142 9.0314, /* FP Emulation */
143 1565.5, /* Fourier */
144 1.0132, /* Assignment */
146 112.93, /* Huffman */
147 1.4799, /* Neural Net */
148 26.732}; /* LU Decomposition */
150 /* Parameter names */
151 char *paramnames[]= {
196 ** Following array is a collection of flags indicating which
199 int tests_to_do[NUMTESTS];
202 ** Buffer for holding output text.
204 char buffer[BUF_SIZ];
207 ** Global parameters.
209 ulong global_min_ticks; /* Minimum ticks */
210 ulong global_min_seconds; /* Minimum seconds tests run */
211 int global_allstats; /* Statistics dump flag */
212 char global_ofile_name[BUF_SIZ];/* Output file name */
213 FILE *global_ofile; /* Output file */
214 int global_custrun; /* Custom run flag */
215 int write_to_file; /* Write output to file */
216 int global_align; /* Memory alignment */
219 ** Following global is the memory array. This is used to store
220 ** original and aligned (modified) memory addresses.
222 ulong mem_array[2][MEM_ARRAY_SIZE];
223 int mem_array_ents; /* # of active entries */
226 ** Following are global structures, one built for
227 ** each of the tests.
229 SortStruct global_numsortstruct; /* For numeric sort */
230 SortStruct global_strsortstruct; /* For string sort */
231 BitOpStruct global_bitopstruct; /* For bitfield operations */
232 EmFloatStruct global_emfloatstruct; /* For emul. float. point */
233 FourierStruct global_fourierstruct; /* For fourier test */
234 AssignStruct global_assignstruct; /* For assignment algorithm */
235 IDEAStruct global_ideastruct; /* For IDEA encryption */
236 HuffStruct global_huffstruct; /* For Huffman compression */
237 NNetStruct global_nnetstruct; /* For Neural Net */
238 LUStruct global_lustruct; /* For LU decomposition */
241 ** The following array of function struct pointers lets
242 ** us very rapidly map a function to its controlling
243 ** data structure. NOTE: These must match the "TF_xxx"
246 void *global_fstruct[] =
247 { (void *)&global_numsortstruct,
248 (void *)&global_strsortstruct,
249 (void *)&global_bitopstruct,
250 (void *)&global_emfloatstruct,
251 (void *)&global_fourierstruct,
252 (void *)&global_assignstruct,
253 (void *)&global_ideastruct,
254 (void *)&global_huffstruct,
255 (void *)&global_nnetstruct,
256 (void *)&global_lustruct };
259 ** Following globals added to support command line emulation on
260 ** the Macintosh....which doesn't have command lines.
263 int argc; /* Argument count */
264 char *argv[20]; /* Argument vectors */
266 unsigned char Uargbuff[129]; /* Buffer holding arguments string */
267 unsigned char Udummy[2]; /* Dummy buffer for first arg */
275 ** Timer globals for Mac
277 struct TMTask myTMTask;
278 long MacHSTdelay,MacHSTohead;
283 ** Following globals used by Win 31 timing routines.
284 ** NOTE: This requires the includes of the w31timer.asm
285 ** file in your project!!
289 #include <toolhelp.h>
290 extern TIMERINFO win31tinfo;
298 static int parse_arg(char *argptr);
299 static void display_help(char *progname);
300 static void read_comfile(FILE *cfile);
301 static int getflag(char *cptr);
302 static void strtoupper(char *s);
303 static void set_request_secs(void);
304 static int bench_with_confidence(int fid,
305 double *mean, double *stdev, ulong *numtries);
307 static int seek_confidence(double scores[5],
308 double *newscore, double *c_half_interval,
309 double *smean,double *sdev);
311 static int calc_confidence(double scores[],
313 double *c_half_interval,double *smean,
315 static double getscore(int fid);
316 static void output_string(char *buffer);
317 static void show_stats(int bid);
320 void UCommandLine(void);
322 unsigned char *UField(unsigned char *ptr);
326 ** EXTERNAL PROTOTYPES
328 extern void DoNumSort(void); /* From NBENCH1 */
329 extern void DoStringSort(void);
330 extern void DoBitops(void);
331 extern void DoEmFloat(void);
332 extern void DoFourier(void);
333 extern void DoAssign(void);
334 extern void DoIDEA(void);
335 extern void DoHuffman(void);
336 extern void DoNNET(void);
337 extern void DoLU(void);
339 extern void ErrorExit(void); /* From SYSSPEC */
342 ** Array of pointers to the benchmark functions.
344 void (*funcpointer[])(void) =