source: trunk/Softwares/Basic_test/src/include/dhry.h @ 114

Last change on this file since 114 was 100, checked in by rosiere, 16 years ago

1) Bug fix (Operation, Instruction)
2) Modif Return Address Stack
3) Add Soft Test
4) Add Soc Test

  • Property svn:keywords set to Id
File size: 16.0 KB
Line 
1/*
2 *************************************************************************
3 *
4 *                   "DHRYSTONE" Benchmark Program
5 *                   -----------------------------
6 *
7 *  Version:    C, Version 2.1
8 *
9 *  File:       dhry.h (part 1 of 3)
10 *
11 *  Date:       May 25, 1988
12 *
13 *  Author:     Reinhold P. Weicker
14 *              Siemens Nixdorf Inf. Syst.
15 *              STM OS 32
16 *              Otto-Hahn-Ring 6
17 *              W-8000 Muenchen 83
18 *              Germany
19 *                      Phone:    [+49]-89-636-42436
20 *                                (8-17 Central European Time)
21 *                      UUCP:     weicker@ztivax.uucp@unido.uucp
22 *                      Internet: weicker@ztivax.siemens.com
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
30 *              used:
31 *              - strcpy, strcmp (inside the measurement loop)
32 *              - printf, scanf (outside the measurement loop)
33 *
34 *  Collection of Results:
35 *              Reinhold Weicker (address see above) and
36 *             
37 *              Rick Richardson
38 *              PC Research. Inc.
39 *              94 Apple Orchard Drive
40 *              Tinton Falls, NJ 07724
41 *                      Phone:  (201) 834-1378 (9-17 EST)
42 *                      UUCP:   ...!uunet!pcrat!rick
43 *
44 *      Please send results to Rick Richardson and/or Reinhold Weicker.
45 *      Complete information should be given on hardware and software
46 *      used. Hardware information includes: Machine type, CPU, type and
47 *      size of caches; for microprocessors: clock frequency, memory speed
48 *      (number of wait states). Software information includes: Compiler
49 *      (and runtime library) manufacturer and version, compilation
50 *      switches, OS version. The Operating System version may give an
51 *      indication about the compiler; Dhrystone itself performs no OS
52 *      calls in the measurement loop.
53 *
54 *      The complete output generated by the program should be mailed
55 *      such that at least some checks for correctness can be made.
56 *
57 *************************************************************************
58 *
59 *  History:    This version C/2.1 has been made for two reasons:
60 *
61 *              1) There is an obvious need for a common C version of
62 *              Dhrystone, since C is at present the most popular system
63 *              programming language for the class of processors
64 *              (microcomputers, minicomputers) where Dhrystone is used
65 *              most. There should be, as far as possible, only one C
66 *              version of Dhrystone such that results can be compared
67 *              without restrictions. In the past, the C versions
68 *              distributed by Rick Richardson (Version 1.1) and by
69 *              Reinhold Weicker had small (though not significant)
70 *              differences.
71 *
72 *              2) As far as it is possible without changes to the
73 *              Dhrystone statistics, optimizing compilers should be
74 *              prevented from removing significant statements.
75 *
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
84 *              benchmark.
85 *
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
89 *              Weicker. As a concession to older compilers, names have
90 *              been made unique within the first 8 characters. Inside the
91 *              measurement loop, this version follows the version
92 *              previously distributed by Reinhold Weicker.
93 *
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
97 *              compilers should be prevented from moving code out of the
98 *              measurement loop, or from removing code altogether. Since
99 *              the statements that are executed within the measurement
100 *              loop have NOT been changed, the numbers defining the
101 *              "Dhrystone distribution" (distribution of statements,
102 *              operand types and locality) still hold. Except for
103 *              sophisticated optimizing compilers, execution times for
104 *              this version should be the same as for previous versions.
105 *
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.
111 *
112 *              All changes within the measurement loop are described
113 *              and discussed in the companion paper "Rationale for
114 *              Dhrystone version 2".
115 *
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
121 *              benchmarks. Users of the benchmark are advised to check
122 *              code listings whether code is generated for all statements
123 *              of Dhrystone.
124 *
125 *              Version 2.1 is identical to version 2.0 distributed via
126 *              the UNIX network Usenet in March 1988 except that it
127 *              corrects some minor deficiencies that were found by users
128 *              of version 2.0. The only change within the measurement
129 *              loop is that a non-executed "else" part was added to the
130 *              "if" statement in Func_3, and a non-executed "else" part
131 *              removed from Proc_3.
132 *
133 *************************************************************************
134 *
135 * Defines:     The following "Defines" are possible:
136 *              -DROPT         (default: Not defined)
137 *                      As an approximation to what an average C
138 *                      programmer might do, the "register" storage class
139 *                      is applied (if enabled by -DROPT)
140 *                      - for local variables, if they are used
141 *                        (dynamically) five or more times
142 *                      - for parameters if they are used (dynamically)
143 *                        six or more times
144 *                      Note that an optimal "register" strategy is
145 *                      compiler-dependent, and that "register"
146 *                      declarations do not necessarily lead to faster
147 *                      execution.
148 *              -DNOSTRUCTASSIGN        (default: Not defined)
149 *                      Define if the C compiler does not support
150 *                      assignment of structures.
151 *              -DNOENUMS               (default: Not defined)
152 *                      Define if the C compiler does not support
153 *                      enumeration types.
154 *
155 *************************************************************************
156 *
157 *  Compilation model and measurement (IMPORTANT):
158 *
159 *  This C version of Dhrystone consists of three files:
160 *  - dhry.h (this file, containing global definitions and comments)
161 *  - dhry_1.c (containing the code corresponding to Ada package Pack_1)
162 *  - dhry_2.c (containing the code corresponding to Ada package Pack_2)
163 *
164 *  The following "ground rules" apply for measurements:
165 *  - Separate compilation
166 *  - No procedure merging
167 *  - Otherwise, compiler optimizations are allowed but should be
168 *    indicated
169 *  - Default results are those without register declarations
170 *  See the companion paper "Rationale for Dhrystone Version 2" for a more
171 *  detailed discussion of these ground rules.
172 *
173 *  For 16-Bit processors (e.g. 80186, 80286), times for all compilation
174 *  models ("small", "medium", "large" etc.) should be given if possible,
175 *  together with a definition of these models for the compiler system
176 *  used.
177 *
178 *************************************************************************
179 *
180 *  Dhrystone (C version) statistics:
181 *
182 *  [Comment from the first distribution, updated for version 2.
183 *   Note that because of language differences, the numbers are slightly
184 *   different from the Ada version.]
185 *
186 *  The following program contains statements of a high level programming
187 *  language (here: C) in a distribution considered representative:
188 *
189 *    assignments                  52 (51.0 %)
190 *    control statements           33 (32.4 %)
191 *    procedure, function calls    17 (16.7 %)
192 *
193 *  103 statements are dynamically executed. The program is balanced with
194 *  respect to the three aspects:
195 *
196 *    - statement type
197 *    - operand type
198 *    - operand locality
199 *         operand global, local, parameter, or constant.
200 *
201 *  The combination of these three aspects is balanced only approximately.
202 *
203 *  1. Statement Type:
204 *  -----------------             number
205 *
206 *     V1 = V2                     9
207 *       (incl. V1 = F(..)
208 *     V = Constant               12
209 *     Assignment,                 7
210 *       with array element
211 *     Assignment,                 6
212 *       with record component
213 *                                --
214 *                                34       34
215 *
216 *     X = Y +|-|"&&"|"|" Z        5
217 *     X = Y +|-|"==" Constant     6
218 *     X = X +|- 1                 3
219 *     X = Y *|/ Z                 2
220 *     X = Expression,             1
221 *           two operators
222 *     X = Expression,             1
223 *           three operators
224 *                                --
225 *                                18       18
226 *
227 *     if ....                    14
228 *       with "else"      7
229 *       without "else"   7
230 *           executed        3
231 *           not executed    4
232 *     for ...                     7  |  counted every time
233 *     while ...                   4  |  the loop condition
234 *     do ... while                1  |  is evaluated
235 *     switch ...                  1
236 *     break                       1
237 *     declaration with            1
238 *       initialization
239 *                                --
240 *                                34       34
241 *
242 *     P (...)  procedure call    11
243 *       user procedure      10
244 *       library procedure    1
245 *     X = F (...)
246 *             function  call      6
247 *       user function        5
248 *       library function     1
249 *                                --
250 *                                17       17
251 *                                        ---
252 *                                        103
253 *
254 *    The average number of parameters in procedure or function calls
255 *    is 1.82 (not counting the function values as implicit parameters).
256 *
257 *
258 *  2. Operators
259 *  ------------
260 *                          number    approximate
261 *                                    percentage
262 *
263 *    Arithmetic             32          50.8
264 *
265 *       +                     21          33.3
266 *       -                      7          11.1
267 *       *                      3           4.8
268 *       / (int div)            1           1.6
269 *
270 *    Comparison             27           42.8
271 *
272 *       ==                     9           14.3
273 *       /=                     4            6.3
274 *       >                      1            1.6
275 *       <                      3            4.8
276 *       >=                     1            1.6
277 *       <=                     9           14.3
278 *
279 *    Logic                   4            6.3
280 *
281 *       && (AND-THEN)          1            1.6
282 *       |  (OR)                1            1.6
283 *       !  (NOT)               2            3.2
284 *
285 *                           --          -----
286 *                           63          100.1
287 *
288 *
289 *  3. Operand Type (counted once per operand reference):
290 *  ---------------
291 *                          number    approximate
292 *                                    percentage
293 *
294 *     Integer               175        72.3 %
295 *     Character              45        18.6 %
296 *     Pointer                12         5.0 %
297 *     String30                6         2.5 %
298 *     Array                   2         0.8 %
299 *     Record                  2         0.8 %
300 *                           ---       -------
301 *                           242       100.0 %
302 *
303 *  When there is an access path leading to the final operand (e.g. a
304 *  record component), only the final data type on the access path is
305 *  counted.
306 *
307 *
308 *  4. Operand Locality:
309 *  -------------------
310 *                                number    approximate
311 *                                          percentage
312 *
313 *     local variable              114        47.1 %
314 *     global variable              22         9.1 %
315 *     parameter                    45        18.6 %
316 *        value                        23         9.5 %
317 *        reference                    22         9.1 %
318 *     function result               6         2.5 %
319 *     constant                     55        22.7 %
320 *                                 ---       -------
321 *                                 242       100.0 %
322 *
323 *
324 *  The program does not compute anything meaningful, but it is
325 *  syntactically and semantically correct. All variables have a value
326 *  assigned to them before they are used as a source operand.
327 *
328 *  There has been no explicit effort to account for the effects of a
329 *  cache, or to balance the use of long or short displacements for code
330 *  or data.
331 *
332 *************************************************************************
333 */
334
335#ifndef DHRY
336#define DHRY
337
338/* Compiler and system dependent definitions: */
339
340// #ifdef SIM2OS
341// #define DOUBLE unsigned int
342// #define Mic_secs_Per_Second     1000000
343// #else
344#define DOUBLE float
345#define Mic_secs_Per_Second     1000000.0
346// #endif //SIM2OS
347
348                /* Berkeley UNIX C returns process times in seconds/HZ */
349
350#ifdef  NOSTRUCTASSIGN
351#define structassign(d, s)      memcpy(&(d), &(s), sizeof(d))
352#else
353#define structassign(d, s)      d = s
354#endif
355
356#ifdef  NOENUM
357#define Ident_1 0
358#define Ident_2 1
359#define Ident_3 2
360#define Ident_4 3
361#define Ident_5 4
362  typedef int   Enumeration;
363#else
364  typedef       enum    {Ident_1, Ident_2, Ident_3, Ident_4, Ident_5}
365                Enumeration;
366#endif
367        /* for boolean and enumeration types in Ada, Pascal */
368
369/* General definitions: */
370
371#include <stdio.h>
372                /* for strcpy, strcmp */
373
374#define Null 0
375                /* Value of a Null pointer */
376#define true  1
377#define false 0
378
379typedef int     One_Thirty;
380typedef int     One_Fifty;
381typedef char    Capital_Letter;
382typedef int     Boolean;
383typedef char    Str_30 [31];
384typedef int     Arr_1_Dim [50];
385typedef int     Arr_2_Dim [50] [50];
386
387typedef struct record
388    {
389    struct record *Ptr_Comp;
390    Enumeration    Discr;
391    union {
392          struct {
393                  Enumeration Enum_Comp;
394                  int         Int_Comp;
395                  char        Str_Comp [31];
396                  } var_1;
397          struct {
398                  Enumeration E_Comp_2;
399                  char        Str_2_Comp [31];
400                  } var_2;
401          struct {
402                  char        Ch_1_Comp;
403                  char        Ch_2_Comp;
404                  } var_3;
405          } variant;
406      } Rec_Type, *Rec_Pointer;
407
408#endif //!DHRY
Note: See TracBrowser for help on using the repository browser.