1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
3 ****************************************************************************
5 * "DHRYSTONE" Benchmark Program
6 * -----------------------------
8 * Version: C, Version 2.1
10 * File: dhry.h (part 1 of 3)
14 * Author: Reinhold P. Weicker
15 * Siemens AG, AUT E 51
19 * Phone: [+49]-9131-7-20330
20 * (8-17 Central European Time)
21 * Usenet: ..!mcsun!unido!estevax!weicker
23 * Original Version (in Ada) published in
24 * "Communications of the ACM" vol. 27., no. 10 (Oct. 1984),
25 * pp. 1013 - 1030, together with the statistics
26 * on which the distribution of statements etc. is based.
28 * In this C version, the following C library functions are used:
29 * - strcpy, strcmp (inside the measurement loop)
30 * - printf, scanf (outside the measurement loop)
31 * In addition, Berkeley UNIX system calls "times ()" or "time ()"
32 * are used for execution time measurement. For measurements
33 * on other systems, these calls have to be changed.
35 * Collection of Results:
36 * Reinhold Weicker (address see above) and
40 * 94 Apple Orchard Drive
41 * Tinton Falls, NJ 07724
42 * Phone: (201) 389-8963 (9-17 EST)
43 * Usenet: ...!uunet!pcrat!rick
45 * Please send results to Rick Richardson and/or Reinhold Weicker.
46 * Complete information should be given on hardware and software used.
47 * Hardware information includes: Machine type, CPU, type and size
48 * of caches; for microprocessors: clock frequency, memory speed
49 * (number of wait states).
50 * Software information includes: Compiler (and runtime library)
51 * manufacturer and version, compilation switches, OS version.
52 * The Operating System version may give an indication about the
53 * compiler; Dhrystone itself performs no OS calls in the measurement loop.
55 * The complete output generated by the program should be mailed
56 * such that at least some checks for correctness can be made.
58 ***************************************************************************
60 * History: This version C/2.1 has been made for two reasons:
62 * 1) There is an obvious need for a common C version of
63 * Dhrystone, since C is at present the most popular system
64 * programming language for the class of processors
65 * (microcomputers, minicomputers) where Dhrystone is used most.
66 * There should be, as far as possible, only one C version of
67 * Dhrystone such that results can be compared without
68 * restrictions. In the past, the C versions distributed
69 * by Rick Richardson (Version 1.1) and by Reinhold Weicker
70 * had small (though not significant) differences.
72 * 2) As far as it is possible without changes to the Dhrystone
73 * statistics, optimizing compilers should be prevented from
74 * removing significant statements.
76 * This C version has been developed in cooperation with
77 * Rick Richardson (Tinton Falls, NJ), it incorporates many
78 * ideas from the "Version 1.1" distributed previously by
79 * him over the UNIX network Usenet.
80 * I also thank Chaim Benedelac (National Semiconductor),
81 * David Ditzel (SUN), Earl Killian and John Mashey (MIPS),
82 * Alan Smith and Rafael Saavedra-Barrera (UC at Berkeley)
83 * for their help with comments on earlier versions of the
86 * Changes: In the initialization part, this version follows mostly
87 * Rick Richardson's version distributed via Usenet, not the
88 * version distributed earlier via floppy disk by Reinhold Weicker.
89 * As a concession to older compilers, names have been made
90 * unique within the first 8 characters.
91 * Inside the measurement loop, this version follows the
92 * version previously distributed by Reinhold Weicker.
94 * At several places in the benchmark, code has been added,
95 * but within the measurement loop only in branches that
96 * are not executed. The intention is that optimizing compilers
97 * should be prevented from moving code out of the measurement
98 * loop, or from removing code altogether. Since the statements
99 * that are executed within the measurement loop have NOT been
100 * changed, the numbers defining the "Dhrystone distribution"
101 * (distribution of statements, operand types and locality)
102 * still hold. Except for sophisticated optimizing compilers,
103 * execution times for this version should be the same as
104 * for previous versions.
106 * Since it has proven difficult to subtract the time for the
107 * measurement loop overhead in a correct way, the loop check
108 * has been made a part of the benchmark. This does have
109 * an impact - though a very minor one - on the distribution
110 * statistics which have been updated for this version.
112 * All changes within the measurement loop are described
113 * and discussed in the companion paper "Rationale for
114 * Dhrystone version 2".
116 * Because of the self-imposed limitation that the order and
117 * distribution of the executed statements should not be
118 * changed, there are still cases where optimizing compilers
119 * may not generate code for some statements. To a certain
120 * degree, this is unavoidable for small synthetic benchmarks.
121 * Users of the benchmark are advised to check code listings
122 * whether code is generated for all statements of Dhrystone.
124 * Version 2.1 is identical to version 2.0 distributed via
125 * the UNIX network Usenet in March 1988 except that it corrects
126 * some minor deficiencies that were found by users of version 2.0.
127 * The only change within the measurement loop is that a
128 * non-executed "else" part was added to the "if" statement in
129 * Func_3, and a non-executed "else" part removed from Proc_3.
131 ***************************************************************************
133 * Compilation model and measurement (IMPORTANT):
135 * This C version of Dhrystone consists of three files:
136 * - dhry.h (this file, containing global definitions and comments)
137 * - dhry_1.c (containing the code corresponding to Ada package Pack_1)
138 * - dhry_2.c (containing the code corresponding to Ada package Pack_2)
140 * The following "ground rules" apply for measurements:
141 * - Separate compilation
142 * - No procedure merging
143 * - Otherwise, compiler optimizations are allowed but should be indicated
144 * - Default results are those without register declarations
145 * See the companion paper "Rationale for Dhrystone Version 2" for a more
146 * detailed discussion of these ground rules.
148 * For 16-Bit processors (e.g. 80186, 80286), times for all compilation
149 * models ("small", "medium", "large" etc.) should be given if possible,
150 * together with a definition of these models for the compiler system used.
152 **************************************************************************
154 * Dhrystone (C version) statistics:
156 * [Comment from the first distribution, updated for version 2.
157 * Note that because of language differences, the numbers are slightly
158 * different from the Ada version.]
160 * The following program contains statements of a high level programming
161 * language (here: C) in a distribution considered representative:
163 * assignments 52 (51.0 %)
164 * control statements 33 (32.4 %)
165 * procedure, function calls 17 (16.7 %)
167 * 103 statements are dynamically executed. The program is balanced with
168 * respect to the three aspects:
173 * operand global, local, parameter, or constant.
175 * The combination of these three aspects is balanced only approximately.
178 * ----------------- number
186 * with record component
190 * X = Y +|-|"&&"|"|" Z 5
191 * X = Y +|-|"==" Constant 6
206 * for ... 7 | counted every time
207 * while ... 4 | the loop condition
208 * do ... while 1 | is evaluated
216 * P (...) procedure call 11
218 * library procedure 1
228 * The average number of parameters in procedure or function calls
229 * is 1.82 (not counting the function values as implicit parameters).
255 * && (AND-THEN) 1 1.6
263 * 3. Operand Type (counted once per operand reference):
269 * Character 45 18.6 %
277 * When there is an access path leading to the final operand (e.g. a record
278 * component), only the final data type on the access path is counted.
281 * 4. Operand Locality:
282 * -------------------
286 * local variable 114 47.1 %
287 * global variable 22 9.1 %
288 * parameter 45 18.6 %
291 * function result 6 2.5 %
297 * The program does not compute anything meaningful, but it is syntactically
298 * and semantically correct. All variables have a value assigned to them
299 * before they are used as a source operand.
301 * There has been no explicit effort to account for the effects of a
302 * cache, or to balance the use of long or short displacements for code or
305 ***************************************************************************
314 } Enumeration; /* for boolean and enumeration types in Ada, Pascal */
316 /* General definitions: */
318 typedef int One_Thirty;
319 typedef int One_Fifty;
320 typedef char Capital_Letter;
322 typedef char Str_30[31];
323 typedef int Arr_1_Dim[50];
324 typedef int Arr_2_Dim[50][50];
326 typedef struct record {
327 struct record *Ptr_Comp;
331 Enumeration Enum_Comp;
336 Enumeration E_Comp_2;
344 } Rec_Type, *Rec_Pointer;
348 extern char Ch_1_Glob;
350 void Proc_6(Enumeration Enum_Val_Par, Enumeration *Enum_Ref_Par);
351 void Proc_7(One_Fifty Int_1_Par_Val, One_Fifty Int_2_Par_Val,
352 One_Fifty *Int_Par_Ref);
353 void Proc_8(Arr_1_Dim Arr_1_Par_Ref, Arr_2_Dim Arr_2_Par_Ref,
354 int Int_1_Par_Val, int Int_2_Par_Val);
355 Enumeration Func_1(Capital_Letter Ch_1_Par_Val, Capital_Letter Ch_2_Par_Val);
356 Boolean Func_2(Str_30 Str_1_Par_Ref, Str_30 Str_2_Par_Ref);