home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-02-21 | 56.5 KB | 1,309 lines |
-
- #! /bin/sh
- # This is a shell archive, meaning:
- # 1. Remove everything above the #! /bin/sh line.
- # 2. Save the resulting text in a file.
- # 3. Execute the file with /bin/sh (not csh) to create:
- # dhry.h
- # dhry.p
- # This archive created: Wed Feb 14 19:32:28 1990
- export PATH; PATH=/bin:/usr/bin:$PATH
- echo shar: "extracting 'dhry.h'" '(18533 characters)'
- if test -f 'dhry.h'
- then
- echo shar: "will not over-write existing file 'dhry.h'"
- else
- sed 's/^X//' << \SHAR_EOF > 'dhry.h'
- X/*
- X ****************************************************************************
- X *
- X * "DHRYSTONE" Benchmark Program
- X * -----------------------------
- X *
- X * Version: C, Version 2.1
- X *
- X * File: dhry.h (part 1 of 3)
- X *
- X * Date: May 25, 1988
- X *
- X * Author: Reinhold P. Weicker
- X * Siemens AG, E STE 35
- X * Postfach 3240
- X * 8520 Erlangen
- X * Germany (West)
- X * Phone: [xxx-49]-9131-7-20330
- X * (8-17 Central European Time)
- X * Usenet: ..!mcvax!unido!estevax!weicker
- X *
- X * Original Version (in Ada) published in
- X * "Communications of the ACM" vol. 27., no. 10 (Oct. 1984),
- X * pp. 1013 - 1030, together with the statistics
- X * on which the distribution of statements etc. is based.
- X *
- X * In this C version, the following C library functions are used:
- X * - strcpy, strcmp (inside the measurement loop)
- X * - printf, scanf (outside the measurement loop)
- X * In addition, Berkeley UNIX system calls "times ()" or "time ()"
- X * are used for execution time measurement. For measurements
- X * on other systems, these calls have to be changed.
- X *
- X * Collection of Results:
- X * Reinhold Weicker (address see above) and
- X *
- X * Rick Richardson
- X * PC Research. Inc.
- X * 94 Apple Orchard Drive
- X * Tinton Falls, NJ 07724
- X * Phone: (201) 389-8963 (9-17 EST)
- X * Usenet: ...!uunet!pcrat!rick
- X *
- X * Please send results to Rick Richardson and/or Reinhold Weicker.
- X * Complete information should be given on hardware and software used.
- X * Hardware information includes: Machine type, CPU, type and size
- X * of caches; for microprocessors: clock frequency, memory speed
- X * (number of wait states).
- X * Software information includes: Compiler (and runtime library)
- X * manufacturer and version, compilation switches, OS version.
- X * The Operating System version may give an indication about the
- X * compiler; Dhrystone itself performs no OS calls in the measurement loop.
- X *
- X * The complete output generated by the program should be mailed
- X * such that at least some checks for correctness can be made.
- X *
- X ***************************************************************************
- X *
- X * History: This version C/2.1 has been made for two reasons:
- X *
- X * 1) There is an obvious need for a common C version of
- X * Dhrystone, since C is at present the most popular system
- X * programming language for the class of processors
- X * (microcomputers, minicomputers) where Dhrystone is used most.
- X * There should be, as far as possible, only one C version of
- X * Dhrystone such that results can be compared without
- X * restrictions. In the past, the C versions distributed
- X * by Rick Richardson (Version 1.1) and by Reinhold Weicker
- X * had small (though not significant) differences.
- X *
- X * 2) As far as it is possible without changes to the Dhrystone
- X * statistics, optimizing compilers should be prevented from
- X * removing significant statements.
- X *
- X * This C version has been developed in cooperation with
- X * Rick Richardson (Tinton Falls, NJ), it incorporates many
- X * ideas from the "Version 1.1" distributed previously by
- X * him over the UNIX network Usenet.
- X * I also thank Chaim Benedelac (National Semiconductor),
- X * David Ditzel (SUN), Earl Killian and John Mashey (MIPS),
- X * Alan Smith and Rafael Saavedra-Barrera (UC at Berkeley)
- X * for their help with comments on earlier versions of the
- X * benchmark.
- X *
- X * Changes: In the initialization part, this version follows mostly
- X * Rick Richardson's version distributed via Usenet, not the
- X * version distributed earlier via floppy disk by Reinhold Weicker.
- X * As a concession to older compilers, names have been made
- X * unique within the first 8 characters.
- X * Inside the measurement loop, this version follows the
- X * version previously distributed by Reinhold Weicker.
- X *
- X * At several places in the benchmark, code has been added,
- X * but within the measurement loop only in branches that
- X * are not executed. The intention is that optimizing compilers
- X * should be prevented from moving code out of the measurement
- X * loop, or from removing code altogether. Since the statements
- X * that are executed within the measurement loop have NOT been
- X * changed, the numbers defining the "Dhrystone distribution"
- X * (distribution of statements, operand types and locality)
- X * still hold. Except for sophisticated optimizing compilers,
- X * execution times for this version should be the same as
- X * for previous versions.
- X *
- X * Since it has proven difficult to subtract the time for the
- X * measurement loop overhead in a correct way, the loop check
- X * has been made a part of the benchmark. This does have
- X * an impact - though a very minor one - on the distribution
- X * statistics which have been updated for this version.
- X *
- X * All changes within the measurement loop are described
- X * and discussed in the companion paper "Rationale for
- X * Dhrystone version 2".
- X *
- X * Because of the self-imposed limitation that the order and
- X * distribution of the executed statements should not be
- X * changed, there are still cases where optimizing compilers
- X * may not generate code for some statements. To a certain
- X * degree, this is unavoidable for small synthetic benchmarks.
- X * Users of the benchmark are advised to check code listings
- X * whether code is generated for all statements of Dhrystone.
- X *
- X * Version 2.1 is identical to version 2.0 distributed via
- X * the UNIX network Usenet in March 1988 except that it corrects
- X * some minor deficiencies that were found by users of version 2.0.
- X * The only change within the measurement loop is that a
- X * non-executed "else" part was added to the "if" statement in
- X * Func_3, and a non-executed "else" part removed from Proc_3.
- X *
- X ***************************************************************************
- X *
- X * Defines: The following "Defines" are possible:
- X * -DREG=register (default: Not defined)
- X * As an approximation to what an average C programmer
- X * might do, the "register" storage class is applied
- X * (if enabled by -DREG=register)
- X * - for local variables, if they are used (dynamically)
- X * five or more times
- X * - for parameters if they are used (dynamically)
- X * six or more times
- X * Note that an optimal "register" strategy is
- X * compiler-dependent, and that "register" declarations
- X * do not necessarily lead to faster execution.
- X * -DNOSTRUCTASSIGN (default: Not defined)
- X * Define if the C compiler does not support
- X * assignment of structures.
- X * -DNOENUMS (default: Not defined)
- X * Define if the C compiler does not support
- X * enumeration types.
- X * -DTIMES (default)
- X * -DTIME
- X * The "times" function of UNIX (returning process times)
- X * or the "time" function (returning wallclock time)
- X * is used for measurement.
- X * For single user machines, "time ()" is adequate. For
- X * multi-user machines where you cannot get single-user
- X * access, use the "times ()" function. If you have
- X * neither, use a stopwatch in the dead of night.
- X * "printf"s are provided marking the points "Start Timer"
- X * and "Stop Timer". DO NOT use the UNIX "time(1)"
- X * command, as this will measure the total time to
- X * run this program, which will (erroneously) include
- X * the time to allocate storage (malloc) and to perform
- X * the initialization.
- X * -DHZ=nnn
- X * In Berkeley UNIX, the function "times" returns process
- X * time in 1/HZ seconds, with HZ = 60 for most systems.
- X * CHECK YOUR SYSTEM DESCRIPTION BEFORE YOU JUST APPLY
- X * A VALUE.
- X *
- X ***************************************************************************
- X *
- X * Compilation model and measurement (IMPORTANT):
- X *
- X * This C version of Dhrystone consists of three files:
- X * - dhry.h (this file, containing global definitions and comments)
- X * - dhry_1.c (containing the code corresponding to Ada package Pack_1)
- X * - dhry_2.c (containing the code corresponding to Ada package Pack_2)
- X *
- X * The following "ground rules" apply for measurements:
- X * - Separate compilation
- X * - No procedure merging
- X * - Otherwise, compiler optimizations are allowed but should be indicated
- X * - Default results are those without register declarations
- X * See the companion paper "Rationale for Dhrystone Version 2" for a more
- X * detailed discussion of these ground rules.
- X *
- X * For 16-Bit processors (e.g. 80186, 80286), times for all compilation
- X * models ("small", "medium", "large" etc.) should be given if possible,
- X * together with a definition of these models for the compiler system used.
- X *
- X **************************************************************************
- X *
- X * Dhrystone (C version) statistics:
- X *
- X * [Comment from the first distribution, updated for version 2.
- X * Note that because of language differences, the numbers are slightly
- X * different from the Ada version.]
- X *
- X * The following program contains statements of a high level programming
- X * language (here: C) in a distribution considered representative:
- X *
- X * assignments 52 (51.0 %)
- X * control statements 33 (32.4 %)
- X * procedure, function calls 17 (16.7 %)
- X *
- X * 103 statements are dynamically executed. The program is balanced with
- X * respect to the three aspects:
- X *
- X * - statement type
- X * - operand type
- X * - operand locality
- X * operand global, local, parameter, or constant.
- X *
- X * The combination of these three aspects is balanced only approximately.
- X *
- X * 1. Statement Type:
- X * ----------------- number
- X *
- X * V1 = V2 9
- X * (incl. V1 = F(..)
- X * V = Constant 12
- X * Assignment, 7
- X * with array element
- X * Assignment, 6
- X * with record component
- X * --
- X * 34 34
- X *
- X * X = Y +|-|"&&"|"|" Z 5
- X * X = Y +|-|"==" Constant 6
- X * X = X +|- 1 3
- X * X = Y *|/ Z 2
- X * X = Expression, 1
- X * two operators
- X * X = Expression, 1
- X * three operators
- X * --
- X * 18 18
- X *
- X * if .... 14
- X * with "else" 7
- X * without "else" 7
- X * executed 3
- X * not executed 4
- X * for ... 7 | counted every time
- X * while ... 4 | the loop condition
- X * do ... while 1 | is evaluated
- X * switch ... 1
- X * break 1
- X * declaration with 1
- X * initialization
- X * --
- X * 34 34
- X *
- X * P (...) procedure call 11
- X * user procedure 10
- X * library procedure 1
- X * X = F (...)
- X * function call 6
- X * user function 5
- X * library function 1
- X * --
- X * 17 17
- X * ---
- X * 103
- X *
- X * The average number of parameters in procedure or function calls
- X * is 1.82 (not counting the function values aX *
- X *
- X * 2. Operators
- X * ------------
- X * number approximate
- X * percentage
- X *
- X * Arithmetic 32 50.8
- X *
- X * + 21 33.3
- X * - 7 11.1
- X * * 3 4.8
- X * / (int div) 1 1.6
- X *
- X * Comparison 27 42.8
- X *
- X * == 9 14.3
- X * /= 4 6.3
- X * > 1 1.6
- X * < 3 4.8
- X * >= 1 1.6
- X * <= 9 14.3
- X *
- X * Logic 4 6.3
- X *
- X * && (AND-THEN) 1 1.6
- X * | (OR) 1 1.6
- X * ! (NOT) 2 3.2
- X *
- X * -- -----
- X * 63 100.1
- X *
- X *
- X * 3. Operand Type (counted once per operand reference):
- X * ---------------
- X * number approximate
- X * percentage
- X *
- X * Integer 175 72.3 %
- X * Character 45 18.6 %
- X * Pointer 12 5.0 %
- X * String30 6 2.5 %
- X * Array 2 0.8 %
- X * Record 2 0.8 %
- X * --- -------
- X * 242 100.0 %
- X *
- X * When there is an access path leading to the final operand (e.g. a record
- X * component), only the final data type on the access path is counted.
- X *
- X *
- X * 4. Operand Locality:
- X * -------------------
- X * number approximate
- X * percentage
- X *
- X * local variable 114 47.1 %
- X * global variable 22 9.1 %
- X * parameter 45 18.6 %
- X * value 23 9.5 %
- X * reference 22 9.1 %
- X * function result 6 2.5 %
- X * constant 55 22.7 %
- X * --- -------
- X * 242 100.0 %
- X *
- X *
- X * The program does not compute anything meaningful, but it is syntactically
- X * and semantically correct. All variables have a value assigned to them
- X * before they are used as a source operand.
- X *
- X * There has been no explicit effort to account for the effects of a
- X * cache, or to balance the use of long or short displacements for code or
- X * data.
- X *
- X ***************************************************************************
- X */
- X
- X/* Compiler and system dependent definitions: */
- X
- X#ifndef TIME
- X#undef TIMES
- X#define TIMES
- X#endif
- X /* Use times(2) time function unless */
- X /* explicitly defined otherwise */
- X
- X#ifdef MSC_CLOCK
- X#undef HZ
- X#undef TIMES
- X#include <time.h>
- X#define HZ CLK_TCK
- X#endif
- X /* Use Microsoft C hi-res clock */
- X
- X#ifdef TIMES
- X#include <sys/types.h>
- X#include <sys/times.h>
- X /* for "times" */
- X#endif
- X
- X#define Mic_secs_Per_Second 1000000.0
- X /* Berkeley UNIX C returns process times in seconds/HZ */
- X
- X#ifdef NOSTRUCTASSIGN
- X#define structassign(d, s) memcpy(&(d), &(s), sizeof(d))
- X#else
- X#define structassign(d, s) d = s
- X#endif
- X
- X#ifdef NOENUM
- X#define Ident_1 0
- X#define Ident_2 1
- X#define Ident_3 2
- X#define Ident_4 3
- X#define Ident_5 4
- X typedef int Enumeration;
- X#else
- X typedef enum {Ident_1, Ident_2, Ident_3, Ident_4, Ident_5}
- X Enumeration;
- X#endif
- X /* for boolean and enumeration types in Ada, Pascal */
- X
- X/* General definitions: */
- X
- X#include <stdio.h>
- X /* for strcpy, strcmp */
- X
- X#define Null 0
- X /* Value of a Null pointer */
- X#define true 1
- X#define false 0
- X
- Xtypedef int One_Thirty;
- Xtypedef int One_Fifty;
- Xtypedef char Capital_Letter;
- Xtypedef int Boolean;
- Xtypedef char Str_30 [31];
- Xtypedef int Arr_1_Dim [50];
- Xtypedef int Arr_2_Dim [50] [50];
- X
- Xtypedef struct record
- X {
- X struct record *Ptr_Comp;
- X Enumeration Discr;
- X union {
- X struct {
- X Enumeration Enum_Comp;
- X int Int_Comp;
- X char Str_Comp [31];
- X } var_1;
- X struct {
- X Enumeration E_Comp_2;
- X char Str_2_Comp [31];
- X } var_2;
- X struct {
- X char Ch_1_Comp;
- X char Ch_2_Comp;
- X } var_3;
- X } variant;
- X } Rec_Type, *Rec_Pointer;
- X
- X
- SHAR_EOF
- if test 18533 -ne "`wc -c < 'dhry.h'`"
- then
- echo shar: "error transmitting 'dhry.h'" '(should have been 18533 characters)'
- fi
- fi
- echo shar: "extracting 'dhry.p'" '(37108 characters)'
- if test -f 'dhry.p'
- then
- echo shar: "will not over-write existing file 'dhry.p'"
- else
- sed 's/^X//' << \SHAR_EOF > 'dhry.p'
- X(*
- X ****************************************************************************
- X *
- X * "DHRYSTONE" Benchmark Program
- X * -----------------------------
- X *
- X * Version: Pascal, Version 2.1
- X *
- X * File: dhry.p
- X *
- X * Date: May 25, 1988
- X *
- X * Author: Reinhold P. Weicker
- X * Siemens AG, E STE 35
- X * Postfach 3240
- X * 8520 Erlangen
- X * Germany (West)
- X * Phone: [xxx-49]-9131-7-20330
- X * (8-17 Central European Time)
- X * Usenet: ..!mcvax!unido!estevax!weicker
- X *
- X * Original Version (in Ada) published in
- X * "Communications of the ACM" vol. 27., no. 10 (Oct. 1984),
- X * pp. 1013 - 1030, together with the statistics
- X * on which the distribution of statements etc. is based,
- X *
- X * This version uses calls to the Pascal runtime library of the
- X * Berkeley UNIX system (4.3 bsd) for time measurement.
- X * For measurements on other systems, these calls need to be
- X * modified.
- X *
- X * Collection of Results:
- X * Reinhold Weicker (address see above) and
- X *
- X * Rick Richardson
- X * PC Research. Inc.
- X * 94 Apple Orchard Drive
- X * Tinton Falls, NJ 07724
- X * Phone: (201) 834-1378 (9-17 EST)
- X * Usenet: ...!seismo!uunet!pcrat!rick
- X *
- X * Please send results to Rick Richardson and/or Reinhold Weicker.
- X * Complete information should be given on hardware and software used.
- X * Hardware information includes: Machine type, CPU, type and size
- X * of caches; for microprocessors: clock frequency, memory speed
- X * (number of wait states).
- X * Software information includes: Compiler (and runtime library)
- X * manufacturer and version, compilation switches, OS version.
- X * The Operating System version may give an indication about the
- X * compiler; Dhrystone itself performs no OS calls in the measurement loop.
- X *
- X * The complete output generated by the program should be mailed
- X * such that at least some checks for correctness can be made.
- X *
- X ****************************************************************************
- X *
- X * History: This version Pascal/2.1 has been made for two reasons:
- X *
- X * 1) There is a need for a common Pascal version of
- X * Dhrystone. Although translation from the published (Ada)
- X * version to Pascal is straightforward in most aspects,
- X * there are cases where it may not be obvious to everyone.
- X * There should be, as far as possible, only one Pascal version
- X * of Dhrystone such that results can be compared without
- X * restrictions. Also, a Pascal version of Dhrystone has not yet
- X * found a network distribution comparable to the C version
- X * (version 1.1) distributed by Rick Richardson.
- X *
- X * 2) As far as it is possible without changes to the Dhrystone
- X * statistics, optimizing compilers should be prevented from
- X * removing significant statements.
- X *
- X * This Pascal version 2.1 has been made consistent with the
- X * C version 2.1; therefore the acknowledgments for the C version
- X * are due for the Pascal version as well: I thank
- X * Rick Richardson (Tinton Falls, NJ), Chaim Benedelac (Nat.
- X * Semi.), David Ditzel (SUN), Earl Killian and John Mashey (MIPS),
- X * Alan Smith and Rafael Saavedra-Barrera (UC at Berkeley)
- X * for their help with comments on earlier versions of the
- X * benchmark.
- X *
- X * Changes: In the initialization part, this version differs
- X * from the Pascal version previously distributed by Reinhold
- X * Weicker, the number of runs through Dhrystone is obtained
- X * interactively from the terminal. Output of the result
- X * has been changed to conform to the C version (2.1).
- X * The changes in the initialization part and in the printing
- X * of the result have no impact on performance measurement
- X * since they are outside the measaurement loop.
- X *
- X * Inside the measurement loop, this version follows the
- X * version previously distributed by Reinhold Weicker.
- X * As a correction to the published version, a statement
- X * initializing Array2Glob [8,7] (outside the measurement
- X * loop) has been added. Otherwise, this array element would
- X * have an undefined value.
- X *
- X * At several places in the benchmark, code has been added,
- X * but within the measurement loop only in branches that
- X * are not executed. The intention is that optimizing compilers
- X * should be prevented from moving code out of the measurement
- X * loop, or from removing code altogether. Since the statements
- X * that are executed within the measurement loop have NOT been
- X * changed, all numbers defining the "Dhrystone distribution"
- X * (distribution of statements, operand types and locality)
- X * still hold. Except for sophisticated optimizing compilers,
- X * execution times for this version should be the same as
- X * for previous versions.
- X *
- X * Since it has proven difficult to subtract the time for the
- X * measurement loop overhead in a correct way, the loop check
- X * has been made a part of the benchmark. This does have
- X * an impact - though a very minor one - on the distribution
- X * statistics which have been updated for this version.
- X *
- X * All changes within the measurement loop are described
- X * and discussed in the companion paper "Rationale for
- X * Dhrystone version 2".
- X *
- X * Because of the self-imposed limitation that the order and
- X * distribution of the executed statements should not be
- X * changed, there are still cases where optimizing compilers
- X * may not generate code for some statements. To a certain
- X * degree, this is unavoidable for small synthetic benchmarks.
- X * Users of the benchmark are advised to check code listings
- X * whether code is generated for all statements of Dhrystone.
- X *
- X * Version 2.1 is identical to version 2.0 distributed via
- X * the UNIX network Usenet in March 1988 except that it corrects
- X * some minor deficiencies that were found by users of version 2.0.
- X * The only change within the measurement loop is that a
- X * non-executed "else" part was added to the "if" statement in
- X * Func3, and a non-executed "else" part removed from Proc3.
- X *
- X ***************************************************************************
- X *
- X * Compilation model and measurement (IMPORTANT):
- X *
- X * This program contains the Dhrystone program, including measurement setup,
- X * in one file. The original (Ada) program contained three packages,
- X * - a package with global type definitions,
- X * - Pack_1, containing the main program (Proc_0 in Ada) and procedures
- X * Proc_1, ... , Proc_5,
- X * - Pack_2, containing Proc_6, ... , Proc_8, Func_1, ..., Func_3.
- X * Since ISO/ANSI Standard Pascal provides no means to express separate
- X * compilation (although many Pascal implementations provide such a feature),
- X * it is not possible to formulate a portable Pascal version with the program
- X * in several modules, corresponding more closely to the Ada and C versions.
- X * Therefore, no attempt has been made to construct a Pascal version with
- X * the program consisting of several modules.
- X *
- X * This difference may impact execution time because the compiler can
- X * perform more data flow analysis for a single-module program;
- X * sophisticated compilers may be able to suppress code generation for
- X * some parts of the program.
- X * Users should check machine code listings generated by the compiler
- X * to ensure that code is generated for all parts of the program.
- X *
- X * The following "ground rules" apply for measurements:
- X * - No procedure merging
- X * - Otherwise, compiler optimizations are allowed but should be indicated
- X * See the companion paper "Rationale for Dhrystone Version 2" for a more
- X * detailed discussion of these ground rules.
- X *
- X * For 16-Bit processors (e.g. 80x86), times for all compilation models
- X * ("small", "medium", "large") should be given if possible, together
- X * with a definition of these models for the compiler system used.
- X *
- X **************************************************************************
- X *
- X * Dhrystone (Pascal version) statistics:
- X *
- X * [Comment from the first distribution by Reinhold Weicker,
- X * the distribution statistics have been updated for Version 2.1.
- X * Note that because of language differences, the numbers are different
- X * from the Ada version. The main difference is that the variables that
- X * are local variables of "Proc_0" (Ada) or "main" (C) are global
- X * variables in the Pascal version.]
- X *
- X * The following program contains statements of a high level programming
- X * language (here: Pascal) in a distribution considered representative:
- X *
- X * assignments 58
- X * control statements 28
- X * procedure, function calls 15
- X *
- X * 100 statements are dynamically executed. The program is balanced with
- X * respect to the three aspects:
- X *
- X * - statement type
- X * - operand type (for simple data types)
- X * - operand access
- X * operand global, local, parameter, or constant.
- X * There is no static nesting of blocks or procedures,
- X * therefore all variables are either global or local.
- X *
- X * The combination of these three aspects is balanced only approximately.
- X *
- X * 1. Statement Type:
- X * ----------------- number
- X *
- X * V1 := V2 15
- X * V := Constant 12
- X * (incl. V1 := F(..)
- X * Assignment, 7
- X * with array element
- X * Assignment, 6
- X * with record component
- X * --
- X * 40 40
- X *
- X * X := Y +|-|and|or Z 5
- X * X := Y +|-|"=" Constant 6
- X * X := X +|- 1 3
- X * X := Y *|/ Z 2
- X * X := Expression, 1
- X * two operators
- X * X := Expression, 1
- X * three operators
- X * --
- X * 18 18
- X *
- X * if .... then .... 14
- X * with "else" 7
- X * without "else" 7
- X * executed 3
- X * not executed 4
- X * for I in 1..N do ... 7 | counted every time
- X * while ... do ... 4 | the loop condition
- X * repeat ... until 1 | is evaluated
- X * case ... end 1
- X * with 1
- X * --
- X * 28 28
- X *
- X * P (...) procedure call 10
- X * X := F (...)
- X * function call 5
- X * --
- X * 15 15
- X * ---
- X * 101
- X *
- X * 22 of the 58 assignments have a variable of a constrained
- X * (sub-)type as their destination. In general, discriminant checks
- X * will be necessary in these cases; however, the compiler may
- X * optimize out some of these checks.
- X *
- X * The average number of parameters in procedure or function calls
- X * is 1.80 (not counting the function values as implicit parameters).
- X *
- X *
- X * 2. Operators
- X * ------------
- X * number approximate
- X * percentage
- X *
- X * Arithmetic 27 52.9
- X *
- X * + 16 31.4
- X * - 7 13.7
- X * * 3 5.9
- X * div 1 2.0
- X *
- X * Comparison 20 39.2
- X *
- X * = 9 17.6
- X * <> 4 7.8
- X * > 1 2.0
- X * < 3 5.9
- X * >= 1 2.0
- X * <= 2 3.9
- X *
- X * Logic 4 7.8
- X *
- X * AND 1 2.0
- X * OR 1 2.0
- X * NOT 2 3.9
- X *
- X * -- -----
- X * 51 99.9
- X *
- X *
- X * 3. Operand Type (counted once per operand reference):
- X * ---------------
- X * number approximate
- X * percentage
- X *
- X * Integer 135 54.7 %
- X * Character 47 19.0 %
- X * Enumeration 31 12.6 %
- X * Boolean 13 5.3 %
- X * Pointer 11 4.5 %
- X * String30 6 2.4 %
- X * Array 2 0.8 %
- X * Record 2 0.8 %
- X * --- -------
- X * 247 100.1 %
- X *
- X * When there is an access path leading to the final operand (e.g. a record
- X * component), only the final data type on the access path is counted.
- X *
- X * There are 16 accesses to components of a record, 9 of them go to
- X * a component in a variant part. For some of these accesses, the
- X * compiler may suppress generation of code checking the tag field
- X * during optimization.
- X *
- X *
- X * 3. Operand Locality:
- X * -------------------
- X *
- X * local variable 84 34.0 %
- X * global variable 58 23.5 %
- X * parameter 45 18.2 %
- X * value 23 9.3 %
- X * reference 22 8.9 %
- X * function result 5 2.0 %
- X * constant 55 22.3 %
- X * --- -------
- X * 247 100.0 %
- X *
- X *
- X * The program does not compute anything meaningful, but it is syntactically
- X * and semantically correct. All variables have a value assigned to them
- X * before they are used as a source operand.
- X *
- X * There may be cases where a highly optimizing compiler may recognize
- X * unnecessary statements and may not generate code for them.
- X *
- X * There has been no explicit effort to account for the effects of a
- X * cache, or to balance the use of long or short displacements for code or
- X * data.
- X *
- X ****************************************************************************
- X *)
- X
- Xprogram Dhrystone (input, output);
- X(***************)
- X
- Xconst (* for measurement *)
- X
- X MicrosecondsPerClock = 1000;
- X ClocksPerSecond = 1000;
- X (* In Berkeley UNIX Pascal, the function "clock" *)
- X (* returns milliseconds *)
- X TooSmallTime = 2000;
- X (* Measurements should last at least 2 seconds *)
- X
- Xtype
- X
- X (* Global type definitions *)
- X
- X Enumeration = (Ident1, Ident2, Ident3, Ident4, Ident5);
- X
- X OneToThirty = 1..30;
- X OneToFifty = 1..50;
- X CapitalLetter = 'A'..'Z';
- X
- X String30 = packed array [OneToThirty] of char;
- X
- X Array1DimInteger = array [OneToFifty] of integer;
- X Array2DimInteger = array [OneToFifty, OneToFifty] of integer;
- X
- X RecordPointer = ^RecordType;
- X
- X RecordType =
- X record
- X PointerComp: RecordPointer;
- X case Discr: Enumeration of
- X Ident1: (* only this variant is used, *)
- X (* but in some cases discriminant *)
- X (* checks are necessary *)
- X (EnumComp: Enumeration;
- X IntComp: OneToFifty;
- X StringComp: String30);
- X Ident2:
- X (Enum2Comp: Enumeration;
- X String2Comp: String30);
- X Ident3, Ident4, Ident5:
- X (Char1Comp,
- X Char2Comp: char);
- X end; (* record *)
- X
- Xvar
- X
- X (* Ada version: Variables local in Proc_0 *)
- X
- X Int1Glob,
- X Int2Glob,
- X Int3Glob: OneToFifty;
- X CharIndex: char;
- X EnumGlob: Enumeration;
- X String1Glob,
- X String2Glob: String30;
- X
- X (* Ada version: Variables global in Pack_1 *)
- X
- X PointerGlob,
- X NextPointerGlob: RecordPointer;
- X IntGlob: integer;
- X
- X BoolGlob: boolean;
- X Char1Glob,
- X Char2Glob: char;
- X Array1Glob: Array1DimInteger;
- X Array2Glob: Array2DimInteger;
- X
- X (* Variables for measurement *)
- X
- X RunIndex,
- X NumberOfRuns,
- X BeginClock,
- X EndClock,
- X SumClocks: integer;
- X Microseconds,
- X DhrystonesPerSecond: real;
- X I: integer;
- X
- X (* end of variables for measurement *)
- X
- Xprocedure Proc1 ( PointerParVal: RecordPointer); forward;
- X
- Xprocedure Proc2 (var IntParRef: OneToFifty); forward;
- X
- Xprocedure Proc3 (var PointerParRef: RecordPointer); forward;
- X
- Xprocedure Proc4; forward;
- X (* without parameters *)
- X
- Xprocedure Proc5; forward;
- X (* without parameters *)
- X
- Xprocedure Proc6 ( EnumParVal: Enumeration;
- X var EnumParRef: Enumeration); forward;
- X
- Xprocedure Proc7 ( Int1ParVal,
- X Int2ParVal: OneToFifty;
- X var IntParRef: OneToFifty); forward;
- X
- Xprocedure Proc8 (var Array1ParRef: Array1DimInteger;
- X var Array2ParRef: Array2DimInteger;
- X Int1ParVal,
- X Int2ParVal: integer); forward;
- X
- Xfunction Func1 ( Char1ParVal,
- X Char2ParVal: CapitalLetter):
- X Enumeration; forward;
- X
- Xfunction Func2 (var String1ParRef,
- X String2ParRef: String30):
- X boolean; forward;
- X
- Xfunction Func3 ( EnumParVal: Enumeration):
- X boolean; forward;
- X
- X
- Xprocedure Proc1; (* (PointerParVal: RecordPointer) *)
- X (* executed once *)
- Xbegin
- X with PointerParVal^.PointerComp^ (* = PointerGlobNext *) do
- X begin
- X PointerParVal^.PointerComp^ := PointerGlob^;
- X PointerParVal^.IntComp := 5;
- X IntComp := PointerParVal^.IntComp;
- X PointerComp := PointerParVal^.PointerComp;
- X Proc3 (PointerComp);
- X (* PointerParVal^.PointerComp^.PointerComp = PointerGlob^.PointerComp *)
- X if Discr = Ident1
- X then (* executed *)
- X begin
- X IntComp := 6;
- X Proc6 (PointerParVal^.EnumComp, EnumComp);
- X PointerComp := PointerGlob^.PointerComp;
- X Proc7 (IntComp, 10, IntComp);
- X end (* then *)
- X else (* not executed *)
- X PointerParVal^ := PointerParVal^.PointerComp^;
- X end; (* with *)
- Xend; (* Proc1 *)
- X
- X
- Xprocedure Proc2; (* (var IntParRef: OneToFifty) *)
- X (* executed once *)
- X (* InParRef = 3, becomes 7 *)
- Xvar
- X IntLoc: OneToFifty;
- X EnumLoc: Enumeration;
- Xbegin
- X IntLoc := IntParRef + 10;
- X repeat (* executed once *)
- X if Char1Glob = 'A'
- X then (* executed *)
- X begin
- X IntLoc := IntLoc - 1;
- X IntParRef := IntLoc - IntGlob;
- X EnumLoc := Ident1;
- X end (* if *)
- X until EnumLoc = Ident1; (* true *)
- Xend; (* Proc2 *)
- X
- X
- Xprocedure Proc3; (* (var PointerParRef: RecordPointer) *)
- X (* executed once *)
- X (* PointerParRef becomes PointerGlob *)
- Xbegin
- X if PointerGlob <> nil
- X then (* executed *)
- X PointerParRef := PointerGlob^.PointerComp;
- X Proc7 (10, IntGlob, PointerGlob^.IntComp);
- Xend; (* Proc3 *)
- X
- X
- Xprocedure Proc4; (* without parameters *)
- X (* executed once *)
- Xvar
- X BoolLoc: boolean;
- Xbegin
- X BoolLoc := Char1Glob = 'A';
- X BoolGlob := BoolLoc or BoolGlob;
- X Char2Glob := 'B';
- Xend; (* Proc4 *)
- X
- X
- Xprocedure Proc5; (* without parameters *)
- X (* executed once *)
- Xbegin
- X Char1Glob := 'A';
- X BoolGlob := false;
- Xend; (* Proc5 *)
- X
- X
- Xprocedure Proc6; (* ( EnumParVal: Enumeration;
- X var EnumParRef: Enumeration) *)
- X (* executed once *)
- X (* EnumParVal = Ident3, EnumParRef becomes Ident2 *)
- Xbegin
- X EnumParRef := EnumParVal;
- X if not Func3 (EnumParVal)
- X then (* not executed *)
- X EnumParRef := Ident4;
- X case EnumParVal of
- X Ident1: EnumParRef := Ident1;
- X Ident2: if IntGlob > 100
- X then EnumParRef := Ident1
- X else EnumParRef := Ident4;
- X Ident3: EnumParRef := Ident2; (* executed *)
- X Ident4: ;
- X Ident5: EnumParRef := Ident3;
- X end; (* case *)
- Xend; (* Proc6 *)
- X
- X
- Xprocedure Proc7; (* ( Int1ParVal,
- X Int2ParVal: OneToFifty;
- X var IntParRef: OneToFifty) *)
- X (* executed three times *)
- X (* first call: Int1ParVal = 2, Int2ParVal = 3, *)
- X (* IntParRef becomes 7 *)
- X (* second call: Int1ParVal = 10, Int2ParVal = 5, *)
- X (* IntParRef becomes 17 *)
- X (* third call: Int1ParVal = 6, Int2ParVal = 10, *)
- X (* IntParRef becomes 18 *)
- Xvar
- X IntLoc: OneToFifty;
- Xbegin
- X IntLoc := Int1ParVal + 2;
- X IntParRef := Int2ParVal + IntLoc;
- Xend; (* Proc7 *)
- X
- X
- Xprocedure Proc8; (* (var Array1ParRef: Array1DimInteger;
- X var Array2ParRef: Array2DimInteger;
- X Int1ParVal,
- X Int2ParVal: integer) *)
- X (* executed once *)
- X (* Int1ParVal = 3 *)
- X (* Int2ParVal = 7 *)
- Xvar
- X IntIndex,
- X IntLoc: OneToFifty;
- Xbegin
- X IntLoc := Int1ParVal + 5;
- X Array1ParRef [IntLoc] := Int2ParVal;
- X Array1ParRef [IntLoc+1] := Array1ParRef [IntLoc];
- X Array1ParRef [IntLoc+30] := IntLoc;
- X for IntIndex := IntLoc to IntLoc+1 do
- X Array2ParRef [IntLoc, IntIndex] := IntLoc;
- X Array2ParRef [IntLoc, IntLoc-1] := Array2ParRef [IntLoc, IntLoc-1] + 1;
- X Array2ParRef [IntLoc+20, IntLoc] := Array1ParRef [IntLoc];
- X IntGlob := 5;
- Xend; (* Proc8 *)
- X
- X
- Xfunction Func1; (* (Char1ParVal,
- X Char2ParVal: CapitalLetter): Enumeration *)
- X (* executed three times, returns always Ident1 *)
- X (* first call: Char1ParVal = 'H', Char2ParVal = 'R' *)
- X (* second call: Char1ParVal = 'A', Char2ParVal = 'C' *)
- X (* third call: Char1ParVal = 'B', Char2ParVal = 'C' *)
- Xvar
- X Char1Loc, Char2Loc: CapitalLetter;
- Xbegin
- X Char1Loc := Char1ParVal;
- X Char2Loc := Char1Loc;
- X if Char2Loc <> Char2ParVal
- X then (* executed *)
- X Func1 := Ident1
- X else (* not executed *)
- X begin
- X Char1Glob := Char1Loc;
- X Func1 := Ident2;
- X end;
- Xend; (* Func1 *)
- X
- X
- Xfunction Func2; (* (var String1ParRef,
- X String2ParRef: String30): boolean *)
- X (* executed once, returns false *)
- X (* String1ParRef = 'DHRYSTONE PROGRAM, 1''ST STRING' *)
- X (* String2ParRef = 'DHRYSTONE PROGRAM, 2''ND STRING' *)
- Xvar
- X IntLoc: OneToThirty;
- X CharLoc: CapitalLetter;
- Xbegin
- X IntLoc := 2;
- X while IntLoc <= 2 do (* loop body executed once *)
- X if Func1 (String1ParRef[IntLoc],
- X String2ParRef[IntLoc+1]) = Ident1
- X then (* executed *)
- X begin
- X CharLoc := 'A';
- X IntLoc := IntLoc + 1;
- X end; (* if, while *)
- X if (CharLoc >= 'W') and (CharLoc < 'Z')
- X then (* not executed *)
- X IntLoc := 7;
- X if CharLoc = 'R'
- X then (* not executed *)
- X Func2 := true
- X else (* executed *)
- X begin
- X if String1ParRef > String2ParRef
- X then (* not executed *)
- X begin
- X IntLoc := IntLoc + 7;
- X IntGlob := IntLoc;
- X Func2 := true
- X end
- X else (* executed *)
- X Func2 := false;
- X end; (* if CharLoc *)
- Xend; (* Func2 *)
- X
- X
- Xfunction Func3; (* (EnumParVal: Enumeration): boolean *)
- X (* executed once, returns true *)
- X (* EnumParVal = Ident3 *)
- Xvar
- X EnumLoc: Enumeration;
- Xbegin
- X EnumLoc := EnumParVal;
- X if EnumLoc = Ident3
- X then (* executed *)
- X Func3 := true
- X else (* not executed *)
- X Func3 := false;
- Xend; (* Func3 *)
- X
- X
- Xbegin (* main program, corresponds to procedures *)
- X (* Main and Proc_0 in the Ada version *)
- X
- X (* Initializations *)
- X
- X new (NextPointerGlob);
- X
- X new (PointerGlob);
- X
- X PointerGlob^.PointerComp := NextPointerGlob;
- X PointerGlob^.Discr := Ident1;
- X PointerGlob^.EnumComp := Ident3;
- X PointerGlob^.IntComp := 40;
- X PointerGlob^.StringComp := 'DHRYSTONE PROGRAM, SOME STRING';
- X
- X String1Glob := 'DHRYSTONE PROGRAM, 1''ST STRING';
- X
- X Array2Glob [8,7] := 10;
- X
- X writeln;
- X writeln ('Dhrystone Benchmark, Version 2.1 (Language: Pascal)');
- X writeln;
- X writeln ('Please give the number of runs through the benchmark: ');
- X readln (NumberOfRuns);
- X writeln;
- X writeln ('Execution starts, ', NumberOfRuns : 7, ' runs through Dhrystone');
- X
- X BeginClock := clock;
- X
- X (***************)
- X (* Start timer *)
- X (***************)
- X
- X for RunIndex := 1 to NumberOfRuns do
- X begin
- X
- X Proc5;
- X Proc4;
- X (* Char1Glob = 'A', Char2Glob = 'B', BoolGlob = false *)
- X Int1Glob := 2;
- X Int2Glob := 3;
- X String2Glob := 'DHRYSTONE PROGRAM, 2''ND STRING';
- X EnumGlob := Ident2;
- X BoolGlob := not Func2 (String1Glob, String2Glob);
- X (* BoolGlob = true *)
- X while Int1Glob < Int2Glob do (* loop body executed once *)
- X begin
- X Int3Glob := 5 * Int1Glob - Int2Glob;
- X (* Int3Glob = 7 *)
- X Proc7 (Int1Glob, Int2Glob, Int3Glob);
- X (* Int3Glob = 7 *)
- X Int1Glob := Int1Glob + 1;
- X end; (* while *)
- X (* Int1Glob = 3 *)
- X Proc8 (Array1Glob, Array2Glob, Int1Glob, Int3Glob);
- X (* IntGlob = 5 *)
- X Proc1 (PointerGlob);
- X for CharIndex := 'A' to Char2Glob do (* loop body executed twice *)
- X if EnumGlob = Func1 (CharIndex, 'C')
- X then (* not executed *)
- X begin
- X Proc6 (Ident1, EnumGlob);
- X String2Glob := 'DHRYSTONE PROGRAM, 3''RD STRING';
- X Int2Glob := RunIndex;
- X IntGlob := RunIndex;
- X end;
- X (* Int1Glob = 3, Int2Glob = 3, Int3Glob = 7 *)
- X Int2Glob := Int2Glob * Int1Glob;
- X Int1Glob := Int2Glob div Int3Glob;
- X Int2Glob := 7 * (Int2Glob - Int3Glob) - Int1Glob;
- X (* Int1Glob = 1, Int2Glob = 13, Int3Glob = 7 *)
- X Proc2 (Int1Glob);
- X (* Int1Glob = 5 *)
- X
- X end; (* for RunIndex *)
- X
- X EndClock := clock;
- X
- X (**************)
- X (* Stop timer *)
- X (**************)
- X
- X writeln ('Execution ends');
- X writeln;
- X writeln ('Final values of the variables used in the benchmark:');
- X writeln;
- X
- X writeln ('IntGlob: ', IntGlob : 5);
- X writeln (' should be: 5');
- X write ('BoolGlob: ');
- X if BoolGlob = true
- X then
- X writeln ('TRUE')
- X else
- X writeln ('FALSE');
- X writeln (' should be: TRUE');
- X writeln ('Char1Glob: ', Char1Glob);
- X writeln (' should be: A');
- X writeln ('Char2Glob: ', Char2Glob);
- X writeln (' should be: B');
- X writeln ('Array1Glob [8]: ', Array1Glob [8] : 5);
- X writeln (' should be: 7');
- X writeln ('Array2Glob [8,7]: ', Array2Glob [8,7] : 5);
- X writeln (' should be: NumberOfRuns + 10');
- X writeln ('PointerGlob^.Discr: ', ord (PointerGlob^.Discr) : 5);
- X writeln (' should be: 0');
- X writeln ('PointerGlob^.EnumComp: ', ord (PointerGlob^.EnumComp) : 5);
- X writeln (' should be: 2');
- X writeln ('PointerGlob^.IntComp : ', PointerGlob^.IntComp : 5);
- X writeln (' should be: 17');
- X write ('PointerGlob^.StringComp: ');
- X for I := 1 to 30 do
- X write (PointerGlob^.StringComp [I]);
- X writeln;
- X writeln (' should be: DHRYSTONE PROGRAM, SOME STRING');
- X writeln ('NextPointerGlob^.Discr: ', ord (NextPointerGlob^.Discr) : 5);
- X writeln (' should be: 0');
- X writeln ('NextPointerGlob^.EnumComp: ',
- X ord (NextPointerGlob^.EnumComp) : 5);
- X writeln (' should be: 1');
- X writeln ('NextPointerGlob^.IntComp: ', NextPointerGlob^.IntComp : 5);
- X writeln (' should be: 18');
- X write ('NextPointerGlob^.StringComp: ');
- X for I := 1 to 30 do
- X write (NextPointerGlob^.StringComp [I]);
- X writeln;
- X writeln (' should be: DHRYSTONE PROGRAM, SOME STRING');
- X writeln ('Int1Glob: ', Int1Glob : 5);
- X writeln (' should be: 5');
- X writeln ('Int2Glob: ', Int2Glob : 5);
- X writeln (' should be: 13');
- X writeln ('Int3Glob: ', Int3Glob : 5);
- X writeln (' should be: 7');
- X writeln ('EnumGlob: ', ord (EnumGlob) : 5);
- X writeln (' should be: 1');
- X write ('String1Glob: ');
- X for I := 1 to 30 do
- X write (String1Glob [I]);
- X writeln;
- X writeln (' should be: DHRYSTONE PROGRAM, 1''ST STRING');
- X write ('String2Glob: ');
- X for I := 1 to 30 do
- X write (String2Glob [I]);
- X writeln;
- X writeln (' should be: DHRYSTONE PROGRAM, 2''ND STRING');
- X writeln;
- X writeln;
- X
- X SumClocks := EndClock - BeginClock;
- X
- X if SumClocks < TooSmallTime
- X then
- X begin
- X writeln ('Measured time too small to obtain meaningful results');
- X writeln ('Please increase number of runs');
- X writeln;
- X end
- X else
- X begin
- X Microseconds := SumClocks * (MicrosecondsPerClock / NumberOfRuns);
- X (* Brackets to prevent integer overflow *)
- X DhrystonesPerSecond := NumberOfRuns * (ClocksPerSecond / SumClocks);
- X write ('Microseconds for one run through Dhrystone: ');
- X writeln (Microseconds : 8 : 1);
- X write ('Dhrystones per Second: ');
- X writeln (DhrystonesPerSecond : 8 : 1);
- X writeln;
- X end;
- X
- Xend.
- SHAR_EOF
- if test 37108 -ne "`wc -c < 'dhry.p'`"
- then
- echo shar: "error transmitting 'dhry.p'" '(should have been 37108 characters)'
- fi
- fi
- exit 0
- # End of shell archive
-
-
-