home *** CD-ROM | disk | FTP | other *** search
- -- Ada version of Whetstone Benchmark Program
- -- This must be edited to "with" the compiler suppliers math routines
- -- SIN, COS, ATAN, SQRT, EXP and LOG
- -- These results may be interesting to compare to Z000093 that uses
- -- a physically included, all Ada set of math routines
-
-
- --------------------------------------------------------------------------
- -- --
- -- WHETADA.ADA distributed as A000092.ADA --
- -- --
- -- Ada version of the Whetstone Benchmark Program. --
- -- Reference: "Computer Journal" February 1976, pages 43-49 --
- -- for description of benchmark and ALGOL60 version. --
- -- Note: Procedure POUT is omitted. --
- -- --
- -- From Timing Studies using a synthetic Whetstone Benchmark --
- -- by Sam Harbaugh and John A. Forakis --
- -- --
- --------------------------------------------------------------------------
- -- --
- -- Authors Disclaimer --
- -- " The Whetstone measure deals only with the most basic scientific/ --
- -- computational aspects of the languages and computers and no general --
- -- conclusions should be drawn from this work. Application specific --
- -- benchmarks should be written and run by anyone needing to draw --
- -- conclusions reguarding suitability of languages, compilers and --
- -- hardware. This data is reported to stimulate interest and work in --
- -- run time benchmarking and in no way is meant to influence anyone's --
- -- choice of languages or software in any situation " --
- -- --
- --------------------------------------------------------------------------
-
- with CPU_TIME_CLOCK ;
- with TEXT_IO; use TEXT_IO;
- -- Change the following line to use the compiler vendors or manufacturers
- -- math library.
- with FLOAT_MATH_LIB; use FLOAT_MATH_LIB; -- manufacturers routines ( VAX )
-
- procedure A000092 is
- --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(CPU_TIME_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 parmeter
- 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 identifiers 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 reference 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 := K + J;
- 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 Moudle 11
-
- end loop CYCLE_LOOP;
-
- STOP_TIME := FLOAT(CPU_TIME_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
-
- begin
- NEW_LINE; PUT_LINE("ADA Whetstone benchmark"); NEW_LINE;
- PUT_LINE("A000092 using manufacturers math routines");
- 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 parocedure
- 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");
-
- -- Write the Whetstone stop time
- NEW_LINE; PUT("Whetstone stop time : ");
- PUT(STOP_TIME,5,2,0); PUT_LINE(" seconds ");
-
- -- Compute and write 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");
-
- -- 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;
-
- -- 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 millieseconds 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");
-
- -- 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; NEW_LINE;
-
- end COMPUTE_WHETSTONE_KIPS;
-
- begin
- COMPUTE_WHETSTONE_KIPS;
- end A000092;
-