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