home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / bytewarp.zip / NBENCH0.H < prev    next >
C/C++ Source or Header  |  1995-11-02  |  10KB  |  335 lines

  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. ** Reision: 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="Generic 486/Pentium";
  32. char *compilername="Watcom C/C++";
  33. char *compilerversion="ver 10.5";
  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. /*
  101. ** Test names
  102. */
  103. char *ftestnames[] = {
  104.         "NUMERIC SORT",
  105.         "STRING SORT",
  106.         "BITFIELD",
  107.         "FP EMULATION",
  108.         "FOURIER",
  109.         "ASSIGNMENT",
  110.         "IDEA",
  111.         "HUFFMAN",
  112.         "NEURAL NET",
  113.         "LU DECOMPOSITION" };
  114.  
  115. /*
  116. ** Indexes -- Baseline is DELL Pentium XP90
  117. ** 11/28/94
  118. */
  119. double bindex[] = {
  120.     38.993,                     /* Numeric sort */
  121.     2.238,                      /* String sort */
  122.     5829704,                    /* Bitfield */
  123.     2.084,                       /* FP Emulation */
  124.     879.278,                     /* Fourier */
  125.     .2628,                     /* Assignment */
  126.     65.382,                      /* IDEA */
  127.     36.062,                     /* Huffman */
  128.     .6225,                       /* Neural Net */
  129.     19.3031 };                   /* LU Decomposition */
  130.  
  131. /* Parameter names */
  132. char *paramnames[]= {
  133.         "GLOBALMINTICKS",
  134.         "MINSECONDS",
  135.         "ALLSTATS",
  136.         "OUTFILE",
  137.         "CUSTOMRUN",
  138.         "DONUMSORT",
  139.         "NUMNUMARRAYS",
  140.         "NUMARRAYSIZE",
  141.         "NUMMINSECONDS",
  142.         "DOSTRINGSORT",
  143.         "STRARRAYSIZE",
  144.         "NUMSTRARRAYS",
  145.         "STRMINSECONDS",
  146.         "DOBITFIELD",
  147.         "NUMBITOPS",
  148.         "BITFIELDSIZE",
  149.         "BITMINSECONDS",
  150.         "DOEMF",
  151.         "EMFARRAYSIZE",
  152.         "EMFLOOPS",
  153.         "EMFMINSECONDS",
  154.         "DOFOUR",
  155.         "FOURSIZE",
  156.         "FOURMINSECONDS",
  157.         "DOASSIGN",
  158.         "ASSIGNARRAYS",
  159.         "ASSIGNMINSECONDS",
  160.         "DOIDEA",
  161.         "IDEARRAYSIZE",
  162.         "IDEALOOPS",
  163.         "IDEAMINSECONDS",
  164.         "DOHUFF",
  165.         "HUFARRAYSIZE",
  166.         "HUFFLOOPS",
  167.         "HUFFMINSECONDS",
  168.         "DONNET",
  169.         "NNETLOOPS",
  170.         "NNETMINSECONDS",
  171.         "DOLU",
  172.         "LUNUMARRAYS",
  173.         "LUMINSECONDS",
  174.     "ALIGN" };
  175.  
  176. /*
  177. ** Following array is a collection of flags indicating which
  178. ** tests to perform.
  179. */
  180. int tests_to_do[NUMTESTS];
  181.  
  182. /*
  183. ** Buffer for holding output text.
  184. */
  185. char buffer[100];
  186.  
  187. /*
  188. ** Global parameters.
  189. */
  190. ulong global_min_ticks;         /* Minimum ticks */
  191. ulong global_min_seconds;       /* Minimum seconds tests run */
  192. int global_allstats;            /* Statistics dump flag */
  193. char global_ofile_name[60];     /* Output file name */
  194. FILE *global_ofile;             /* Output file */
  195. int global_custrun;             /* Custom run flag */
  196. int write_to_file;              /* Write output to file */
  197. int global_align;            /* Memory alignment */
  198.  
  199. /*
  200. ** Following global is the memory array.  This is used to store
  201. ** original and aligned (modified) memory addresses.
  202. */
  203. ulong mem_array[2][MEM_ARRAY_SIZE];
  204. int mem_array_ents;        /* # of active entries */
  205.  
  206. /*
  207. ** Following are global structures, one built for
  208. ** each of the tests.
  209. */
  210. SortStruct global_numsortstruct;        /* For numeric sort */
  211. SortStruct global_strsortstruct;        /* For string sort */
  212. BitOpStruct global_bitopstruct;         /* For bitfield operations */
  213. EmFloatStruct global_emfloatstruct;     /* For emul. float. point */
  214. FourierStruct global_fourierstruct;     /* For fourier test */
  215. AssignStruct global_assignstruct;       /* For assignment algorithm */
  216. IDEAStruct global_ideastruct;           /* For IDEA encryption */
  217. HuffStruct global_huffstruct;           /* For Huffman compression */
  218. NNetStruct global_nnetstruct;           /* For Neural Net */
  219. LUStruct global_lustruct;               /* For LU decomposition */
  220.  
  221. /*
  222. ** The following array of function struct pointers lets
  223. ** us very rapidly map a function to its controlling
  224. ** data structure. NOTE: These must match the "TF_xxx"
  225. ** constants above.
  226. */
  227. void *global_fstruct[] =
  228. {       (void *)&global_numsortstruct,
  229.         (void *)&global_strsortstruct,
  230.         (void *)&global_bitopstruct,
  231.         (void *)&global_emfloatstruct,
  232.         (void *)&global_fourierstruct,
  233.         (void *)&global_assignstruct,
  234.         (void *)&global_ideastruct,
  235.         (void *)&global_huffstruct,
  236.         (void *)&global_nnetstruct,
  237.         (void *)&global_lustruct };
  238.  
  239. /*
  240. ** Following globals added to support command line emulation on
  241. ** the Macintosh....which doesn't have command lines.
  242. */
  243. #ifdef MAC
  244. int argc;                       /* Argument count */
  245. char *argv[20];         /* Argument vectors */
  246.  
  247. unsigned char Uargbuff[129];    /* Buffer holding arguments string */
  248. unsigned char Udummy[2];                /* Dummy buffer for first arg */
  249.  
  250. #endif
  251.  
  252. #ifdef MACTIMEMGR
  253. #include <Types.h>
  254. #include <Timer.h>
  255. /*
  256. ** Timer globals for Mac
  257. */
  258. struct TMTask myTMTask;
  259. long MacHSTdelay,MacHSTohead;
  260.  
  261. #endif
  262.  
  263. /*
  264. ** Following globals used by Win 31 timing routines.
  265. ** NOTE: This requires the includes of the w31timer.asm
  266. ** file in your project!!
  267. */
  268. #ifdef WIN31TIMER
  269. #include <windows.h>
  270. #include <toolhelp.h>
  271. extern TIMERINFO win31tinfo;
  272. extern HANDLE hThlp;
  273. extern FARPROC lpfn;
  274. #endif
  275.  
  276. /*
  277. ** PROTOTYPES
  278. */
  279. static int parse_arg(char *argptr);
  280. static void display_help(char *progname);
  281. static void read_comfile(FILE *cfile);
  282. static int getflag(char *cptr);
  283. static void strtoupper(char *s);
  284. static void set_request_secs(void);
  285. static int bench_with_confidence(int fid,
  286.         double *mean, double *stdev, ulong *numtries);
  287. static int seek_confidence(double scores[5],
  288.         double *newscore, double *c_half_interval,
  289.         double *smean,double *sdev);
  290. static void calc_confidence(double scores[],
  291.         double *c_half_interval,double *smean,
  292.         double *sdev);
  293. static double getscore(int fid);
  294. static void output_string(char *buffer);
  295. static void show_stats(int bid);
  296.  
  297. #ifdef MAC
  298. void UCommandLine(void);
  299. void UParse(void);
  300. unsigned char *UField(unsigned char *ptr);
  301. #endif
  302.  
  303. /*
  304. ** EXTERNAL PROTOTYPES
  305. */
  306. extern void DoNumSort(void);    /* From NBENCH1 */
  307. extern void DoStringSort(void);
  308. extern void DoBitops(void);
  309. extern void DoEmFloat(void);
  310. extern void DoFourier(void);
  311. extern void DoAssign(void);
  312. extern void DoIDEA(void);
  313. extern void DoHuffman(void);
  314. extern void DoNNET(void);
  315. extern void DoLU(void);
  316.  
  317. extern void ErrorExit(void);    /* From SYSSPEC */
  318.  
  319. /*
  320. ** Array of pointers to the benchmark functions.
  321. */
  322. void (*funcpointer[])(void) =
  323. {       DoNumSort,
  324.         DoStringSort,
  325.         DoBitops,
  326.         DoEmFloat,
  327.         DoFourier,
  328.         DoAssign,
  329.         DoIDEA,
  330.         DoHuffman,
  331.         DoNNET,
  332.         DoLU };
  333.  
  334.  
  335.