1 /** Sanatised version of the dhrystone-2.1 test.
3 Modifications Michael Hope <michaelh@earthling.net>
5 This is derrived from the dhrystone-2.1.tar.gz tarball available
6 all over the net. I sourced it from the Red Hat src rpm.
9 * Made it more ANSI compliant.
10 * Changed any array function arguments to pointers to make my
12 * Removed malloc's for a couple of static arrays.
15 I couldnt find a copyright in the original - the most relevent
19 I didn't write the DHRYSTONE benchmark. Rheinhold Weicker did. He has
20 certainly provided us with a useful tool for benchmarking, and is
25 (201) 389-8963 (9-17 EST)
26 (201) 542-3734 (7-9,17-24 EST)
27 ...!uunet!pcrat!rick (normal mail)
28 ...!uunet!pcrat!dry2 (results only)
32 /* Temporary definitions. Remove soon :) */
33 char *strcpy(char *dest, const char *src);
34 void *memcpy(void *dest, const char *src, int wLen);
35 int strcmp(const char *s1, const char *s2);
44 int Arr_2_Glob [50] [50];
46 /* Used instead of malloc() */
47 static Rec_Type _r[2];
49 void Proc_1 (REG Rec_Pointer Ptr_Val_Par);
50 void Proc_2 (One_Fifty *Int_Par_Ref);
53 void Proc_7 (One_Fifty Int_1_Par_Val, One_Fifty Int_2_Par_Val, One_Fifty *Int_Par_Ref);
54 void Proc_8 (int **Arr_1_Par_Ref, int **Arr_2_Par_Ref,
55 int Int_1_Par_Val, int Int_2_Par_Val);
56 void Proc_6 (Enumeration Enum_Val_Par, Enumeration *Enum_Ref_Par);
57 void Proc_3 (Rec_Pointer *Ptr_Ref_Par);
58 Enumeration Func_1 (Capital_Letter Ch_1_Par_Val, Capital_Letter Ch_2_Par_Val);
59 Boolean Func_2 (char *Str_1_Par_Ref, char *Str_2_Par_Ref);
60 Boolean Func_3 (Enumeration Enum_Par_Val);
65 REG One_Fifty Int_2_Loc;
67 REG Capital_Letter Ch_Index;
72 REG int Number_Of_Runs;
78 Next_Ptr_Glob = &_r[0];
81 Ptr_Glob->Ptr_Comp = Next_Ptr_Glob;
82 Ptr_Glob->Discr = Ident_1;
83 Ptr_Glob->variant.var_1.Enum_Comp = Ident_3;
84 Ptr_Glob->variant.var_1.Int_Comp = 40;
85 strcpy (Ptr_Glob->variant.var_1.Str_Comp,
86 "DHRYSTONE PROGRAM, SOME STRING");
87 strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING");
89 Arr_2_Glob [8][7] = 10;
90 /* Was missing in published program. Without this statement, */
91 /* Arr_2_Glob [8][7] would have an undefined value. */
92 /* Warning: With 16-Bit processors and Number_Of_Runs > 32000, */
93 /* overflow may occur for this array element. */
98 for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index) {
101 /* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */
104 strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
106 Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc);
108 while (Int_1_Loc < Int_2_Loc) /* loop body executed once */
110 Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc;
112 Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc);
116 /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
117 Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc);
120 for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index)
121 /* loop body executed twice */
123 if (Enum_Loc == Func_1 (Ch_Index, 'C'))
124 /* then, not executed */
126 Proc_6 (Ident_1, &Enum_Loc);
127 strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
128 Int_2_Loc = Run_Index;
129 Int_Glob = Run_Index;
132 /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
133 Int_2_Loc = Int_2_Loc * Int_1_Loc;
134 Int_1_Loc = Int_2_Loc / Int_3_Loc;
135 Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc;
136 /* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */
140 } /* loop "for Run_Index" */
143 printf ("Execution ends\n");
145 printf ("Final values of the variables used in the benchmark:\n");
147 printf ("Int_Glob: %d\n", Int_Glob);
148 printf (" should be: %d\n", 5);
149 printf ("Bool_Glob: %d\n", Bool_Glob);
150 printf (" should be: %d\n", 1);
151 printf ("Ch_1_Glob: %c\n", Ch_1_Glob);
152 printf (" should be: %c\n", 'A');
153 printf ("Ch_2_Glob: %c\n", Ch_2_Glob);
154 printf (" should be: %c\n", 'B');
155 printf ("Arr_1_Glob[8]: %d\n", Arr_1_Glob[8]);
156 printf (" should be: %d\n", 7);
157 printf ("Arr_2_Glob[8][7]: %d\n", Arr_2_Glob[8][7]);
158 printf (" should be: Number_Of_Runs + 10\n");
159 printf ("Ptr_Glob->\n");
160 printf (" Ptr_Comp: %d\n", (int) Ptr_Glob->Ptr_Comp);
161 printf (" should be: (implementation-dependent)\n");
162 printf (" Discr: %d\n", Ptr_Glob->Discr);
163 printf (" should be: %d\n", 0);
164 printf (" Enum_Comp: %d\n", Ptr_Glob->variant.var_1.Enum_Comp);
165 printf (" should be: %d\n", 2);
166 printf (" Int_Comp: %d\n", Ptr_Glob->variant.var_1.Int_Comp);
167 printf (" should be: %d\n", 17);
168 printf (" Str_Comp: %s\n", Ptr_Glob->variant.var_1.Str_Comp);
169 printf (" should be: DHRYSTONE PROGRAM, SOME STRING\n");
170 printf ("Next_Ptr_Glob->\n");
171 printf (" Ptr_Comp: %d\n", (int) Next_Ptr_Glob->Ptr_Comp);
172 printf (" should be: (implementation-dependent), same as above\n");
173 printf (" Discr: %d\n", Next_Ptr_Glob->Discr);
174 printf (" should be: %d\n", 0);
175 printf (" Enum_Comp: %d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp);
176 printf (" should be: %d\n", 1);
177 printf (" Int_Comp: %d\n", Next_Ptr_Glob->variant.var_1.Int_Comp);
178 printf (" should be: %d\n", 18);
179 printf (" Str_Comp: %s\n",
180 Next_Ptr_Glob->variant.var_1.Str_Comp);
181 printf (" should be: DHRYSTONE PROGRAM, SOME STRING\n");
182 printf ("Int_1_Loc: %d\n", Int_1_Loc);
183 printf (" should be: %d\n", 5);
184 printf ("Int_2_Loc: %d\n", Int_2_Loc);
185 printf (" should be: %d\n", 13);
186 printf ("Int_3_Loc: %d\n", Int_3_Loc);
187 printf (" should be: %d\n", 7);
188 printf ("Enum_Loc: %d\n", Enum_Loc);
189 printf (" should be: %d\n", 1);
190 printf ("Str_1_Loc: %s\n", Str_1_Loc);
191 printf (" should be: DHRYSTONE PROGRAM, 1'ST STRING\n");
192 printf ("Str_2_Loc: %s\n", Str_2_Loc);
193 printf (" should be: DHRYSTONE PROGRAM, 2'ND STRING\n");
198 void Proc_1 (REG Rec_Pointer Ptr_Val_Par)
201 REG Rec_Pointer Next_Record = Ptr_Val_Par->Ptr_Comp;
202 /* == Ptr_Glob_Next */
203 /* Local variable, initialized with Ptr_Val_Par->Ptr_Comp, */
204 /* corresponds to "rename" in Ada, "with" in Pascal */
206 structassign (*Ptr_Val_Par->Ptr_Comp, *Ptr_Glob);
207 Ptr_Val_Par->variant.var_1.Int_Comp = 5;
208 Next_Record->variant.var_1.Int_Comp
209 = Ptr_Val_Par->variant.var_1.Int_Comp;
210 Next_Record->Ptr_Comp = Ptr_Val_Par->Ptr_Comp;
211 Proc_3 (&Next_Record->Ptr_Comp);
212 /* Ptr_Val_Par->Ptr_Comp->Ptr_Comp
213 == Ptr_Glob->Ptr_Comp */
214 if (Next_Record->Discr == Ident_1)
217 Next_Record->variant.var_1.Int_Comp = 6;
218 Proc_6 (Ptr_Val_Par->variant.var_1.Enum_Comp,
219 &Next_Record->variant.var_1.Enum_Comp);
220 Next_Record->Ptr_Comp = Ptr_Glob->Ptr_Comp;
221 Proc_7 (Next_Record->variant.var_1.Int_Comp, 10,
222 &Next_Record->variant.var_1.Int_Comp);
224 else /* not executed */
225 structassign (*Ptr_Val_Par, *Ptr_Val_Par->Ptr_Comp);
229 void Proc_2 (One_Fifty *Int_Par_Ref)
232 /* *Int_Par_Ref == 1, becomes 4 */
235 Enumeration Enum_Loc;
237 Int_Loc = *Int_Par_Ref + 10;
238 do /* executed once */
239 if (Ch_1_Glob == 'A')
243 *Int_Par_Ref = Int_Loc - Int_Glob;
246 while (Enum_Loc != Ident_1); /* true */
250 void Proc_3 (Rec_Pointer *Ptr_Ref_Par)
253 /* Ptr_Ref_Par becomes Ptr_Glob */
255 if (Ptr_Glob != Null)
257 *Ptr_Ref_Par = Ptr_Glob->Ptr_Comp;
258 Proc_7 (10, Int_Glob, &Ptr_Glob->variant.var_1.Int_Comp);
262 void Proc_4 (void) /* without parameters */
268 Bool_Loc = Ch_1_Glob == 'A';
269 Bool_Glob = Bool_Loc | Bool_Glob;
274 void Proc_5 () /* without parameters */
282 void Proc_6 (Enumeration Enum_Val_Par, Enumeration *Enum_Ref_Par)
283 /*********************************/
285 /* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */
288 *Enum_Ref_Par = Enum_Val_Par;
289 if (! Func_3 (Enum_Val_Par))
290 /* then, not executed */
291 *Enum_Ref_Par = Ident_4;
292 switch (Enum_Val_Par)
295 *Enum_Ref_Par = Ident_1;
300 *Enum_Ref_Par = Ident_1;
301 else *Enum_Ref_Par = Ident_4;
303 case Ident_3: /* executed */
304 *Enum_Ref_Par = Ident_2;
308 *Enum_Ref_Par = Ident_3;
314 /*************************************************/
315 /* executed three times */
316 /* first call: Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R' */
317 /* second call: Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C' */
318 /* third call: Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C' */
319 Enumeration Func_1 (Capital_Letter Ch_1_Par_Val, Capital_Letter Ch_2_Par_Val)
321 Capital_Letter Ch_1_Loc;
322 Capital_Letter Ch_2_Loc;
324 Ch_1_Loc = Ch_1_Par_Val;
326 if (Ch_2_Loc != Ch_2_Par_Val)
329 else /* not executed */
331 Ch_1_Glob = Ch_1_Loc;
336 Boolean Func_3 (Enumeration Enum_Par_Val)
337 /***************************/
339 /* Enum_Par_Val == Ident_3 */
341 Enumeration Enum_Loc;
343 Enum_Loc = Enum_Par_Val;
344 if (Enum_Loc == Ident_3)
347 else /* not executed */
351 void Proc_7 (One_Fifty Int_1_Par_Val, One_Fifty Int_2_Par_Val, One_Fifty *Int_Par_Ref)
352 /**********************************************/
353 /* executed three times */
354 /* first call: Int_1_Par_Val == 2, Int_2_Par_Val == 3, */
355 /* Int_Par_Ref becomes 7 */
356 /* second call: Int_1_Par_Val == 10, Int_2_Par_Val == 5, */
357 /* Int_Par_Ref becomes 17 */
358 /* third call: Int_1_Par_Val == 6, Int_2_Par_Val == 10, */
359 /* Int_Par_Ref becomes 18 */
363 Int_Loc = Int_1_Par_Val + 2;
364 *Int_Par_Ref = Int_2_Par_Val + Int_Loc;
367 /*void Proc_8 (Arr_1_Dim Arr_1_Par_Ref, Arr_2_Dim Arr_2_Par_Ref,
368 int Int_1_Par_Val, int Int_2_Par_Val)*/
369 void Proc_8 (int **Arr_1_Par_Ref, int **Arr_2_Par_Ref,
370 int Int_1_Par_Val, int Int_2_Par_Val)
372 REG One_Fifty Int_Index;
373 REG One_Fifty Int_Loc;
375 Int_Loc = Int_1_Par_Val + 5;
376 Arr_1_Par_Ref [Int_Loc] = Int_2_Par_Val;
377 Arr_1_Par_Ref [Int_Loc+1] = Arr_1_Par_Ref [Int_Loc];
378 Arr_1_Par_Ref [Int_Loc+30] = Int_Loc;
379 for (Int_Index = Int_Loc; Int_Index <= Int_Loc+1; ++Int_Index)
380 Arr_2_Par_Ref [Int_Loc] [Int_Index] = Int_Loc;
381 Arr_2_Par_Ref [Int_Loc] [Int_Loc-1] += 1;
382 Arr_2_Par_Ref [Int_Loc+20] [Int_Loc] = Arr_1_Par_Ref [Int_Loc];
386 /*********************************************************************/
388 /* Int_Par_Val_1 == 3 */
389 /* Int_Par_Val_2 == 7 */
390 Boolean Func_2 (char *Str_1_Par_Ref, char *Str_2_Par_Ref)
391 /*************************************************/
393 /* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */
394 /* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */
396 REG One_Thirty Int_Loc;
397 Capital_Letter Ch_Loc;
400 while (Int_Loc <= 2) /* loop body executed once */
401 if (Func_1 (Str_1_Par_Ref[Int_Loc],
402 Str_2_Par_Ref[Int_Loc+1]) == Ident_1)
408 if (Ch_Loc >= 'W' && Ch_Loc < 'Z')
409 /* then, not executed */
412 /* then, not executed */
416 if (strcmp (Str_1_Par_Ref, Str_2_Par_Ref) > 0)
417 /* then, not executed */