dhry.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. /*
  2. **************************************************************************
  3. * DHRYSTONE 2.1 BENCHMARK PC VERSION
  4. **************************************************************************
  5. *
  6. * "DHRYSTONE" Benchmark Program
  7. * -----------------------------
  8. *
  9. * Version: C, Version 2.1
  10. *
  11. * File: dhry.h (part 1 of 3)
  12. *
  13. * Date: May 25, 1988
  14. *
  15. * Author: Reinhold P. Weicker
  16. * Siemens AG, AUT E 51
  17. * Postfach 3220
  18. * 8520 Erlangen
  19. * Germany (West)
  20. * Phone: [+49]-9131-7-20330
  21. * (8-17 Central European Time)
  22. * Usenet: ..!mcsun!unido!estevax!weicker
  23. *
  24. * Original Version (in Ada) published in
  25. * "Communications of the ACM" vol. 27., no. 10 (Oct. 1984),
  26. * pp. 1013 - 1030, together with the statistics
  27. * on which the distribution of statements etc. is based.
  28. *
  29. * In this C version, the following C library functions are used:
  30. * - strcpy, strcmp (inside the measurement loop)
  31. * - printf, scanf (outside the measurement loop)
  32. * In addition, Berkeley UNIX system calls "times ()" or "time ()"
  33. * are used for execution time measurement. For measurements
  34. * on other systems, these calls have to be changed.
  35. *
  36. * Collection of Results:
  37. * Reinhold Weicker (address see above) and
  38. *
  39. * Rick Richardson
  40. * PC Research. Inc.
  41. * 94 Apple Orchard Drive
  42. * Tinton Falls, NJ 07724
  43. * Phone: (201) 389-8963 (9-17 EST)
  44. * Usenet: ...!uunet!pcrat!rick
  45. *
  46. * Please send results to Rick Richardson and/or Reinhold Weicker.
  47. * Complete information should be given on hardware and software used.
  48. * Hardware information includes: Machine type, CPU, type and size
  49. * of caches; for microprocessors: clock frequency, memory speed
  50. * (number of wait states).
  51. * Software information includes: Compiler (and runtime library)
  52. * manufacturer and version, compilation switches, OS version.
  53. * The Operating System version may give an indication about the
  54. * compiler; Dhrystone itself performs no OS calls in the measurement
  55. * loop.
  56. *
  57. * The complete output generated by the program should be mailed
  58. * such that at least some checks for correctness can be made.
  59. *
  60. **************************************************************************
  61. *
  62. * This version has changes made by Roy Longbottom to conform to a common
  63. * format for a series of standard benchmarks for PCs:
  64. *
  65. * Running time greater than 5 seconds due to inaccuracy of the PC clock.
  66. *
  67. * Automatic adjustment of run time, no manually inserted parameters.
  68. *
  69. * Initial display of calibration times to confirm linearity.
  70. *
  71. * Display of results within one screen (or at a slow speed as the test
  72. * progresses) so that it can be seen to have run successfully.
  73. *
  74. * Facilities to type in details of system used etc.
  75. *
  76. * All results and details appended to a results file.
  77. *
  78. *
  79. * Roy Longbottom
  80. * 101323.2241@compuserve.com
  81. *
  82. **************************************************************************
  83. *
  84. * For details of history, changes, other defines, benchmark construction
  85. * statistics see official versions from ftp.nosc.mil/pub/aburto where
  86. * the latest table of results (dhry.tbl) are available. See also
  87. * netlib@ornl.gov
  88. *
  89. **************************************************************************
  90. *
  91. * Defines: The following "Defines" are possible:
  92. * -DREG=register (default: Not defined)
  93. * As an approximation to what an average C programmer
  94. * might do, the "register" storage class is applied
  95. * (if enabled by -DREG=register)
  96. * - for local variables, if they are used (dynamically)
  97. * five or more times
  98. * - for parameters if they are used (dynamically)
  99. * six or more times
  100. * Note that an optimal "register" strategy is
  101. * compiler-dependent, and that "register" declarations
  102. * do not necessarily lead to faster execution.
  103. * -DNOSTRUCTASSIGN (default: Not defined)
  104. * Define if the C compiler does not support
  105. * assignment of structures.
  106. * -DNOENUMS (default: Not defined)
  107. * Define if the C compiler does not support
  108. * enumeration types.
  109. ***************************************************************************
  110. *
  111. * Compilation model and measurement (IMPORTANT):
  112. *
  113. * This C version of Dhrystone consists of three files:
  114. * - dhry.h (this file, containing global definitions and comments)
  115. * - dhry_1.c (containing the code corresponding to Ada package Pack_1)
  116. * - dhry_2.c (containing the code corresponding to Ada package Pack_2)
  117. *
  118. * The following "ground rules" apply for measurements:
  119. * - Separate compilation
  120. * - No procedure merging
  121. * - Otherwise, compiler optimizations are allowed but should be indicated
  122. * - Default results are those without register declarations
  123. * See the companion paper "Rationale for Dhrystone Version 2" for a more
  124. * detailed discussion of these ground rules.
  125. *
  126. * For 16-Bit processors (e.g. 80186, 80286), times for all compilation
  127. * models ("small", "medium", "large" etc.) should be given if possible,
  128. * together with a definition of these models for the compiler system used.
  129. *
  130. **************************************************************************
  131. * Examples of Pentium Results
  132. *
  133. * Dhrystone Benchmark Version 2.1 (Language: C)
  134. *
  135. * Month run 4/1996
  136. * PC model Escom
  137. * CPU Pentium
  138. * Clock MHz 100
  139. * Cache 256K
  140. * Options Neptune chipset
  141. * OS/DOS Windows 95
  142. * Compiler Watcom C/ C++ 10.5 Win386
  143. * OptLevel -otexan -zp8 -fp5 -5r
  144. * Run by Roy Longbottom
  145. * From UK
  146. * Mail 101323.2241@compuserve.com
  147. *
  148. * Final values (* implementation-dependent):
  149. *
  150. * Int_Glob: O.K. 5
  151. * Bool_Glob: O.K. 1
  152. * Ch_1_Glob: O.K. A
  153. * Ch_2_Glob: O.K. B
  154. * Arr_1_Glob[8]: O.K. 7
  155. * Arr_2_Glob8/7: O.K. 1600010
  156. * Ptr_Glob->
  157. * Ptr_Comp: * 98008
  158. * Discr: O.K. 0
  159. * Enum_Comp: O.K. 2
  160. * Int_Comp: O.K. 17
  161. * Str_Comp: O.K. DHRYSTONE PROGRAM, SOME STRING
  162. * Next_Ptr_Glob->
  163. * Ptr_Comp: * 98008 same as above
  164. * Discr: O.K. 0
  165. * Enum_Comp: O.K. 1
  166. * Int_Comp: O.K. 18
  167. * Str_Comp: O.K. DHRYSTONE PROGRAM, SOME STRING
  168. * Int_1_Loc: O.K. 5
  169. * Int_2_Loc: O.K. 13
  170. * Int_3_Loc: O.K. 7
  171. * Enum_Loc: O.K. 1
  172. * Str_1_Loc: O.K. DHRYSTONE PROGRAM, 1'ST STRING
  173. * Str_2_Loc: O.K. DHRYSTONE PROGRAM, 2'ND STRING
  174. *
  175. * Register option Selected.
  176. *
  177. * Microseconds 1 loop: 4.53
  178. * Dhrystones / second: 220690
  179. * VAX MIPS rating: 125.61
  180. *
  181. *
  182. * Dhrystone Benchmark Version 2.1 (Language: C)
  183. *
  184. * Month run 4/1996
  185. * PC model Escom
  186. * CPU Pentium
  187. * Clock MHz 100
  188. * Cache 256K
  189. * Options Neptune chipset
  190. * OS/DOS Windows 95
  191. * Compiler Watcom C/ C++ 10.5 Win386
  192. * OptLevel No optimisation
  193. * Run by Roy Longbottom
  194. * From UK
  195. * Mail 101323.2241@compuserve.com
  196. *
  197. * Final values (* implementation-dependent):
  198. *
  199. * Int_Glob: O.K. 5
  200. * Bool_Glob: O.K. 1
  201. * Ch_1_Glob: O.K. A
  202. * Ch_2_Glob: O.K. B
  203. * Arr_1_Glob[8]: O.K. 7
  204. * Arr_2_Glob8/7: O.K. 320010
  205. * Ptr_Glob->
  206. * Ptr_Comp: * 98004
  207. * Discr: O.K. 0
  208. * Enum_Comp: O.K. 2
  209. * Int_Comp: O.K. 17
  210. * Str_Comp: O.K. DHRYSTONE PROGRAM, SOME STRING
  211. * Next_Ptr_Glob->
  212. * Ptr_Comp: * 98004 same as above
  213. * Discr: O.K. 0
  214. * Enum_Comp: O.K. 1
  215. * Int_Comp: O.K. 18
  216. * Str_Comp: O.K. DHRYSTONE PROGRAM, SOME STRING
  217. * Int_1_Loc: O.K. 5
  218. * Int_2_Loc: O.K. 13
  219. * Int_3_Loc: O.K. 7
  220. * Enum_Loc: O.K. 1
  221. * Str_1_Loc: O.K. DHRYSTONE PROGRAM, 1'ST STRING
  222. * Str_2_Loc: O.K. DHRYSTONE PROGRAM, 2'ND STRING
  223. *
  224. * Register option Not selected.
  225. *
  226. * Microseconds 1 loop: 20.06
  227. * Dhrystones / second: 49844
  228. * VAX MIPS rating: 28.37
  229. *
  230. **************************************************************************
  231. */
  232. /* Compiler and system dependent definitions: */
  233. #ifndef TIME
  234. #define TIMES
  235. #endif
  236. /* Use times(2) time function unless */
  237. /* explicitly defined otherwise */
  238. #ifdef TIMES
  239. /* #include <sys/types.h>
  240. #include <sys/times.h> */
  241. /* for "times" */
  242. #endif
  243. #define Mic_secs_Per_Second 1000000.0
  244. /* Berkeley UNIX C returns process times in seconds/HZ */
  245. #ifdef NOSTRUCTASSIGN
  246. #define structassign(d, s) memcpy(&(d), &(s), sizeof(d))
  247. #else
  248. #define structassign(d, s) d = s
  249. #endif
  250. #ifdef NOENUM
  251. #define Ident_1 0
  252. #define Ident_2 1
  253. #define Ident_3 2
  254. #define Ident_4 3
  255. #define Ident_5 4
  256. typedef int Enumeration;
  257. #else
  258. typedef enum { Ident_1, Ident_2, Ident_3, Ident_4, Ident_5 } Enumeration;
  259. #endif
  260. /* for boolean and enumeration types in Ada, Pascal */
  261. /* General definitions: */
  262. #include <stdio.h>
  263. #include <string.h>
  264. /* for strcpy, strcmp */
  265. #define Null 0
  266. /* Value of a Null pointer */
  267. #define true 1
  268. #define false 0
  269. typedef int One_Thirty;
  270. typedef int One_Fifty;
  271. typedef char Capital_Letter;
  272. typedef int Boolean;
  273. typedef char Str_30[31];
  274. typedef int Arr_1_Dim[50];
  275. typedef int Arr_2_Dim[50][50];
  276. typedef struct record {
  277. struct record *Ptr_Comp;
  278. Enumeration Discr;
  279. union {
  280. struct {
  281. Enumeration Enum_Comp;
  282. int Int_Comp;
  283. char Str_Comp[31];
  284. } var_1;
  285. struct {
  286. Enumeration E_Comp_2;
  287. char Str_2_Comp[31];
  288. } var_2;
  289. struct {
  290. char Ch_1_Comp;
  291. char Ch_2_Comp;
  292. } var_3;
  293. } variant;
  294. } Rec_Type, *Rec_Pointer;