1 /*****************************************************************************
2 * The BYTE UNIX Benchmarks - Release 3
3 * Module: dhry.h SID: 3.4 5/15/91 19:30:21
5 *****************************************************************************
6 * Bug reports, patches, comments, suggestions should be sent to:
8 * Ben Smith, Rick Grehan or Tom Yager
9 * ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com
11 *****************************************************************************
16 * "DHRYSTONE" Benchmark Program
17 * -----------------------------
19 * Version: C, Version 2.1
21 * File: dhry.h (part 1 of 3)
25 * Author: Reinhold P. Weicker
26 * Siemens AG, AUT E 51
30 * Phone: [+49]-9131-7-20330
31 * (8-17 Central European Time)
32 * Usenet: ..!mcvax!unido!estevax!weicker
34 * Original Version (in Ada) published in
35 * "Communications of the ACM" vol. 27., no. 10 (Oct. 1984),
36 * pp. 1013 - 1030, together with the statistics
37 * on which the distribution of statements etc. is based.
39 * In this C version, the following C library functions are used:
40 * - strcpy, strcmp (inside the measurement loop)
41 * - printf, scanf (outside the measurement loop)
42 * In addition, Berkeley UNIX system calls "times ()" or "time ()"
43 * are used for execution time measurement. For measurements
44 * on other systems, these calls have to be changed.
46 * Collection of Results:
47 * Reinhold Weicker (address see above) and
51 * 94 Apple Orchard Drive
52 * Tinton Falls, NJ 07724
53 * Phone: (201) 834-1378 (9-17 EST)
54 * Usenet: ...!seismo!uunet!pcrat!rick
56 * Please send results to Rick Richardson and/or Reinhold Weicker.
57 * Complete information should be given on hardware and software used.
58 * Hardware information includes: Machine type, CPU, type and size
59 * of caches; for microprocessors: clock frequency, memory speed
60 * (number of wait states).
61 * Software information includes: Compiler (and runtime library)
62 * manufacturer and version, compilation switches, OS version.
63 * The Operating System version may give an indication about the
64 * compiler; Dhrystone itself performs no OS calls in the measurement loop.
66 * The complete output generated by the program should be mailed
67 * such that at least some checks for correctness can be made.
69 ***************************************************************************
71 * History: This version C/2.1 has been made for two reasons:
73 * 1) There is an obvious need for a common C version of
74 * Dhrystone, since C is at present the most popular system
75 * programming language for the class of processors
76 * (microcomputers, minicomputers) where Dhrystone is used most.
77 * There should be, as far as possible, only one C version of
78 * Dhrystone such that results can be compared without
79 * restrictions. In the past, the C versions distributed
80 * by Rick Richardson (Version 1.1) and by Reinhold Weicker
81 * had small (though not significant) differences.
83 * 2) As far as it is possible without changes to the Dhrystone
84 * statistics, optimizing compilers should be prevented from
85 * removing significant statements.
87 * This C version has been developed in cooperation with
88 * Rick Richardson (Tinton Falls, NJ), it incorporates many
89 * ideas from the "Version 1.1" distributed previously by
90 * him over the UNIX network Usenet.
91 * I also thank Chaim Benedelac (National Semiconductor),
92 * David Ditzel (SUN), Earl Killian and John Mashey (MIPS),
93 * Alan Smith and Rafael Saavedra-Barrera (UC at Berkeley)
94 * for their help with comments on earlier versions of the
97 * Changes: In the initialization part, this version follows mostly
98 * Rick Richardson's version distributed via Usenet, not the
99 * version distributed earlier via floppy disk by Reinhold Weicker.
100 * As a concession to older compilers, names have been made
101 * unique within the first 8 characters.
102 * Inside the measurement loop, this version follows the
103 * version previously distributed by Reinhold Weicker.
105 * At several places in the benchmark, code has been added,
106 * but within the measurement loop only in branches that
107 * are not executed. The intention is that optimizing compilers
108 * should be prevented from moving code out of the measurement
109 * loop, or from removing code altogether. Since the statements
110 * that are executed within the measurement loop have NOT been
111 * changed, the numbers defining the "Dhrystone distribution"
112 * (distribution of statements, operand types and locality)
113 * still hold. Except for sophisticated optimizing compilers,
114 * execution times for this version should be the same as
115 * for previous versions.
117 * Since it has proven difficult to subtract the time for the
118 * measurement loop overhead in a correct way, the loop check
119 * has been made a part of the benchmark. This does have
120 * an impact - though a very minor one - on the distribution
121 * statistics which have been updated for this version.
123 * All changes within the measurement loop are described
124 * and discussed in the companion paper "Rationale for
125 * Dhrystone version 2".
127 * Because of the self-imposed limitation that the order and
128 * distribution of the executed statements should not be
129 * changed, there are still cases where optimizing compilers
130 * may not generate code for some statements. To a certain
131 * degree, this is unavoidable for small synthetic benchmarks.
132 * Users of the benchmark are advised to check code listings
133 * whether code is generated for all statements of Dhrystone.
135 * Version 2.1 is identical to version 2.0 distributed via
136 * the UNIX network Usenet in March 1988 except that it corrects
137 * some minor deficiencies that were found by users of version 2.0.
138 * The only change within the measurement loop is that a
139 * non-executed "else" part was added to the "if" statement in
140 * Func_3, and a non-executed "else" part removed from Proc_3.
142 ***************************************************************************
144 * Defines: The following "Defines" are possible:
145 * -DREG=register (default: Not defined)
146 * As an approximation to what an average C programmer
147 * might do, the "register" storage class is applied
148 * (if enabled by -DREG=register)
149 * - for local variables, if they are used (dynamically)
151 * - for parameters if they are used (dynamically)
153 * Note that an optimal "register" strategy is
154 * compiler-dependent, and that "register" declarations
155 * do not necessarily lead to faster execution.
156 * -DNOSTRUCTASSIGN (default: Not defined)
157 * Define if the C compiler does not support
158 * assignment of structures.
159 * -DNOENUMS (default: Not defined)
160 * Define if the C compiler does not support
164 * The "times" function of UNIX (returning process times)
165 * or the "time" function (returning wallclock time)
166 * is used for measurement.
167 * For single user machines, "time ()" is adequate. For
168 * multi-user machines where you cannot get single-user
169 * access, use the "times ()" function. If you have
170 * neither, use a stopwatch in the dead of night.
171 * "printf"s are provided marking the points "Start Timer"
172 * and "Stop Timer". DO NOT use the UNIX "time(1)"
173 * command, as this will measure the total time to
174 * run this program, which will (erroneously) include
175 * the time to allocate storage (malloc) and to perform
176 * the initialization.
178 * In Berkeley UNIX, the function "times" returns process
179 * time in 1/HZ seconds, with HZ = 60 for most systems.
180 * CHECK YOUR SYSTEM DESCRIPTION BEFORE YOU JUST APPLY
183 ***************************************************************************
185 * Compilation model and measurement (IMPORTANT):
187 * This C version of Dhrystone consists of three files:
188 * - dhry.h (this file, containing global definitions and comments)
189 * - dhry_1.c (containing the code corresponding to Ada package Pack_1)
190 * - dhry_2.c (containing the code corresponding to Ada package Pack_2)
192 * The following "ground rules" apply for measurements:
193 * - Separate compilation
194 * - No procedure merging
195 * - Otherwise, compiler optimizations are allowed but should be indicated
196 * - Default results are those without register declarations
197 * See the companion paper "Rationale for Dhrystone Version 2" for a more
198 * detailed discussion of these ground rules.
200 * For 16-Bit processors (e.g. 80186, 80286), times for all compilation
201 * models ("small", "medium", "large" etc.) should be given if possible,
202 * together with a definition of these models for the compiler system used.
204 **************************************************************************
206 * Dhrystone (C version) statistics:
208 * [Comment from the first distribution, updated for version 2.
209 * Note that because of language differences, the numbers are slightly
210 * different from the Ada version.]
212 * The following program contains statements of a high level programming
213 * language (here: C) in a distribution considered representative:
215 * assignments 52 (51.0 %)
216 * control statements 33 (32.4 %)
217 * procedure, function calls 17 (16.7 %)
219 * 103 statements are dynamically executed. The program is balanced with
220 * respect to the three aspects:
225 * operand global, local, parameter, or constant.
227 * The combination of these three aspects is balanced only approximately.
230 * ----------------- number
238 * with record component
242 * X = Y +|-|"&&"|"|" Z 5
243 * X = Y +|-|"==" Constant 6
258 * for ... 7 | counted every time
259 * while ... 4 | the loop condition
260 * do ... while 1 | is evaluated
268 * P (...) procedure call 11
270 * library procedure 1
280 * The average number of parameters in procedure or function calls
281 * is 1.82 (not counting the function values as implicit parameters).
307 * && (AND-THEN) 1 1.6
315 * 3. Operand Type (counted once per operand reference):
321 * Character 45 18.6 %
329 * When there is an access path leading to the final operand (e.g. a record
330 * component), only the final data type on the access path is counted.
333 * 4. Operand Locality:
334 * -------------------
338 * local variable 114 47.1 %
339 * global variable 22 9.1 %
340 * parameter 45 18.6 %
343 * function result 6 2.5 %
349 * The program does not compute anything meaningful, but it is syntactically
350 * and semantically correct. All variables have a value assigned to them
351 * before they are used as a source operand.
353 * There has been no explicit effort to account for the effects of a
354 * cache, or to balance the use of long or short displacements for code or
357 ***************************************************************************
361 /* Compiler and system dependent definitions: */
366 /* Use times(2) time function unless */
367 /* explicitly defined otherwise */
370 #include <sys/types.h>
371 #include <sys/times.h>
375 #define Mic_secs_Per_Second 1000000.0
376 /* Berkeley UNIX C returns process times in seconds/HZ */
378 #ifdef NOSTRUCTASSIGN
379 #define structassign(d, s) memcpy(&(d), &(s), sizeof(d))
381 #define structassign(d, s) d = s
390 typedef int Enumeration
;
392 typedef enum {Ident_1
, Ident_2
, Ident_3
, Ident_4
, Ident_5
}
395 /* for boolean and enumeration types in Ada, Pascal */
397 /* General definitions: */
400 /* for strcpy, strcmp */
403 /* Value of a Null pointer */
407 typedef int One_Thirty
;
408 typedef int One_Fifty
;
409 typedef char Capital_Letter
;
411 typedef char Str_30
[31];
412 typedef int Arr_1_Dim
[50];
413 typedef int Arr_2_Dim
[50] [50];
415 typedef struct record
417 struct record
*Ptr_Comp
;
421 Enumeration Enum_Comp
;
426 Enumeration E_Comp_2
;
427 char Str_2_Comp
[31];
434 } Rec_Type
, *Rec_Pointer
;