From 93f00beeecd3004cc27b5f97339ffc4608e5f3a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= Date: Sat, 7 Mar 2015 11:37:25 +0100 Subject: Get rid of DOS style newlines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bernhard Rosenkränzer --- dhry.h | 622 ++++++++++++------------- dhry_1.c | 1548 +++++++++++++++++++++++++++++++------------------------------- dhry_2.c | 372 +++++++-------- 3 files changed, 1271 insertions(+), 1271 deletions(-) diff --git a/dhry.h b/dhry.h index 69b8526..3010aec 100644 --- a/dhry.h +++ b/dhry.h @@ -1,311 +1,311 @@ -/* - ************************************************************************** - * DHRYSTONE 2.1 BENCHMARK PC VERSION - ************************************************************************** - * - * "DHRYSTONE" Benchmark Program - * ----------------------------- - * - * Version: C, Version 2.1 - * - * File: dhry.h (part 1 of 3) - * - * Date: May 25, 1988 - * - * Author: Reinhold P. Weicker - * Siemens AG, AUT E 51 - * Postfach 3220 - * 8520 Erlangen - * Germany (West) - * Phone: [+49]-9131-7-20330 - * (8-17 Central European Time) - * Usenet: ..!mcsun!unido!estevax!weicker - * - * Original Version (in Ada) published in - * "Communications of the ACM" vol. 27., no. 10 (Oct. 1984), - * pp. 1013 - 1030, together with the statistics - * on which the distribution of statements etc. is based. - * - * In this C version, the following C library functions are used: - * - strcpy, strcmp (inside the measurement loop) - * - printf, scanf (outside the measurement loop) - * In addition, Berkeley UNIX system calls "times ()" or "time ()" - * are used for execution time measurement. For measurements - * on other systems, these calls have to be changed. - * - * Collection of Results: - * Reinhold Weicker (address see above) and - * - * Rick Richardson - * PC Research. Inc. - * 94 Apple Orchard Drive - * Tinton Falls, NJ 07724 - * Phone: (201) 389-8963 (9-17 EST) - * Usenet: ...!uunet!pcrat!rick - * - * Please send results to Rick Richardson and/or Reinhold Weicker. - * Complete information should be given on hardware and software used. - * Hardware information includes: Machine type, CPU, type and size - * of caches; for microprocessors: clock frequency, memory speed - * (number of wait states). - * Software information includes: Compiler (and runtime library) - * manufacturer and version, compilation switches, OS version. - * The Operating System version may give an indication about the - * compiler; Dhrystone itself performs no OS calls in the measurement - * loop. - * - * The complete output generated by the program should be mailed - * such that at least some checks for correctness can be made. - * - ************************************************************************** - * - * This version has changes made by Roy Longbottom to conform to a common - * format for a series of standard benchmarks for PCs: - * - * Running time greater than 5 seconds due to inaccuracy of the PC clock. - * - * Automatic adjustment of run time, no manually inserted parameters. - * - * Initial display of calibration times to confirm linearity. - * - * Display of results within one screen (or at a slow speed as the test - * progresses) so that it can be seen to have run successfully. - * - * Facilities to type in details of system used etc. - * - * All results and details appended to a results file. - * - * - * Roy Longbottom - * 101323.2241@compuserve.com - * - ************************************************************************** - * - * For details of history, changes, other defines, benchmark construction - * statistics see official versions from ftp.nosc.mil/pub/aburto where - * the latest table of results (dhry.tbl) are available. See also - * netlib@ornl.gov - * - ************************************************************************** - * - * Defines: The following "Defines" are possible: - * -DREG=register (default: Not defined) - * As an approximation to what an average C programmer - * might do, the "register" storage class is applied - * (if enabled by -DREG=register) - * - for local variables, if they are used (dynamically) - * five or more times - * - for parameters if they are used (dynamically) - * six or more times - * Note that an optimal "register" strategy is - * compiler-dependent, and that "register" declarations - * do not necessarily lead to faster execution. - * -DNOSTRUCTASSIGN (default: Not defined) - * Define if the C compiler does not support - * assignment of structures. - * -DNOENUMS (default: Not defined) - * Define if the C compiler does not support - * enumeration types. - *************************************************************************** - * - * Compilation model and measurement (IMPORTANT): - * - * This C version of Dhrystone consists of three files: - * - dhry.h (this file, containing global definitions and comments) - * - dhry_1.c (containing the code corresponding to Ada package Pack_1) - * - dhry_2.c (containing the code corresponding to Ada package Pack_2) - * - * The following "ground rules" apply for measurements: - * - Separate compilation - * - No procedure merging - * - Otherwise, compiler optimizations are allowed but should be indicated - * - Default results are those without register declarations - * See the companion paper "Rationale for Dhrystone Version 2" for a more - * detailed discussion of these ground rules. - * - * For 16-Bit processors (e.g. 80186, 80286), times for all compilation - * models ("small", "medium", "large" etc.) should be given if possible, - * together with a definition of these models for the compiler system used. - * - ************************************************************************** - * Examples of Pentium Results - * - * Dhrystone Benchmark Version 2.1 (Language: C) - * - * Month run 4/1996 - * PC model Escom - * CPU Pentium - * Clock MHz 100 - * Cache 256K - * Options Neptune chipset - * OS/DOS Windows 95 - * Compiler Watcom C/ C++ 10.5 Win386 - * OptLevel -otexan -zp8 -fp5 -5r - * Run by Roy Longbottom - * From UK - * Mail 101323.2241@compuserve.com - * - * Final values (* implementation-dependent): - * - * Int_Glob: O.K. 5 - * Bool_Glob: O.K. 1 - * Ch_1_Glob: O.K. A - * Ch_2_Glob: O.K. B - * Arr_1_Glob[8]: O.K. 7 - * Arr_2_Glob8/7: O.K. 1600010 - * Ptr_Glob-> - * Ptr_Comp: * 98008 - * Discr: O.K. 0 - * Enum_Comp: O.K. 2 - * Int_Comp: O.K. 17 - * Str_Comp: O.K. DHRYSTONE PROGRAM, SOME STRING - * Next_Ptr_Glob-> - * Ptr_Comp: * 98008 same as above - * Discr: O.K. 0 - * Enum_Comp: O.K. 1 - * Int_Comp: O.K. 18 - * Str_Comp: O.K. DHRYSTONE PROGRAM, SOME STRING - * Int_1_Loc: O.K. 5 - * Int_2_Loc: O.K. 13 - * Int_3_Loc: O.K. 7 - * Enum_Loc: O.K. 1 - * Str_1_Loc: O.K. DHRYSTONE PROGRAM, 1'ST STRING - * Str_2_Loc: O.K. DHRYSTONE PROGRAM, 2'ND STRING - * - * Register option Selected. - * - * Microseconds 1 loop: 4.53 - * Dhrystones / second: 220690 - * VAX MIPS rating: 125.61 - * - * - * Dhrystone Benchmark Version 2.1 (Language: C) - * - * Month run 4/1996 - * PC model Escom - * CPU Pentium - * Clock MHz 100 - * Cache 256K - * Options Neptune chipset - * OS/DOS Windows 95 - * Compiler Watcom C/ C++ 10.5 Win386 - * OptLevel No optimisation - * Run by Roy Longbottom - * From UK - * Mail 101323.2241@compuserve.com - * - * Final values (* implementation-dependent): - * - * Int_Glob: O.K. 5 - * Bool_Glob: O.K. 1 - * Ch_1_Glob: O.K. A - * Ch_2_Glob: O.K. B - * Arr_1_Glob[8]: O.K. 7 - * Arr_2_Glob8/7: O.K. 320010 - * Ptr_Glob-> - * Ptr_Comp: * 98004 - * Discr: O.K. 0 - * Enum_Comp: O.K. 2 - * Int_Comp: O.K. 17 - * Str_Comp: O.K. DHRYSTONE PROGRAM, SOME STRING - * Next_Ptr_Glob-> - * Ptr_Comp: * 98004 same as above - * Discr: O.K. 0 - * Enum_Comp: O.K. 1 - * Int_Comp: O.K. 18 - * Str_Comp: O.K. DHRYSTONE PROGRAM, SOME STRING - * Int_1_Loc: O.K. 5 - * Int_2_Loc: O.K. 13 - * Int_3_Loc: O.K. 7 - * Enum_Loc: O.K. 1 - * Str_1_Loc: O.K. DHRYSTONE PROGRAM, 1'ST STRING - * Str_2_Loc: O.K. DHRYSTONE PROGRAM, 2'ND STRING - * - * Register option Not selected. - * - * Microseconds 1 loop: 20.06 - * Dhrystones / second: 49844 - * VAX MIPS rating: 28.37 - * - ************************************************************************** - */ - -/* Compiler and system dependent definitions: */ - -#ifndef TIME -#define TIMES -#endif - /* Use times(2) time function unless */ - /* explicitly defined otherwise */ - -#ifdef TIMES -/* #include - #include */ - /* for "times" */ -#endif - -#define Mic_secs_Per_Second 1000000.0 - /* Berkeley UNIX C returns process times in seconds/HZ */ - -#ifdef NOSTRUCTASSIGN -#define structassign(d, s) memcpy(&(d), &(s), sizeof(d)) -#else -#define structassign(d, s) d = s -#endif - -#ifdef NOENUM -#define Ident_1 0 -#define Ident_2 1 -#define Ident_3 2 -#define Ident_4 3 -#define Ident_5 4 - typedef int Enumeration; -#else - typedef enum {Ident_1, Ident_2, Ident_3, Ident_4, Ident_5} - Enumeration; -#endif - /* for boolean and enumeration types in Ada, Pascal */ - -/* General definitions: */ - -#include -#include - - /* for strcpy, strcmp */ - -#define Null 0 - /* Value of a Null pointer */ -#define true 1 -#define false 0 - -typedef int One_Thirty; -typedef int One_Fifty; -typedef char Capital_Letter; -typedef int Boolean; -typedef char Str_30 [31]; -typedef int Arr_1_Dim [50]; -typedef int Arr_2_Dim [50] [50]; - -typedef struct record - { - struct record *Ptr_Comp; - Enumeration Discr; - union { - struct { - Enumeration Enum_Comp; - int Int_Comp; - char Str_Comp [31]; - } var_1; - struct { - Enumeration E_Comp_2; - char Str_2_Comp [31]; - } var_2; - struct { - char Ch_1_Comp; - char Ch_2_Comp; - } var_3; - } variant; - } Rec_Type, *Rec_Pointer; - - - +/* + ************************************************************************** + * DHRYSTONE 2.1 BENCHMARK PC VERSION + ************************************************************************** + * + * "DHRYSTONE" Benchmark Program + * ----------------------------- + * + * Version: C, Version 2.1 + * + * File: dhry.h (part 1 of 3) + * + * Date: May 25, 1988 + * + * Author: Reinhold P. Weicker + * Siemens AG, AUT E 51 + * Postfach 3220 + * 8520 Erlangen + * Germany (West) + * Phone: [+49]-9131-7-20330 + * (8-17 Central European Time) + * Usenet: ..!mcsun!unido!estevax!weicker + * + * Original Version (in Ada) published in + * "Communications of the ACM" vol. 27., no. 10 (Oct. 1984), + * pp. 1013 - 1030, together with the statistics + * on which the distribution of statements etc. is based. + * + * In this C version, the following C library functions are used: + * - strcpy, strcmp (inside the measurement loop) + * - printf, scanf (outside the measurement loop) + * In addition, Berkeley UNIX system calls "times ()" or "time ()" + * are used for execution time measurement. For measurements + * on other systems, these calls have to be changed. + * + * Collection of Results: + * Reinhold Weicker (address see above) and + * + * Rick Richardson + * PC Research. Inc. + * 94 Apple Orchard Drive + * Tinton Falls, NJ 07724 + * Phone: (201) 389-8963 (9-17 EST) + * Usenet: ...!uunet!pcrat!rick + * + * Please send results to Rick Richardson and/or Reinhold Weicker. + * Complete information should be given on hardware and software used. + * Hardware information includes: Machine type, CPU, type and size + * of caches; for microprocessors: clock frequency, memory speed + * (number of wait states). + * Software information includes: Compiler (and runtime library) + * manufacturer and version, compilation switches, OS version. + * The Operating System version may give an indication about the + * compiler; Dhrystone itself performs no OS calls in the measurement + * loop. + * + * The complete output generated by the program should be mailed + * such that at least some checks for correctness can be made. + * + ************************************************************************** + * + * This version has changes made by Roy Longbottom to conform to a common + * format for a series of standard benchmarks for PCs: + * + * Running time greater than 5 seconds due to inaccuracy of the PC clock. + * + * Automatic adjustment of run time, no manually inserted parameters. + * + * Initial display of calibration times to confirm linearity. + * + * Display of results within one screen (or at a slow speed as the test + * progresses) so that it can be seen to have run successfully. + * + * Facilities to type in details of system used etc. + * + * All results and details appended to a results file. + * + * + * Roy Longbottom + * 101323.2241@compuserve.com + * + ************************************************************************** + * + * For details of history, changes, other defines, benchmark construction + * statistics see official versions from ftp.nosc.mil/pub/aburto where + * the latest table of results (dhry.tbl) are available. See also + * netlib@ornl.gov + * + ************************************************************************** + * + * Defines: The following "Defines" are possible: + * -DREG=register (default: Not defined) + * As an approximation to what an average C programmer + * might do, the "register" storage class is applied + * (if enabled by -DREG=register) + * - for local variables, if they are used (dynamically) + * five or more times + * - for parameters if they are used (dynamically) + * six or more times + * Note that an optimal "register" strategy is + * compiler-dependent, and that "register" declarations + * do not necessarily lead to faster execution. + * -DNOSTRUCTASSIGN (default: Not defined) + * Define if the C compiler does not support + * assignment of structures. + * -DNOENUMS (default: Not defined) + * Define if the C compiler does not support + * enumeration types. + *************************************************************************** + * + * Compilation model and measurement (IMPORTANT): + * + * This C version of Dhrystone consists of three files: + * - dhry.h (this file, containing global definitions and comments) + * - dhry_1.c (containing the code corresponding to Ada package Pack_1) + * - dhry_2.c (containing the code corresponding to Ada package Pack_2) + * + * The following "ground rules" apply for measurements: + * - Separate compilation + * - No procedure merging + * - Otherwise, compiler optimizations are allowed but should be indicated + * - Default results are those without register declarations + * See the companion paper "Rationale for Dhrystone Version 2" for a more + * detailed discussion of these ground rules. + * + * For 16-Bit processors (e.g. 80186, 80286), times for all compilation + * models ("small", "medium", "large" etc.) should be given if possible, + * together with a definition of these models for the compiler system used. + * + ************************************************************************** + * Examples of Pentium Results + * + * Dhrystone Benchmark Version 2.1 (Language: C) + * + * Month run 4/1996 + * PC model Escom + * CPU Pentium + * Clock MHz 100 + * Cache 256K + * Options Neptune chipset + * OS/DOS Windows 95 + * Compiler Watcom C/ C++ 10.5 Win386 + * OptLevel -otexan -zp8 -fp5 -5r + * Run by Roy Longbottom + * From UK + * Mail 101323.2241@compuserve.com + * + * Final values (* implementation-dependent): + * + * Int_Glob: O.K. 5 + * Bool_Glob: O.K. 1 + * Ch_1_Glob: O.K. A + * Ch_2_Glob: O.K. B + * Arr_1_Glob[8]: O.K. 7 + * Arr_2_Glob8/7: O.K. 1600010 + * Ptr_Glob-> + * Ptr_Comp: * 98008 + * Discr: O.K. 0 + * Enum_Comp: O.K. 2 + * Int_Comp: O.K. 17 + * Str_Comp: O.K. DHRYSTONE PROGRAM, SOME STRING + * Next_Ptr_Glob-> + * Ptr_Comp: * 98008 same as above + * Discr: O.K. 0 + * Enum_Comp: O.K. 1 + * Int_Comp: O.K. 18 + * Str_Comp: O.K. DHRYSTONE PROGRAM, SOME STRING + * Int_1_Loc: O.K. 5 + * Int_2_Loc: O.K. 13 + * Int_3_Loc: O.K. 7 + * Enum_Loc: O.K. 1 + * Str_1_Loc: O.K. DHRYSTONE PROGRAM, 1'ST STRING + * Str_2_Loc: O.K. DHRYSTONE PROGRAM, 2'ND STRING + * + * Register option Selected. + * + * Microseconds 1 loop: 4.53 + * Dhrystones / second: 220690 + * VAX MIPS rating: 125.61 + * + * + * Dhrystone Benchmark Version 2.1 (Language: C) + * + * Month run 4/1996 + * PC model Escom + * CPU Pentium + * Clock MHz 100 + * Cache 256K + * Options Neptune chipset + * OS/DOS Windows 95 + * Compiler Watcom C/ C++ 10.5 Win386 + * OptLevel No optimisation + * Run by Roy Longbottom + * From UK + * Mail 101323.2241@compuserve.com + * + * Final values (* implementation-dependent): + * + * Int_Glob: O.K. 5 + * Bool_Glob: O.K. 1 + * Ch_1_Glob: O.K. A + * Ch_2_Glob: O.K. B + * Arr_1_Glob[8]: O.K. 7 + * Arr_2_Glob8/7: O.K. 320010 + * Ptr_Glob-> + * Ptr_Comp: * 98004 + * Discr: O.K. 0 + * Enum_Comp: O.K. 2 + * Int_Comp: O.K. 17 + * Str_Comp: O.K. DHRYSTONE PROGRAM, SOME STRING + * Next_Ptr_Glob-> + * Ptr_Comp: * 98004 same as above + * Discr: O.K. 0 + * Enum_Comp: O.K. 1 + * Int_Comp: O.K. 18 + * Str_Comp: O.K. DHRYSTONE PROGRAM, SOME STRING + * Int_1_Loc: O.K. 5 + * Int_2_Loc: O.K. 13 + * Int_3_Loc: O.K. 7 + * Enum_Loc: O.K. 1 + * Str_1_Loc: O.K. DHRYSTONE PROGRAM, 1'ST STRING + * Str_2_Loc: O.K. DHRYSTONE PROGRAM, 2'ND STRING + * + * Register option Not selected. + * + * Microseconds 1 loop: 20.06 + * Dhrystones / second: 49844 + * VAX MIPS rating: 28.37 + * + ************************************************************************** + */ + +/* Compiler and system dependent definitions: */ + +#ifndef TIME +#define TIMES +#endif + /* Use times(2) time function unless */ + /* explicitly defined otherwise */ + +#ifdef TIMES +/* #include + #include */ + /* for "times" */ +#endif + +#define Mic_secs_Per_Second 1000000.0 + /* Berkeley UNIX C returns process times in seconds/HZ */ + +#ifdef NOSTRUCTASSIGN +#define structassign(d, s) memcpy(&(d), &(s), sizeof(d)) +#else +#define structassign(d, s) d = s +#endif + +#ifdef NOENUM +#define Ident_1 0 +#define Ident_2 1 +#define Ident_3 2 +#define Ident_4 3 +#define Ident_5 4 + typedef int Enumeration; +#else + typedef enum {Ident_1, Ident_2, Ident_3, Ident_4, Ident_5} + Enumeration; +#endif + /* for boolean and enumeration types in Ada, Pascal */ + +/* General definitions: */ + +#include +#include + + /* for strcpy, strcmp */ + +#define Null 0 + /* Value of a Null pointer */ +#define true 1 +#define false 0 + +typedef int One_Thirty; +typedef int One_Fifty; +typedef char Capital_Letter; +typedef int Boolean; +typedef char Str_30 [31]; +typedef int Arr_1_Dim [50]; +typedef int Arr_2_Dim [50] [50]; + +typedef struct record + { + struct record *Ptr_Comp; + Enumeration Discr; + union { + struct { + Enumeration Enum_Comp; + int Int_Comp; + char Str_Comp [31]; + } var_1; + struct { + Enumeration E_Comp_2; + char Str_2_Comp [31]; + } var_2; + struct { + char Ch_1_Comp; + char Ch_2_Comp; + } var_3; + } variant; + } Rec_Type, *Rec_Pointer; + + + diff --git a/dhry_1.c b/dhry_1.c index 3b15712..2ed964c 100644 --- a/dhry_1.c +++ b/dhry_1.c @@ -1,774 +1,774 @@ -/* - ************************************************************************* - * - * "DHRYSTONE" Benchmark Program - * ----------------------------- - * - * Version: C, Version 2.1 - * - * File: dhry_1.c (part 2 of 3) - * - * Date: May 25, 1988 - * - * Author: Reinhold P. Weicker - * - ************************************************************************* - */ - - #include - #include - #include - #include "dhry.h" - /*COMPILER COMPILER COMPILER COMPILER COMPILER COMPILER COMPILER*/ - - #ifdef COW - #define compiler "Watcom C/C++ 10.5 Win386" - #define options " -otexan -zp8 -5r -ms" - #endif - #ifdef CNW - #define compiler "Watcom C/C++ 10.5 Win386" - #define options " No optimisation" - #endif - #ifdef COD - #define compiler "Watcom C/C++ 10.5 Dos4GW" - #define options " -otexan -zp8 -5r -ms" - #endif - #ifdef CND - #define compiler "Watcom C/C++ 10.5 Dos4GW" - #define options " No optimisation" - #endif - #ifdef CONT - #define compiler "Watcom C/C++ 10.5 Win32NT" - #define options " -otexan -zp8 -5r -ms" - #endif - #ifdef CNNT - #define compiler "Watcom C/C++ 10.5 Win32NT" - #define options " No optimisation" - #endif - #ifdef COO2 - #define compiler "Watcom C/C++ 10.5 OS/2-32" - #define options " -otexan -zp8 -5r -ms" - #endif - #ifdef CNO2 - #define compiler "Watcom C/C++ 10.5 OS/2-32" - #define options " No optimisation" - #endif - - -/* Global Variables: */ - -Rec_Pointer Ptr_Glob, - Next_Ptr_Glob; -int Int_Glob; - Boolean Bool_Glob; - char Ch_1_Glob, - Ch_2_Glob; - int Arr_1_Glob [50]; - int Arr_2_Glob [50] [50]; - int getinput = 1; - - - char Reg_Define[100] = "Register option Selected."; - - Enumeration Func_1 (Capital_Letter Ch_1_Par_Val, - Capital_Letter Ch_2_Par_Val); - /* - forward declaration necessary since Enumeration may not simply be int - */ - - #ifndef ROPT - #define REG - /* REG becomes defined as empty */ - /* i.e. no register variables */ - #else - #define REG register - #endif - - void Proc_1 (REG Rec_Pointer Ptr_Val_Par); - void Proc_2 (One_Fifty *Int_Par_Ref); - void Proc_3 (Rec_Pointer *Ptr_Ref_Par); - void Proc_4 (); - void Proc_5 (); - void Proc_6 (Enumeration Enum_Val_Par, Enumeration *Enum_Ref_Par); - void Proc_7 (One_Fifty Int_1_Par_Val, One_Fifty Int_2_Par_Val, - One_Fifty *Int_Par_Ref); - void Proc_8 (Arr_1_Dim Arr_1_Par_Ref, Arr_2_Dim Arr_2_Par_Ref, - int Int_1_Par_Val, int Int_2_Par_Val); - - Boolean Func_2 (Str_30 Str_1_Par_Ref, Str_30 Str_2_Par_Ref); - - - /* variables for time measurement: */ - - #define Too_Small_Time 2 - /* Measurements should last at least 2 seconds */ - - double Begin_Time, - End_Time, - User_Time; - - double Microseconds, - Dhrystones_Per_Second, - Vax_Mips; - - /* end of variables for time measurement */ - - - void main (int argc, char *argv[]) - /*****/ - - /* main program, corresponds to procedures */ - /* Main and Proc_0 in the Ada version */ - { - double dtime(); - - One_Fifty Int_1_Loc; - REG One_Fifty Int_2_Loc; - One_Fifty Int_3_Loc; - REG char Ch_Index; - Enumeration Enum_Loc; - Str_30 Str_1_Loc; - Str_30 Str_2_Loc; - REG int Run_Index; - REG int Number_Of_Runs; - int endit, count = 10; - FILE *Ap; - char general[9][80] = {" "}; - - /* Initializations */ - if (argc > 1) - { - switch (argv[1][0]) - { - case 'N': - getinput = 0; - break; - case 'n': - getinput = 0; - break; - } - } - - if ((Ap = fopen("Dhry.txt","a+")) == NULL) - { - printf("Can not open Dhry.txt\n\n"); - printf("Press any key\n"); - exit(1); - } - -/*********************************************************************** - * Change for compiler and optimisation used * - ***********************************************************************/ - - Next_Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type)); - Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type)); - - Ptr_Glob->Ptr_Comp = Next_Ptr_Glob; - Ptr_Glob->Discr = Ident_1; - Ptr_Glob->variant.var_1.Enum_Comp = Ident_3; - Ptr_Glob->variant.var_1.Int_Comp = 40; - strcpy (Ptr_Glob->variant.var_1.Str_Comp, - "DHRYSTONE PROGRAM, SOME STRING"); - strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING"); - - Arr_2_Glob [8][7] = 10; - /* Was missing in published program. Without this statement, */ - /* Arr_2_Glob [8][7] would have an undefined value. */ - /* Warning: With 16-Bit processors and Number_Of_Runs > 32000, */ - /* overflow may occur for this array element. */ - - printf ("\n"); - printf ("Dhrystone Benchmark, Version 2.1 (Language: C or C++)\n"); - printf ("\n"); - - if (getinput == 0) - { - printf ("No run time input data\n\n"); - } - else - { - printf ("With run time input data\n\n"); - } - - #ifdef ROPT - printf ("Register option selected\n\n"); - #else - printf ("Register option not selected\n\n"); - strcpy(Reg_Define, "Register option Not selected."); - #endif - - /* - if (Reg) - { - printf ("Program compiled with 'register' attribute\n"); - printf ("\n"); - } - else - { - printf ("Program compiled without 'register' attribute\n"); - printf ("\n"); - } - - printf ("Please give the number of runs through the benchmark: "); - { - int n; - scanf ("%d", &n); - Number_Of_Runs = n; - } - printf ("\n"); - printf ("Execution starts, %d runs through Dhrystone\n", - Number_Of_Runs); - */ - - Number_Of_Runs = 5000; - - do - { - - Number_Of_Runs = Number_Of_Runs * 2; - count = count - 1; - Arr_2_Glob [8][7] = 10; - - /***************/ - /* Start timer */ - /***************/ - - Begin_Time = dtime(); - - for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index) - { - - Proc_5(); - Proc_4(); - /* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */ - Int_1_Loc = 2; - Int_2_Loc = 3; - strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING"); - Enum_Loc = Ident_2; - Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc); - /* Bool_Glob == 1 */ - while (Int_1_Loc < Int_2_Loc) /* loop body executed once */ - { - Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc; - /* Int_3_Loc == 7 */ - Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc); - /* Int_3_Loc == 7 */ - Int_1_Loc += 1; - } /* while */ - /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */ - Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc); - /* Int_Glob == 5 */ - Proc_1 (Ptr_Glob); - for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index) - /* loop body executed twice */ - { - if (Enum_Loc == Func_1 (Ch_Index, 'C')) - /* then, not executed */ - { - Proc_6 (Ident_1, &Enum_Loc); - strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING"); - Int_2_Loc = Run_Index; - Int_Glob = Run_Index; - } - } - /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */ - Int_2_Loc = Int_2_Loc * Int_1_Loc; - Int_1_Loc = Int_2_Loc / Int_3_Loc; - Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc; - /* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */ - Proc_2 (&Int_1_Loc); - /* Int_1_Loc == 5 */ - - } /* loop "for Run_Index" */ - - /**************/ - /* Stop timer */ - /**************/ - - End_Time = dtime(); - User_Time = End_Time - Begin_Time; - - printf ("%12.0f runs %6.2f seconds \n",(double) Number_Of_Runs, User_Time); - if (User_Time > 5) - { - count = 0; - } - else - { - if (User_Time < 0.1) - { - Number_Of_Runs = Number_Of_Runs * 5; - } - } - } /* calibrate/run do while */ - while (count >0); - - printf ("\n"); - printf ("Final values (* implementation-dependent):\n"); - printf ("\n"); - printf ("Int_Glob: "); - if (Int_Glob == 5) printf ("O.K. "); - else printf ("WRONG "); - printf ("%d ", Int_Glob); - - printf ("Bool_Glob: "); - if (Bool_Glob == 1) printf ("O.K. "); - else printf ("WRONG "); - printf ("%d\n", Bool_Glob); - - printf ("Ch_1_Glob: "); - if (Ch_1_Glob == 'A') printf ("O.K. "); - else printf ("WRONG "); - printf ("%c ", Ch_1_Glob); - - printf ("Ch_2_Glob: "); - if (Ch_2_Glob == 'B') printf ("O.K. "); - else printf ("WRONG "); - printf ("%c\n", Ch_2_Glob); - - printf ("Arr_1_Glob[8]: "); - if (Arr_1_Glob[8] == 7) printf ("O.K. "); - else printf ("WRONG "); - printf ("%d ", Arr_1_Glob[8]); - - printf ("Arr_2_Glob8/7: "); - if (Arr_2_Glob[8][7] == Number_Of_Runs + 10) - printf ("O.K. "); - else printf ("WRONG "); - printf ("%10d\n", Arr_2_Glob[8][7]); - - printf ("Ptr_Glob-> "); - printf (" Ptr_Comp: * %ld\n", (long) Ptr_Glob->Ptr_Comp); - - printf (" Discr: "); - if (Ptr_Glob->Discr == 0) printf ("O.K. "); - else printf ("WRONG "); - printf ("%d ", Ptr_Glob->Discr); - - printf ("Enum_Comp: "); - if (Ptr_Glob->variant.var_1.Enum_Comp == 2) - printf ("O.K. "); - else printf ("WRONG "); - printf ("%d\n", Ptr_Glob->variant.var_1.Enum_Comp); - - printf (" Int_Comp: "); - if (Ptr_Glob->variant.var_1.Int_Comp == 17) printf ("O.K. "); - else printf ("WRONG "); - printf ("%d ", Ptr_Glob->variant.var_1.Int_Comp); - - printf ("Str_Comp: "); - if (strcmp(Ptr_Glob->variant.var_1.Str_Comp, - "DHRYSTONE PROGRAM, SOME STRING") == 0) - printf ("O.K. "); - else printf ("WRONG "); - printf ("%s\n", Ptr_Glob->variant.var_1.Str_Comp); - - printf ("Next_Ptr_Glob-> "); - printf (" Ptr_Comp: * %ld", (long) Next_Ptr_Glob->Ptr_Comp); - printf (" same as above\n"); - - printf (" Discr: "); - if (Next_Ptr_Glob->Discr == 0) - printf ("O.K. "); - else printf ("WRONG "); - printf ("%d ", Next_Ptr_Glob->Discr); - - printf ("Enum_Comp: "); - if (Next_Ptr_Glob->variant.var_1.Enum_Comp == 1) - printf ("O.K. "); - else printf ("WRONG "); - printf ("%d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp); - - printf (" Int_Comp: "); - if (Next_Ptr_Glob->variant.var_1.Int_Comp == 18) - printf ("O.K. "); - else printf ("WRONG "); - printf ("%d ", Next_Ptr_Glob->variant.var_1.Int_Comp); - - printf ("Str_Comp: "); - if (strcmp(Next_Ptr_Glob->variant.var_1.Str_Comp, - "DHRYSTONE PROGRAM, SOME STRING") == 0) - printf ("O.K. "); - else printf ("WRONG "); - printf ("%s\n", Next_Ptr_Glob->variant.var_1.Str_Comp); - - printf ("Int_1_Loc: "); - if (Int_1_Loc == 5) - printf ("O.K. "); - else printf ("WRONG "); - printf ("%d ", Int_1_Loc); - - printf ("Int_2_Loc: "); - if (Int_2_Loc == 13) - printf ("O.K. "); - else printf ("WRONG "); - printf ("%d\n", Int_2_Loc); - - printf ("Int_3_Loc: "); - if (Int_3_Loc == 7) - printf ("O.K. "); - else printf ("WRONG "); - printf ("%d ", Int_3_Loc); - - printf ("Enum_Loc: "); - if (Enum_Loc == 1) - printf ("O.K. "); - else printf ("WRONG "); - printf ("%d\n", Enum_Loc); - - printf ("Str_1_Loc: "); - if (strcmp(Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING") == 0) - printf ("O.K. "); - else printf ("WRONG "); - printf ("%s\n", Str_1_Loc); - - printf ("Str_2_Loc: "); - if (strcmp(Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING") == 0) - printf ("O.K. "); - else printf ("WRONG "); - printf ("%s\n", Str_2_Loc); - - printf ("\n"); - - - if (User_Time < Too_Small_Time) - { - printf ("Measured time too small to obtain meaningful results\n"); - printf ("Please increase number of runs\n"); - printf ("\n"); - } - else - { - Microseconds = User_Time * Mic_secs_Per_Second - / (double) Number_Of_Runs; - Dhrystones_Per_Second = (double) Number_Of_Runs / User_Time; - Vax_Mips = Dhrystones_Per_Second / 1757.0; - - printf ("Microseconds for one run through Dhrystone: "); - printf ("%12.2lf \n", Microseconds); - printf ("Dhrystones per Second: "); - printf ("%10.0lf \n", Dhrystones_Per_Second); - printf ("VAX MIPS rating = "); - printf ("%12.2lf \n",Vax_Mips); - printf ("\n"); - -/************************************************************************ - * Type details of hardware, software etc. * - ************************************************************************/ - - if (getinput == 1) - { - printf ("Enter the following which will be added with results to file DHRY.TXT\n"); - printf ("When submitting a number of results you need only provide details once\n"); - printf ("but a cross reference such as an abbreviated CPU type would be useful.\n"); - printf ("You can kill (exit or close) the program now and no data will be added.\n\n"); - - printf ("PC Supplier/model ? "); - gets(general[1]); - - printf ("CPU chip ? "); - gets(general[2]); - - printf ("Clock MHz ? "); - gets(general[3]); - - printf ("Cache size ? "); - gets(general[4]); - - printf ("Chipset & H/W options ? "); - gets(general[5]); - - printf ("OS/DOS version ? "); - gets(general[6]); - - printf ("Your name ? "); - gets(general[7]); - - printf ("Company/Location ? "); - gets(general[8]); - - printf ("E-mail address ? "); - gets(general[0]); - } -/************************************************************************ - * Add results to output file Dhry.txt * - ************************************************************************/ - fprintf (Ap, "-------------------- -----------------------------------" - "\n"); - fprintf (Ap, "Dhrystone Benchmark Version 2.1 (Language: C++)\n\n"); - fprintf (Ap, "PC model %s\n", general[1]); - fprintf (Ap, "CPU %s\n", general[2]); - fprintf (Ap, "Clock MHz %s\n", general[3]); - fprintf (Ap, "Cache %s\n", general[4]); - fprintf (Ap, "Options %s\n", general[5]); - fprintf (Ap, "OS/DOS %s\n", general[6]); - fprintf (Ap, "Run by %s\n", general[7]); - fprintf (Ap, "From %s\n", general[8]); - fprintf (Ap, "Mail %s\n\n", general[0]); - - fprintf (Ap, "Final values (* implementation-dependent):\n"); - fprintf (Ap, "\n"); - fprintf (Ap, "Int_Glob: "); - if (Int_Glob == 5) fprintf (Ap, "O.K. "); - else fprintf (Ap, "WRONG "); - fprintf (Ap, "%d\n", Int_Glob); - - fprintf (Ap, "Bool_Glob: "); - if (Bool_Glob == 1) fprintf (Ap, "O.K. "); - else fprintf (Ap, "WRONG "); - fprintf (Ap, "%d\n", Bool_Glob); - - fprintf (Ap, "Ch_1_Glob: "); - if (Ch_1_Glob == 'A') fprintf (Ap, "O.K. "); - else fprintf (Ap, "WRONG "); - fprintf (Ap, "%c\n", Ch_1_Glob); - - fprintf (Ap, "Ch_2_Glob: "); - if (Ch_2_Glob == 'B') fprintf (Ap, "O.K. "); - else fprintf (Ap, "WRONG "); - fprintf (Ap, "%c\n", Ch_2_Glob); - - fprintf (Ap, "Arr_1_Glob[8]: "); - if (Arr_1_Glob[8] == 7) fprintf (Ap, "O.K. "); - else fprintf (Ap, "WRONG "); - fprintf (Ap, "%d\n", Arr_1_Glob[8]); - - fprintf (Ap, "Arr_2_Glob8/7: "); - if (Arr_2_Glob[8][7] == Number_Of_Runs + 10) - fprintf (Ap, "O.K. "); - else fprintf (Ap, "WRONG "); - fprintf (Ap, "%10d\n", Arr_2_Glob[8][7]); - - fprintf (Ap, "Ptr_Glob-> \n"); - fprintf (Ap, " Ptr_Comp: * %x\n", (long) Ptr_Glob->Ptr_Comp); - - fprintf (Ap, " Discr: "); - if (Ptr_Glob->Discr == 0) fprintf (Ap, "O.K. "); - else fprintf (Ap, "WRONG "); - fprintf (Ap, "%d\n", Ptr_Glob->Discr); - - fprintf (Ap, " Enum_Comp: "); - if (Ptr_Glob->variant.var_1.Enum_Comp == 2) - fprintf (Ap, "O.K. "); - else fprintf (Ap, "WRONG "); - fprintf (Ap, "%d\n", Ptr_Glob->variant.var_1.Enum_Comp); - - fprintf (Ap, " Int_Comp: "); - if (Ptr_Glob->variant.var_1.Int_Comp == 17) fprintf (Ap, "O.K. "); - else fprintf (Ap, "WRONG "); - fprintf (Ap, "%d\n", Ptr_Glob->variant.var_1.Int_Comp); - - fprintf (Ap, " Str_Comp: "); - if (strcmp(Ptr_Glob->variant.var_1.Str_Comp, - "DHRYSTONE PROGRAM, SOME STRING") == 0) - fprintf (Ap, "O.K. "); - else fprintf (Ap, "WRONG "); - fprintf (Ap, "%s\n", Ptr_Glob->variant.var_1.Str_Comp); - - fprintf (Ap, "Next_Ptr_Glob-> \n"); - fprintf (Ap, " Ptr_Comp: * %x", (long) Next_Ptr_Glob->Ptr_Comp); - fprintf (Ap, " same as above\n"); - - fprintf (Ap, " Discr: "); - if (Next_Ptr_Glob->Discr == 0) - fprintf (Ap, "O.K. "); - else fprintf (Ap, "WRONG "); - fprintf (Ap, "%d\n", Next_Ptr_Glob->Discr); - - fprintf (Ap, " Enum_Comp: "); - if (Next_Ptr_Glob->variant.var_1.Enum_Comp == 1) - fprintf (Ap, "O.K. "); - else fprintf (Ap, "WRONG "); - fprintf (Ap, "%d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp); - - fprintf (Ap, " Int_Comp: "); - if (Next_Ptr_Glob->variant.var_1.Int_Comp == 18) - fprintf (Ap, "O.K. "); - else fprintf (Ap, "WRONG "); - fprintf (Ap, "%d\n", Next_Ptr_Glob->variant.var_1.Int_Comp); - - fprintf (Ap, " Str_Comp: "); - if (strcmp(Next_Ptr_Glob->variant.var_1.Str_Comp, - "DHRYSTONE PROGRAM, SOME STRING") == 0) - fprintf (Ap, "O.K. "); - else fprintf (Ap, "WRONG "); - fprintf (Ap, "%s\n", Next_Ptr_Glob->variant.var_1.Str_Comp); - - fprintf (Ap, "Int_1_Loc: "); - if (Int_1_Loc == 5) - fprintf (Ap, "O.K. "); - else fprintf (Ap, "WRONG "); - fprintf (Ap, "%d\n", Int_1_Loc); - - fprintf (Ap, "Int_2_Loc: "); - if (Int_2_Loc == 13) - fprintf (Ap, "O.K. "); - else fprintf (Ap, "WRONG "); - fprintf (Ap, "%d\n", Int_2_Loc); - - fprintf (Ap, "Int_3_Loc: "); - if (Int_3_Loc == 7) - fprintf (Ap, "O.K. "); - else fprintf (Ap, "WRONG "); - fprintf (Ap, "%d\n", Int_3_Loc); - - fprintf (Ap, "Enum_Loc: "); - if (Enum_Loc == 1) - fprintf (Ap, "O.K. "); - else fprintf (Ap, "WRONG "); - fprintf (Ap, "%d\n", Enum_Loc); - - fprintf (Ap, "Str_1_Loc: "); - if (strcmp(Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING") == 0) - fprintf (Ap, "O.K. "); - else fprintf (Ap, "WRONG "); - fprintf (Ap, "%s\n", Str_1_Loc); - - fprintf (Ap, "Str_2_Loc: "); - if (strcmp(Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING") == 0) - fprintf (Ap, "O.K. "); - else fprintf (Ap, "WRONG "); - fprintf (Ap, "%s\n", Str_2_Loc); - - - fprintf (Ap, "\n"); - fprintf(Ap,"%s\n",Reg_Define); - fprintf (Ap, "\n"); - fprintf(Ap,"Microseconds 1 loop: %12.2lf\n",Microseconds); - fprintf(Ap,"Dhrystones / second: %10.0lf\n",Dhrystones_Per_Second); - fprintf(Ap,"VAX MIPS rating: %12.2lf\n\n",Vax_Mips); - fclose(Ap); - } - - printf ("\n"); - printf ("A new results file will have been created in the same directory as the\n"); - printf (".EXE files if one did not already exist. If you made a mistake on input, \n"); - printf ("you can use a text editor to correct it, delete the results or copy \n"); - printf ("them to a different file name. If you intend to run multiple tests you\n"); - printf ("you may wish to rename DHRY.TXT with a more informative title.\n\n"); - printf ("Please submit feedback and results files as a posting in Section 12\n"); - printf ("or to Roy_Longbottom@compuserve.com\n\n"); - - if (getinput == 1) - { - printf("Press any key to exit\n"); - printf ("\nIf this is displayed you must close the window in the normal way\n"); - } - } - - - void Proc_1 (REG Rec_Pointer Ptr_Val_Par) - /******************/ - - /* executed once */ - { - REG Rec_Pointer Next_Record = Ptr_Val_Par->Ptr_Comp; - /* == Ptr_Glob_Next */ - /* Local variable, initialized with Ptr_Val_Par->Ptr_Comp, */ - /* corresponds to "rename" in Ada, "with" in Pascal */ - - structassign (*Ptr_Val_Par->Ptr_Comp, *Ptr_Glob); - Ptr_Val_Par->variant.var_1.Int_Comp = 5; - Next_Record->variant.var_1.Int_Comp - = Ptr_Val_Par->variant.var_1.Int_Comp; - Next_Record->Ptr_Comp = Ptr_Val_Par->Ptr_Comp; - Proc_3 (&Next_Record->Ptr_Comp); - /* Ptr_Val_Par->Ptr_Comp->Ptr_Comp - == Ptr_Glob->Ptr_Comp */ - if (Next_Record->Discr == Ident_1) - /* then, executed */ - { - Next_Record->variant.var_1.Int_Comp = 6; - Proc_6 (Ptr_Val_Par->variant.var_1.Enum_Comp, - &Next_Record->variant.var_1.Enum_Comp); - Next_Record->Ptr_Comp = Ptr_Glob->Ptr_Comp; - Proc_7 (Next_Record->variant.var_1.Int_Comp, 10, - &Next_Record->variant.var_1.Int_Comp); - } - else /* not executed */ - structassign (*Ptr_Val_Par, *Ptr_Val_Par->Ptr_Comp); - } /* Proc_1 */ - - - void Proc_2 (One_Fifty *Int_Par_Ref) - /******************/ - /* executed once */ - /* *Int_Par_Ref == 1, becomes 4 */ - - { - One_Fifty Int_Loc; - Enumeration Enum_Loc; - - Int_Loc = *Int_Par_Ref + 10; - do /* executed once */ - if (Ch_1_Glob == 'A') - /* then, executed */ - { - Int_Loc -= 1; - *Int_Par_Ref = Int_Loc - Int_Glob; - Enum_Loc = Ident_1; - } /* if */ - while (Enum_Loc != Ident_1); /* true */ - } /* Proc_2 */ - - - void Proc_3 (Rec_Pointer *Ptr_Ref_Par) - /******************/ - /* executed once */ - /* Ptr_Ref_Par becomes Ptr_Glob */ - - { - if (Ptr_Glob != Null) - /* then, executed */ - *Ptr_Ref_Par = Ptr_Glob->Ptr_Comp; - Proc_7 (10, Int_Glob, &Ptr_Glob->variant.var_1.Int_Comp); - } /* Proc_3 */ - - -void Proc_4 () /* without parameters */ - /*******/ - /* executed once */ - { - Boolean Bool_Loc; - - Bool_Loc = Ch_1_Glob == 'A'; - Bool_Glob = Bool_Loc | Bool_Glob; - Ch_2_Glob = 'B'; - } /* Proc_4 */ - - - void Proc_5 () /* without parameters */ - /*******/ - /* executed once */ - { - Ch_1_Glob = 'A'; - Bool_Glob = false; - } /* Proc_5 */ - - - /* Procedure for the assignment of structures, */ - /* if the C compiler doesn't support this feature */ - #ifdef NOSTRUCTASSIGN - memcpy (d, s, l) - register char *d; - register char *s; - register int l; - { - while (l--) *d++ = *s++; - } - #endif - - -double dtime() -{ - - /* #include */ - - #define HZ CLOCKS_PER_SEC - clock_t tnow; - - double q; - tnow = clock(); - q = (double)tnow / (double)HZ; - return q; -} +/* + ************************************************************************* + * + * "DHRYSTONE" Benchmark Program + * ----------------------------- + * + * Version: C, Version 2.1 + * + * File: dhry_1.c (part 2 of 3) + * + * Date: May 25, 1988 + * + * Author: Reinhold P. Weicker + * + ************************************************************************* + */ + + #include + #include + #include + #include "dhry.h" + /*COMPILER COMPILER COMPILER COMPILER COMPILER COMPILER COMPILER*/ + + #ifdef COW + #define compiler "Watcom C/C++ 10.5 Win386" + #define options " -otexan -zp8 -5r -ms" + #endif + #ifdef CNW + #define compiler "Watcom C/C++ 10.5 Win386" + #define options " No optimisation" + #endif + #ifdef COD + #define compiler "Watcom C/C++ 10.5 Dos4GW" + #define options " -otexan -zp8 -5r -ms" + #endif + #ifdef CND + #define compiler "Watcom C/C++ 10.5 Dos4GW" + #define options " No optimisation" + #endif + #ifdef CONT + #define compiler "Watcom C/C++ 10.5 Win32NT" + #define options " -otexan -zp8 -5r -ms" + #endif + #ifdef CNNT + #define compiler "Watcom C/C++ 10.5 Win32NT" + #define options " No optimisation" + #endif + #ifdef COO2 + #define compiler "Watcom C/C++ 10.5 OS/2-32" + #define options " -otexan -zp8 -5r -ms" + #endif + #ifdef CNO2 + #define compiler "Watcom C/C++ 10.5 OS/2-32" + #define options " No optimisation" + #endif + + +/* Global Variables: */ + +Rec_Pointer Ptr_Glob, + Next_Ptr_Glob; +int Int_Glob; + Boolean Bool_Glob; + char Ch_1_Glob, + Ch_2_Glob; + int Arr_1_Glob [50]; + int Arr_2_Glob [50] [50]; + int getinput = 1; + + + char Reg_Define[100] = "Register option Selected."; + + Enumeration Func_1 (Capital_Letter Ch_1_Par_Val, + Capital_Letter Ch_2_Par_Val); + /* + forward declaration necessary since Enumeration may not simply be int + */ + + #ifndef ROPT + #define REG + /* REG becomes defined as empty */ + /* i.e. no register variables */ + #else + #define REG register + #endif + + void Proc_1 (REG Rec_Pointer Ptr_Val_Par); + void Proc_2 (One_Fifty *Int_Par_Ref); + void Proc_3 (Rec_Pointer *Ptr_Ref_Par); + void Proc_4 (); + void Proc_5 (); + void Proc_6 (Enumeration Enum_Val_Par, Enumeration *Enum_Ref_Par); + void Proc_7 (One_Fifty Int_1_Par_Val, One_Fifty Int_2_Par_Val, + One_Fifty *Int_Par_Ref); + void Proc_8 (Arr_1_Dim Arr_1_Par_Ref, Arr_2_Dim Arr_2_Par_Ref, + int Int_1_Par_Val, int Int_2_Par_Val); + + Boolean Func_2 (Str_30 Str_1_Par_Ref, Str_30 Str_2_Par_Ref); + + + /* variables for time measurement: */ + + #define Too_Small_Time 2 + /* Measurements should last at least 2 seconds */ + + double Begin_Time, + End_Time, + User_Time; + + double Microseconds, + Dhrystones_Per_Second, + Vax_Mips; + + /* end of variables for time measurement */ + + + void main (int argc, char *argv[]) + /*****/ + + /* main program, corresponds to procedures */ + /* Main and Proc_0 in the Ada version */ + { + double dtime(); + + One_Fifty Int_1_Loc; + REG One_Fifty Int_2_Loc; + One_Fifty Int_3_Loc; + REG char Ch_Index; + Enumeration Enum_Loc; + Str_30 Str_1_Loc; + Str_30 Str_2_Loc; + REG int Run_Index; + REG int Number_Of_Runs; + int endit, count = 10; + FILE *Ap; + char general[9][80] = {" "}; + + /* Initializations */ + if (argc > 1) + { + switch (argv[1][0]) + { + case 'N': + getinput = 0; + break; + case 'n': + getinput = 0; + break; + } + } + + if ((Ap = fopen("Dhry.txt","a+")) == NULL) + { + printf("Can not open Dhry.txt\n\n"); + printf("Press any key\n"); + exit(1); + } + +/*********************************************************************** + * Change for compiler and optimisation used * + ***********************************************************************/ + + Next_Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type)); + Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type)); + + Ptr_Glob->Ptr_Comp = Next_Ptr_Glob; + Ptr_Glob->Discr = Ident_1; + Ptr_Glob->variant.var_1.Enum_Comp = Ident_3; + Ptr_Glob->variant.var_1.Int_Comp = 40; + strcpy (Ptr_Glob->variant.var_1.Str_Comp, + "DHRYSTONE PROGRAM, SOME STRING"); + strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING"); + + Arr_2_Glob [8][7] = 10; + /* Was missing in published program. Without this statement, */ + /* Arr_2_Glob [8][7] would have an undefined value. */ + /* Warning: With 16-Bit processors and Number_Of_Runs > 32000, */ + /* overflow may occur for this array element. */ + + printf ("\n"); + printf ("Dhrystone Benchmark, Version 2.1 (Language: C or C++)\n"); + printf ("\n"); + + if (getinput == 0) + { + printf ("No run time input data\n\n"); + } + else + { + printf ("With run time input data\n\n"); + } + + #ifdef ROPT + printf ("Register option selected\n\n"); + #else + printf ("Register option not selected\n\n"); + strcpy(Reg_Define, "Register option Not selected."); + #endif + + /* + if (Reg) + { + printf ("Program compiled with 'register' attribute\n"); + printf ("\n"); + } + else + { + printf ("Program compiled without 'register' attribute\n"); + printf ("\n"); + } + + printf ("Please give the number of runs through the benchmark: "); + { + int n; + scanf ("%d", &n); + Number_Of_Runs = n; + } + printf ("\n"); + printf ("Execution starts, %d runs through Dhrystone\n", + Number_Of_Runs); + */ + + Number_Of_Runs = 5000; + + do + { + + Number_Of_Runs = Number_Of_Runs * 2; + count = count - 1; + Arr_2_Glob [8][7] = 10; + + /***************/ + /* Start timer */ + /***************/ + + Begin_Time = dtime(); + + for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index) + { + + Proc_5(); + Proc_4(); + /* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */ + Int_1_Loc = 2; + Int_2_Loc = 3; + strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING"); + Enum_Loc = Ident_2; + Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc); + /* Bool_Glob == 1 */ + while (Int_1_Loc < Int_2_Loc) /* loop body executed once */ + { + Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc; + /* Int_3_Loc == 7 */ + Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc); + /* Int_3_Loc == 7 */ + Int_1_Loc += 1; + } /* while */ + /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */ + Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc); + /* Int_Glob == 5 */ + Proc_1 (Ptr_Glob); + for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index) + /* loop body executed twice */ + { + if (Enum_Loc == Func_1 (Ch_Index, 'C')) + /* then, not executed */ + { + Proc_6 (Ident_1, &Enum_Loc); + strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING"); + Int_2_Loc = Run_Index; + Int_Glob = Run_Index; + } + } + /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */ + Int_2_Loc = Int_2_Loc * Int_1_Loc; + Int_1_Loc = Int_2_Loc / Int_3_Loc; + Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc; + /* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */ + Proc_2 (&Int_1_Loc); + /* Int_1_Loc == 5 */ + + } /* loop "for Run_Index" */ + + /**************/ + /* Stop timer */ + /**************/ + + End_Time = dtime(); + User_Time = End_Time - Begin_Time; + + printf ("%12.0f runs %6.2f seconds \n",(double) Number_Of_Runs, User_Time); + if (User_Time > 5) + { + count = 0; + } + else + { + if (User_Time < 0.1) + { + Number_Of_Runs = Number_Of_Runs * 5; + } + } + } /* calibrate/run do while */ + while (count >0); + + printf ("\n"); + printf ("Final values (* implementation-dependent):\n"); + printf ("\n"); + printf ("Int_Glob: "); + if (Int_Glob == 5) printf ("O.K. "); + else printf ("WRONG "); + printf ("%d ", Int_Glob); + + printf ("Bool_Glob: "); + if (Bool_Glob == 1) printf ("O.K. "); + else printf ("WRONG "); + printf ("%d\n", Bool_Glob); + + printf ("Ch_1_Glob: "); + if (Ch_1_Glob == 'A') printf ("O.K. "); + else printf ("WRONG "); + printf ("%c ", Ch_1_Glob); + + printf ("Ch_2_Glob: "); + if (Ch_2_Glob == 'B') printf ("O.K. "); + else printf ("WRONG "); + printf ("%c\n", Ch_2_Glob); + + printf ("Arr_1_Glob[8]: "); + if (Arr_1_Glob[8] == 7) printf ("O.K. "); + else printf ("WRONG "); + printf ("%d ", Arr_1_Glob[8]); + + printf ("Arr_2_Glob8/7: "); + if (Arr_2_Glob[8][7] == Number_Of_Runs + 10) + printf ("O.K. "); + else printf ("WRONG "); + printf ("%10d\n", Arr_2_Glob[8][7]); + + printf ("Ptr_Glob-> "); + printf (" Ptr_Comp: * %ld\n", (long) Ptr_Glob->Ptr_Comp); + + printf (" Discr: "); + if (Ptr_Glob->Discr == 0) printf ("O.K. "); + else printf ("WRONG "); + printf ("%d ", Ptr_Glob->Discr); + + printf ("Enum_Comp: "); + if (Ptr_Glob->variant.var_1.Enum_Comp == 2) + printf ("O.K. "); + else printf ("WRONG "); + printf ("%d\n", Ptr_Glob->variant.var_1.Enum_Comp); + + printf (" Int_Comp: "); + if (Ptr_Glob->variant.var_1.Int_Comp == 17) printf ("O.K. "); + else printf ("WRONG "); + printf ("%d ", Ptr_Glob->variant.var_1.Int_Comp); + + printf ("Str_Comp: "); + if (strcmp(Ptr_Glob->variant.var_1.Str_Comp, + "DHRYSTONE PROGRAM, SOME STRING") == 0) + printf ("O.K. "); + else printf ("WRONG "); + printf ("%s\n", Ptr_Glob->variant.var_1.Str_Comp); + + printf ("Next_Ptr_Glob-> "); + printf (" Ptr_Comp: * %ld", (long) Next_Ptr_Glob->Ptr_Comp); + printf (" same as above\n"); + + printf (" Discr: "); + if (Next_Ptr_Glob->Discr == 0) + printf ("O.K. "); + else printf ("WRONG "); + printf ("%d ", Next_Ptr_Glob->Discr); + + printf ("Enum_Comp: "); + if (Next_Ptr_Glob->variant.var_1.Enum_Comp == 1) + printf ("O.K. "); + else printf ("WRONG "); + printf ("%d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp); + + printf (" Int_Comp: "); + if (Next_Ptr_Glob->variant.var_1.Int_Comp == 18) + printf ("O.K. "); + else printf ("WRONG "); + printf ("%d ", Next_Ptr_Glob->variant.var_1.Int_Comp); + + printf ("Str_Comp: "); + if (strcmp(Next_Ptr_Glob->variant.var_1.Str_Comp, + "DHRYSTONE PROGRAM, SOME STRING") == 0) + printf ("O.K. "); + else printf ("WRONG "); + printf ("%s\n", Next_Ptr_Glob->variant.var_1.Str_Comp); + + printf ("Int_1_Loc: "); + if (Int_1_Loc == 5) + printf ("O.K. "); + else printf ("WRONG "); + printf ("%d ", Int_1_Loc); + + printf ("Int_2_Loc: "); + if (Int_2_Loc == 13) + printf ("O.K. "); + else printf ("WRONG "); + printf ("%d\n", Int_2_Loc); + + printf ("Int_3_Loc: "); + if (Int_3_Loc == 7) + printf ("O.K. "); + else printf ("WRONG "); + printf ("%d ", Int_3_Loc); + + printf ("Enum_Loc: "); + if (Enum_Loc == 1) + printf ("O.K. "); + else printf ("WRONG "); + printf ("%d\n", Enum_Loc); + + printf ("Str_1_Loc: "); + if (strcmp(Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING") == 0) + printf ("O.K. "); + else printf ("WRONG "); + printf ("%s\n", Str_1_Loc); + + printf ("Str_2_Loc: "); + if (strcmp(Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING") == 0) + printf ("O.K. "); + else printf ("WRONG "); + printf ("%s\n", Str_2_Loc); + + printf ("\n"); + + + if (User_Time < Too_Small_Time) + { + printf ("Measured time too small to obtain meaningful results\n"); + printf ("Please increase number of runs\n"); + printf ("\n"); + } + else + { + Microseconds = User_Time * Mic_secs_Per_Second + / (double) Number_Of_Runs; + Dhrystones_Per_Second = (double) Number_Of_Runs / User_Time; + Vax_Mips = Dhrystones_Per_Second / 1757.0; + + printf ("Microseconds for one run through Dhrystone: "); + printf ("%12.2lf \n", Microseconds); + printf ("Dhrystones per Second: "); + printf ("%10.0lf \n", Dhrystones_Per_Second); + printf ("VAX MIPS rating = "); + printf ("%12.2lf \n",Vax_Mips); + printf ("\n"); + +/************************************************************************ + * Type details of hardware, software etc. * + ************************************************************************/ + + if (getinput == 1) + { + printf ("Enter the following which will be added with results to file DHRY.TXT\n"); + printf ("When submitting a number of results you need only provide details once\n"); + printf ("but a cross reference such as an abbreviated CPU type would be useful.\n"); + printf ("You can kill (exit or close) the program now and no data will be added.\n\n"); + + printf ("PC Supplier/model ? "); + gets(general[1]); + + printf ("CPU chip ? "); + gets(general[2]); + + printf ("Clock MHz ? "); + gets(general[3]); + + printf ("Cache size ? "); + gets(general[4]); + + printf ("Chipset & H/W options ? "); + gets(general[5]); + + printf ("OS/DOS version ? "); + gets(general[6]); + + printf ("Your name ? "); + gets(general[7]); + + printf ("Company/Location ? "); + gets(general[8]); + + printf ("E-mail address ? "); + gets(general[0]); + } +/************************************************************************ + * Add results to output file Dhry.txt * + ************************************************************************/ + fprintf (Ap, "-------------------- -----------------------------------" + "\n"); + fprintf (Ap, "Dhrystone Benchmark Version 2.1 (Language: C++)\n\n"); + fprintf (Ap, "PC model %s\n", general[1]); + fprintf (Ap, "CPU %s\n", general[2]); + fprintf (Ap, "Clock MHz %s\n", general[3]); + fprintf (Ap, "Cache %s\n", general[4]); + fprintf (Ap, "Options %s\n", general[5]); + fprintf (Ap, "OS/DOS %s\n", general[6]); + fprintf (Ap, "Run by %s\n", general[7]); + fprintf (Ap, "From %s\n", general[8]); + fprintf (Ap, "Mail %s\n\n", general[0]); + + fprintf (Ap, "Final values (* implementation-dependent):\n"); + fprintf (Ap, "\n"); + fprintf (Ap, "Int_Glob: "); + if (Int_Glob == 5) fprintf (Ap, "O.K. "); + else fprintf (Ap, "WRONG "); + fprintf (Ap, "%d\n", Int_Glob); + + fprintf (Ap, "Bool_Glob: "); + if (Bool_Glob == 1) fprintf (Ap, "O.K. "); + else fprintf (Ap, "WRONG "); + fprintf (Ap, "%d\n", Bool_Glob); + + fprintf (Ap, "Ch_1_Glob: "); + if (Ch_1_Glob == 'A') fprintf (Ap, "O.K. "); + else fprintf (Ap, "WRONG "); + fprintf (Ap, "%c\n", Ch_1_Glob); + + fprintf (Ap, "Ch_2_Glob: "); + if (Ch_2_Glob == 'B') fprintf (Ap, "O.K. "); + else fprintf (Ap, "WRONG "); + fprintf (Ap, "%c\n", Ch_2_Glob); + + fprintf (Ap, "Arr_1_Glob[8]: "); + if (Arr_1_Glob[8] == 7) fprintf (Ap, "O.K. "); + else fprintf (Ap, "WRONG "); + fprintf (Ap, "%d\n", Arr_1_Glob[8]); + + fprintf (Ap, "Arr_2_Glob8/7: "); + if (Arr_2_Glob[8][7] == Number_Of_Runs + 10) + fprintf (Ap, "O.K. "); + else fprintf (Ap, "WRONG "); + fprintf (Ap, "%10d\n", Arr_2_Glob[8][7]); + + fprintf (Ap, "Ptr_Glob-> \n"); + fprintf (Ap, " Ptr_Comp: * %x\n", (long) Ptr_Glob->Ptr_Comp); + + fprintf (Ap, " Discr: "); + if (Ptr_Glob->Discr == 0) fprintf (Ap, "O.K. "); + else fprintf (Ap, "WRONG "); + fprintf (Ap, "%d\n", Ptr_Glob->Discr); + + fprintf (Ap, " Enum_Comp: "); + if (Ptr_Glob->variant.var_1.Enum_Comp == 2) + fprintf (Ap, "O.K. "); + else fprintf (Ap, "WRONG "); + fprintf (Ap, "%d\n", Ptr_Glob->variant.var_1.Enum_Comp); + + fprintf (Ap, " Int_Comp: "); + if (Ptr_Glob->variant.var_1.Int_Comp == 17) fprintf (Ap, "O.K. "); + else fprintf (Ap, "WRONG "); + fprintf (Ap, "%d\n", Ptr_Glob->variant.var_1.Int_Comp); + + fprintf (Ap, " Str_Comp: "); + if (strcmp(Ptr_Glob->variant.var_1.Str_Comp, + "DHRYSTONE PROGRAM, SOME STRING") == 0) + fprintf (Ap, "O.K. "); + else fprintf (Ap, "WRONG "); + fprintf (Ap, "%s\n", Ptr_Glob->variant.var_1.Str_Comp); + + fprintf (Ap, "Next_Ptr_Glob-> \n"); + fprintf (Ap, " Ptr_Comp: * %x", (long) Next_Ptr_Glob->Ptr_Comp); + fprintf (Ap, " same as above\n"); + + fprintf (Ap, " Discr: "); + if (Next_Ptr_Glob->Discr == 0) + fprintf (Ap, "O.K. "); + else fprintf (Ap, "WRONG "); + fprintf (Ap, "%d\n", Next_Ptr_Glob->Discr); + + fprintf (Ap, " Enum_Comp: "); + if (Next_Ptr_Glob->variant.var_1.Enum_Comp == 1) + fprintf (Ap, "O.K. "); + else fprintf (Ap, "WRONG "); + fprintf (Ap, "%d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp); + + fprintf (Ap, " Int_Comp: "); + if (Next_Ptr_Glob->variant.var_1.Int_Comp == 18) + fprintf (Ap, "O.K. "); + else fprintf (Ap, "WRONG "); + fprintf (Ap, "%d\n", Next_Ptr_Glob->variant.var_1.Int_Comp); + + fprintf (Ap, " Str_Comp: "); + if (strcmp(Next_Ptr_Glob->variant.var_1.Str_Comp, + "DHRYSTONE PROGRAM, SOME STRING") == 0) + fprintf (Ap, "O.K. "); + else fprintf (Ap, "WRONG "); + fprintf (Ap, "%s\n", Next_Ptr_Glob->variant.var_1.Str_Comp); + + fprintf (Ap, "Int_1_Loc: "); + if (Int_1_Loc == 5) + fprintf (Ap, "O.K. "); + else fprintf (Ap, "WRONG "); + fprintf (Ap, "%d\n", Int_1_Loc); + + fprintf (Ap, "Int_2_Loc: "); + if (Int_2_Loc == 13) + fprintf (Ap, "O.K. "); + else fprintf (Ap, "WRONG "); + fprintf (Ap, "%d\n", Int_2_Loc); + + fprintf (Ap, "Int_3_Loc: "); + if (Int_3_Loc == 7) + fprintf (Ap, "O.K. "); + else fprintf (Ap, "WRONG "); + fprintf (Ap, "%d\n", Int_3_Loc); + + fprintf (Ap, "Enum_Loc: "); + if (Enum_Loc == 1) + fprintf (Ap, "O.K. "); + else fprintf (Ap, "WRONG "); + fprintf (Ap, "%d\n", Enum_Loc); + + fprintf (Ap, "Str_1_Loc: "); + if (strcmp(Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING") == 0) + fprintf (Ap, "O.K. "); + else fprintf (Ap, "WRONG "); + fprintf (Ap, "%s\n", Str_1_Loc); + + fprintf (Ap, "Str_2_Loc: "); + if (strcmp(Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING") == 0) + fprintf (Ap, "O.K. "); + else fprintf (Ap, "WRONG "); + fprintf (Ap, "%s\n", Str_2_Loc); + + + fprintf (Ap, "\n"); + fprintf(Ap,"%s\n",Reg_Define); + fprintf (Ap, "\n"); + fprintf(Ap,"Microseconds 1 loop: %12.2lf\n",Microseconds); + fprintf(Ap,"Dhrystones / second: %10.0lf\n",Dhrystones_Per_Second); + fprintf(Ap,"VAX MIPS rating: %12.2lf\n\n",Vax_Mips); + fclose(Ap); + } + + printf ("\n"); + printf ("A new results file will have been created in the same directory as the\n"); + printf (".EXE files if one did not already exist. If you made a mistake on input, \n"); + printf ("you can use a text editor to correct it, delete the results or copy \n"); + printf ("them to a different file name. If you intend to run multiple tests you\n"); + printf ("you may wish to rename DHRY.TXT with a more informative title.\n\n"); + printf ("Please submit feedback and results files as a posting in Section 12\n"); + printf ("or to Roy_Longbottom@compuserve.com\n\n"); + + if (getinput == 1) + { + printf("Press any key to exit\n"); + printf ("\nIf this is displayed you must close the window in the normal way\n"); + } + } + + + void Proc_1 (REG Rec_Pointer Ptr_Val_Par) + /******************/ + + /* executed once */ + { + REG Rec_Pointer Next_Record = Ptr_Val_Par->Ptr_Comp; + /* == Ptr_Glob_Next */ + /* Local variable, initialized with Ptr_Val_Par->Ptr_Comp, */ + /* corresponds to "rename" in Ada, "with" in Pascal */ + + structassign (*Ptr_Val_Par->Ptr_Comp, *Ptr_Glob); + Ptr_Val_Par->variant.var_1.Int_Comp = 5; + Next_Record->variant.var_1.Int_Comp + = Ptr_Val_Par->variant.var_1.Int_Comp; + Next_Record->Ptr_Comp = Ptr_Val_Par->Ptr_Comp; + Proc_3 (&Next_Record->Ptr_Comp); + /* Ptr_Val_Par->Ptr_Comp->Ptr_Comp + == Ptr_Glob->Ptr_Comp */ + if (Next_Record->Discr == Ident_1) + /* then, executed */ + { + Next_Record->variant.var_1.Int_Comp = 6; + Proc_6 (Ptr_Val_Par->variant.var_1.Enum_Comp, + &Next_Record->variant.var_1.Enum_Comp); + Next_Record->Ptr_Comp = Ptr_Glob->Ptr_Comp; + Proc_7 (Next_Record->variant.var_1.Int_Comp, 10, + &Next_Record->variant.var_1.Int_Comp); + } + else /* not executed */ + structassign (*Ptr_Val_Par, *Ptr_Val_Par->Ptr_Comp); + } /* Proc_1 */ + + + void Proc_2 (One_Fifty *Int_Par_Ref) + /******************/ + /* executed once */ + /* *Int_Par_Ref == 1, becomes 4 */ + + { + One_Fifty Int_Loc; + Enumeration Enum_Loc; + + Int_Loc = *Int_Par_Ref + 10; + do /* executed once */ + if (Ch_1_Glob == 'A') + /* then, executed */ + { + Int_Loc -= 1; + *Int_Par_Ref = Int_Loc - Int_Glob; + Enum_Loc = Ident_1; + } /* if */ + while (Enum_Loc != Ident_1); /* true */ + } /* Proc_2 */ + + + void Proc_3 (Rec_Pointer *Ptr_Ref_Par) + /******************/ + /* executed once */ + /* Ptr_Ref_Par becomes Ptr_Glob */ + + { + if (Ptr_Glob != Null) + /* then, executed */ + *Ptr_Ref_Par = Ptr_Glob->Ptr_Comp; + Proc_7 (10, Int_Glob, &Ptr_Glob->variant.var_1.Int_Comp); + } /* Proc_3 */ + + +void Proc_4 () /* without parameters */ + /*******/ + /* executed once */ + { + Boolean Bool_Loc; + + Bool_Loc = Ch_1_Glob == 'A'; + Bool_Glob = Bool_Loc | Bool_Glob; + Ch_2_Glob = 'B'; + } /* Proc_4 */ + + + void Proc_5 () /* without parameters */ + /*******/ + /* executed once */ + { + Ch_1_Glob = 'A'; + Bool_Glob = false; + } /* Proc_5 */ + + + /* Procedure for the assignment of structures, */ + /* if the C compiler doesn't support this feature */ + #ifdef NOSTRUCTASSIGN + memcpy (d, s, l) + register char *d; + register char *s; + register int l; + { + while (l--) *d++ = *s++; + } + #endif + + +double dtime() +{ + + /* #include */ + + #define HZ CLOCKS_PER_SEC + clock_t tnow; + + double q; + tnow = clock(); + q = (double)tnow / (double)HZ; + return q; +} diff --git a/dhry_2.c b/dhry_2.c index 74cb65b..434945c 100644 --- a/dhry_2.c +++ b/dhry_2.c @@ -1,186 +1,186 @@ - /* - ************************************************************************* - * - * "DHRYSTONE" Benchmark Program - * ----------------------------- - * - * Version: C, Version 2.1 - * - * File: dhry_2.c (part 3 of 3) - * - * Date: May 25, 1988 - * - * Author: Reinhold P. Weicker - * - ************************************************************************* - */ - - #include "dhry.h" - - #ifndef REG - #define REG - /* REG becomes defined as empty */ - /* i.e. no register variables */ - #else - #define REG register - #endif - - extern int Int_Glob; - extern char Ch_1_Glob; - - Boolean Func_3 (Enumeration Enum_Par_Val); - - void Proc_6 (Enumeration Enum_Val_Par, Enumeration *Enum_Ref_Par) - /*********************************/ - /* executed once */ - /* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */ - - { - *Enum_Ref_Par = Enum_Val_Par; - if (! Func_3 (Enum_Val_Par)) - /* then, not executed */ - *Enum_Ref_Par = Ident_4; - switch (Enum_Val_Par) - { - case Ident_1: - *Enum_Ref_Par = Ident_1; - break; - case Ident_2: - if (Int_Glob > 100) - /* then */ - *Enum_Ref_Par = Ident_1; - else *Enum_Ref_Par = Ident_4; - break; - case Ident_3: /* executed */ - *Enum_Ref_Par = Ident_2; - break; - case Ident_4: break; - case Ident_5: - *Enum_Ref_Par = Ident_3; - break; - } /* switch */ - } /* Proc_6 */ - - - void Proc_7 (One_Fifty Int_1_Par_Val, One_Fifty Int_2_Par_Val, - One_Fifty *Int_Par_Ref) - /**********************************************/ - /* executed three times */ - /* first call: Int_1_Par_Val == 2, Int_2_Par_Val == 3, */ - /* Int_Par_Ref becomes 7 */ - /* second call: Int_1_Par_Val == 10, Int_2_Par_Val == 5, */ - /* Int_Par_Ref becomes 17 */ - /* third call: Int_1_Par_Val == 6, Int_2_Par_Val == 10, */ - /* Int_Par_Ref becomes 18 */ - - { - One_Fifty Int_Loc; - - Int_Loc = Int_1_Par_Val + 2; - *Int_Par_Ref = Int_2_Par_Val + Int_Loc; - } /* Proc_7 */ - - - void Proc_8 (Arr_1_Dim Arr_1_Par_Ref, Arr_2_Dim Arr_2_Par_Ref, - int Int_1_Par_Val, int Int_2_Par_Val) - /*********************************************************************/ - /* executed once */ - /* Int_Par_Val_1 == 3 */ - /* Int_Par_Val_2 == 7 */ - - { - REG One_Fifty Int_Index; - REG One_Fifty Int_Loc; - - Int_Loc = Int_1_Par_Val + 5; - Arr_1_Par_Ref [Int_Loc] = Int_2_Par_Val; - Arr_1_Par_Ref [Int_Loc+1] = Arr_1_Par_Ref [Int_Loc]; - Arr_1_Par_Ref [Int_Loc+30] = Int_Loc; - for (Int_Index = Int_Loc; Int_Index <= Int_Loc+1; ++Int_Index) - Arr_2_Par_Ref [Int_Loc] [Int_Index] = Int_Loc; - Arr_2_Par_Ref [Int_Loc] [Int_Loc-1] += 1; - Arr_2_Par_Ref [Int_Loc+20] [Int_Loc] = Arr_1_Par_Ref [Int_Loc]; - Int_Glob = 5; - } /* Proc_8 */ - - - Enumeration Func_1 (Capital_Letter Ch_1_Par_Val, - Capital_Letter Ch_2_Par_Val) - /*************************************************/ - /* executed three times */ - /* first call: Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R' */ - /* second call: Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C' */ - /* third call: Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C' */ - - { - Capital_Letter Ch_1_Loc; - Capital_Letter Ch_2_Loc; - - Ch_1_Loc = Ch_1_Par_Val; - Ch_2_Loc = Ch_1_Loc; - if (Ch_2_Loc != Ch_2_Par_Val) - /* then, executed */ - return (Ident_1); - else /* not executed */ - { - Ch_1_Glob = Ch_1_Loc; - return (Ident_2); - } - } /* Func_1 */ - - - Boolean Func_2 (Str_30 Str_1_Par_Ref, Str_30 Str_2_Par_Ref) - /*************************************************/ - /* executed once */ - /* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */ - /* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */ - - { - REG One_Thirty Int_Loc; - Capital_Letter Ch_Loc; - - Int_Loc = 2; - while (Int_Loc <= 2) /* loop body executed once */ - if (Func_1 (Str_1_Par_Ref[Int_Loc], - Str_2_Par_Ref[Int_Loc+1]) == Ident_1) - /* then, executed */ - { - Ch_Loc = 'A'; - Int_Loc += 1; - } /* if, while */ - if (Ch_Loc >= 'W' && Ch_Loc < 'Z') - /* then, not executed */ - Int_Loc = 7; - if (Ch_Loc == 'R') - /* then, not executed */ - return (true); - else /* executed */ - { - if (strcmp (Str_1_Par_Ref, Str_2_Par_Ref) > 0) - /* then, not executed */ - { - Int_Loc += 7; - Int_Glob = Int_Loc; - return (true); - } - else /* executed */ - return (false); - } /* if Ch_Loc */ - } /* Func_2 */ - - - Boolean Func_3 (Enumeration Enum_Par_Val) - /***************************/ - /* executed once */ - /* Enum_Par_Val == Ident_3 */ - - { - Enumeration Enum_Loc; - - Enum_Loc = Enum_Par_Val; - if (Enum_Loc == Ident_3) - /* then, executed */ - return (true); - else /* not executed */ - return (false); - } /* Func_3 */ + /* + ************************************************************************* + * + * "DHRYSTONE" Benchmark Program + * ----------------------------- + * + * Version: C, Version 2.1 + * + * File: dhry_2.c (part 3 of 3) + * + * Date: May 25, 1988 + * + * Author: Reinhold P. Weicker + * + ************************************************************************* + */ + + #include "dhry.h" + + #ifndef REG + #define REG + /* REG becomes defined as empty */ + /* i.e. no register variables */ + #else + #define REG register + #endif + + extern int Int_Glob; + extern char Ch_1_Glob; + + Boolean Func_3 (Enumeration Enum_Par_Val); + + void Proc_6 (Enumeration Enum_Val_Par, Enumeration *Enum_Ref_Par) + /*********************************/ + /* executed once */ + /* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */ + + { + *Enum_Ref_Par = Enum_Val_Par; + if (! Func_3 (Enum_Val_Par)) + /* then, not executed */ + *Enum_Ref_Par = Ident_4; + switch (Enum_Val_Par) + { + case Ident_1: + *Enum_Ref_Par = Ident_1; + break; + case Ident_2: + if (Int_Glob > 100) + /* then */ + *Enum_Ref_Par = Ident_1; + else *Enum_Ref_Par = Ident_4; + break; + case Ident_3: /* executed */ + *Enum_Ref_Par = Ident_2; + break; + case Ident_4: break; + case Ident_5: + *Enum_Ref_Par = Ident_3; + break; + } /* switch */ + } /* Proc_6 */ + + + void Proc_7 (One_Fifty Int_1_Par_Val, One_Fifty Int_2_Par_Val, + One_Fifty *Int_Par_Ref) + /**********************************************/ + /* executed three times */ + /* first call: Int_1_Par_Val == 2, Int_2_Par_Val == 3, */ + /* Int_Par_Ref becomes 7 */ + /* second call: Int_1_Par_Val == 10, Int_2_Par_Val == 5, */ + /* Int_Par_Ref becomes 17 */ + /* third call: Int_1_Par_Val == 6, Int_2_Par_Val == 10, */ + /* Int_Par_Ref becomes 18 */ + + { + One_Fifty Int_Loc; + + Int_Loc = Int_1_Par_Val + 2; + *Int_Par_Ref = Int_2_Par_Val + Int_Loc; + } /* Proc_7 */ + + + void Proc_8 (Arr_1_Dim Arr_1_Par_Ref, Arr_2_Dim Arr_2_Par_Ref, + int Int_1_Par_Val, int Int_2_Par_Val) + /*********************************************************************/ + /* executed once */ + /* Int_Par_Val_1 == 3 */ + /* Int_Par_Val_2 == 7 */ + + { + REG One_Fifty Int_Index; + REG One_Fifty Int_Loc; + + Int_Loc = Int_1_Par_Val + 5; + Arr_1_Par_Ref [Int_Loc] = Int_2_Par_Val; + Arr_1_Par_Ref [Int_Loc+1] = Arr_1_Par_Ref [Int_Loc]; + Arr_1_Par_Ref [Int_Loc+30] = Int_Loc; + for (Int_Index = Int_Loc; Int_Index <= Int_Loc+1; ++Int_Index) + Arr_2_Par_Ref [Int_Loc] [Int_Index] = Int_Loc; + Arr_2_Par_Ref [Int_Loc] [Int_Loc-1] += 1; + Arr_2_Par_Ref [Int_Loc+20] [Int_Loc] = Arr_1_Par_Ref [Int_Loc]; + Int_Glob = 5; + } /* Proc_8 */ + + + Enumeration Func_1 (Capital_Letter Ch_1_Par_Val, + Capital_Letter Ch_2_Par_Val) + /*************************************************/ + /* executed three times */ + /* first call: Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R' */ + /* second call: Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C' */ + /* third call: Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C' */ + + { + Capital_Letter Ch_1_Loc; + Capital_Letter Ch_2_Loc; + + Ch_1_Loc = Ch_1_Par_Val; + Ch_2_Loc = Ch_1_Loc; + if (Ch_2_Loc != Ch_2_Par_Val) + /* then, executed */ + return (Ident_1); + else /* not executed */ + { + Ch_1_Glob = Ch_1_Loc; + return (Ident_2); + } + } /* Func_1 */ + + + Boolean Func_2 (Str_30 Str_1_Par_Ref, Str_30 Str_2_Par_Ref) + /*************************************************/ + /* executed once */ + /* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */ + /* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */ + + { + REG One_Thirty Int_Loc; + Capital_Letter Ch_Loc; + + Int_Loc = 2; + while (Int_Loc <= 2) /* loop body executed once */ + if (Func_1 (Str_1_Par_Ref[Int_Loc], + Str_2_Par_Ref[Int_Loc+1]) == Ident_1) + /* then, executed */ + { + Ch_Loc = 'A'; + Int_Loc += 1; + } /* if, while */ + if (Ch_Loc >= 'W' && Ch_Loc < 'Z') + /* then, not executed */ + Int_Loc = 7; + if (Ch_Loc == 'R') + /* then, not executed */ + return (true); + else /* executed */ + { + if (strcmp (Str_1_Par_Ref, Str_2_Par_Ref) > 0) + /* then, not executed */ + { + Int_Loc += 7; + Int_Glob = Int_Loc; + return (true); + } + else /* executed */ + return (false); + } /* if Ch_Loc */ + } /* Func_2 */ + + + Boolean Func_3 (Enumeration Enum_Par_Val) + /***************************/ + /* executed once */ + /* Enum_Par_Val == Ident_3 */ + + { + Enumeration Enum_Loc; + + Enum_Loc = Enum_Par_Val; + if (Enum_Loc == Ident_3) + /* then, executed */ + return (true); + else /* not executed */ + return (false); + } /* Func_3 */ -- cgit v1.2.3