OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [branches/] [stable_0_2_x/] [or1ksim/] [testbench/] [dhry.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.