Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Benchmark_Dhrystone
dhry.h
00001 /* 00002 ************************************************************************* 00003 * 00004 * "DHRYSTONE" Benchmark Program 00005 * ----------------------------- 00006 * 00007 * Version: C, Version 2.1 00008 * 00009 * File: dhry.h (part 1 of 3) 00010 * 00011 * Date: May 25, 1988 00012 * 00013 * Author: Reinhold P. Weicker 00014 * Siemens Nixdorf Inf. Syst. 00015 * STM OS 32 00016 * Otto-Hahn-Ring 6 00017 * W-8000 Muenchen 83 00018 * Germany 00019 * Phone: [+49]-89-636-42436 00020 * (8-17 Central European Time) 00021 * UUCP: weicker@ztivax.uucp@unido.uucp 00022 * Internet: weicker@ztivax.siemens.com 00023 * 00024 * Original Version (in Ada) published in 00025 * "Communications of the ACM" vol. 27., no. 10 (Oct. 1984), 00026 * pp. 1013 - 1030, together with the statistics 00027 * on which the distribution of statements etc. is based. 00028 * 00029 * In this C version, the following C library functions are 00030 * used: 00031 * - strcpy, strcmp (inside the measurement loop) 00032 * - printf, scanf (outside the measurement loop) 00033 * 00034 * Collection of Results: 00035 * Reinhold Weicker (address see above) and 00036 * 00037 * Rick Richardson 00038 * PC Research. Inc. 00039 * 94 Apple Orchard Drive 00040 * Tinton Falls, NJ 07724 00041 * Phone: (201) 834-1378 (9-17 EST) 00042 * UUCP: ...!uunet!pcrat!rick 00043 * 00044 * Please send results to Rick Richardson and/or Reinhold Weicker. 00045 * Complete information should be given on hardware and software 00046 * used. Hardware information includes: Machine type, CPU, type and 00047 * size of caches; for microprocessors: clock frequency, memory speed 00048 * (number of wait states). Software information includes: Compiler 00049 * (and runtime library) manufacturer and version, compilation 00050 * switches, OS version. The Operating System version may give an 00051 * indication about the compiler; Dhrystone itself performs no OS 00052 * calls in the measurement loop. 00053 * 00054 * The complete output generated by the program should be mailed 00055 * such that at least some checks for correctness can be made. 00056 * 00057 ************************************************************************* 00058 * 00059 * History: This version C/2.1 has been made for two reasons: 00060 * 00061 * 1) There is an obvious need for a common C version of 00062 * Dhrystone, since C is at present the most popular system 00063 * programming language for the class of processors 00064 * (microcomputers, minicomputers) where Dhrystone is used 00065 * most. There should be, as far as possible, only one C 00066 * version of Dhrystone such that results can be compared 00067 * without restrictions. In the past, the C versions 00068 * distributed by Rick Richardson (Version 1.1) and by 00069 * Reinhold Weicker had small (though not significant) 00070 * differences. 00071 * 00072 * 2) As far as it is possible without changes to the 00073 * Dhrystone statistics, optimizing compilers should be 00074 * prevented from removing significant statements. 00075 * 00076 * This C version has been developed in cooperation with 00077 * Rick Richardson (Tinton Falls, NJ), it incorporates many 00078 * ideas from the "Version 1.1" distributed previously by 00079 * him over the UNIX network Usenet. 00080 * I also thank Chaim Benedelac (National Semiconductor), 00081 * David Ditzel (SUN), Earl Killian and John Mashey (MIPS), 00082 * Alan Smith and Rafael Saavedra-Barrera (UC at Berkeley) 00083 * for their help with comments on earlier versions of the 00084 * benchmark. 00085 * 00086 * Changes: In the initialization part, this version follows mostly 00087 * Rick Richardson's version distributed via Usenet, not the 00088 * version distributed earlier via floppy disk by Reinhold 00089 * Weicker. As a concession to older compilers, names have 00090 * been made unique within the first 8 characters. Inside the 00091 * measurement loop, this version follows the version 00092 * previously distributed by Reinhold Weicker. 00093 * 00094 * At several places in the benchmark, code has been added, 00095 * but within the measurement loop only in branches that 00096 * are not executed. The intention is that optimizing 00097 * compilers should be prevented from moving code out of the 00098 * measurement loop, or from removing code altogether. Since 00099 * the statements that are executed within the measurement 00100 * loop have NOT been changed, the numbers defining the 00101 * "Dhrystone distribution" (distribution of statements, 00102 * operand types and locality) still hold. Except for 00103 * sophisticated optimizing compilers, execution times for 00104 * this version should be the same as for previous versions. 00105 * 00106 * Since it has proven difficult to subtract the time for the 00107 * measurement loop overhead in a correct way, the loop check 00108 * has been made a part of the benchmark. This does have 00109 * an impact - though a very minor one - on the distribution 00110 * statistics which have been updated for this version. 00111 * 00112 * All changes within the measurement loop are described 00113 * and discussed in the companion paper "Rationale for 00114 * Dhrystone version 2". 00115 * 00116 * Because of the self-imposed limitation that the order and 00117 * distribution of the executed statements should not be 00118 * changed, there are still cases where optimizing compilers 00119 * may not generate code for some statements. To a certain 00120 * degree, this is unavoidable for small synthetic 00121 * benchmarks. Users of the benchmark are advised to check 00122 * code listings whether code is generated for all statements 00123 * of Dhrystone. 00124 * 00125 * Version 2.1 is identical to version 2.0 distributed via 00126 * the UNIX network Usenet in March 1988 except that it 00127 * corrects some minor deficiencies that were found by users 00128 * of version 2.0. The only change within the measurement 00129 * loop is that a non-executed "else" part was added to the 00130 * "if" statement in Func_3, and a non-executed "else" part 00131 * removed from Proc_3. 00132 * 00133 ************************************************************************* 00134 * 00135 * Defines: The following "Defines" are possible: 00136 * -DROPT (default: Not defined) 00137 * As an approximation to what an average C 00138 * programmer might do, the "register" storage class 00139 * is applied (if enabled by -DROPT) 00140 * - for local variables, if they are used 00141 * (dynamically) five or more times 00142 * - for parameters if they are used (dynamically) 00143 * six or more times 00144 * Note that an optimal "register" strategy is 00145 * compiler-dependent, and that "register" 00146 * declarations do not necessarily lead to faster 00147 * execution. 00148 * -DNOSTRUCTASSIGN (default: Not defined) 00149 * Define if the C compiler does not support 00150 * assignment of structures. 00151 * -DNOENUMS (default: Not defined) 00152 * Define if the C compiler does not support 00153 * enumeration types. 00154 * 00155 ************************************************************************* 00156 * 00157 * Compilation model and measurement (IMPORTANT): 00158 * 00159 * This C version of Dhrystone consists of three files: 00160 * - dhry.h (this file, containing global definitions and comments) 00161 * - dhry_1.c (containing the code corresponding to Ada package Pack_1) 00162 * - dhry_2.c (containing the code corresponding to Ada package Pack_2) 00163 * 00164 * The following "ground rules" apply for measurements: 00165 * - Separate compilation 00166 * - No procedure merging 00167 * - Otherwise, compiler optimizations are allowed but should be 00168 * indicated 00169 * - Default results are those without register declarations 00170 * See the companion paper "Rationale for Dhrystone Version 2" for a more 00171 * detailed discussion of these ground rules. 00172 * 00173 * For 16-Bit processors (e.g. 80186, 80286), times for all compilation 00174 * models ("small", "medium", "large" etc.) should be given if possible, 00175 * together with a definition of these models for the compiler system 00176 * used. 00177 * 00178 ************************************************************************* 00179 * 00180 * Dhrystone (C version) statistics: 00181 * 00182 * [Comment from the first distribution, updated for version 2. 00183 * Note that because of language differences, the numbers are slightly 00184 * different from the Ada version.] 00185 * 00186 * The following program contains statements of a high level programming 00187 * language (here: C) in a distribution considered representative: 00188 * 00189 * assignments 52 (51.0 %) 00190 * control statements 33 (32.4 %) 00191 * procedure, function calls 17 (16.7 %) 00192 * 00193 * 103 statements are dynamically executed. The program is balanced with 00194 * respect to the three aspects: 00195 * 00196 * - statement type 00197 * - operand type 00198 * - operand locality 00199 * operand global, local, parameter, or constant. 00200 * 00201 * The combination of these three aspects is balanced only approximately. 00202 * 00203 * 1. Statement Type: 00204 * ----------------- number 00205 * 00206 * V1 = V2 9 00207 * (incl. V1 = F(..) 00208 * V = Constant 12 00209 * Assignment, 7 00210 * with array element 00211 * Assignment, 6 00212 * with record component 00213 * -- 00214 * 34 34 00215 * 00216 * X = Y +|-|"&&"|"|" Z 5 00217 * X = Y +|-|"==" Constant 6 00218 * X = X +|- 1 3 00219 * X = Y *|/ Z 2 00220 * X = Expression, 1 00221 * two operators 00222 * X = Expression, 1 00223 * three operators 00224 * -- 00225 * 18 18 00226 * 00227 * if .... 14 00228 * with "else" 7 00229 * without "else" 7 00230 * executed 3 00231 * not executed 4 00232 * for ... 7 | counted every time 00233 * while ... 4 | the loop condition 00234 * do ... while 1 | is evaluated 00235 * switch ... 1 00236 * break 1 00237 * declaration with 1 00238 * initialization 00239 * -- 00240 * 34 34 00241 * 00242 * P (...) procedure call 11 00243 * user procedure 10 00244 * library procedure 1 00245 * X = F (...) 00246 * function call 6 00247 * user function 5 00248 * library function 1 00249 * -- 00250 * 17 17 00251 * --- 00252 * 103 00253 * 00254 * The average number of parameters in procedure or function calls 00255 * is 1.82 (not counting the function values as implicit parameters). 00256 * 00257 * 00258 * 2. Operators 00259 * ------------ 00260 * number approximate 00261 * percentage 00262 * 00263 * Arithmetic 32 50.8 00264 * 00265 * + 21 33.3 00266 * - 7 11.1 00267 * * 3 4.8 00268 * / (int div) 1 1.6 00269 * 00270 * Comparison 27 42.8 00271 * 00272 * == 9 14.3 00273 * /= 4 6.3 00274 * > 1 1.6 00275 * < 3 4.8 00276 * >= 1 1.6 00277 * <= 9 14.3 00278 * 00279 * Logic 4 6.3 00280 * 00281 * && (AND-THEN) 1 1.6 00282 * | (OR) 1 1.6 00283 * ! (NOT) 2 3.2 00284 * 00285 * -- ----- 00286 * 63 100.1 00287 * 00288 * 00289 * 3. Operand Type (counted once per operand reference): 00290 * --------------- 00291 * number approximate 00292 * percentage 00293 * 00294 * Integer 175 72.3 % 00295 * Character 45 18.6 % 00296 * Pointer 12 5.0 % 00297 * String30 6 2.5 % 00298 * Array 2 0.8 % 00299 * Record 2 0.8 % 00300 * --- ------- 00301 * 242 100.0 % 00302 * 00303 * When there is an access path leading to the final operand (e.g. a 00304 * record component), only the final data type on the access path is 00305 * counted. 00306 * 00307 * 00308 * 4. Operand Locality: 00309 * ------------------- 00310 * number approximate 00311 * percentage 00312 * 00313 * local variable 114 47.1 % 00314 * global variable 22 9.1 % 00315 * parameter 45 18.6 % 00316 * value 23 9.5 % 00317 * reference 22 9.1 % 00318 * function result 6 2.5 % 00319 * constant 55 22.7 % 00320 * --- ------- 00321 * 242 100.0 % 00322 * 00323 * 00324 * The program does not compute anything meaningful, but it is 00325 * syntactically and semantically correct. All variables have a value 00326 * assigned to them before they are used as a source operand. 00327 * 00328 * There has been no explicit effort to account for the effects of a 00329 * cache, or to balance the use of long or short displacements for code 00330 * or data. 00331 * 00332 ************************************************************************* 00333 */ 00334 00335 /* Compiler and system dependent definitions: */ 00336 00337 #define Mic_secs_Per_Second 1000000.0 00338 /* Berkeley UNIX C returns process times in seconds/HZ */ 00339 00340 #ifdef NOSTRUCTASSIGN 00341 #define structassign(d, s) memcpy(&(d), &(s), sizeof(d)) 00342 #else 00343 #define structassign(d, s) d = s 00344 #endif 00345 00346 #ifdef NOENUM 00347 #define Ident_1 0 00348 #define Ident_2 1 00349 #define Ident_3 2 00350 #define Ident_4 3 00351 #define Ident_5 4 00352 typedef int Enumeration; 00353 #else 00354 typedef enum {Ident_1, Ident_2, Ident_3, Ident_4, Ident_5} 00355 Enumeration; 00356 #endif 00357 /* for boolean and enumeration types in Ada, Pascal */ 00358 00359 /* General definitions: */ 00360 00361 00362 #define Null 0 00363 /* Value of a Null pointer */ 00364 #define true 1 00365 #define false 0 00366 00367 typedef int One_Thirty; 00368 typedef int One_Fifty; 00369 typedef char Capital_Letter; 00370 typedef int Booleann; 00371 typedef char Str_30[31]; 00372 typedef int Arr_1_Dim[25]; /* <-- changed from 50 */ 00373 typedef int Arr_2_Dim[25][25]; /* <-- changed from 50 */ 00374 00375 typedef struct record 00376 { 00377 struct record *Ptr_Comp; 00378 Enumeration Discr; 00379 union { 00380 struct { 00381 Enumeration Enum_Comp; 00382 int Int_Comp; 00383 char Str_Comp [31]; 00384 } var_1; 00385 struct { 00386 Enumeration E_Comp_2; 00387 char Str_2_Comp [31]; 00388 } var_2; 00389 struct { 00390 char Ch_1_Comp; 00391 char Ch_2_Comp; 00392 } var_3; 00393 } variant; 00394 } Rec_Type, *Rec_Pointer; 00395 00396 /* Prototypes of function defined in dhry21b.c and called from dhry21a.c. 00397 */ 00398 void Proc_6( Enumeration Enum_Val_Par, Enumeration * Enum_Ref_Par ); 00399 void Proc_7( One_Fifty Int_1_Par_Val, One_Fifty Int_2_Par_Val, 00400 One_Fifty * Int_Par_Ref ); 00401 void Proc_8( Arr_1_Dim Arr_1_Par_Ref, Arr_2_Dim Arr_2_Par_Ref, 00402 int Int_1_Par_Val, int Int_2_Par_Val ); 00403 Enumeration Func_1( Capital_Letter Ch_1_Par_Val, Capital_Letter Ch_2_Par_Val ); 00404 Booleann Func_2( Str_30 Str_1_Par_Ref, Str_30 Str_2_Par_Ref ); 00405
Generated on Wed Jul 13 2022 07:26:21 by
1.7.2