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

/* Compiler and system dependent definitions: */

#ifndef TIME
#define TIMES
#endif
                /* Use times(2) time function unless    */
                /* explicitly defined otherwise         */

#ifdef TIMES
/* #include <sys/types.h> 
   #include <sys/times.h> */
                /* for "times" */
#endif

#define Mic_secs_Per_Second     1000000.0
                /* Berkeley UNIX C returns process times in seconds/HZ */

#ifdef  NOSTRUCTASSIGN
#define structassign(d, s)      memcpy(&(d), &(s), sizeof(d))
#else
#define structassign(d, s)      d = s
#endif

#ifdef  NOENUM
#define Ident_1 0
#define Ident_2 1
#define Ident_3 2
#define Ident_4 3
#define Ident_5 4
  typedef int   Enumeration;
#else
  typedef       enum    {Ident_1, Ident_2, Ident_3, Ident_4, Ident_5}
                Enumeration;
#endif
        /* for boolean and enumeration types in Ada, Pascal */

/* General definitions: */

#include <stdio.h>
#include <string.h>

                /* for strcpy, strcmp */

#define Null 0 
                /* Value of a Null pointer */
#define true  1
#define false 0

typedef int     One_Thirty;
typedef int     One_Fifty;
typedef char    Capital_Letter;
typedef int     Boolean;
typedef char    Str_30 [31];
typedef int     Arr_1_Dim [50];
typedef int     Arr_2_Dim [50] [50];

typedef struct record 
    {
    struct record *Ptr_Comp;
    Enumeration    Discr;
    union {
          struct {
                  Enumeration Enum_Comp;
                  int         Int_Comp;
                  char        Str_Comp [31];
                  } var_1;
          struct {
                  Enumeration E_Comp_2;
                  char        Str_2_Comp [31];
                  } var_2;
          struct {
                  char        Ch_1_Comp;
                  char        Ch_2_Comp;
                  } var_3;
          } variant;
      } Rec_Type, *Rec_Pointer;