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