xref: /freebsd/contrib/cortex-strings/benchmarks/dhry/dhry.h (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
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 
233 /* Compiler and system dependent definitions: */
234 
235 #ifndef TIME
236 #define TIMES
237 #endif
238                 /* Use times(2) time function unless    */
239                 /* explicitly defined otherwise         */
240 
241 #ifdef TIMES
242 /* #include <sys/types.h>
243    #include <sys/times.h> */
244                 /* for "times" */
245 #endif
246 
247 #define Mic_secs_Per_Second     1000000.0
248                 /* Berkeley UNIX C returns process times in seconds/HZ */
249 
250 #ifdef  NOSTRUCTASSIGN
251 #define structassign(d, s)      memcpy(&(d), &(s), sizeof(d))
252 #else
253 #define structassign(d, s)      d = s
254 #endif
255 
256 #ifdef  NOENUM
257 #define Ident_1 0
258 #define Ident_2 1
259 #define Ident_3 2
260 #define Ident_4 3
261 #define Ident_5 4
262   typedef int   Enumeration;
263 #else
264   typedef       enum    {Ident_1, Ident_2, Ident_3, Ident_4, Ident_5}
265                 Enumeration;
266 #endif
267         /* for boolean and enumeration types in Ada, Pascal */
268 
269 /* General definitions: */
270 
271 #include <stdio.h>
272 #include <string.h>
273 
274                 /* for strcpy, strcmp */
275 
276 #define Null 0
277                 /* Value of a Null pointer */
278 #define true  1
279 #define false 0
280 
281 typedef int     One_Thirty;
282 typedef int     One_Fifty;
283 typedef char    Capital_Letter;
284 typedef int     Boolean;
285 typedef char    Str_30 [31];
286 typedef int     Arr_1_Dim [50];
287 typedef int     Arr_2_Dim [50] [50];
288 
289 typedef struct record
290     {
291     struct record *Ptr_Comp;
292     Enumeration    Discr;
293     union {
294           struct {
295                   Enumeration Enum_Comp;
296                   int         Int_Comp;
297                   char        Str_Comp [31];
298                   } var_1;
299           struct {
300                   Enumeration E_Comp_2;
301                   char        Str_2_Comp [31];
302                   } var_2;
303           struct {
304                   char        Ch_1_Comp;
305                   char        Ch_2_Comp;
306                   } var_3;
307           } variant;
308       } Rec_Type, *Rec_Pointer;
309 
310 
311 
312