1 /* 2 ** nbench0.h 3 ** Header for nbench0.c 4 ** BYTEmark (tm) 5 ** BYTE's Native Mode Benchmarks 6 ** Rick Grehan, BYTE Magazine 7 ** 8 ** Creation: 9 ** Revision: 3/95;10/95 10 ** 10/95 - Added memory array & alignment -- RG 11 ** 12 ** DISCLAIMER 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 24 ** this code. 25 */ 26 27 /* 28 ** Following should be modified accordingly per each 29 ** compilation. 30 */ 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"; 34 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 */ 79 80 #define MAXPARAM 41 81 82 /* Tests-to-do flags...must coincide with test. */ 83 #define TF_NUMSORT 0 84 #define TF_SSORT 1 85 #define TF_BITOP 2 86 #define TF_FPEMU 3 87 #define TF_FFPU 4 88 #define TF_ASSIGN 5 89 #define TF_IDEA 6 90 #define TF_HUFF 7 91 #define TF_NNET 8 92 #define TF_LU 9 93 94 #define NUMTESTS 10 95 96 /* 97 ** GLOBALS 98 */ 99 100 #define BUF_SIZ 1024 101 102 /* 103 ** Test names 104 */ 105 char *ftestnames[] = { 106 "NUMERIC SORT ", 107 "STRING SORT ", 108 "BITFIELD ", 109 "FP EMULATION ", 110 "FOURIER ", 111 "ASSIGNMENT ", 112 "IDEA ", 113 "HUFFMAN ", 114 "NEURAL NET ", 115 "LU DECOMPOSITION" }; 116 117 /* 118 ** Indexes -- Baseline is DELL Pentium XP90 119 ** 11/28/94 120 */ 121 double bindex[] = { 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 */ 128 65.382, /* IDEA */ 129 36.062, /* Huffman */ 130 .6225, /* Neural Net */ 131 19.3031 }; /* LU Decomposition */ 132 133 /* 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) 136 ** Nov/30/97 137 */ 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 */ 145 220.21, /* IDEA */ 146 112.93, /* Huffman */ 147 1.4799, /* Neural Net */ 148 26.732}; /* LU Decomposition */ 149 150 /* Parameter names */ 151 char *paramnames[]= { 152 "GLOBALMINTICKS", 153 "MINSECONDS", 154 "ALLSTATS", 155 "OUTFILE", 156 "CUSTOMRUN", 157 "DONUMSORT", 158 "NUMNUMARRAYS", 159 "NUMARRAYSIZE", 160 "NUMMINSECONDS", 161 "DOSTRINGSORT", 162 "STRARRAYSIZE", 163 "NUMSTRARRAYS", 164 "STRMINSECONDS", 165 "DOBITFIELD", 166 "NUMBITOPS", 167 "BITFIELDSIZE", 168 "BITMINSECONDS", 169 "DOEMF", 170 "EMFARRAYSIZE", 171 "EMFLOOPS", 172 "EMFMINSECONDS", 173 "DOFOUR", 174 "FOURSIZE", 175 "FOURMINSECONDS", 176 "DOASSIGN", 177 "ASSIGNARRAYS", 178 "ASSIGNMINSECONDS", 179 "DOIDEA", 180 "IDEARRAYSIZE", 181 "IDEALOOPS", 182 "IDEAMINSECONDS", 183 "DOHUFF", 184 "HUFARRAYSIZE", 185 "HUFFLOOPS", 186 "HUFFMINSECONDS", 187 "DONNET", 188 "NNETLOOPS", 189 "NNETMINSECONDS", 190 "DOLU", 191 "LUNUMARRAYS", 192 "LUMINSECONDS", 193 "ALIGN" }; 194 195 /* 196 ** Following array is a collection of flags indicating which 197 ** tests to perform. 198 */ 199 int tests_to_do[NUMTESTS]; 200 201 /* 202 ** Buffer for holding output text. 203 */ 204 char buffer[BUF_SIZ]; 205 206 /* 207 ** Global parameters. 208 */ 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 */ 217 218 /* 219 ** Following global is the memory array. This is used to store 220 ** original and aligned (modified) memory addresses. 221 */ 222 ulong mem_array[2][MEM_ARRAY_SIZE]; 223 int mem_array_ents; /* # of active entries */ 224 225 /* 226 ** Following are global structures, one built for 227 ** each of the tests. 228 */ 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 */ 239 240 /* 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" 244 ** constants above. 245 */ 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 }; 257 258 /* 259 ** Following globals added to support command line emulation on 260 ** the Macintosh....which doesn't have command lines. 261 */ 262 #ifdef MAC 263 int argc; /* Argument count */ 264 char *argv[20]; /* Argument vectors */ 265 266 unsigned char Uargbuff[129]; /* Buffer holding arguments string */ 267 unsigned char Udummy[2]; /* Dummy buffer for first arg */ 268 269 #endif 270 271 #ifdef MACTIMEMGR 272 #include <Types.h> 273 #include <Timer.h> 274 /* 275 ** Timer globals for Mac 276 */ 277 struct TMTask myTMTask; 278 long MacHSTdelay,MacHSTohead; 279 280 #endif 281 282 /* 283 ** Following globals used by Win 31 timing routines. 284 ** NOTE: This requires the includes of the w31timer.asm 285 ** file in your project!! 286 */ 287 #ifdef WIN31TIMER 288 #include <windows.h> 289 #include <toolhelp.h> 290 extern TIMERINFO win31tinfo; 291 extern HANDLE hThlp; 292 extern FARPROC lpfn; 293 #endif 294 295 /* 296 ** PROTOTYPES 297 */ 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); 306 /* 307 static int seek_confidence(double scores[5], 308 double *newscore, double *c_half_interval, 309 double *smean,double *sdev); 310 */ 311 static int calc_confidence(double scores[], 312 int num_scores, 313 double *c_half_interval,double *smean, 314 double *sdev); 315 static double getscore(int fid); 316 static void output_string(char *buffer); 317 static void show_stats(int bid); 318 319 #ifdef MAC 320 void UCommandLine(void); 321 void UParse(void); 322 unsigned char *UField(unsigned char *ptr); 323 #endif 324 325 /* 326 ** EXTERNAL PROTOTYPES 327 */ 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); 338 339 extern void ErrorExit(void); /* From SYSSPEC */ 340 341 /* 342 ** Array of pointers to the benchmark functions. 343 */ 344 void (*funcpointer[])(void) = 345 { DoNumSort, 346 DoStringSort, 347 DoBitops, 348 DoEmFloat, 349 DoFourier, 350 DoAssign, 351 DoIDEA, 352 DoHuffman, 353 DoNNET, 354 DoLU }; 355 356 357