home *** CD-ROM | disk | FTP | other *** search
Text File | 1988-05-03 | 73.3 KB | 2,331 lines |
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --mathstub.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- -- Filename: MATHSTUB.ADA
- package MATHSTUB is
- function SIN(X: in FLOAT) return FLOAT;
- function COS(X: in FLOAT) return FLOAT;
- function ATAN(X: in FLOAT) return FLOAT;
- function LOG(X: in FLOAT) return FLOAT;
- function SQRT(X: in FLOAT) return FLOAT;
- function EXP(X: in FLOAT) return FLOAT;
- end MATHSTUB;
- package body MATHSTUB is
- function SIN (X: in FLOAT) return FLOAT is
- begin return 1.0; end SIN;
- function COS (X: in FLOAT) return FLOAT is
- begin return 1.0; end COS;
- function ATAN (X: in FLOAT) return FLOAT is
- begin return 1.0; end ATAN;
- function LOG (X: in FLOAT) return FLOAT is
- begin return 1.0; end LOG;
- function SQRT (X: in FLOAT) return FLOAT is
- begin return 1.0; end SQRT;
- function EXP (X: in FLOAT) return FLOAT is
- begin return 1.0; end EXP;
- end MATHSTUB;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --helptools.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- with text_io; use text_io;
- with system;
- with direct_io;
- package help_tools is
-
- procedure time_filename (file_name: out string);
-
- procedure read_environ (outfile_ptr: in file_type);
-
- procedure read_envfile (outfile_ptr: in file_type);
-
- end help_tools;
-
- -------------------------------------------------------------------------------
- with calendar; use calendar;
- with text_io; use text_io;
- with system;
- with direct_io;
-
- package body help_tools is
- --------------------------------------------------------------------------------
- --
- -- procedure time_filename
- --
- -- purpose: to create a string which can be used as a file name which
- -- has the date encoded in the title
- --
- --------------------------------------------------------------------------------
- procedure time_filename (file_name: out string) is
-
- subtype month_name is string(1..2);
-
- MON_START_POS : CONSTANT := 2; -- start and end indices for month
- MON_END_POS: CONSTANT := 3;
- DAY_START_POS: CONSTANT := 4; -- start and end indices for day
- DAY_END_POS: CONSTANT := 5;
- HOUR_START_POS: CONSTANT := 6; -- start and end indices for hour
- HOUR_END_POS: CONSTANT := 7;
- MIN_START_POS: CONSTANT := 8; -- start and end indices for minutes
- MIN_END_POS: CONSTANT := 9;
- SMAX: constant := 2; -- maximum length for a numeric string
-
- date : time; -- date
- cur_year: year_number; -- current year
- cur_mon: month_number; -- current month
- cur_day: day_number; -- current day
-
- ipass, -- total_seconds/max_int
- itemp, -- temporary integer variable
- hours, -- number of hours
- minutes: integer; -- number of minutes
-
- total_sec: day_duration; -- total number of seconds
-
- int_seconds: integer; -- integer variable for seconds
-
- hour_string, -- ascii string for hours
- min_string, -- ascii string for minutes
- day_string: string (1..2); -- ascii string for days
-
- dtotal_sec, -- floating point var for seconds
- dtemp_result, -- results
- dtemp_num, -- temp variable for floating pt numbers
- dtemp_remainder: float; -- remainder of total seconds
-
- month_code : array (month_number) of month_name :=
- ("ja","fe","mr","ap","my","jn",
- "jl","ag","sp","oc","nv","dc");
-
-
- function int_to_string (I: integer) return string is
-
- -- converts integers to strings
-
- S: string (1..smax);
- SPOS : integer := s'last;
- HOLD : integer := I;
- DIGIT : integer;
- --
- begin
- S := (others=>'0');
- while HOLD /= 0 loop
- DIGIT := HOLD rem 10;
- S(SPOS) := character'val(abs(DIGIT) + character'pos('0'));
- SPOS := SPOS - 1;
- HOLD := HOLD/10;
- end loop;
- return S;
- end INT_TO_STRING;
-
- begin
- --
- -- initialize the filename to Wmmddhhmm.DAT
- -- get the informations for the current date and time
- --
- file_name := "Wmmddmmmm.DAT";
- date := clock;
- cur_year := year (date);
- cur_mon := month (date);
- cur_day := day(date);
- total_sec := seconds(date);
- --
- -- get the largest integer available to the system
- -- float the values for both max_int and the total number of seconds
- --
- itemp := integer'last;
- dtotal_sec := float (total_sec);
- dtemp_num := float (itemp);
- dtemp_result := dtotal_sec - dtemp_num;
- --
- -- if the total number of seconds is greater than max_int
- -- ( a case which is true for doing 16 bit arithmetic)
- -- determine how many times max_int is a divisor for total number
- -- of seconds
- -- for the number of passes (max_int divides) do
- -- increment the hours accordingly
- -- increment the minutes accordingly
- -- end for
- -- calculate the values of minutes
- --
- if (dtemp_result > 0.0) then
-
- while (dtemp_result > 0.0) loop
- ipass := ipass + 1;
- dtemp_result := dtemp_result - dtemp_num;
- end loop;
- hours := 0; minutes := 0;
- dtemp_remainder := dtemp_num + dtemp_result;
- for iter in 1..ipass loop
- hours := hours + 9;
- minutes := minutes + 6;
- end loop;
- itemp := integer(dtemp_remainder);
- minutes := minutes + itemp/60;
- --
- -- else
- -- calculate hours directly from total seconds
- -- calculate minutes directly from total seconds
- -- endif
- --
- else
-
- int_seconds := integer(total_sec);
- hours := int_seconds/3600;
- minutes := (int_seconds - (hours*3600))/60;
-
- end if;
- --
- -- translate the numbers to acsii representations and
- -- build the filename
- --
- day_string := int_to_string (CUR_DAY);
- hour_string:= int_to_string(hours);
- min_string := int_to_string (minutes);
-
- file_name (mon_START_POS..mon_END_POS) := month_code(cur_mon);
- file_name (DAY_START_POS..DAY_END_POS) := day_STRING;
- file_name (HOUR_START_POS..HOUR_END_POS) := hour_string;
- file_name (MIN_START_POS..MIN_END_POS) := min_string;
-
- end time_filename;
- --------------------------------------------------------------------------------
- --
- -- procedure read_environ
- --
- -- purpose: writes system specific data in to the data file
- --
- --------------------------------------------------------------------------------
- procedure read_environ (outfile_ptr: in file_type) is
-
- package int_io is new integer_io(integer);
- use int_io;
-
- package flt_io is new float_io(float);
- use flt_io;
-
- package dur_io is new fixed_io(duration);
- use dur_io;
-
- package dirinf_io is new direct_io(integer);
-
- temp_dvar: day_duration; -- temporary variable for day duration;
-
- temp_fvar: float; -- temporary variable for floating constants
-
- temp_ivar, -- temporary variable to get values from
- -- package system
- last_char: integer; -- pointer to last character in line
-
- blank_line,
- line : string (1..80) := (others => ' ');
-
- begin
- --
- -- get data from package system
- --
-
- Read_Envfile (outfile_ptr);
-
- new_line(outfile_ptr);
- put_line (outfile_ptr," DATA FROM PACKAGE SYSTEM: ");
-
- temp_ivar := system.storage_unit;
- put (outfile_ptr,"SYSTEM.STORAGE_UNIT = ");
- int_io.put (outfile_ptr,temp_ivar);
-
- new_line(outfile_ptr);
- temp_ivar := system.memory_size;
- put (outfile_ptr,"SYSTEM.MEMORY_SIZE = ");
- int_io.put (outfile_ptr,temp_ivar);
-
- new_line(outfile_ptr);
- temp_ivar := system.min_int;
- put (outfile_ptr,"SYSTEM.MIN_INT = ");
- int_io.put (outfile_ptr,temp_ivar);
-
- new_line(outfile_ptr);
- temp_ivar := system.max_int;
- put (outfile_ptr,"SYSTEM.MAX_INT = ");
- int_io.put (outfile_ptr,temp_ivar);
-
- new_line(outfile_ptr);
- temp_ivar := system.max_digits;
- put (outfile_ptr,"SYSTEM.MAX_DIGITS = ");
- int_io.put (outfile_ptr,temp_ivar);
-
- new_line(outfile_ptr);
- temp_ivar := system.max_mantissa;
- put (outfile_ptr,"SYSTEM.MAX_MANTISSA = ");
- int_io.put (outfile_ptr,temp_ivar);
-
-
- new_line(outfile_ptr);
- temp_fvar := system.fine_delta;
- put (outfile_ptr,"SYSTEM.FINE_DELTA = ");
- put (outfile_ptr,temp_fvar);
-
- new_line(outfile_ptr);
- temp_fvar := system.tick;
- put (outfile_ptr,"SYSTEM.TICK = ");
- put (outfile_ptr,temp_fvar);
-
- new_line(outfile_ptr); new_line(outfile_ptr);
- put (outfile_ptr," DATA FROM PACKAGES FROM I-O SYSTEMS: ");
-
- new_line(outfile_ptr);
- temp_ivar := integer(text_io.count'last);
- put (outfile_ptr,"text_io.count'last = ");
- put (outfile_ptr,temp_ivar);
-
- new_line(outfile_ptr);
- temp_ivar := integer(dirinf_io.count'last);
- put (outfile_ptr,"direct_io.count'last = ");
- put (outfile_ptr,temp_ivar);
-
-
- new_line (outfile_ptr); new_line(outfile_ptr);
- put_line (outfile_ptr,"DATA FROM PACKAGE STANDARD: ");
-
- temp_ivar := integer'first;
- put (outfile_ptr,"Integer range is ");
- put(outfile_ptr,temp_ivar);
- temp_ivar := integer'last;
- put (outfile_ptr," .. "); put(outfile_ptr,temp_ivar);
-
-
- new_line (outfile_ptr);
- temp_fvar := duration'delta;
- put (outfile_ptr,"DURATION is delta ");
- put (outfile_ptr,temp_fvar);
-
-
- new_line (outfile_ptr);
- temp_fvar := duration'small;
- put (outfile_ptr,"DURATION'small = ");
- put (outfile_ptr,temp_fvar);
-
- new_line (outfile_ptr); new_line(outfile_ptr);
- put (outfile_ptr,"Calendar package values: ");
- new_line (outfile_ptr);
- temp_dvar := calendar.day_duration'first;
- put (outfile_ptr,"DAY DURATION range is : ");
- put (outfile_ptr,temp_dvar);put (outfile_ptr," to ");
- temp_dvar := calendar.day_duration'last;
- put (outfile_ptr,temp_dvar);
-
- new_line (outfile_ptr); new_line (outfile_ptr);
- put (outfile_ptr,"End of looking at system parameters");
- new_line (outfile_ptr); new_line (outfile_ptr);
-
- end read_environ;
- -------------------------------------------------------------------------------
- --
- -- procedure read_envfile
- --
- -- purpose: to copy the data from a file called ENVIRON.INF into the
- -- file specified by the outfile_ptr
- --
- -- exception: if the file ENVIRON.INF does not exit, an exception
- -- handler will write a message in file specified by outfile_ptr
- -- that ENVIRON.INF has existence problems
- --
- -------------------------------------------------------------------------------
- procedure read_envfile (outfile_ptr: in file_type) is
- --
- indata: file_type; -- internal filename for actual data file
-
- file_name : string (1..11) := ("environ.inf");
-
- blank_line,
- line : string (1..120) := (others => ' ');
-
- last_char: integer; -- position of last character in line read
-
- --
- -- get data out of environment file ENVIRON.INF
- --
-
- begin
-
- open (indata,in_file,file_name);
- while not end_of_file (indata) loop
- line := blank_line;
- get_line(indata,line,last_char);
- put_line(outfile_ptr,line(1..last_char));
- end loop;
- close (indata);
-
- exception
- when others =>
- put_line (outfile_ptr,
- "Something is wrong with the existence of file ENVIRON.INF");
- new_line (outfile_ptr);
-
- end read_envfile;
-
- end help_tools;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --whetadaa.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- -- Filename: WHETADAA.DEC
- -- Version 1.1 of benchmark programs (DS 2.11.85)
- -- Ada version of Whetstone Benchmark Program.
- -- Reference: "Computer Journal ," February 1976, pages 43-49,
- -- for description of benchmark and ALGOL60 version.
- -- Note: Procedure POUT is omitted.
-
- with CALENDAR; use CALENDAR;
- with TEXT_IO; use TEXT_IO;
- with HELP_TOOLS; use HELP_TOOLS;
- with IO_EXCEPTIONS; use IO_EXCEPTIONS;
-
- --Comment out following with use to run with math library stubbed off
- --with CORE_FUNCTIONS,TRIG_LIB;use CORE_FUNCTIONS,TRIG_LIB;
- --Uncomment the following line to run with math library stubbed off
- with MATHSTUB; use MATHSTUB;
-
- procedure WHETADAA is
- --Comment out following pragma suppresses to run unsuppressed
- --pragma SUPPRESS(ACCESS_CHECK);
- --pragma SUPPRESS(DISCRIMINANT_CHECK);
- --pragma SUPPRESS(INDEX_CHECK);
- --pragma SUPPRESS(LENGTH_CHECK);
- --pragma SUPPRESS(RANGE_CHECK);
- --pragma SUPPRESS(DIVISION_CHECK);
- --pragma SUPPRESS(OVERFLOW_CHECK);
- --pragma SUPPRESS(STORAGE_CHECK);
- --pragma SUPPRESS(ELABORATION_CHECK);
- --
- package INT_IO is new INTEGER_IO(INTEGER); use INT_IO;
- package REAL_IO is new FLOAT_IO(FLOAT) ; use REAL_IO;
- procedure WHETSTONE (I, NO_OF_CYCLES: in INTEGER;
- START_TIME, STOP_TIME: out FLOAT) is
- --
- --Calling procedure provides the loop count weight
- --factor, I, and the encompassing loop count, NO_OF_CYCLES.
- --
- type VECTOR is array (INTEGER range <>) of FLOAT;
- X1,X2,X3,X4,X,Y,Z,T,T1,T2: FLOAT;
- E1: VECTOR(1..4);
- J,K,L,N1,N2,N3,N4,N5,N6,N7,N8,N9,N10,N11: INTEGER;
- --
- procedure PA (E: in out VECTOR) is
- --tests computations with an array as a parameter
- J: INTEGER;
- -- T, T2 : FLOAT are global variables.
- begin
- J:=0;
- <<LAB>>
- E(1):= (E(1)+E(2)+E(3)-E(4))*T;
- E(2):= (E(1)+E(2)-E(3)+E(4))*T;
- E(3):= (E(1)-E(2)+E(3)+E(4))*T;
- E(4):= (-E(1)+E(2)+E(3)+E(4))/T2;
- J:=J+1;
- if J < 6 then
- goto LAB;
- end if;
- end PA;
- --
- procedure P0 is
- --tests computations with no parameters
- -- T1,T2: FLOAT are global
- -- E1: VECTOR(1..4) is global
- -- J,K,L: INTEGER are global
- begin
- E1(J):= E1(K);
- E1(K):= E1(L);
- E1(L):= E1(J);
- end P0;
- --
- procedure P3 (X,Y: in out FLOAT; Z: out FLOAT) is
- --tests computations with simple identifiers as parameters
- -- T,T2: FLOAT are global
- begin
- X:= T*(X+Y);
- Y:= T*(X+Y);
- Z:= (X+Y)/T2;
- end P3;
- --
- begin
- --Set constants
- T:= 0.499975;
- T1:= 0.50025;
- T2:= 2.0;
- --Compute the execution frequency for the benchmark modules.
- N1:= 0; --Module 1 not executed.
- N2:= 12*I;
- N3:= 14*I;
- N4:= 345*I;
- N5:= 0; --Module 5 not executed.
- N6:= 210*I;
- N7:= 32*I;
- N8:= 899*I;
- N9:= 616*I;
- N10:= 0; --Module 10 not executed.
- N11:= 93*I;
- --
- START_TIME:= FLOAT(SECONDS(CLOCK)); --Get Whetstone start time
- --
- CYCLE_LOOP:
- for CYCLE_NO in 1..NO_OF_CYCLES loop
- --Module 1: computations with simple identifiers
- X1:= 1.0;
- X2:= -1.0;
- X3:= -1.0;
- X4:= -1.0;
- for I in 1..N1 loop
- X1:= (X1+X2+X3-X4)*T;
- X2:= (X1+X2-X3+X4)*T;
- X3:= (X1-X2+X3+X4)*T;
- X4:= (-X1+X2+X3+X4)*T;
- end loop;
- --end Module 1
- --
- --Module 2: computations with array elements
- E1(1):= 1.0;
- E1(2):= -1.0;
- E1(3):= -1.0;
- E1(4):= -1.0;
- for I in 1..N2 loop
- E1(1):= (E1(1)+E1(2)+E1(3)-E1(4))*T;
- E1(2):= (E1(1)+E1(2)-E1(3)+E1(4))*T;
- E1(3):= (E1(1)-E1(2)+E1(3)+E1(4))*T;
- E1(4):= (-E1(1)+E1(2)+E1(3)+E1(4))*T;
- end loop;
- --end Module 2
- --
- --Module 3: passing an array as a parameter
- for I in 1..N3 loop
- PA(E1);
- end loop;
- --end Module 3
- --
- --Module 4: performing conditional jumps
- J:=1;
- for I in 1..N4 loop
- if J=1 then
- J:=2;
- else
- J:=3;
- end if;
- if J>2 then
- J:=0;
- else
- J:=1;
- end if;
- if J<1 then
- J:=1;
- else
- J:=0;
- end if;
- end loop;
- --end Module 4
- --
- --Module 5: omitted
- --
- --Module 6: performing integer arithmetic
- J:=1;
- K:=2;
- L:=3;
- for I in 1..N6 loop
- J:= J*(K-J)*(L-K);
- K:= L*K-(L-J)*K;
- L:= (L-K)*(K+J);
- E1(L-1):=FLOAT(J+K+L);
- E1(K-1):=FLOAT(J*K*L);
- end loop;
- --end Module 6
- --
- --Module 7: performing computations using trigonometric
- -- functions
- X:= 0.5;
- Y:= 0.5;
- for I in 1..N7 loop
- X:= T*ATAN(T2*SIN(X)*COS(X)/(COS(X+Y)+COS(X-Y)-1.0));
- Y:= T*ATAN(T2*SIN(Y)*COS(Y)/(COS(X+Y)+COS(X-Y)-1.0));
- end loop;
- --end Module 7
- --
- --Module 8: procedure calls with simple indentifiers as
- -- parameters
- X:=1.0;
- Y:=1.0;
- Z:=1.0;
- for I in 1..N8 loop
- P3(X,Y,Z);
- end loop;
- --end Module 8
- --
- --Module 9: array references and procedure calls with no
- -- parameters
- J:=1;
- K:=2;
- L:=3;
- E1(1):=1.0;
- E1(2):=2.0;
- E1(3):=3.0;
- for I in 1..N9 loop
- P0;
- end loop;
- --end Module 9
- --
- --Module 10: integer arithmetic
- J:=2;
- K:=3;
- for I in 1..N10 loop
- J:=J+K;
- K:=J+K;
- J:=K-J;
- K:=K-J-J;
- end loop;
- --end Module 10
- --
- --Module 11: performing computations using standard
- -- mathematical functions
- X:=0.75;
- for I in 1..N11 loop
- X:=SQRT(EXP(LOG(X)/T1));
- end loop;
- --end Module 11
- end loop CYCLE_LOOP;
- --
- STOP_TIME:= FLOAT(SECONDS(CLOCK)); --Get Whetstone stop time
- --
- end WHETSTONE;
- --
- --
- procedure COMPUTE_WHETSTONE_KIPS is
- --
- -- Variables used to control execution of benchmark and to
- -- compute the Whetstone rating:
- --
- NO_OF_RUNS: INTEGER; --Number of times the benchmark is executed
- NO_OF_CYCLES: INTEGER; --Number of times the group of benchmark
- --modules is executed
- I: INTEGER; --Factor weighting number of times each module loops.
- --A value of ten gives a total weight for modules
- --of approximately one million Whetstone instructions.
- START_TIME: FLOAT; --Time at which execution of benchmark modules
- -- begins
- STOP_TIME: FLOAT; --Time at which execution of benchmark modules
- -- ends (time for NO_OF_CYCLES)
- ELAPSED_TIME: FLOAT; --Time between START_TIME and STOP_TIME
- MEAN_TIME: FLOAT; --Average time per cycle
- RATING: FLOAT; --Thousands of Whetstone instructions per sec.
- MEAN_RATING: FLOAT; --Average Whetstone rating
- INT_RATING: INTEGER; --Integer value of KWIPS
- DATA_FILE: FILE_TYPE; --File identifier
- FILENAME: STRING (1..13) := "Wnnddhhmm.DAT";
- --
- begin
- TIME_FILENAME (FILENAME);
- CREATE(DATA_FILE, OUT_FILE, FILENAME, "");
- READ_ENVIRON (DATA_FILE);
- PUT_LINE(DATA_FILE," ADA Whetstone benchmark(WHETADAA.DEC)");NEW_LINE(DATA_FILE);
- NEW_LINE; PUT_LINE(" ADA Whetstone benchmark(WHETADAA.DEC)");NEW_LINE;
- --
- MEAN_TIME:=0.0;
- MEAN_RATING:=0.0;
- NO_OF_CYCLES:=10;
- NO_OF_RUNS:=5;
- I:=10;
- --
- RUN_LOOP:
- for RUN_NO in 1..NO_OF_RUNS loop
- --
- -- Call the Whetstone benchmark procedure
- --
- WHETSTONE (I, NO_OF_CYCLES, START_TIME, STOP_TIME);
- --
- -- Write the Whetstone start time
- --
- NEW_LINE; PUT(" Whetstone start time: "); PUT(START_TIME, 5, 2, 0);
- PUT_LINE(" seconds");
- NEW_LINE(DATA_FILE); PUT(DATA_FILE," Whetstone start time: ");
- PUT(DATA_FILE, START_TIME, 5, 2, 0);PUT_LINE(DATA_FILE," seconds");
- --
- -- Write the Whetstone stop time
- --
- NEW_LINE; PUT(" Whetstone stop time: "); PUT(STOP_TIME, 5, 2, 0);
- PUT_LINE(" seconds");
- NEW_LINE(DATA_FILE); PUT(DATA_FILE," Whetstone stop time: ");
- PUT(DATA_FILE, STOP_TIME, 5, 2, 0); PUT_LINE(DATA_FILE," seconds");
- --
- -- Compute and write the elapsed time
- --
- ELAPSED_TIME:= STOP_TIME - START_TIME;
- NEW_LINE; PUT(" Elapsed time for "); PUT(NO_OF_CYCLES, 3);
- PUT(" cycles: "); PUT(ELAPSED_TIME,5,2,0); PUT_LINE(" seconds");
- NEW_LINE(DATA_FILE); PUT(DATA_FILE," Elapsed time for ");
- PUT(DATA_FILE, NO_OF_CYCLES, 3); PUT(DATA_FILE," cycles: ");
- PUT(DATA_FILE,ELAPSED_TIME,5,2,0); PUT_LINE(DATA_FILE," seconds");
- --
- -- Sum time in milliseconds per cycle
- MEAN_TIME:= MEAN_TIME + (ELAPSED_TIME*1000.0)/FLOAT(NO_OF_CYCLES);
- --
- -- Calculate the Whetstone rating based on the time for the number
- -- of cycles just executed and write
- --
- RATING:= (1000.0*FLOAT(NO_OF_CYCLES))/ELAPSED_TIME;
- --
- -- Sum Whetstone rating
- MEAN_RATING:= MEAN_RATING + RATING;
- INT_RATING:= INTEGER(RATING);
- NEW_LINE;PUT(" Whetstone rating: ");PUT(INT_RATING);
- PUT_LINE(" KWIPS");NEW_LINE;
- NEW_LINE(DATA_FILE); PUT(DATA_FILE," Whetstone rating: ");
- PUT(DATA_FILE, INT_RATING); PUT_LINE(DATA_FILE," KWIPS");
- NEW_LINE(DATA_FILE);
- --
- -- Reset NO_OF_CYCLES for next run using ten cycles more
- --
- NO_OF_CYCLES:= NO_OF_CYCLES + 10;
- end loop RUN_LOOP;
- --
- -- Compute average time in milliseconds per cycle and write
- --
- MEAN_TIME:= MEAN_TIME/FLOAT(NO_OF_RUNS);
- NEW_LINE; PUT(" Average time per cycle: "); PUT(MEAN_TIME, 5, 2, 0);
- PUT_LINE(" milliseconds");
- NEW_LINE(DATA_FILE);
- PUT(DATA_FILE," Average time per cycle: ");
- PUT(DATA_FILE,MEAN_TIME,5,2,0); PUT_LINE(DATA_FILE," milliseconds");
- --
- -- Calculate average Whetstone rating and write
- --
- MEAN_RATING:= MEAN_RATING/FLOAT(NO_OF_RUNS);
- INT_RATING:= INTEGER(MEAN_RATING);
- NEW_LINE; PUT(" Average Whetstone rating: "); PUT(INT_RATING);
- PUT_LINE(" KWIPS");
- NEW_LINE(DATA_FILE); PUT(DATA_FILE," Average Whetstone rating: ");
- PUT(DATA_FILE, INT_RATING); PUT_LINE(DATA_FILE," KWIPS");
- CLOSE(DATA_FILE);
- end COMPUTE_WHETSTONE_KIPS;
- --
- begin
- COMPUTE_WHETSTONE_KIPS;
- end WHETADAA;
-
- --comment out next line if not VAX Ada version (1.0)
- pragma SUPPRESS_ALL;
-
- --### 11458 is the file CHECK-SUM number computed on 2/20/1985 at 14:34
- --### CHECK-SUM := sum (ASCII values of all characters in this file) mod 2**16
- --### -- (excluding these three lines) --
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --whetadab.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- -- Filename: WHETADAB.DEC
- -- Version 1.1 of benchmark programs (DS.2.14.85)
- -- Ada version of Whetstone Benchmark Program.
- -- Reference: "Computer Journal ," February 1976, pages 43-49,
- -- for description of benchmark and ALGOL60 version.
- -- Note: Procedure POUT is omitted.
-
- with CALENDAR; use CALENDAR;
- with TEXT_IO; use TEXT_IO;
- with HELP_TOOLS; use HELP_TOOLS;
- with IO_EXCEPTIONS; use IO_EXCEPTIONS;
-
- --Comment out following with use to run with math library stubbed off
- --with CORE_FUNCTIONS,TRIG_LIB;use CORE_FUNCTIONS,TRIG_LIB;
- --Uncomment the following line to run with math library stubbed off
- with MATHSTUB; use MATHSTUB;
-
- procedure WHETADAB is
- --Comment out following pragma suppresses to run unsuppressed
- --pragma SUPPRESS(ACCESS_CHECK);
- --pragma SUPPRESS(DISCRIMINANT_CHECK);
- --pragma SUPPRESS(INDEX_CHECK);
- --pragma SUPPRESS(LENGTH_CHECK);
- --pragma SUPPRESS(RANGE_CHECK);
- --pragma SUPPRESS(DIVISION_CHECK);
- --pragma SUPPRESS(OVERFLOW_CHECK);
- --pragma SUPPRESS(STORAGE_CHECK);
- --pragma SUPPRESS(ELABORATION_CHECK);
- --
- package INT_IO is new INTEGER_IO(INTEGER); use INT_IO;
- package REAL_IO is new FLOAT_IO(FLOAT) ; use REAL_IO;
- procedure WHETSTONE (I, NO_OF_CYCLES: in INTEGER;
- START_TIME, STOP_TIME: out FLOAT) is
- --
- --Calling procedure provides the loop count weight
- --factor, I, and the encompassing loop count, NO_OF_CYCLES.
- --
- type VECTOR is array (INTEGER range <>) of FLOAT;
- X1,X2,X3,X4,X,Y,Z,T,T1,T2: FLOAT;
- E1: VECTOR(1..4);
- J,K,L,N1,N2,N3,N4,N5,N6,N7,N8,N9,N10,N11: INTEGER;
- --
- procedure PA (E: in out VECTOR) is
- --tests computations with an array as a parameter
- J: INTEGER;
- -- T, T2 : FLOAT are global variables.
- begin
- J:=0;
- <<LAB>>
- E(1):= (E(1)+E(2)+E(3)-E(4))*T;
- E(2):= (E(1)+E(2)-E(3)+E(4))*T;
- E(3):= (E(1)-E(2)+E(3)+E(4))*T;
- E(4):= (-E(1)+E(2)+E(3)+E(4))/T2;
- J:=J+1;
- if J < 6 then
- goto LAB;
- end if;
- end PA;
- --
- procedure P0 is
- --tests computations with no parameters
- -- T1,T2: FLOAT are global
- -- E1: VECTOR(1..4) is global
- -- J,K,L: INTEGER are global
- begin
- E1(J):= E1(K);
- E1(K):= E1(L);
- E1(L):= E1(J);
- end P0;
- --
- procedure P3 (X,Y: in out FLOAT; Z: out FLOAT) is
- --tests computations with simple identifiers as parameters
- -- T,T2: FLOAT are global
- begin
- X:= T*(X+Y);
- Y:= T*(X+Y);
- Z:= (X+Y)/T2;
- end P3;
- --
- begin
- --Set constants
- T:= 0.499975;
- T1:= 0.50025;
- T2:= 2.0;
- --Compute the execution frequency for the benchmark modules.
- N1:= 0; --Module 1 not executed.
- N2:= 12*I;
- N3:= 14*I;
- N4:= 345*I;
- N5:= 0; --Module 5 not executed.
- N6:= 210*I;
- N7:= 32*I;
- N8:= 899*I;
- N9:= 616*I;
- N10:= 0; --Module 10 not executed.
- N11:= 93*I;
- --
- START_TIME:= FLOAT(SECONDS(CLOCK)); --Get Whetstone start time
- --
- CYCLE_LOOP:
- for CYCLE_NO in 1..NO_OF_CYCLES loop
- --Module 1: computations with simple identifiers
- X1:= 1.0;
- X2:= -1.0;
- X3:= -1.0;
- X4:= -1.0;
- for I in 1..N1 loop
- X1:= (X1+X2+X3-X4)*T;
- X2:= (X1+X2-X3+X4)*T;
- X3:= (X1-X2+X3+X4)*T;
- X4:= (-X1+X2+X3+X4)*T;
- end loop;
- --end Module 1
- --
- --Module 2: computations with array elements
- E1(1):= 1.0;
- E1(2):= -1.0;
- E1(3):= -1.0;
- E1(4):= -1.0;
- for I in 1..N2 loop
- E1(1):= (E1(1)+E1(2)+E1(3)-E1(4))*T;
- E1(2):= (E1(1)+E1(2)-E1(3)+E1(4))*T;
- E1(3):= (E1(1)-E1(2)+E1(3)+E1(4))*T;
- E1(4):= (-E1(1)+E1(2)+E1(3)+E1(4))*T;
- end loop;
- --end Module 2
- --
- --Module 3: passing an array as a parameter
- for I in 1..N3 loop
- PA(E1);
- end loop;
- --end Module 3
- --
- --Module 4: performing conditional jumps
- J:=1;
- for I in 1..N4 loop
- if J=1 then
- J:=2;
- else
- J:=3;
- end if;
- if J>2 then
- J:=0;
- else
- J:=1;
- end if;
- if J<1 then
- J:=1;
- else
- J:=0;
- end if;
- end loop;
- --end Module 4
- --
- --Module 5: omitted
- --
- --Module 6: performing integer arithmetic
- J:=1;
- K:=2;
- L:=3;
- for I in 1..N6 loop
- J:= J*(K-J)*(L-K);
- K:= L*K-(L-J)*K;
- L:= (L-K)*(K+J);
- E1(L-1):=FLOAT(J+K+L);
- E1(K-1):=FLOAT(J*K*L);
- end loop;
- --end Module 6
- --
- --Module 7: performing computations using trigonometric
- -- functions
- X:= 0.5;
- Y:= 0.5;
- for I in 1..N7 loop
- X:= T*ATAN(T2*SIN(X)*COS(X)/(COS(X+Y)+COS(X-Y)-1.0));
- Y:= T*ATAN(T2*SIN(Y)*COS(Y)/(COS(X+Y)+COS(X-Y)-1.0));
- end loop;
- --end Module 7
- --
- --Module 8: procedure calls with simple indentifiers as
- -- parameters
- X:=1.0;
- Y:=1.0;
- Z:=1.0;
- for I in 1..N8 loop
- P3(X,Y,Z);
- end loop;
- --end Module 8
- --
- --Module 9: array references and procedure calls with no
- -- parameters
- J:=1;
- K:=2;
- L:=3;
- E1(1):=1.0;
- E1(2):=2.0;
- E1(3):=3.0;
- for I in 1..N9 loop
- P0;
- end loop;
- --end Module 9
- --
- --Module 10: integer arithmetic
- J:=2;
- K:=3;
- for I in 1..N10 loop
- J:=J+K;
- K:=J+K;
- J:=K-J;
- K:=K-J-J;
- end loop;
- --end Module 10
- --Module 11: performing computations using standard
- -- mathematical functions
- X:=0.75;
- for I in 1..N11 loop
- X:=SQRT(EXP(LOG(X)/T1));
- end loop;
- --end Module 11
- end loop CYCLE_LOOP;
- --
- STOP_TIME:= FLOAT(SECONDS(CLOCK)); --Get Whetstone stop time
- --
- end WHETSTONE;
- --
- --
- procedure COMPUTE_WHETSTONE_KIPS is
- --
- -- Variables used to control execution of benchmark and to
- -- compute the Whetstone rating:
- --
- NO_OF_RUNS: INTEGER; --Number of times the benchmark is executed
- NO_OF_CYCLES: INTEGER; --Number of times the group of benchmark
- --modules is executed
- I: INTEGER; --Factor weighting number of times each module loops.
- --A value of ten gives a total weight for modules
- --of approximately one million Whetstone instructions.
- START_TIME: FLOAT; --Time at which execution of benchmark modules
- -- begins
- STOP_TIME: FLOAT; --Time at which execution of benchmark modules
- -- ends (time for NO_OF_CYCLES)
- ELAPSED_TIME: FLOAT; --Time between START_TIME and STOP_TIME
- MEAN_TIME: FLOAT; --Average time per cycle
- RATING: FLOAT; --Thousands of Whetstone instructions per sec.
- MEAN_RATING: FLOAT; --Average Whetstone rating
- INT_RATING: INTEGER; --Integer value of KWIPS
- DATA_FILE: FILE_TYPE; --File identifier
- FILENAME: STRING (1..13) := "Wnnddhhmm.DAT";
- --
- begin
- TIME_FILENAME (FILENAME);
- CREATE(DATA_FILE, OUT_FILE, FILENAME, "");
- READ_ENVIRON (DATA_FILE);
- PUT_LINE(DATA_FILE," ADA Whetstone benchmark(WHETADAB.DEC)");NEW_LINE(DATA_FILE);
- NEW_LINE; PUT_LINE(" ADA Whetstone benchmark(WHETADAB.DEC)");NEW_LINE;
- --
- MEAN_TIME:=0.0;
- MEAN_RATING:=0.0;
- NO_OF_CYCLES:=10;
- NO_OF_RUNS:=5;
- I:=10;
- --
- RUN_LOOP:
- for RUN_NO in 1..NO_OF_RUNS loop
- --
- -- Call the Whetstone benchmark procedure
- --
- WHETSTONE (I, NO_OF_CYCLES, START_TIME, STOP_TIME);
- --
- -- Write the Whetstone start time
- --
- NEW_LINE; PUT(" Whetstone start time: "); PUT(START_TIME, 5, 2, 0);
- PUT_LINE(" seconds");
- NEW_LINE(DATA_FILE); PUT(DATA_FILE," Whetstone start time: ");
- PUT(DATA_FILE, START_TIME, 5, 2, 0);PUT_LINE(DATA_FILE," seconds");
- --
- -- Write the Whetstone stop time
- --
- NEW_LINE; PUT(" Whetstone stop time: "); PUT(STOP_TIME, 5, 2, 0);
- PUT_LINE(" seconds");
- NEW_LINE(DATA_FILE); PUT(DATA_FILE," Whetstone stop time: ");
- PUT(DATA_FILE, STOP_TIME, 5, 2, 0); PUT_LINE(DATA_FILE," seconds");
- --
- -- Compute and write the elapsed time
- --
- ELAPSED_TIME:= STOP_TIME - START_TIME;
- NEW_LINE; PUT(" Elapsed time for "); PUT(NO_OF_CYCLES, 3);
- PUT(" cycles: "); PUT(ELAPSED_TIME,5,2,0); PUT_LINE(" seconds");
- NEW_LINE(DATA_FILE); PUT(DATA_FILE," Elapsed time for ");
- PUT(DATA_FILE, NO_OF_CYCLES, 3); PUT(DATA_FILE," cycles: ");
- PUT(DATA_FILE,ELAPSED_TIME,5,2,0); PUT_LINE(DATA_FILE," seconds");
- --
- -- Sum time in milliseconds per cycle
- MEAN_TIME:= MEAN_TIME + (ELAPSED_TIME*1000.0)/FLOAT(NO_OF_CYCLES);
- --
- -- Calculate the Whetstone rating based on the time for the number
- -- of cycles just executed and write
- --
- RATING:= (1000.0*FLOAT(NO_OF_CYCLES))/ELAPSED_TIME;
- --
- -- Sum Whetstone rating
- MEAN_RATING:= MEAN_RATING + RATING;
- INT_RATING:= INTEGER(RATING);
- NEW_LINE;PUT(" Whetstone rating: ");PUT(INT_RATING);
- PUT_LINE(" KWIPS");NEW_LINE;
- NEW_LINE(DATA_FILE); PUT(DATA_FILE," Whetstone rating: ");
- PUT(DATA_FILE, INT_RATING); PUT_LINE(DATA_FILE," KWIPS");
- NEW_LINE(DATA_FILE);
- --
- -- Reset NO_OF_CYCLES for next run using ten cycles more
- --
- NO_OF_CYCLES:= NO_OF_CYCLES + 10;
- end loop RUN_LOOP;
- --
- -- Compute average time in milliseconds per cycle and write
- --
- MEAN_TIME:= MEAN_TIME/FLOAT(NO_OF_RUNS);
- NEW_LINE; PUT(" Average time per cycle: "); PUT(MEAN_TIME, 5, 2, 0);
- PUT_LINE(" milliseconds");
- NEW_LINE(DATA_FILE);
- PUT(DATA_FILE," Average time per cycle: ");
- PUT(DATA_FILE,MEAN_TIME,5,2,0); PUT_LINE(DATA_FILE," milliseconds");
- --
- -- Calculate average Whetstone rating and write
- --
- MEAN_RATING:= MEAN_RATING/FLOAT(NO_OF_RUNS);
- INT_RATING:= INTEGER(MEAN_RATING);
- NEW_LINE; PUT(" Average Whetstone rating: "); PUT(INT_RATING);
- PUT_LINE(" KWIPS");
- NEW_LINE(DATA_FILE); PUT(DATA_FILE," Average Whetstone rating: ");
- PUT(DATA_FILE, INT_RATING); PUT_LINE(DATA_FILE," KWIPS");
- CLOSE(DATA_FILE);
- end COMPUTE_WHETSTONE_KIPS;
- --
- begin
- COMPUTE_WHETSTONE_KIPS;
- end WHETADAB;
-
- --### 48743 is the file CHECK-SUM number computed on 2/20/1985 at 14:34
- --### CHECK-SUM := sum (ASCII values of all characters in this file) mod 2**16
- --### -- (excluding these three lines) --
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --whetadac.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- -- Filename: WHETADAC.DEC
- -- Version 1.1 of benchmark programs (DS.2.14.85)
- -- Ada version of Whetstone Benchmark Program.
- -- Reference: "Computer Journal ," February 1976, pages 43-49,
- -- for description of benchmark and ALGOL60 version.
- -- Note: Procedure POUT is omitted.
-
- with CALENDAR; use CALENDAR;
- with TEXT_IO; use TEXT_IO;
- with HELP_TOOLS; use HELP_TOOLS;
- with IO_EXCEPTIONS; use IO_EXCEPTIONS;
-
- --Comment out following if not use VAX Ada (version 1.0)
- with FLOAT_MATH_LIB;use FLOAT_MATH_LIB;
-
- --Comment out following with use to run with math library stubbed off
- --with CORE_FUNCTIONS,TRIG_LIB;use CORE_FUNCTIONS,TRIG_LIB;
- --Uncomment the following line to run with math library stubbed off
- --with MATHSTUB; use MATHSTUB;
-
- procedure WHETADAC is
- --Comment out following pragma suppresses to run unsuppressed
- --pragma SUPPRESS(ACCESS_CHECK);
- --pragma SUPPRESS(DISCRIMINANT_CHECK);
- --pragma SUPPRESS(INDEX_CHECK);
- --pragma SUPPRESS(LENGTH_CHECK);
- --pragma SUPPRESS(RANGE_CHECK);
- --pragma SUPPRESS(DIVISION_CHECK);
- --pragma SUPPRESS(OVERFLOW_CHECK);
- --pragma SUPPRESS(STORAGE_CHECK);
- --pragma SUPPRESS(ELABORATION_CHECK);
- --
- package INT_IO is new INTEGER_IO(INTEGER); use INT_IO;
- package REAL_IO is new FLOAT_IO(FLOAT) ; use REAL_IO;
- procedure WHETSTONE (I, NO_OF_CYCLES: in INTEGER;
- START_TIME, STOP_TIME: out FLOAT) is
- --
- --Calling procedure provides the loop count weight
- --factor, I, and the encompassing loop count, NO_OF_CYCLES.
- --
- type VECTOR is array (INTEGER range <>) of FLOAT;
- X1,X2,X3,X4,X,Y,Z,T,T1,T2: FLOAT;
- E1: VECTOR(1..4);
- J,K,L,N1,N2,N3,N4,N5,N6,N7,N8,N9,N10,N11: INTEGER;
- --
- procedure PA (E: in out VECTOR) is
- --tests computations with an array as a parameter
- J: INTEGER;
- -- T, T2 : FLOAT are global variables.
- begin
- J:=0;
- <<LAB>>
- E(1):= (E(1)+E(2)+E(3)-E(4))*T;
- E(2):= (E(1)+E(2)-E(3)+E(4))*T;
- E(3):= (E(1)-E(2)+E(3)+E(4))*T;
- E(4):= (-E(1)+E(2)+E(3)+E(4))/T2;
- J:=J+1;
- if J < 6 then
- goto LAB;
- end if;
- end PA;
- --
- procedure P0 is
- --tests computations with no parameters
- -- T1,T2: FLOAT are global
- -- E1: VECTOR(1..4) is global
- -- J,K,L: INTEGER are global
- begin
- E1(J):= E1(K);
- E1(K):= E1(L);
- E1(L):= E1(J);
- end P0;
- --
- procedure P3 (X,Y: in out FLOAT; Z: out FLOAT) is
- --tests computations with simple identifiers as parameters
- -- T,T2: FLOAT are global
- begin
- X:= T*(X+Y);
- Y:= T*(X+Y);
- Z:= (X+Y)/T2;
- end P3;
- --
- begin
- --Set constants
- T:= 0.499975;
- T1:= 0.50025;
- T2:= 2.0;
- --Compute the execution frequency for the benchmark modules.
- N1:= 0; --Module 1 not executed.
- N2:= 12*I;
- N3:= 14*I;
- N4:= 345*I;
- N5:= 0; --Module 5 not executed.
- N6:= 210*I;
- N7:= 32*I;
- N8:= 899*I;
- N9:= 616*I;
- N10:= 0; --Module 10 not executed.
- N11:= 93*I;
- --
- START_TIME:= FLOAT(SECONDS(CLOCK)); --Get Whetstone start time
- --
- CYCLE_LOOP:
- for CYCLE_NO in 1..NO_OF_CYCLES loop
- --Module 1: computations with simple identifiers
- X1:= 1.0;
- X2:= -1.0;
- X3:= -1.0;
- X4:= -1.0;
- for I in 1..N1 loop
- X1:= (X1+X2+X3-X4)*T;
- X2:= (X1+X2-X3+X4)*T;
- X3:= (X1-X2+X3+X4)*T;
- X4:= (-X1+X2+X3+X4)*T;
- end loop;
- --end Module 1
- --
- --Module 2: computations with array elements
- E1(1):= 1.0;
- E1(2):= -1.0;
- E1(3):= -1.0;
- E1(4):= -1.0;
- for I in 1..N2 loop
- E1(1):= (E1(1)+E1(2)+E1(3)-E1(4))*T;
- E1(2):= (E1(1)+E1(2)-E1(3)+E1(4))*T;
- E1(3):= (E1(1)-E1(2)+E1(3)+E1(4))*T;
- E1(4):= (-E1(1)+E1(2)+E1(3)+E1(4))*T;
- end loop;
- --end Module 2
- --
- --Module 3: passing an array as a parameter
- for I in 1..N3 loop
- PA(E1);
- end loop;
- --end Module 3
- --
- --Module 4: performing conditional jumps
- J:=1;
- for I in 1..N4 loop
- if J=1 then
- J:=2;
- else
- J:=3;
- end if;
- if J>2 then
- J:=0;
- else
- J:=1;
- end if;
- if J<1 then
- J:=1;
- else
- J:=0;
- end if;
- end loop;
- --end Module 4
- --
- --Module 5: omitted
- --
- --Module 6: performing integer arithmetic
- J:=1;
- K:=2;
- L:=3;
- for I in 1..N6 loop
- J:= J*(K-J)*(L-K);
- K:= L*K-(L-J)*K;
- L:= (L-K)*(K+J);
- E1(L-1):=FLOAT(J+K+L);
- E1(K-1):=FLOAT(J*K*L);
- end loop;
- --end Module 6
- --
- --Module 7: performing computations using trigonometric
- -- functions
- X:= 0.5;
- Y:= 0.5;
- for I in 1..N7 loop
- X:= T*ATAN(T2*SIN(X)*COS(X)/(COS(X+Y)+COS(X-Y)-1.0));
- Y:= T*ATAN(T2*SIN(Y)*COS(Y)/(COS(X+Y)+COS(X-Y)-1.0));
- end loop;
- --end Module 7
- --
- --Module 8: procedure calls with simple indentifiers as
- -- parameters
- X:=1.0;
- Y:=1.0;
- Z:=1.0;
- for I in 1..N8 loop
- P3(X,Y,Z);
- end loop;
- --end Module 8
- --
- --Module 9: array references and procedure calls with no
- -- parameters
- J:=1;
- K:=2;
- L:=3;
- E1(1):=1.0;
- E1(2):=2.0;
- E1(3):=3.0;
- for I in 1..N9 loop
- P0;
- end loop;
- --end Module 9
- --
- --Module 10: integer arithmetic
- J:=2;
- K:=3;
- for I in 1..N10 loop
- J:=J+K;
- K:=J+K;
- J:=K-J;
- K:=K-J-J;
- end loop;
- --end Module 10
- --Module 11: performing computations using standard
- -- mathematical functions
- X:=0.75;
- for I in 1..N11 loop
- X:=SQRT(EXP(LOG(X)/T1));
- end loop;
- --end Module 11
- end loop CYCLE_LOOP;
- --
- STOP_TIME:= FLOAT(SECONDS(CLOCK)); --Get Whetstone stop time
- --
- end WHETSTONE;
- --
- --
- procedure COMPUTE_WHETSTONE_KIPS is
- --
- -- Variables used to control execution of benchmark and to
- -- compute the Whetstone rating:
- --
- NO_OF_RUNS: INTEGER; --Number of times the benchmark is executed
- NO_OF_CYCLES: INTEGER; --Number of times the group of benchmark
- --modules is executed
- I: INTEGER; --Factor weighting number of times each module loops.
- --A value of ten gives a total weight for modules
- --of approximately one million Whetstone instructions.
- START_TIME: FLOAT; --Time at which execution of benchmark modules
- -- begins
- STOP_TIME: FLOAT; --Time at which execution of benchmark modules
- -- ends (time for NO_OF_CYCLES)
- ELAPSED_TIME: FLOAT; --Time between START_TIME and STOP_TIME
- MEAN_TIME: FLOAT; --Average time per cycle
- RATING: FLOAT; --Thousands of Whetstone instructions per sec.
- MEAN_RATING: FLOAT; --Average Whetstone rating
- INT_RATING: INTEGER; --Integer value of KWIPS
- DATA_FILE: FILE_TYPE; --File identifier
- FILENAME: STRING (1..13) := "Wnnddhhmm.DAT";
- --
- begin
- TIME_FILENAME (FILENAME);
- CREATE(DATA_FILE, OUT_FILE, FILENAME, "");
- READ_ENVIRON (DATA_FILE);
- PUT_LINE(DATA_FILE," ADA Whetstone benchmark(WHETADAC.DEC)");NEW_LINE(DATA_FILE);
- NEW_LINE; PUT_LINE(" ADA Whetstone benchmark(WHETADAC.DEC)");NEW_LINE;
- --
- MEAN_TIME:=0.0;
- MEAN_RATING:=0.0;
- NO_OF_CYCLES:=10;
- NO_OF_RUNS:=5;
- I:=10;
- --
- RUN_LOOP:
- for RUN_NO in 1..NO_OF_RUNS loop
- --
- -- Call the Whetstone benchmark procedure
- --
- WHETSTONE (I, NO_OF_CYCLES, START_TIME, STOP_TIME);
- --
- -- Write the Whetstone start time
- --
- NEW_LINE; PUT(" Whetstone start time: "); PUT(START_TIME, 5, 2, 0);
- PUT_LINE(" seconds");
- NEW_LINE(DATA_FILE); PUT(DATA_FILE," Whetstone start time: ");
- PUT(DATA_FILE, START_TIME, 5, 2, 0);PUT_LINE(DATA_FILE," seconds");
- --
- -- Write the Whetstone stop time
- --
- NEW_LINE; PUT(" Whetstone stop time: "); PUT(STOP_TIME, 5, 2, 0);
- PUT_LINE(" seconds");
- NEW_LINE(DATA_FILE); PUT(DATA_FILE," Whetstone stop time: ");
- PUT(DATA_FILE, STOP_TIME, 5, 2, 0); PUT_LINE(DATA_FILE," seconds");
- --
- -- Compute and write the elapsed time
- --
- ELAPSED_TIME:= STOP_TIME - START_TIME;
- NEW_LINE; PUT(" Elapsed time for "); PUT(NO_OF_CYCLES, 3);
- PUT(" cycles: "); PUT(ELAPSED_TIME,5,2,0); PUT_LINE(" seconds");
- NEW_LINE(DATA_FILE); PUT(DATA_FILE," Elapsed time for ");
- PUT(DATA_FILE, NO_OF_CYCLES, 3); PUT(DATA_FILE," cycles: ");
- PUT(DATA_FILE,ELAPSED_TIME,5,2,0); PUT_LINE(DATA_FILE," seconds");
- --
- -- Sum time in milliseconds per cycle
- MEAN_TIME:= MEAN_TIME + (ELAPSED_TIME*1000.0)/FLOAT(NO_OF_CYCLES);
- --
- -- Calculate the Whetstone rating based on the time for the number
- -- of cycles just executed and write
- --
- RATING:= (1000.0*FLOAT(NO_OF_CYCLES))/ELAPSED_TIME;
- --
- -- Sum Whetstone rating
- MEAN_RATING:= MEAN_RATING + RATING;
- INT_RATING:= INTEGER(RATING);
- NEW_LINE;PUT(" Whetstone rating: ");PUT(INT_RATING);
- PUT_LINE(" KWIPS");NEW_LINE;
- NEW_LINE(DATA_FILE); PUT(DATA_FILE," Whetstone rating: ");
- PUT(DATA_FILE, INT_RATING); PUT_LINE(DATA_FILE," KWIPS");
- NEW_LINE(DATA_FILE);
- --
- -- Reset NO_OF_CYCLES for next run using ten cycles more
- --
- NO_OF_CYCLES:= NO_OF_CYCLES + 10;
- end loop RUN_LOOP;
- --
- -- Compute average time in milliseconds per cycle and write
- --
- MEAN_TIME:= MEAN_TIME/FLOAT(NO_OF_RUNS);
- NEW_LINE; PUT(" Average time per cycle: "); PUT(MEAN_TIME, 5, 2, 0);
- PUT_LINE(" milliseconds");
- NEW_LINE(DATA_FILE);
- PUT(DATA_FILE," Average time per cycle: ");
- PUT(DATA_FILE,MEAN_TIME,5,2,0); PUT_LINE(DATA_FILE," milliseconds");
- --
- -- Calculate average Whetstone rating and write
- --
- MEAN_RATING:= MEAN_RATING/FLOAT(NO_OF_RUNS);
- INT_RATING:= INTEGER(MEAN_RATING);
- NEW_LINE; PUT(" Average Whetstone rating: "); PUT(INT_RATING);
- PUT_LINE(" KWIPS");
- NEW_LINE(DATA_FILE); PUT(DATA_FILE," Average Whetstone rating: ");
- PUT(DATA_FILE, INT_RATING); PUT_LINE(DATA_FILE," KWIPS");
- CLOSE(DATA_FILE);
- end COMPUTE_WHETSTONE_KIPS;
- --
- begin
- COMPUTE_WHETSTONE_KIPS;
- end WHETADAC;
-
- --Comment out next line if not VAX Ada version (1.0)
- pragma SUPPRESS_ALL;
-
- --### 32644 is the file CHECK-SUM number computed on 2/20/1985 at 14:34
- --### CHECK-SUM := sum (ASCII values of all characters in this file) mod 2**16
- --### -- (excluding these three lines) --
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --whetadad.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- -- Filename: WHETADAD.DEC
- -- Version 1.1 of benchmark programs (DS.2.14.85)
- -- Ada version of Whetstone Benchmark Program.
- -- Reference: "Computer Journal ," February 1976, pages 43-49,
- -- for description of benchmark and ALGOL60 version.
- -- Note: Procedure POUT is omitted.
-
- with CALENDAR; use CALENDAR;
- with TEXT_IO; use TEXT_IO;
- with HELP_TOOLS; use HELP_TOOLS;
- with IO_EXCEPTIONS; use IO_EXCEPTIONS;
-
- --Comment out following with use to run with math library stubbed off
- --if not for VAX Ada (version 1.0)
- with FLOAT_MATH_LIB; use FLOAT_MATH_LIB;
-
- --Comment out following with use to run with math library stubbed off
- --with CORE_FUNCTIONS,TRIG_LIB;use CORE_FUNCTIONS,TRIG_LIB;
- --Uncomment the following line to run with math library stubbed off
- --with MATHSTUB; use MATHSTUB;
-
- procedure WHETADAD is
- --Comment out following pragma suppresses to run unsuppressed
- --pragma SUPPRESS(ACCESS_CHECK);
- --pragma SUPPRESS(DISCRIMINANT_CHECK);
- --pragma SUPPRESS(INDEX_CHECK);
- --pragma SUPPRESS(LENGTH_CHECK);
- --pragma SUPPRESS(RANGE_CHECK);
- --pragma SUPPRESS(DIVISION_CHECK);
- --pragma SUPPRESS(OVERFLOW_CHECK);
- --pragma SUPPRESS(STORAGE_CHECK);
- --pragma SUPPRESS(ELABORATION_CHECK);
- --
- package INT_IO is new INTEGER_IO(INTEGER); use INT_IO;
- package REAL_IO is new FLOAT_IO(FLOAT) ; use REAL_IO;
- procedure WHETSTONE (I, NO_OF_CYCLES: in INTEGER;
- START_TIME, STOP_TIME: out FLOAT) is
- --
- --Calling procedure provides the loop count weight
- --factor, I, and the encompassing loop count, NO_OF_CYCLES.
- --
- type VECTOR is array (INTEGER range <>) of FLOAT;
- X1,X2,X3,X4,X,Y,Z,T,T1,T2: FLOAT;
- E1: VECTOR(1..4);
- J,K,L,N1,N2,N3,N4,N5,N6,N7,N8,N9,N10,N11: INTEGER;
- --
- procedure PA (E: in out VECTOR) is
- --tests computations with an array as a parameter
- J: INTEGER;
- -- T, T2 : FLOAT are global variables.
- begin
- J:=0;
- <<LAB>>
- E(1):= (E(1)+E(2)+E(3)-E(4))*T;
- E(2):= (E(1)+E(2)-E(3)+E(4))*T;
- E(3):= (E(1)-E(2)+E(3)+E(4))*T;
- E(4):= (-E(1)+E(2)+E(3)+E(4))/T2;
- J:=J+1;
- if J < 6 then
- goto LAB;
- end if;
- end PA;
- --
- procedure P0 is
- --tests computations with no parameters
- -- T1,T2: FLOAT are global
- -- E1: VECTOR(1..4) is global
- -- J,K,L: INTEGER are global
- begin
- E1(J):= E1(K);
- E1(K):= E1(L);
- E1(L):= E1(J);
- end P0;
- --
- procedure P3 (X,Y: in out FLOAT; Z: out FLOAT) is
- --tests computations with simple identifiers as parameters
- -- T,T2: FLOAT are global
- begin
- X:= T*(X+Y);
- Y:= T*(X+Y);
- Z:= (X+Y)/T2;
- end P3;
- --
- begin
- --Set constants
- T:= 0.499975;
- T1:= 0.50025;
- T2:= 2.0;
- --Compute the execution frequency for the benchmark modules.
- N1:= 0; --Module 1 not executed.
- N2:= 12*I;
- N3:= 14*I;
- N4:= 345*I;
- N5:= 0; --Module 5 not executed.
- N6:= 210*I;
- N7:= 32*I;
- N8:= 899*I;
- N9:= 616*I;
- N10:= 0; --Module 10 not executed.
- N11:= 93*I;
- --
- START_TIME:= FLOAT(SECONDS(CLOCK)); --Get Whetstone start time
- --
- CYCLE_LOOP:
- for CYCLE_NO in 1..NO_OF_CYCLES loop
- --Module 1: computations with simple identifiers
- X1:= 1.0;
- X2:= -1.0;
- X3:= -1.0;
- X4:= -1.0;
- for I in 1..N1 loop
- X1:= (X1+X2+X3-X4)*T;
- X2:= (X1+X2-X3+X4)*T;
- X3:= (X1-X2+X3+X4)*T;
- X4:= (-X1+X2+X3+X4)*T;
- end loop;
- --end Module 1
- --
- --Module 2: computations with array elements
- E1(1):= 1.0;
- E1(2):= -1.0;
- E1(3):= -1.0;
- E1(4):= -1.0;
- for I in 1..N2 loop
- E1(1):= (E1(1)+E1(2)+E1(3)-E1(4))*T;
- E1(2):= (E1(1)+E1(2)-E1(3)+E1(4))*T;
- E1(3):= (E1(1)-E1(2)+E1(3)+E1(4))*T;
- E1(4):= (-E1(1)+E1(2)+E1(3)+E1(4))*T;
- end loop;
- --end Module 2
- --
- --Module 3: passing an array as a parameter
- for I in 1..N3 loop
- PA(E1);
- end loop;
- --end Module 3
- --
- --Module 4: performing conditional jumps
- J:=1;
- for I in 1..N4 loop
- if J=1 then
- J:=2;
- else
- J:=3;
- end if;
- if J>2 then
- J:=0;
- else
- J:=1;
- end if;
- if J<1 then
- J:=1;
- else
- J:=0;
- end if;
- end loop;
- --end Module 4
- --
- --Module 5: omitted
- --
- --Module 6: performing integer arithmetic
- J:=1;
- K:=2;
- L:=3;
- for I in 1..N6 loop
- J:= J*(K-J)*(L-K);
- K:= L*K-(L-J)*K;
- L:= (L-K)*(K+J);
- E1(L-1):=FLOAT(J+K+L);
- E1(K-1):=FLOAT(J*K*L);
- end loop;
- --end Module 6
- --
- --Module 7: performing computations using trigonometric
- -- functions
- X:= 0.5;
- Y:= 0.5;
- for I in 1..N7 loop
- X:= T*ATAN(T2*SIN(X)*COS(X)/(COS(X+Y)+COS(X-Y)-1.0));
- Y:= T*ATAN(T2*SIN(Y)*COS(Y)/(COS(X+Y)+COS(X-Y)-1.0));
- end loop;
- --end Module 7
- --
- --Module 8: procedure calls with simple indentifiers as
- -- parameters
- X:=1.0;
- Y:=1.0;
- Z:=1.0;
- for I in 1..N8 loop
- P3(X,Y,Z);
- end loop;
- --end Module 8
- --
- --Module 9: array references and procedure calls with no
- -- parameters
- J:=1;
- K:=2;
- L:=3;
- E1(1):=1.0;
- E1(2):=2.0;
- E1(3):=3.0;
- for I in 1..N9 loop
- P0;
- end loop;
- --end Module 9
- --
- --Module 10: integer arithmetic
- J:=2;
- K:=3;
- for I in 1..N10 loop
- J:=J+K;
- K:=J+K;
- J:=K-J;
- K:=K-J-J;
- end loop;
- --end Module 10
- --Module 11: performing computations using standard
- -- mathematical functions
- X:=0.75;
- for I in 1..N11 loop
- X:=SQRT(EXP(LOG(X)/T1));
- end loop;
- --end Module 11
- end loop CYCLE_LOOP;
- --
- STOP_TIME:= FLOAT(SECONDS(CLOCK)); --Get Whetstone stop time
- --
- end WHETSTONE;
- --
- --
- procedure COMPUTE_WHETSTONE_KIPS is
- --
- -- Variables used to control execution of benchmark and to
- -- compute the Whetstone rating:
- --
- NO_OF_RUNS: INTEGER; --Number of times the benchmark is executed
- NO_OF_CYCLES: INTEGER; --Number of times the group of benchmark
- --modules is executed
- I: INTEGER; --Factor weighting number of times each module loops.
- --A value of ten gives a total weight for modules
- --of approximately one million Whetstone instructions.
- START_TIME: FLOAT; --Time at which execution of benchmark modules
- -- begins
- STOP_TIME: FLOAT; --Time at which execution of benchmark modules
- -- ends (time for NO_OF_CYCLES)
- ELAPSED_TIME: FLOAT; --Time between START_TIME and STOP_TIME
- MEAN_TIME: FLOAT; --Average time per cycle
- RATING: FLOAT; --Thousands of Whetstone instructions per sec.
- MEAN_RATING: FLOAT; --Average Whetstone rating
- INT_RATING: INTEGER; --Integer value of KWIPS
- DATA_FILE: FILE_TYPE; --File identifier
- FILENAME: STRING (1..13) := "Wnnddhhmm.DAT";
- --
- begin
- TIME_FILENAME (FILENAME);
- CREATE(DATA_FILE, OUT_FILE, FILENAME, "");
- READ_ENVIRON (DATA_FILE);
- PUT_LINE(DATA_FILE," ADA Whetstone benchmark(WHETADAD.DEC)");NEW_LINE(DATA_FILE);
- NEW_LINE; PUT_LINE(" ADA Whetstone benchmark(WHETADAD.DEC)");NEW_LINE;
- --
- MEAN_TIME:=0.0;
- MEAN_RATING:=0.0;
- NO_OF_CYCLES:=10;
- NO_OF_RUNS:=5;
- I:=10;
- --
- RUN_LOOP:
- for RUN_NO in 1..NO_OF_RUNS loop
- --
- -- Call the Whetstone benchmark procedure
- --
- WHETSTONE (I, NO_OF_CYCLES, START_TIME, STOP_TIME);
- --
- -- Write the Whetstone start time
- --
- NEW_LINE; PUT(" Whetstone start time: "); PUT(START_TIME, 5, 2, 0);
- PUT_LINE(" seconds");
- NEW_LINE(DATA_FILE); PUT(DATA_FILE," Whetstone start time: ");
- PUT(DATA_FILE, START_TIME, 5, 2, 0);PUT_LINE(DATA_FILE," seconds");
- --
- -- Write the Whetstone stop time
- --
- NEW_LINE; PUT(" Whetstone stop time: "); PUT(STOP_TIME, 5, 2, 0);
- PUT_LINE(" seconds");
- NEW_LINE(DATA_FILE); PUT(DATA_FILE," Whetstone stop time: ");
- PUT(DATA_FILE, STOP_TIME, 5, 2, 0); PUT_LINE(DATA_FILE," seconds");
- --
- -- Compute and write the elapsed time
- --
- ELAPSED_TIME:= STOP_TIME - START_TIME;
- NEW_LINE; PUT(" Elapsed time for "); PUT(NO_OF_CYCLES, 3);
- PUT(" cycles: "); PUT(ELAPSED_TIME,5,2,0); PUT_LINE(" seconds");
- NEW_LINE(DATA_FILE); PUT(DATA_FILE," Elapsed time for ");
- PUT(DATA_FILE, NO_OF_CYCLES, 3); PUT(DATA_FILE," cycles: ");
- PUT(DATA_FILE,ELAPSED_TIME,5,2,0); PUT_LINE(DATA_FILE," seconds");
- --
- -- Sum time in milliseconds per cycle
- MEAN_TIME:= MEAN_TIME + (ELAPSED_TIME*1000.0)/FLOAT(NO_OF_CYCLES);
- --
- -- Calculate the Whetstone rating based on the time for the number
- -- of cycles just executed and write
- --
- RATING:= (1000.0*FLOAT(NO_OF_CYCLES))/ELAPSED_TIME;
- --
- -- Sum Whetstone rating
- MEAN_RATING:= MEAN_RATING + RATING;
- INT_RATING:= INTEGER(RATING);
- NEW_LINE;PUT(" Whetstone rating: ");PUT(INT_RATING);
- PUT_LINE(" KWIPS");NEW_LINE;
- NEW_LINE(DATA_FILE); PUT(DATA_FILE," Whetstone rating: ");
- PUT(DATA_FILE, INT_RATING); PUT_LINE(DATA_FILE," KWIPS");
- NEW_LINE(DATA_FILE);
- --
- -- Reset NO_OF_CYCLES for next run using ten cycles more
- --
- NO_OF_CYCLES:= NO_OF_CYCLES + 10;
- end loop RUN_LOOP;
- --
- -- Compute average time in milliseconds per cycle and write
- --
- MEAN_TIME:= MEAN_TIME/FLOAT(NO_OF_RUNS);
- NEW_LINE; PUT(" Average time per cycle: "); PUT(MEAN_TIME, 5, 2, 0);
- PUT_LINE(" milliseconds");
- NEW_LINE(DATA_FILE);
- PUT(DATA_FILE," Average time per cycle: ");
- PUT(DATA_FILE,MEAN_TIME,5,2,0); PUT_LINE(DATA_FILE," milliseconds");
- --
- -- Calculate average Whetstone rating and write
- --
- MEAN_RATING:= MEAN_RATING/FLOAT(NO_OF_RUNS);
- INT_RATING:= INTEGER(MEAN_RATING);
- NEW_LINE; PUT(" Average Whetstone rating: "); PUT(INT_RATING);
- PUT_LINE(" KWIPS");
- NEW_LINE(DATA_FILE); PUT(DATA_FILE," Average Whetstone rating: ");
- PUT(DATA_FILE, INT_RATING); PUT_LINE(DATA_FILE," KWIPS");
- CLOSE(DATA_FILE);
- end COMPUTE_WHETSTONE_KIPS;
- --
- begin
- COMPUTE_WHETSTONE_KIPS;
- end WHETADAD;
-
- --### 23622 is the file CHECK-SUM number computed on 2/20/1985 at 14:34
- --### CHECK-SUM := sum (ASCII values of all characters in this file) mod 2**16
- --### -- (excluding these three lines) --
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --dhryadaa.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- -------------------------------------------------------------------------------
- -- --
- -- "DHRYSTONE" Benchmark Program --
- -- -------------------------------- --
- -- --
- -- Version: ADA/1 --
- -- --
- -- Date: 04/15/84 --
- -- --
- -- Author: Reinhold P. Weicker --
- -- --
- -- Filename: DHRYADAA.DEC --
- -- --
- -- History: --
- -- --
- -- CHANGE MADE BY WHOM DATE --
- -- ----------- --------- ------- --
- -- --
- -- added timing calls D. Sayon 13 Feb 85 --
- -- to write to file --
- -- --
- -------------------------------------------------------------------------------
- -- --
- -- The following program contains statements of a high-level programming --
- -- language (Ada) in a distribution considered representative: --
- -- --
- -- assignments 53% --
- -- control statements 32% --
- -- procedure, function calls 15% --
-
- -- --
- -- 100 statements are dynamically executed. The program is balanced with --
- -- respect to the three aspects: --
- -- --
- -- -statement type --
- -- -operand type (for simple data types) --
- -- -operand access --
- -- operand global, local, parameter, or constant. --
- -- --
- -- The combination of these three aspects is balanced only approximately. --
- -- --
- -- The program does not compute anything meaningful, but it is syntacially --
- -- and semantically correct. All variables have a value assigned to them --
- -- before they are used as a source operand. --
- -------------------------------------------------------------------------------
- package Global_Def is
- ------------------
- -- Global type definitions
-
- type Enumeration is (Ident_1,Ident_2,Ident_3,Ident_4,Ident_5);
-
- subtype One_To_Thirty is integer range 1..30;
- subtype One_To_Fifty is integer range 1..50;
- subtype Capital_Letter is character range 'A'..'Z';
-
- type String_30 is array(One_To_Thirty)of character;
- pragma Pack(String_30);
-
- type Array_1_Dim_Integer is array(One_To_Fifty)of integer;
- type Array_2_Dim_Integer is array(One_To_Fifty,
- One_To_Fifty)of integer;
-
- type Record_Type(Discr:Enumeration := Ident_1);
-
- type Record_Pointer is access Record_Type;
-
- type Record_Type(Discr:Enumeration := Ident_1)is
- record
- Pointer_Comp: Record_Pointer;
- case Discr is
- when Ident_1 => -- only this variant is used,
- -- but in some cases discriminant
- -- checks are necessary
-
- Enum_Comp: Enumeration;
- Int_Comp: One_To_Fifty;
- String_Comp: String_30;
- when Ident_2 =>
- Enum_Comp_2: Enumeration;
- String_Comp_2: String_30;
- when others =>
- Char_Comp_1,
- Char_Comp_2: character;
- end case;
- end record;
-
- end Global_Def;
-
- with Global_Def,Calendar;
- use Global_Def,Calendar;
-
- package Pack_1 is
- -------------
-
- procedure Proc_0(cycles: in integer; start_time, stop_time: out Float);
- procedure Proc_1(Pointer_Par_in: in Record_Pointer);
- procedure Proc_2(Int_Par_In_Out: in out One_To_Fifty);
- procedure Proc_3(Pointer_Par_Out: out Record_Pointer);
-
- Int_Glob: integer;
-
- end Pack_1;
-
- with Global_Def;
- use Global_Def;
-
- package Pack_2 is
- --------------
-
- procedure Proc_6 (Enum_Par_In: in Enumeration;
- Enum_Par_Out: out Enumeration);
- procedure Proc_7 (Int_Par_In_1,
- Int_Par_In_2: in One_To_Fifty;
- Int_Par_Out: out One_To_Fifty);
- procedure Proc_8 (Array_Par_In_Out_1: in out Array_1_Dim_Integer;
- Array_Par_In_Out_2: in out Array_2_Dim_Integer;
- Int_Par_In_1,
- Int_Par_In_2: in integer);
- function Func_1 (Char_Par_In_1,
- Char_Par_In_2: in Capital_Letter)
- return Enumeration;
- function Func_2 (String_Par_In_1,
- String_Par_In_2: in String_30)
- return boolean;
-
- end Pack_2;
-
- with Global_Def,Pack_1,Text_IO, Help_Tools;
- use Global_Def, Text_IO, Help_Tools;
-
- procedure Dhryadaa is
- --------------
-
- package real_io is new float_io(float);
- use real_io;
-
- package int_io is new integer_io(integer);
- use int_io;
-
- filename: string (1..13);
-
- int_rating,
- No_of_Cycles,
- No_of_Runs : integer;
-
- mean_rating,
- rating,
- mean_time,
- elapsed_time,
- start_time,
- stop_time: float;
-
- data_file: file_type;
-
- begin
-
- mean_time := 0.0;
- mean_rating := 0.0;
- No_of_Runs := 5;
-
- time_filename (filename);
- filename(1) := 'D';
- create (data_file,out_file,filename,"");
-
- read_environ(data_file);
-
- put("ADA Dhrystone Benchmark (DHRYADAA.DEC)"); new_line;
- put(data_file,"ADA Dhrystone Benchmark (DHRYADAA.DEC)");new_line(data_file);
-
- for N in 1..No_of_Runs loop
-
- No_of_Cycles := N*100;
-
- Pack_1.Proc_0(No_of_Cycles,start_time,stop_time);
- -- Proc_0 is actually the main program, but it is part
- -- of a package, and a program within a package can
- -- not be designated as the Dhryadaa program for execution.
- -- Therefore Proc_0 is activated by a call from "Dhryadaa".
-
- --
- -- WRITE OUT TIMING RESULTS
- --
- --
- -- write out start time
- --
-
- new_line; put (" Dhrystone start time: ");put (start_time, 5, 2, 0);
- put (" seconds"); new_line;
- new_line(data_file); put (data_file," Dhrystone start time: ");
- put (data_file,start_time, 5, 2, 0);
- put (data_file," seconds"); new_line(data_file);
-
- --
- -- write out stop time
- --
-
- put (" Dhrystone stop time: ");put (stop_time, 5, 2, 0);
- put (" seconds");new_line;
- put (data_file," Dhrystone stop time: ");
- put (data_file,stop_time, 5, 2, 0);
- put (data_file," seconds");
- new_line(data_file);
-
- --
- -- write out elapsed time
- --
-
- elapsed_time := stop_time - start_time;
- put (" Elapsed time for ");put (no_of_cycles, 3);
- put (" cycles: ");put(elapsed_time, 5,2,0); put(" seconds ");
- new_line;
- put (data_file," Elapsed time for ");
- put (data_file,no_of_cycles, 3);
- put (data_file," cycles: ");put(data_file,elapsed_time, 5,2,0);
- put (data_file," seconds ");
- new_line(data_file);
-
- --
- -- Sum the time in millisecs per cycle
- --
-
- mean_time := mean_time + (elapsed_time*1000.0)/float(no_of_cycles);
-
- --
- -- Compute the Dhrystone rating based on the time for the number
- -- of cycles just executed and write
- --
- -- RATING = (100 statements/cycle * number of cycles)/elapsed time
- --
-
- rating := (100.0*FLOAT(NO_OF_CYCLES))/ELAPSED_TIME;
-
- --
- -- Sum Dhrystone rating
- --
-
- mean_rating := mean_rating + rating;
- int_rating := integer(rating);
- put (" Dhrystone rating: "); put(int_rating);
- put (" statement execution per unit time "); new_line;
- put(data_file," Dhrystone rating: ");
- put(data_file, int_rating);
- put(data_file," statement execution per unit time ");
- new_line(data_file);
-
- end loop;
-
- --
- -- Calculate the average time in millisecs per cycle
- --
-
- mean_time := mean_time/float(no_of_runs);
- new_line; put (" Average time per cycle: "); put (mean_time,5,2,0);
- put_line (" millisecs ");
- new_line (data_file);
- put (data_file," Average time per cycle: "); put (data_file,mean_time,5,2,0);
- put (data_file," millisecs ");
-
- --
- -- Calculate the average Dhrystone ratings
- --
-
- mean_rating := mean_rating/float(no_of_runs);
- int_rating := integer(mean_rating);
-
- new_line; put(" Average Dhrystone rating: ");
- put (int_rating); put (" statement execution per unit time ");
- new_line(data_file); put (data_file," Average Dhrystone rating: ");
- put (data_file,int_rating);
- put (data_file," statement execution per unit time ");
-
- close (data_file);
-
- end Dhryadaa;
-
- with Global_Def,Calendar,Pack_2;
- use Global_Def,Calendar;
-
- package body Pack_1 is
- -----------
-
- Bool_Glob: boolean;
- Char_Glob_1,
- Char_Glob_2: character;
- Array_Glob_1: Array_1_Dim_Integer;
- Array_Glob_2: Array_2_Dim_Integer;
- Pointer_Glob,
- Pointer_Glob_Next: Record_Pointer;
-
- procedure Proc_4;
- procedure Proc_5;
-
- procedure Proc_0 (cycles: in integer;start_time,stop_time: out float)
- is
- Int_Loc_1,
- Int_Loc_2,
- Int_Loc_3: One_To_Fifty;
- Char_Loc: character;
- Enum_Loc: Enumeration;
- String_Loc_1,
- String_Loc_2: String_30;
-
-
- begin
- -- Initializations
-
- Pack_1.Pointer_Glob_Next := new Record_Type;
- Pack_1.Pointer_Glob := new Record_Type
- '(
- Pointer_Comp =>Pack_1.Pointer_Glob_Next,
- Discr =>Ident_1,
- Enum_Comp =>Ident_3,
- Int_Comp =>40,
- String_Comp =>"DHRYSTONE PROGRAM, SOME STRING"
- );
- String_Loc_1 := "DHRYSTONE PROGRAM, 1'ST STRING";
- -----------------
-
- -- Start timer --
-
- Start_Time := float (seconds (clock));
- -----------------
- for N in 1..cycles loop
- Proc_5;
- Proc_4;
- -- Char_Glob_1 = 'A',Char_Glob_2 = 'B',Bool_Glob = false
- Int_Loc_1 := 2;
- Int_Loc_2 := 3;
- String_Loc_2 := "DHRYSTONE PROGRAM, 2'ND STRING";
- Enum_Loc := Ident_2;
- Bool_Glob := not Pack_2.Func_2(String_Loc_1,String_Loc_2);
- -- Bool_Glob = true
- while Int_Loc_1 < Int_Loc_2 loop --loop body executed once
- Int_Loc_3 := 5 * Int_Loc_1 - Int_Loc_2;
- -- Int_Loc_3 = 7
- Pack_2.Proc_7 (Int_Loc_1,Int_Loc_2,Int_Loc_3);
- -- Int_Loc_3 = 7
- Int_Loc_1 := Int_Loc_1 + 1;
- end loop;
- -- Int_Loc_1 = 3
- Pack_2.Proc_8(Array_Glob_1,Array_Glob_2,Int_Loc_1,Int_Loc_3);
- -- Int_Glob = 5
- Proc_1 (Pointer_Glob);
- for Char_Index in 'A'..Char_Glob_2 loop --loop body executed twice
- if Enum_Loc=Pack_2.Func_1(Char_Index,'C')
- then--not executed
- Pack_2.Proc_6(Ident_1,Enum_Loc);
- end if;
- end loop;
- -- Enum_Loc = Ident_1
- -- Int_Loc_1 = 3,Int_Loc_2 = 3,Int_Loc_3 = 7
- Int_Loc_3 := Int_Loc_2 * Int_Loc_1;
- Int_Loc_2 := Int_Loc_3 / Int_Loc_1;
- Int_Loc_2 := 7 * (Int_Loc_3 - Int_Loc_2) - Int_Loc_1;
- Proc_2(Int_Loc_1);
-
- end loop;
- -----------------
-
- -- Stop timer --
-
- Stop_Time := float (seconds(clock));
- -----------------
-
- end Proc_0;
-
- procedure Proc_1 (Pointer_Par_In: in Record_Pointer)
- is--executed once
- Next_Record: Record_Type
- renames Pointer_Par_In.Pointer_Comp.all;--=Pointer_Glob_Next.all
- begin
- Next_Record := Pointer_Glob.all;
- Pointer_Par_In.Int_Comp := 5;
- Next_Record.Int_Comp := Pointer_Par_In.Int_Comp;
- Next_Record.Pointer_Comp := Pointer_Par_In.Pointer_Comp;
- Proc_3 (Next_Record.Pointer_Comp);
- -- Next_Record.Pointer_Comp = Pointer_Glob.Pointer_Comp = Pointer_Glob_Next
- if Next_Record.Discr = Ident_1
- then -- executed
- Next_Record.Int_Comp := 6;
- Pack_2.Proc_6(Pointer_Par_In.Enum_Comp,Next_Record.Enum_Comp);
- Next_Record.Pointer_Comp := Pointer_Glob.Pointer_Comp;
- Pack_2.Proc_7(Next_Record.Int_Comp, 10, Next_Record.Int_Comp);
- else -- not executed
- Pointer_Par_In.all := Next_Record;
- end if;
- end Proc_1;
-
- procedure Proc_2 (Int_Par_In_Out:in out One_To_Fifty)
- is -- executed once
- -- In_Par_In_Out = 3,becomes 7
- Int_Loc: One_To_Fifty;
- Enum_Loc: Enumeration;
- begin
- Int_Loc := Int_Par_In_Out + 10;
- loop -- executed once
- if Char_Glob_1 = 'A'
- then -- executed
- Int_Loc := Int_Loc - 1;
- Int_Par_In_Out := Int_Loc - Int_Glob;
- Enum_Loc := Ident_1;
- end if;
- exit when Enum_Loc = Ident_1; -- true
- end loop;
- end Proc_2;
-
- procedure Proc_3 (Pointer_Par_Out: out Record_Pointer)
- is -- executed once
- -- Pointer_Par_Out becomes Pointer_Glob
- begin
- if Pointer_Glob /= null
- then -- executed
- Pointer_Par_Out := Pointer_Glob.Pointer_Comp;
- else -- not executed
- Int_Glob := 100;
- end if;
- Pack_2.Proc_7(10,Int_Glob,Pointer_Glob.Int_Comp);
- end Proc_3;
-
- procedure Proc_4 -- without parameters
- is -- executed once
- Bool_Loc: boolean;
- begin
- Bool_Loc := Char_Glob_1 = 'A';
- Bool_Loc := Bool_Loc or Bool_Glob;
- Char_Glob_2 := 'B';
- end Proc_4;
-
- procedure Proc_5 -- without parameters
- is--executed once
- begin
- Char_Glob_1 := 'A';
- Bool_Glob := false;
- end Proc_5;
-
- end Pack_1;
-
- with Global_Def,Pack_1;
- use Global_Def;
-
- package body Pack_2 is
- -------------------
- function Func_3(Enum_Par_In: in Enumeration)return boolean;
- -- forward declaration
-
- procedure Proc_6(Enum_Par_In: in Enumeration;
- Enum_Par_Out: out Enumeration)
- is -- executed once
- -- Enum_Par_In = Ident_3,Enum_Par_Out becomes Ident_2
- begin
- Enum_Par_Out := Enum_Par_In;
- if not Func_3(Enum_Par_In)
- then -- not executed
- Enum_Par_Out := Ident_4;
- end if;
- case Enum_Par_In is
- when Ident_1 => Enum_Par_Out := Ident_1;
- when Ident_2 => if Pack_1.Int_Glob > 100
- then Enum_Par_Out := Ident_1;
- else Enum_Par_Out := Ident_4;
- end if;
- when Ident_3 => Enum_Par_Out := Ident_2; -- executed
- when Ident_4 => null;
- when Ident_5 => Enum_Par_Out := Ident_3;
- end case;
- end Proc_6;
- procedure Proc_7(Int_Par_In_1,
- Int_Par_In_2: in One_To_Fifty;
- Int_Par_Out: out One_To_Fifty)
- is -- executed three times
- -- first call: Int_Par_In_1 = 2,Int_Par_In_2 = 3,
- -- Int_Par_Out becomes 7
- -- second call: Int_Par_In_1 = 6,Int_Par_In_2 = 10,
- -- Int_Par_Out becomes 18
- -- third call: Int_Par_In_1 = 10,Int_par_In_2 = 5,
- -- Int_Par_Out becomes 17
- Int_Loc: One_To_Fifty;
- begin
- Int_Loc := Int_Par_In_1 + 2;
- Int_Par_Out := Int_Par_In_2 + Int_Loc;
- end Proc_7;
- procedure Proc_8 (Array_Par_In_Out_1:in out Array_1_Dim_Integer;
- Array_Par_In_Out_2:in out Array_2_Dim_Integer;
- Int_Par_In_1,
- Int_Par_In_2: in integer)
- is -- executed once
- -- Int_Par_In_1 = 3
- -- Int_Par_In_2 = 7
- Int_Loc:One_To_Fifty;
- begin
- Int_Loc := Int_par_In_1 + 5;
- Array_Par_In_Out_1(Int_Loc) := Int_Par_In_2;
- Array_Par_In_Out_1(Int_Loc+1) :=
- Array_Par_In_Out_1 (Int_Loc);
- Array_Par_In_Out_1(Int_Loc+30) := Int_Loc;
- for Int_Index in Int_Loc .. Int_Loc+1 loop -- loop body executed twice
- Array_Par_In_Out_2(Int_Loc,Int_Index) := Int_Loc;
- end loop;
- Array_Par_In_Out_2(Int_Loc,Int_Loc-1) :=
- Array_Par_In_Out_2(Int_Loc,Int_Loc-1)+1;
- Array_Par_In_Out_2(Int_Loc+20,Int_Loc) :=
- Array_Par_In_Out_1(Int_Loc);
- Pack_1.Int_Glob := 5;
- end Proc_8;
- function Func_1(Char_Par_In_1,
- Char_Par_In_2:in Capital_Letter)
- return Enumeration
- is -- executed three times, returns Ident_1 each time
- -- first call: Char_Par_In_1 = 'H', Char_Par_In_2 = 'R'
- -- second call: Char_Par_In_1 = 'A', Char_Par_In_2 = 'C'
- -- third call: Char_Par_In_1 = 'B', Char_Par_In_2 = 'C'
- Char_Loc_1,Char_Loc_2:Capital_Letter;
- begin
- Char_Loc_1 := Char_Par_In_1;
- Char_Loc_2 := Char_Loc_1;
- if Char_Loc_2 /= Char_Par_In_2
- then-- executed
- return Ident_1;
- else-- not executed
- return Ident_2;
- end if;
- end Func_1;
- function Func_2(String_Par_In_1,
- String_Par_In_2:in String_30)return boolean
- is -- executed once, returns false
- -- String_Par_In_1 = "DHRYSTONE, 1'ST STRING"
- -- String_Par_In_2 = "DHRYSTONE, 2'ND STRING"
- Int_Loc: One_To_Thirty;
- Char_Loc: Capital_Letter;
- begin
- Int_Loc := 2;
- while Int_Loc<=2 Loop -- loop body executed once
- if Func_1(String_Par_In_1(Int_Loc),
- String_Par_In_2(Int_Loc+1)) = Ident_1
- then-- executed
- Char_Loc := 'A';
- Int_Loc := Int_Loc + 1;
- end if;
- end loop;
- if Char_Loc >= 'W' and Char_Loc < 'Z'
- then-- not executed
- Int_Loc := 7;
- end if;
- if Char_Loc = 'X'
- then-- not executed
- return true;
- else -- executed
- if String_Par_In_1 > String_Par_In_2
- then -- not executed
- Int_Loc := Int_Loc + 7;
- return true;
- else -- executed
- return false;
- end if;
- end if;
- end Func_2;
-
- function Func_3(Enum_Par_In: in Enumeration)return boolean
- is -- executed once, returns true
- -- Enum_Par_In = Ident_3
- Enum_Loc: Enumeration;
- begin
- Enum_Loc := Enum_Par_In;
- if Enum_Loc = Ident_3
- then -- executed
- return true;
- end if;
- end Func_3;
-
- end Pack_2;
-
-