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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [sim/] [rtl_sim/] [src-c/] [dhrystone_v2.1/] [original_files/] [RATIONALE] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 olivier.gi
 
2
 
3
    Dhrystone Benchmark: Rationale for Version 2 and Measurement Rules
4
 
5
 
6
                 Reinhold P. Weicker
7
                 Siemens AG, E STE 35
8
                 Postfach 3240
9
                 D-8520 Erlangen
10
                 Germany (West)
11
 
12
 
13
 
14
 
15
1.  Why a Version 2 of Dhrystone?
16
 
17
The Dhrystone benchmark  program  [1]  has  become  a  popular  benchmark  for
18
CPU/compiler   performance   measurement,   in   particular  in  the  area  of
19
minicomputers, workstations, PC's and microprocesors.  It apparently satisfies
20
a  need  for  an  easy-to-use  integer benchmark; it gives a first performance
21
indication which is more meaningful than MIPS numbers which, in their  literal
22
meaning  (million  instructions  per  second), cannot be used across different
23
instruction sets (e.g. RISC  vs.  CISC).   With  the  increasing  use  of  the
24
benchmark, it seems necessary to reconsider the benchmark and to check whether
25
it can still fulfill this function.  Version 2 of Dhrystone is the  result  of
26
such a re-evaluation, it has been made for two reasons:
27
 
28
o Dhrystone has been published in Ada [1], and Versions in Ada, Pascal  and  C
29
  have  been  distributed  by  Reinhold Weicker via floppy disk.  However, the
30
  version that was used most often for benchmarking has been the version  made
31
  by  Rick  Richardson  by another translation from the Ada version into the C
32
  programming language, this has been the version  distributed  via  the  UNIX
33
  network Usenet [2].
34
 
35
  There is an obvious need for a common C version of Dhrystone, since C is  at
36
  present  the  most  popular  system  programming  language  for the class of
37
  systems (microcomputers, minicomputers,  workstations)  where  Dhrystone  is
38
  used  most.   There  should  be,  as  far as possible, only one C version of
39
  Dhrystone such that results can be compared  without  restrictions.  In  the
40
  past,  the  C  versions  distributed by Rick Richardson (Version 1.1) and by
41
  Reinhold Weicker had small (though not significant) differences.
42
 
43
  Together with the new C version, the  Ada  and  Pascal  versions  have  been
44
  updated as well.
45
 
46
o As far as it is  possible  without  changes  to  the  Dhrystone  statistics,
47
  optimizing   compilers   should   be  prevented  from  removing  significant
48
  statements.  It has  turned  out  in  the  past  that  optimizing  compilers
49
  suppressed  code  generation for too many statements (by "dead code removal"
50
  or  "dead  variable  elimination").   This  has  lead  to  the  danger  that
51
  benchmarking  results obtained by a naive application of Dhrystone - without
52
  inspection of the code that was generated - could become meaningless.
53
 
54
The  overall  policiy  for  version  2  has  been  that  the  distribution  of
55
statements,  operand types and operand locality described in [1] should remain
56
unchanged as much as possible.  (Very few changes were necessary; their impact
57
should be negligible.)  Also, the order of statements should remain unchanged.
58
Although I am aware of some critical remarks on the benchmark - I  agree  with
59
several  of them - and know some suggestions for improvement, I didn't want to
60
change the benchmark into something different from what has  become  known  as
61
"Dhrystone"; the confusion generated by such a change would probably outweight
62
the benefits. If I were to write a new benchmark program, I wouldn't  give  it
63
the  name  "Dhrystone"  since  this  denotes  the  program  published  in [1].
64
However, I do recognize  the  need  for  a  larger  number  of  representative
65
programs  that can be used as benchmarks; users should always be encouraged to
66
use more than just one benchmark.
67
 
68
The new versions (version 2.1 for C, Pascal and Ada) will  be  distributed  as
69
widely as possible.  (Version 2.1 differs from version 2.0 distributed via the
70
UNIX Network Usenet in  March  1988  only  in  a  few  corrections  for  minor
71
deficiencies  found  by  users  of  version 2.0.)  Readers who want to use the
72
benchmark for their own measurements can obtain  a  copy  in  machine-readable
73
form on floppy disk (MS-DOS or XENIX format) from the author.
74
 
75
 
76
2.  Overall Characteristics of Version 2
77
 
78
In general, version 2  follows  -  in  the  parts  that  are  significant  for
79
performance  measurement,  i.e.   within  the measurement loop - the published
80
(Ada) version and the C versions previously distributed.  Where  the  versions
81
distributed  by  Rick Richardson [2] and Reinhold Weicker have been different,
82
it  follows  the  version  distributed  by  Reinhold  Weicker.  (However,  the
83
differences  have  been  so  small  that their impact on execution time in all
84
likelihood has been negligible.)  The initialization and UNIX  instrumentation
85
part  -  which  had  been  omitted  in  [1] - follows mostly the ideas of Rick
86
Richardson [2].  However, any changes in the initialization part  and  in  the
87
printing  of  the  result have no impact on performance measurement since they
88
are outside the measaurement loop.  As a concession to older compilers,  names
89
have been made unique within the first 8 characters for the C version.
90
 
91
The original publication of Dhrystone did not contain any statements for  time
92
measurement  since  they  are necessarily system-dependent. However, it turned
93
out that it is not enough just to inclose the main procedure of Dhrystone in a
94
loop  and  to  measure the execution time.  If the variables that are computed
95
are not used somehow, there is the danger that the compiler considers them  as
96
"dead  variables" and suppresses code generation for a part of the statements.
97
Therefore in version 2 all variables of "main" are printed at the end  of  the
98
program.  This also permits some plausibility control for correct execution of
99
the benchmark.
100
 
101
At several places in the benchmark, code has been added, but only in  branches
102
that  are  not  executed. The intention is that optimizing compilers should be
103
prevented from moving code out of the measurement loop, or from removing  code
104
altogether.  Statements that are executed have been changed in very few places
105
only.  In these cases, only the role of some operands has been changed, and it
106
was   made  sure  that  the  numbers  defining  the  "Dhrystone  distribution"
107
(distribution of statements, operand types and locality) still hold as much as
108
possible.   Except for sophisticated optimizing compilers, execution times for
109
version 2.1 should be the same as for previous versions.
110
 
111
Because of the self-imposed limitation that the order and distribution of  the
112
executed  statements  should  not  be  changed,  there  are  still cases where
113
optimizing compilers may not generate code for some statements. To  a  certain
114
degree,  this  is  unavoidable  for  small synthetic benchmarks.  Users of the
115
benchmark are advised to check code listings whether code is generated for all
116
statements of Dhrystone.
117
 
118
Contrary to the suggestion in the published paper and its realization  in  the
119
versions previously distributed, no attempt has been made to subtract the time
120
for the measurement loop overhead. (This calculation has proven  difficult  to
121
implement  in  a  correct  way,  and  its omission makes the program simpler.)
122
However, since the loop check is now part of the benchmark, this does have  an
123
impact  -  though a very minor one - on the distribution statistics which have
124
been updated for this version.
125
 
126
 
127
3.  Discussion of Individual Changes
128
 
129
In this section, all changes are described that affect  the  measurement  loop
130
and  that  are  not  just  renamings  of variables. All remarks refer to the C
131
version; the other language versions have been updated similarly.
132
 
133
In addition to adding  the  measurement  loop  and  the  printout  statements,
134
changes have been made at the following places:
135
 
136
o In procedure "main", three statements have been added  in  the  non-executed
137
  "then" part of the statement
138
 
139
        if (Enum_Loc == Func_1 (Ch_Index, 'C'))
140
 
141
  they are
142
 
143
        strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
144
        Int_2_Loc = Run_Index;
145
        Int_Glob = Run_Index;
146
 
147
  The string assignment prevents  movement  of  the  preceding  assignment  to
148
  Str_2_Loc  (5'th  statement  of  "main")  out  of the measurement loop (This
149
  probably will not happen for the C version, but it did happen  with  another
150
  language   and  compiler.)   The  assignment  to  Int_2_Loc  prevents  value
151
  propagation for Int_2_Loc, and the assignment to Int_Glob makes the value of
152
  Int_Glob possibly dependent from the value of Run_Index.
153
 
154
o In the three arithmetic computations at the end of the measurement  loop  in
155
  "main  ",  the  role  of  some  variables has been exchanged, to prevent the
156
  division from just cancelling out the multiplication as it was  in  [1].   A
157
  very   smart  compiler  might  have  recognized  this  and  suppressed  code
158
  generation for the division.
159
 
160
o For Proc_2, no code has been changed, but the values of the actual parameter
161
  have changed due to changes in "main".
162
 
163
o In Proc_4, the second assignment has been changed from
164
 
165
        Bool_Loc = Bool_Loc | Bool_Glob;
166
 
167
  to
168
 
169
        Bool_Glob = Bool_Loc | Bool_Glob;
170
 
171
  It now assigns a value to a global variable  instead  of  a  local  variable
172
  (Bool_Loc);   Bool_Loc  would  be  a  "dead  variable"  which  is  not  used
173
  afterwards.
174
 
175
o In Func_1, the statement
176
 
177
        Ch_1_Glob = Ch_1_Loc;
178
 
179
  was added in the non-executed "else" part of the "if" statement, to  prevent
180
  the suppression of code generation for the assignment to Ch_1_Loc.
181
 
182
o In Func_2, the second character comparison statement has been changed to
183
 
184
        if (Ch_Loc == 'R')
185
 
186
  ('R' instead of 'X') because  a  comparison  with  'X'  is  implied  in  the
187
  preceding "if" statement.
188
 
189
  Also in Func_2, the statement
190
 
191
        Int_Glob = Int_Loc;
192
 
193
  has been added in the non-executed part of the last "if" statement, in order
194
  to prevent Int_Loc from becoming a dead variable.
195
 
196
o In Func_3, a non-executed "else" part has been added to the "if"  statement.
197
  While  the  program  would  not be incorrect without this "else" part, it is
198
  considered bad programming practice if a function  can  be  left  without  a
199
  return value.
200
 
201
  To compensate for this change, the (non-executed) "else" part  in  the  "if"
202
  statement of Proc_3 was removed.
203
 
204
The distribution statistics have been changed only  by  the  addition  of  the
205
measurement loop iteration (1 additional statement, 4 additional local integer
206
operands) and by the change in Proc_4  (one  operand  changed  from  local  to
207
global).  The distribution statistics in the comment headers have been updated
208
accordingly.
209
 
210
 
211
4.  String Operations
212
 
213
The string operations (string assignment and string comparison) have not  been
214
changed, to keep the program consistent with the original version.
215
 
216
There has been some concern that the string operations are over-represented in
217
the  program,  and that execution time is dominated by these operations.  This
218
was true in particular when optimizing compilers removed too much code in  the
219
main part of the program, this should have been mitigated in version 2.
220
 
221
It should be noted that this is a  language-dependent  issue:   Dhrystone  was
222
first  published  in  Ada, and with Ada or Pascal semantics, the time spent in
223
the string operations is,  at  least  in  all  implementations  known  to  me,
224
considerably smaller.  In Ada and Pascal, assignment and comparison of strings
225
are operators defined in the language, and the upper  bounds  of  the  strings
226
occuring  in  Dhrystone  are part of the type information known at compilation
227
time.  The compilers can therefore generate  efficient  inline  code.   In  C,
228
string  assignemt  and comparisons are not part of the language, so the string
229
operations must be expressed in terms of the C library functions "strcpy"  and
230
"strcmp".   (ANSI  C  allows  an  implementation  to use inline code for these
231
functions.)  In addition to the overhead caused by additional function  calls,
232
these  functions  are  defined for null-terminated strings where the length of
233
the strings is not known at compilation time; the function has to check  every
234
byte for the termination condition (the null byte).
235
 
236
Obviously, a C library which includes efficiently coded "strcpy" and  "strcmp"
237
functions  helps to obtain good Dhrystone results. However, I don't think that
238
this is unfair since string  functions  do  occur  quite  frequently  in  real
239
programs  (editors, command interpreters, etc.).  If the strings functions are
240
implemented efficiently,  this  helps  real  programs  as  well  as  benchmark
241
programs.
242
 
243
I admit that the  string  comparison  in  Dhrystone  terminates  later  (after
244
scanning  20  characters)  than most string comparisons in real programs.  For
245
consistency with the original benchmark, I didn't change the  program  despite
246
this weakness.
247
 
248
 
249
5.  Intended Use of Dhrystone
250
 
251
When Dhrystone is used, the following "ground rules" apply:
252
 
253
o Separate compilation (Ada and C versions)
254
 
255
  As mentioned in [1], Dhrystone was written  to  reflect  actual  programming
256
  practice  in  systems  programming.   The  division into several compilation
257
  units (5 in the Ada version, 2 in the C version)  is  intended,  as  is  the
258
  distribution of inter-module and intra-module subprogram calls.  Although on
259
  many systems there will be no difference in execution time  to  a  Dhrystone
260
  version  where  all  compilation units are merged into one file, the rule is
261
  that separate compilation should  be  used.   The  intention  is  that  real
262
  programming  practice,  where  programs  consist  of  several  independently
263
  compiled units, should  be  reflected.   This  also  has  implies  that  the
264
  compiler,  while  compiling  one  unit,  has no information about the use of
265
  variables, register allocation etc.  occuring in  other  compilation  units.
266
  Although  in  real  life  compilation  units  will  probably  be larger, the
267
  intention is that these effects  of  separate  compilation  are  modeled  in
268
  Dhrystone.
269
 
270
  A few language systems have post-linkage optimization available (e.g., final
271
  register allocation is performed after linkage).  This is a borderline case:
272
  Post-linkage  optimization  involves  additional  program  preparation  time
273
  (although  not  as  much  as  compilation in one unit) which may prevent its
274
  general use in practical programming.  I think that  since  it  defeats  the
275
  intentions given above, it should not be used for Dhrystone.
276
 
277
  Unfortunately, ISO/ANSI  Pascal  does  not  contain  language  features  for
278
  separate  compilation.   Although  most  commercial Pascal compilers provide
279
  separate compilation in some way, we cannot use it for Dhrystone since  such
280
  a  version  would  not  be portable.  Therefore, no attempt has been made to
281
  provide a Pascal version with several compilation units.
282
 
283
o No procedure merging
284
 
285
  Although Dhrystone contains some very short procedures where execution would
286
  benefit  from  procedure  merging (inlining, macro expansion of procedures),
287
  procedure merging is not to be used.  The reason is that the  percentage  of
288
  procedure  and  function  calls  is  part of the "Dhrystone distribution" of
289
  statements contained in [1].  This restriction does not hold for the  string
290
  functions  of  the  C  version  since ANSI C allows an implementation to use
291
  inline code for these functions.
292
 
293
o Other optimizations are allowed, but they should be indicated
294
 
295
  It is often hard to draw an exact line between "normal code generation"  and
296
  "optimization"  in  compilers:  Some compilers perform operations by default
297
  that are invoked in other compilers only  when  optimization  is  explicitly
298
  requested.  Also, we cannot avoid that in benchmarking people try to achieve
299
  results that look as good as possible.  Therefore,  optimizations  performed
300
  by  compilers  -  other  than  those  listed  above - are not forbidden when
301
  Dhrystone execution times are measured.  Dhrystone is  not  intended  to  be
302
  non-optimizable  but  is  intended  to  be  similarly  optimizable as normal
303
  programs.   For  example,  there  are  several  places  in  Dhrystone  where
304
  performance   benefits   from   optimizations   like   common  subexpression
305
  elimination, value  propagation  etc.,  but  normal  programs  usually  also
306
  benefit  from  these  optimizations.   Therefore,  no  effort  was  made  to
307
  artificially  prevent  such  optimizations.   However,  measurement  reports
308
  should  indicate  which  compiler  optimization  levels  have been used, and
309
  reporting results with different levels of  compiler  optimization  for  the
310
  same hardware is encouraged.
311
 
312
o Default results are those without "register" declarations (C version)
313
 
314
  When Dhrystone results are quoted  without  additional  qualification,  they
315
  should  be  understood  as  results  obtained  without use of the "register"
316
  attribute. Good compilers should be able to make good use of registers  even
317
  without explicit register declarations ([3], p. 193).
318
 
319
Of course, for experimental  purposes,  post-linkage  optimization,  procedure
320
merging and/or compilation in one unit can be done to determine their effects.
321
However,  Dhrystone  numbers  obtained  under  these  conditions   should   be
322
explicitly  marked as such; "normal" Dhrystone results should be understood as
323
results obtained following the ground rules listed above.
324
 
325
In any case, for serious performance evaluation, users are advised to ask  for
326
code  listings  and  to  check  them carefully.  In this way, when results for
327
different systems are  compared,  the  reader  can  get  a  feeling  how  much
328
performance  difference is due to compiler optimization and how much is due to
329
hardware speed.
330
 
331
 
332
6.  Acknowledgements
333
 
334
The C version 2.1 of Dhrystone has been developed  in  cooperation  with  Rick
335
Richardson  (Tinton  Falls,  NJ), it incorporates many ideas from the "Version
336
1.1" distributed previously by him over the UNIX network Usenet.  Through  his
337
activity with Usenet, Rick Richardson has made a very valuable contribution to
338
the dissemination of the benchmark.  I also thank  Chaim  Benedelac  (National
339
Semiconductor),  David Ditzel (SUN), Earl Killian and John Mashey (MIPS), Alan
340
Smith and Rafael  Saavedra-Barrera  (UC  at  Berkeley)  for  their  help  with
341
comments on earlier versions of the benchmark.
342
 
343
 
344
7.  Bibliography
345
 
346
[1]
347
   Reinhold P. Weicker: Dhrystone: A Synthetic Systems Programming Benchmark.
348
   Communications of the ACM 27, 10 (Oct. 1984), 1013-1030
349
 
350
[2]
351
   Rick Richardson: Dhrystone 1.1 Benchmark Summary (and Program Text)
352
   Informal Distribution via "Usenet", Last Version Known  to  me:  Sept.  21,
353
   1987
354
 
355
[3]
356
   Brian W. Kernighan and Dennis M. Ritchie:  The C Programming Language.
357
   Prentice-Hall, Englewood Cliffs (NJ) 1978
358
 

powered by: WebSVN 2.1.0

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