1 /* SPDX-License-Identifier: (GPL-2.0-only OR B 1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ 2 /* 2 /* 3 ********************************************* 3 **************************************************************************** 4 * 4 * 5 * "DHRYSTONE" Benchmark Pro 5 * "DHRYSTONE" Benchmark Program 6 * ------------------------- 6 * ----------------------------- 7 * 7 * 8 * Version: C, Version 2.1 8 * Version: C, Version 2.1 9 * 9 * 10 * File: dhry.h (part 1 of 3) 10 * File: dhry.h (part 1 of 3) 11 * 11 * 12 * Date: May 25, 1988 12 * Date: May 25, 1988 13 * 13 * 14 * Author: Reinhold P. Weicker 14 * Author: Reinhold P. Weicker 15 * Siemens AG, AUT E 51 15 * Siemens AG, AUT E 51 16 * Postfach 3220 16 * Postfach 3220 17 * 8520 Erlangen 17 * 8520 Erlangen 18 * Germany (West) 18 * Germany (West) 19 * Phone: [+49]- 19 * Phone: [+49]-9131-7-20330 20 * (8-17 20 * (8-17 Central European Time) 21 * Usenet: ..!mcs 21 * Usenet: ..!mcsun!unido!estevax!weicker 22 * 22 * 23 * Original Version (in Ada) publ 23 * Original Version (in Ada) published in 24 * "Communications of the ACM" vo 24 * "Communications of the ACM" vol. 27., no. 10 (Oct. 1984), 25 * pp. 1013 - 1030, together with 25 * pp. 1013 - 1030, together with the statistics 26 * on which the distribution of s 26 * on which the distribution of statements etc. is based. 27 * 27 * 28 * In this C version, the followi 28 * In this C version, the following C library functions are used: 29 * - strcpy, strcmp (inside the m 29 * - strcpy, strcmp (inside the measurement loop) 30 * - printf, scanf (outside the m 30 * - printf, scanf (outside the measurement loop) 31 * In addition, Berkeley UNIX sys 31 * In addition, Berkeley UNIX system calls "times ()" or "time ()" 32 * are used for execution time me 32 * are used for execution time measurement. For measurements 33 * on other systems, these calls 33 * on other systems, these calls have to be changed. 34 * 34 * 35 * Collection of Results: 35 * Collection of Results: 36 * Reinhold Weicker (address see 36 * Reinhold Weicker (address see above) and 37 * 37 * 38 * Rick Richardson 38 * Rick Richardson 39 * PC Research. Inc. 39 * PC Research. Inc. 40 * 94 Apple Orchard Drive 40 * 94 Apple Orchard Drive 41 * Tinton Falls, NJ 07724 41 * Tinton Falls, NJ 07724 42 * Phone: (201) 389-8963 42 * Phone: (201) 389-8963 (9-17 EST) 43 * Usenet: ...!uunet!pcra 43 * Usenet: ...!uunet!pcrat!rick 44 * 44 * 45 * Please send results to Rick Richardson 45 * Please send results to Rick Richardson and/or Reinhold Weicker. 46 * Complete information should be given o 46 * Complete information should be given on hardware and software used. 47 * Hardware information includes: Machine 47 * Hardware information includes: Machine type, CPU, type and size 48 * of caches; for microprocessors: clock 48 * of caches; for microprocessors: clock frequency, memory speed 49 * (number of wait states). 49 * (number of wait states). 50 * Software information includes: Compile 50 * Software information includes: Compiler (and runtime library) 51 * manufacturer and version, compilation 51 * manufacturer and version, compilation switches, OS version. 52 * The Operating System version may give 52 * The Operating System version may give an indication about the 53 * compiler; Dhrystone itself performs no 53 * compiler; Dhrystone itself performs no OS calls in the measurement loop. 54 * 54 * 55 * The complete output generated by the p 55 * The complete output generated by the program should be mailed 56 * such that at least some checks for cor 56 * such that at least some checks for correctness can be made. 57 * 57 * 58 ********************************************* 58 *************************************************************************** 59 * 59 * 60 * History: This version C/2.1 has been ma 60 * History: This version C/2.1 has been made for two reasons: 61 * 61 * 62 * 1) There is an obvious need fo 62 * 1) There is an obvious need for a common C version of 63 * Dhrystone, since C is at prese 63 * Dhrystone, since C is at present the most popular system 64 * programming language for the c 64 * programming language for the class of processors 65 * (microcomputers, minicomputers 65 * (microcomputers, minicomputers) where Dhrystone is used most. 66 * There should be, as far as pos 66 * There should be, as far as possible, only one C version of 67 * Dhrystone such that results ca 67 * Dhrystone such that results can be compared without 68 * restrictions. In the past, the 68 * restrictions. In the past, the C versions distributed 69 * by Rick Richardson (Version 1. 69 * by Rick Richardson (Version 1.1) and by Reinhold Weicker 70 * had small (though not signific 70 * had small (though not significant) differences. 71 * 71 * 72 * 2) As far as it is possible wi 72 * 2) As far as it is possible without changes to the Dhrystone 73 * statistics, optimizing compile 73 * statistics, optimizing compilers should be prevented from 74 * removing significant statement 74 * removing significant statements. 75 * 75 * 76 * This C version has been develo 76 * This C version has been developed in cooperation with 77 * Rick Richardson (Tinton Falls, 77 * Rick Richardson (Tinton Falls, NJ), it incorporates many 78 * ideas from the "Version 1.1" d 78 * ideas from the "Version 1.1" distributed previously by 79 * him over the UNIX network Usen 79 * him over the UNIX network Usenet. 80 * I also thank Chaim Benedelac ( 80 * I also thank Chaim Benedelac (National Semiconductor), 81 * David Ditzel (SUN), Earl Killi 81 * David Ditzel (SUN), Earl Killian and John Mashey (MIPS), 82 * Alan Smith and Rafael Saavedra 82 * Alan Smith and Rafael Saavedra-Barrera (UC at Berkeley) 83 * for their help with comments o 83 * for their help with comments on earlier versions of the 84 * benchmark. 84 * benchmark. 85 * 85 * 86 * Changes: In the initialization part, th 86 * Changes: In the initialization part, this version follows mostly 87 * Rick Richardson's version dist 87 * Rick Richardson's version distributed via Usenet, not the 88 * version distributed earlier vi 88 * version distributed earlier via floppy disk by Reinhold Weicker. 89 * As a concession to older compi 89 * As a concession to older compilers, names have been made 90 * unique within the first 8 char 90 * unique within the first 8 characters. 91 * Inside the measurement loop, t 91 * Inside the measurement loop, this version follows the 92 * version previously distributed 92 * version previously distributed by Reinhold Weicker. 93 * 93 * 94 * At several places in the bench 94 * At several places in the benchmark, code has been added, 95 * but within the measurement loo 95 * but within the measurement loop only in branches that 96 * are not executed. The intentio 96 * are not executed. The intention is that optimizing compilers 97 * should be prevented from movin 97 * should be prevented from moving code out of the measurement 98 * loop, or from removing code al 98 * loop, or from removing code altogether. Since the statements 99 * that are executed within the m 99 * that are executed within the measurement loop have NOT been 100 * changed, the numbers defining 100 * changed, the numbers defining the "Dhrystone distribution" 101 * (distribution of statements, o 101 * (distribution of statements, operand types and locality) 102 * still hold. Except for sophist 102 * still hold. Except for sophisticated optimizing compilers, 103 * execution times for this versi 103 * execution times for this version should be the same as 104 * for previous versions. 104 * for previous versions. 105 * 105 * 106 * Since it has proven difficult 106 * Since it has proven difficult to subtract the time for the 107 * measurement loop overhead in a 107 * measurement loop overhead in a correct way, the loop check 108 * has been made a part of the be 108 * has been made a part of the benchmark. This does have 109 * an impact - though a very mino 109 * an impact - though a very minor one - on the distribution 110 * statistics which have been upd 110 * statistics which have been updated for this version. 111 * 111 * 112 * All changes within the measure 112 * All changes within the measurement loop are described 113 * and discussed in the companion 113 * and discussed in the companion paper "Rationale for 114 * Dhrystone version 2". 114 * Dhrystone version 2". 115 * 115 * 116 * Because of the self-imposed li 116 * Because of the self-imposed limitation that the order and 117 * distribution of the executed s 117 * distribution of the executed statements should not be 118 * changed, there are still cases 118 * changed, there are still cases where optimizing compilers 119 * may not generate code for some 119 * may not generate code for some statements. To a certain 120 * degree, this is unavoidable fo 120 * degree, this is unavoidable for small synthetic benchmarks. 121 * Users of the benchmark are adv 121 * Users of the benchmark are advised to check code listings 122 * whether code is generated for 122 * whether code is generated for all statements of Dhrystone. 123 * 123 * 124 * Version 2.1 is identical to ve 124 * Version 2.1 is identical to version 2.0 distributed via 125 * the UNIX network Usenet in Mar 125 * the UNIX network Usenet in March 1988 except that it corrects 126 * some minor deficiencies that w 126 * some minor deficiencies that were found by users of version 2.0. 127 * The only change within the mea 127 * The only change within the measurement loop is that a 128 * non-executed "else" part was a 128 * non-executed "else" part was added to the "if" statement in 129 * Func_3, and a non-executed "el 129 * Func_3, and a non-executed "else" part removed from Proc_3. 130 * 130 * 131 ********************************************* 131 *************************************************************************** 132 * 132 * 133 * Compilation model and measurement (IMPORTA 133 * Compilation model and measurement (IMPORTANT): 134 * 134 * 135 * This C version of Dhrystone consists of th 135 * This C version of Dhrystone consists of three files: 136 * - dhry.h (this file, containing global def 136 * - dhry.h (this file, containing global definitions and comments) 137 * - dhry_1.c (containing the code correspond 137 * - dhry_1.c (containing the code corresponding to Ada package Pack_1) 138 * - dhry_2.c (containing the code correspond 138 * - dhry_2.c (containing the code corresponding to Ada package Pack_2) 139 * 139 * 140 * The following "ground rules" apply for mea 140 * The following "ground rules" apply for measurements: 141 * - Separate compilation 141 * - Separate compilation 142 * - No procedure merging 142 * - No procedure merging 143 * - Otherwise, compiler optimizations are al 143 * - Otherwise, compiler optimizations are allowed but should be indicated 144 * - Default results are those without regist 144 * - Default results are those without register declarations 145 * See the companion paper "Rationale for Dhr 145 * See the companion paper "Rationale for Dhrystone Version 2" for a more 146 * detailed discussion of these ground rules. 146 * detailed discussion of these ground rules. 147 * 147 * 148 * For 16-Bit processors (e.g. 80186, 80286), 148 * For 16-Bit processors (e.g. 80186, 80286), times for all compilation 149 * models ("small", "medium", "large" etc.) s 149 * models ("small", "medium", "large" etc.) should be given if possible, 150 * together with a definition of these models 150 * together with a definition of these models for the compiler system used. 151 * 151 * 152 ********************************************* 152 ************************************************************************** 153 * 153 * 154 * Dhrystone (C version) statistics: 154 * Dhrystone (C version) statistics: 155 * 155 * 156 * [Comment from the first distribution, upda 156 * [Comment from the first distribution, updated for version 2. 157 * Note that because of language differences 157 * Note that because of language differences, the numbers are slightly 158 * different from the Ada version.] 158 * different from the Ada version.] 159 * 159 * 160 * The following program contains statements 160 * The following program contains statements of a high level programming 161 * language (here: C) in a distribution consi 161 * language (here: C) in a distribution considered representative: 162 * 162 * 163 * assignments 52 (51.0 %) 163 * assignments 52 (51.0 %) 164 * control statements 33 (32.4 %) 164 * control statements 33 (32.4 %) 165 * procedure, function calls 17 (16.7 %) 165 * procedure, function calls 17 (16.7 %) 166 * 166 * 167 * 103 statements are dynamically executed. T 167 * 103 statements are dynamically executed. The program is balanced with 168 * respect to the three aspects: 168 * respect to the three aspects: 169 * 169 * 170 * - statement type 170 * - statement type 171 * - operand type 171 * - operand type 172 * - operand locality 172 * - operand locality 173 * operand global, local, parameter, o 173 * operand global, local, parameter, or constant. 174 * 174 * 175 * The combination of these three aspects is 175 * The combination of these three aspects is balanced only approximately. 176 * 176 * 177 * 1. Statement Type: 177 * 1. Statement Type: 178 * ----------------- number 178 * ----------------- number 179 * 179 * 180 * V1 = V2 9 180 * V1 = V2 9 181 * (incl. V1 = F(..) 181 * (incl. V1 = F(..) 182 * V = Constant 12 182 * V = Constant 12 183 * Assignment, 7 183 * Assignment, 7 184 * with array element 184 * with array element 185 * Assignment, 6 185 * Assignment, 6 186 * with record component 186 * with record component 187 * -- 187 * -- 188 * 34 34 188 * 34 34 189 * 189 * 190 * X = Y +|-|"&&"|"|" Z 5 190 * X = Y +|-|"&&"|"|" Z 5 191 * X = Y +|-|"==" Constant 6 191 * X = Y +|-|"==" Constant 6 192 * X = X +|- 1 3 192 * X = X +|- 1 3 193 * X = Y *|/ Z 2 193 * X = Y *|/ Z 2 194 * X = Expression, 1 194 * X = Expression, 1 195 * two operators 195 * two operators 196 * X = Expression, 1 196 * X = Expression, 1 197 * three operators 197 * three operators 198 * -- 198 * -- 199 * 18 18 199 * 18 18 200 * 200 * 201 * if .... 14 201 * if .... 14 202 * with "else" 7 202 * with "else" 7 203 * without "else" 7 203 * without "else" 7 204 * executed 3 204 * executed 3 205 * not executed 4 205 * not executed 4 206 * for ... 7 | count 206 * for ... 7 | counted every time 207 * while ... 4 | the l 207 * while ... 4 | the loop condition 208 * do ... while 1 | is ev 208 * do ... while 1 | is evaluated 209 * switch ... 1 209 * switch ... 1 210 * break 1 210 * break 1 211 * declaration with 1 211 * declaration with 1 212 * initialization 212 * initialization 213 * -- 213 * -- 214 * 34 34 214 * 34 34 215 * 215 * 216 * P (...) procedure call 11 216 * P (...) procedure call 11 217 * user procedure 10 217 * user procedure 10 218 * library procedure 1 218 * library procedure 1 219 * X = F (...) 219 * X = F (...) 220 * function call 6 220 * function call 6 221 * user function 5 221 * user function 5 222 * library function 1 222 * library function 1 223 * -- 223 * -- 224 * 17 17 224 * 17 17 225 * --- 225 * --- 226 * 103 226 * 103 227 * 227 * 228 * The average number of parameters in proc 228 * The average number of parameters in procedure or function calls 229 * is 1.82 (not counting the function value 229 * is 1.82 (not counting the function values as implicit parameters). 230 * 230 * 231 * 231 * 232 * 2. Operators 232 * 2. Operators 233 * ------------ 233 * ------------ 234 * number approxim 234 * number approximate 235 * percenta 235 * percentage 236 * 236 * 237 * Arithmetic 32 50.8 237 * Arithmetic 32 50.8 238 * 238 * 239 * + 21 33. 239 * + 21 33.3 240 * - 7 11. 240 * - 7 11.1 241 * * 3 4. 241 * * 3 4.8 242 * / (int div) 1 1. 242 * / (int div) 1 1.6 243 * 243 * 244 * Comparison 27 42.8 244 * Comparison 27 42.8 245 * 245 * 246 * == 9 14 246 * == 9 14.3 247 * /= 4 6 247 * /= 4 6.3 248 * > 1 1 248 * > 1 1.6 249 * < 3 4 249 * < 3 4.8 250 * >= 1 1 250 * >= 1 1.6 251 * <= 9 14 251 * <= 9 14.3 252 * 252 * 253 * Logic 4 6.3 253 * Logic 4 6.3 254 * 254 * 255 * && (AND-THEN) 1 1 255 * && (AND-THEN) 1 1.6 256 * | (OR) 1 1 256 * | (OR) 1 1.6 257 * ! (NOT) 2 3 257 * ! (NOT) 2 3.2 258 * 258 * 259 * -- ----- 259 * -- ----- 260 * 63 100.1 260 * 63 100.1 261 * 261 * 262 * 262 * 263 * 3. Operand Type (counted once per operand 263 * 3. Operand Type (counted once per operand reference): 264 * --------------- 264 * --------------- 265 * number approxim 265 * number approximate 266 * percenta 266 * percentage 267 * 267 * 268 * Integer 175 72.3 % 268 * Integer 175 72.3 % 269 * Character 45 18.6 % 269 * Character 45 18.6 % 270 * Pointer 12 5.0 % 270 * Pointer 12 5.0 % 271 * String30 6 2.5 % 271 * String30 6 2.5 % 272 * Array 2 0.8 % 272 * Array 2 0.8 % 273 * Record 2 0.8 % 273 * Record 2 0.8 % 274 * --- ------- 274 * --- ------- 275 * 242 100.0 % 275 * 242 100.0 % 276 * 276 * 277 * When there is an access path leading to th 277 * When there is an access path leading to the final operand (e.g. a record 278 * component), only the final data type on th 278 * component), only the final data type on the access path is counted. 279 * 279 * 280 * 280 * 281 * 4. Operand Locality: 281 * 4. Operand Locality: 282 * ------------------- 282 * ------------------- 283 * number ap 283 * number approximate 284 * pe 284 * percentage 285 * 285 * 286 * local variable 114 286 * local variable 114 47.1 % 287 * global variable 22 287 * global variable 22 9.1 % 288 * parameter 45 288 * parameter 45 18.6 % 289 * value 23 289 * value 23 9.5 % 290 * reference 22 290 * reference 22 9.1 % 291 * function result 6 291 * function result 6 2.5 % 292 * constant 55 292 * constant 55 22.7 % 293 * --- - 293 * --- ------- 294 * 242 1 294 * 242 100.0 % 295 * 295 * 296 * 296 * 297 * The program does not compute anything mean 297 * The program does not compute anything meaningful, but it is syntactically 298 * and semantically correct. All variables ha 298 * and semantically correct. All variables have a value assigned to them 299 * before they are used as a source operand. 299 * before they are used as a source operand. 300 * 300 * 301 * There has been no explicit effort to accou 301 * There has been no explicit effort to account for the effects of a 302 * cache, or to balance the use of long or sh 302 * cache, or to balance the use of long or short displacements for code or 303 * data. 303 * data. 304 * 304 * 305 ********************************************* 305 *************************************************************************** 306 */ 306 */ 307 307 308 typedef enum { 308 typedef enum { 309 Ident_1, 309 Ident_1, 310 Ident_2, 310 Ident_2, 311 Ident_3, 311 Ident_3, 312 Ident_4, 312 Ident_4, 313 Ident_5 313 Ident_5 314 } Enumeration; /* for boolean and enumeration 314 } Enumeration; /* for boolean and enumeration types in Ada, Pascal */ 315 315 316 /* General definitions: */ 316 /* General definitions: */ 317 317 318 typedef int One_Thirty; 318 typedef int One_Thirty; 319 typedef int One_Fifty; 319 typedef int One_Fifty; 320 typedef char Capital_Letter; 320 typedef char Capital_Letter; 321 typedef int Boolean; 321 typedef int Boolean; 322 typedef char Str_30[31]; 322 typedef char Str_30[31]; 323 typedef int Arr_1_Dim[50]; 323 typedef int Arr_1_Dim[50]; 324 typedef int Arr_2_Dim[50][50]; 324 typedef int Arr_2_Dim[50][50]; 325 325 326 typedef struct record { 326 typedef struct record { 327 struct record *Ptr_Comp; 327 struct record *Ptr_Comp; 328 Enumeration Discr; 328 Enumeration Discr; 329 union { 329 union { 330 struct { 330 struct { 331 Enumeration Enum_Comp; 331 Enumeration Enum_Comp; 332 int Int_Comp; 332 int Int_Comp; 333 char Str_Comp[31]; 333 char Str_Comp[31]; 334 } var_1; 334 } var_1; 335 struct { 335 struct { 336 Enumeration E_Comp_2; 336 Enumeration E_Comp_2; 337 char Str_2_Comp[31]; 337 char Str_2_Comp[31]; 338 } var_2; 338 } var_2; 339 struct { 339 struct { 340 char Ch_1_Comp; 340 char Ch_1_Comp; 341 char Ch_2_Comp; 341 char Ch_2_Comp; 342 } var_3; 342 } var_3; 343 } variant; 343 } variant; 344 } Rec_Type, *Rec_Pointer; 344 } Rec_Type, *Rec_Pointer; 345 345 346 346 347 extern int Int_Glob; 347 extern int Int_Glob; 348 extern char Ch_1_Glob; 348 extern char Ch_1_Glob; 349 349 350 void Proc_6(Enumeration Enum_Val_Par, Enumera 350 void Proc_6(Enumeration Enum_Val_Par, Enumeration *Enum_Ref_Par); 351 void Proc_7(One_Fifty Int_1_Par_Val, One_Fifty 351 void Proc_7(One_Fifty Int_1_Par_Val, One_Fifty Int_2_Par_Val, 352 One_Fifty *Int_Par_Ref); 352 One_Fifty *Int_Par_Ref); 353 void Proc_8(Arr_1_Dim Arr_1_Par_Ref, Arr_2_Dim 353 void Proc_8(Arr_1_Dim Arr_1_Par_Ref, Arr_2_Dim Arr_2_Par_Ref, 354 int Int_1_Par_Val, int Int_2_Par_V 354 int Int_1_Par_Val, int Int_2_Par_Val); 355 Enumeration Func_1(Capital_Letter Ch_1_Par_Val 355 Enumeration Func_1(Capital_Letter Ch_1_Par_Val, Capital_Letter Ch_2_Par_Val); 356 Boolean Func_2(Str_30 Str_1_Par_Ref, Str_30 St 356 Boolean Func_2(Str_30 Str_1_Par_Ref, Str_30 Str_2_Par_Ref); 357 357 358 int dhry(int n); 358 int dhry(int n); 359 359
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.