home *** CD-ROM | disk | FTP | other *** search
/ Programmer's ROM - The Computer Language Library / programmersrom.iso / ada / test / benchada.src < prev    next >
Encoding:
Text File  |  1988-05-03  |  73.3 KB  |  2,331 lines

  1. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2. --mathstub.ada
  3. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  4. --  Filename: MATHSTUB.ADA
  5.   package MATHSTUB is
  6.     function  SIN(X: in FLOAT) return FLOAT;
  7.     function  COS(X: in FLOAT) return FLOAT;
  8.     function ATAN(X: in FLOAT) return FLOAT;
  9.     function  LOG(X: in FLOAT) return FLOAT;
  10.     function SQRT(X: in FLOAT) return FLOAT;
  11.     function  EXP(X: in FLOAT) return FLOAT;
  12.   end MATHSTUB;
  13.   package body MATHSTUB is
  14.     function  SIN (X: in FLOAT) return FLOAT is
  15.                   begin return 1.0; end SIN;
  16.     function  COS (X: in FLOAT) return FLOAT is
  17.                   begin return 1.0; end COS;
  18.     function ATAN (X: in FLOAT) return FLOAT is
  19.                   begin return 1.0; end ATAN;
  20.     function  LOG (X: in FLOAT) return FLOAT is
  21.                   begin return 1.0; end LOG;
  22.     function SQRT (X: in FLOAT) return FLOAT is 
  23.                   begin return 1.0; end SQRT;
  24.     function  EXP (X: in FLOAT) return FLOAT is
  25.                   begin return 1.0; end EXP;
  26.   end MATHSTUB;
  27. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  28. --helptools.ada
  29. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  30. with text_io; use text_io;
  31. with system;
  32. with direct_io;
  33. package help_tools is
  34.  
  35.   procedure time_filename (file_name: out string);
  36.  
  37.   procedure read_environ (outfile_ptr: in file_type);
  38.  
  39.   procedure read_envfile (outfile_ptr: in file_type);
  40.  
  41. end help_tools;
  42.  
  43. -------------------------------------------------------------------------------
  44. with calendar; use calendar;
  45. with text_io; use text_io;
  46. with system;
  47. with direct_io;
  48.  
  49. package body help_tools is
  50. --------------------------------------------------------------------------------
  51. --
  52. --  procedure time_filename
  53. --
  54. --  purpose: to create a string which can be used as a file name which
  55. --          has the date encoded in the title
  56. -- 
  57. --------------------------------------------------------------------------------
  58. procedure time_filename (file_name: out string) is
  59.  
  60. subtype month_name is string(1..2);
  61.  
  62. MON_START_POS :  CONSTANT := 2;        -- start and end indices for month
  63. MON_END_POS:  CONSTANT := 3;
  64. DAY_START_POS:  CONSTANT := 4;        -- start and end indices for day
  65. DAY_END_POS:  CONSTANT := 5;
  66. HOUR_START_POS: CONSTANT := 6;        -- start and end indices for hour
  67. HOUR_END_POS: CONSTANT := 7;
  68. MIN_START_POS:  CONSTANT := 8;        -- start and end indices for minutes
  69. MIN_END_POS:    CONSTANT := 9;
  70. SMAX: constant := 2;            -- maximum length for a numeric string
  71.  
  72. date : time;                -- date
  73. cur_year: year_number;            -- current year
  74. cur_mon:  month_number;            -- current month
  75. cur_day:  day_number;            -- current day
  76.  
  77. ipass,                    -- total_seconds/max_int 
  78. itemp,                    -- temporary integer variable
  79. hours,                    -- number of hours
  80. minutes: integer;            -- number of minutes
  81.  
  82. total_sec: day_duration;        -- total number of seconds
  83.  
  84. int_seconds: integer;            -- integer variable for seconds
  85.  
  86. hour_string,                -- ascii string for hours
  87. min_string,                -- ascii string for minutes
  88. day_string: string (1..2);        -- ascii string for days
  89.     
  90. dtotal_sec,                -- floating point var for seconds
  91. dtemp_result,                -- results 
  92. dtemp_num,                -- temp variable for floating pt numbers
  93. dtemp_remainder:  float;        -- remainder of total seconds
  94.  
  95. month_code : array (month_number) of month_name := 
  96.         ("ja","fe","mr","ap","my","jn",
  97.          "jl","ag","sp","oc","nv","dc");
  98.  
  99.  
  100. function int_to_string (I: integer) return string is
  101.  
  102. -- converts integers to strings
  103.  
  104.    S: string (1..smax);
  105.    SPOS : integer := s'last; 
  106.    HOLD : integer := I;
  107.    DIGIT : integer;
  108. --
  109. begin
  110.    S := (others=>'0');  
  111.    while HOLD /= 0 loop
  112.      DIGIT := HOLD rem 10;
  113.      S(SPOS) := character'val(abs(DIGIT) + character'pos('0'));
  114.      SPOS := SPOS - 1;
  115.      HOLD := HOLD/10;
  116.    end loop;
  117.    return S;
  118. end INT_TO_STRING;
  119.     
  120. begin
  121. --
  122. --  initialize the filename to Wmmddhhmm.DAT
  123. --  get the informations for the current date and time
  124. --
  125.     file_name := "Wmmddmmmm.DAT";
  126.     date := clock;
  127.     cur_year := year (date);
  128.     cur_mon  := month (date);
  129.     cur_day  := day(date);
  130.     total_sec := seconds(date);
  131. --
  132. --  get the largest integer available to the system
  133. --  float the values for both max_int and the total number of seconds
  134. --
  135.     itemp := integer'last;
  136.     dtotal_sec := float (total_sec);
  137.     dtemp_num := float (itemp);
  138.     dtemp_result := dtotal_sec - dtemp_num;
  139. --
  140. --  if the total number of seconds is greater than max_int
  141. --     ( a case which is true for doing 16 bit arithmetic)
  142. --     determine how many times max_int is a divisor for total number
  143. --          of seconds
  144. --     for the number of passes (max_int divides) do
  145. --         increment the hours accordingly
  146. --         increment the minutes accordingly
  147. --     end for
  148. --     calculate the values of minutes
  149. --    
  150.     if (dtemp_result > 0.0) then
  151.  
  152.        while (dtemp_result > 0.0) loop
  153.           ipass := ipass + 1;
  154.       dtemp_result := dtemp_result - dtemp_num;
  155.        end loop;
  156.        hours := 0; minutes := 0;
  157.        dtemp_remainder := dtemp_num + dtemp_result;
  158.        for iter in 1..ipass loop
  159.        hours := hours + 9;
  160.        minutes :=  minutes + 6;
  161.        end loop;
  162.        itemp := integer(dtemp_remainder);
  163.        minutes := minutes + itemp/60;
  164. --
  165. --  else
  166. --     calculate hours directly from total seconds
  167. --     calculate minutes directly from total seconds
  168. --  endif
  169. --
  170.     else
  171.  
  172.        int_seconds :=  integer(total_sec);
  173.        hours := int_seconds/3600; 
  174.        minutes := (int_seconds - (hours*3600))/60;
  175.  
  176.     end if;
  177. --
  178. --  translate the numbers to acsii representations and
  179. --      build the filename
  180. --
  181.     day_string := int_to_string (CUR_DAY);
  182.     hour_string:=  int_to_string(hours);
  183.     min_string  := int_to_string (minutes);
  184.     
  185.     file_name (mon_START_POS..mon_END_POS) := month_code(cur_mon);
  186.     file_name (DAY_START_POS..DAY_END_POS) := day_STRING;
  187.     file_name (HOUR_START_POS..HOUR_END_POS) := hour_string;
  188.     file_name (MIN_START_POS..MIN_END_POS) := min_string;
  189.  
  190. end time_filename;
  191. --------------------------------------------------------------------------------
  192. --
  193. --  procedure read_environ
  194. --
  195. --  purpose: writes system specific data in to the data file
  196. --
  197. --------------------------------------------------------------------------------
  198. procedure read_environ (outfile_ptr: in file_type) is
  199.  
  200. package int_io is new integer_io(integer);
  201. use int_io;
  202.  
  203. package flt_io is new float_io(float);
  204. use flt_io;
  205.  
  206. package dur_io is new fixed_io(duration);
  207. use dur_io;
  208.  
  209. package dirinf_io is new direct_io(integer);
  210.  
  211. temp_dvar:  day_duration;    -- temporary variable for day duration;
  212.  
  213. temp_fvar:  float;        -- temporary variable for floating constants
  214.  
  215. temp_ivar,            -- temporary variable to get values from
  216.                 --   package system
  217. last_char: integer;        -- pointer to last character in line
  218.  
  219. blank_line,
  220. line : string (1..80) := (others => ' ');
  221.  
  222. begin
  223. --
  224. --  get data from package system
  225. --
  226.  
  227.     Read_Envfile (outfile_ptr);
  228.  
  229.     new_line(outfile_ptr); 
  230.     put_line (outfile_ptr," DATA FROM PACKAGE SYSTEM: ");
  231.     
  232.     temp_ivar := system.storage_unit;
  233.     put (outfile_ptr,"SYSTEM.STORAGE_UNIT = ");
  234.     int_io.put (outfile_ptr,temp_ivar);
  235.  
  236.     new_line(outfile_ptr);
  237.     temp_ivar := system.memory_size; 
  238.     put (outfile_ptr,"SYSTEM.MEMORY_SIZE  = ");
  239.     int_io.put (outfile_ptr,temp_ivar);
  240.  
  241.     new_line(outfile_ptr);
  242.     temp_ivar := system.min_int;
  243.     put (outfile_ptr,"SYSTEM.MIN_INT      = ");
  244.     int_io.put (outfile_ptr,temp_ivar);
  245.  
  246.     new_line(outfile_ptr);
  247.     temp_ivar := system.max_int;
  248.     put (outfile_ptr,"SYSTEM.MAX_INT      = ");
  249.     int_io.put (outfile_ptr,temp_ivar);
  250.  
  251.     new_line(outfile_ptr);
  252.     temp_ivar := system.max_digits;
  253.     put (outfile_ptr,"SYSTEM.MAX_DIGITS   = ");
  254.     int_io.put (outfile_ptr,temp_ivar);
  255.  
  256.     new_line(outfile_ptr);
  257.     temp_ivar := system.max_mantissa;
  258.     put (outfile_ptr,"SYSTEM.MAX_MANTISSA = ");
  259.     int_io.put (outfile_ptr,temp_ivar);
  260.  
  261.  
  262.     new_line(outfile_ptr);
  263.     temp_fvar := system.fine_delta;
  264.     put (outfile_ptr,"SYSTEM.FINE_DELTA   = ");
  265.     put (outfile_ptr,temp_fvar);
  266.  
  267.     new_line(outfile_ptr);
  268.     temp_fvar := system.tick;
  269.     put (outfile_ptr,"SYSTEM.TICK         = ");
  270.     put (outfile_ptr,temp_fvar);
  271.  
  272.      new_line(outfile_ptr); new_line(outfile_ptr);
  273.      put (outfile_ptr," DATA FROM PACKAGES FROM I-O SYSTEMS: ");
  274.  
  275.      new_line(outfile_ptr);
  276.      temp_ivar := integer(text_io.count'last); 
  277.      put (outfile_ptr,"text_io.count'last   = ");
  278.      put (outfile_ptr,temp_ivar); 
  279.  
  280.      new_line(outfile_ptr);
  281.      temp_ivar := integer(dirinf_io.count'last); 
  282.      put (outfile_ptr,"direct_io.count'last = "); 
  283.      put (outfile_ptr,temp_ivar);
  284.  
  285.  
  286.      new_line (outfile_ptr); new_line(outfile_ptr);
  287.      put_line (outfile_ptr,"DATA FROM PACKAGE STANDARD: ");
  288.  
  289.      temp_ivar := integer'first;
  290.      put (outfile_ptr,"Integer range is "); 
  291.      put(outfile_ptr,temp_ivar);
  292.      temp_ivar := integer'last;
  293.      put (outfile_ptr," .. "); put(outfile_ptr,temp_ivar);
  294.  
  295.  
  296.      new_line (outfile_ptr);
  297.      temp_fvar := duration'delta;
  298.      put (outfile_ptr,"DURATION is delta ");
  299.      put (outfile_ptr,temp_fvar);
  300.  
  301.  
  302.      new_line (outfile_ptr);
  303.      temp_fvar := duration'small;
  304.      put (outfile_ptr,"DURATION'small = ");
  305.      put (outfile_ptr,temp_fvar);
  306.  
  307.      new_line (outfile_ptr); new_line(outfile_ptr);
  308.      put (outfile_ptr,"Calendar package values: ");
  309.      new_line (outfile_ptr);
  310.      temp_dvar := calendar.day_duration'first;
  311.      put (outfile_ptr,"DAY DURATION range is : ");
  312.      put (outfile_ptr,temp_dvar);put (outfile_ptr," to ");
  313.      temp_dvar := calendar.day_duration'last;
  314.      put (outfile_ptr,temp_dvar);
  315.  
  316.      new_line (outfile_ptr); new_line (outfile_ptr);
  317.      put (outfile_ptr,"End of looking at system parameters");
  318.      new_line (outfile_ptr); new_line (outfile_ptr);
  319.  
  320. end read_environ;
  321. -------------------------------------------------------------------------------
  322. --
  323. --   procedure read_envfile
  324. --
  325. --   purpose:  to copy the data from a file called ENVIRON.INF into the
  326. --         file specified by the outfile_ptr
  327. --
  328. --   exception: if the file ENVIRON.INF does not exit, an exception 
  329. --         handler will write a message in file specified by outfile_ptr
  330. --         that ENVIRON.INF has existence problems
  331. --
  332. -------------------------------------------------------------------------------
  333. procedure read_envfile (outfile_ptr: in file_type) is
  334. --
  335. indata: file_type;        -- internal filename for actual data file
  336.  
  337. file_name : string (1..11) := ("environ.inf");
  338.  
  339. blank_line,
  340. line : string (1..120) := (others => ' ');
  341.  
  342. last_char: integer;        -- position of last character in line read
  343.  
  344. --
  345. --  get data out of environment file ENVIRON.INF
  346. --
  347.  
  348. begin
  349.  
  350.     open (indata,in_file,file_name);
  351.     while not end_of_file (indata) loop
  352.         line := blank_line;
  353.         get_line(indata,line,last_char);
  354.         put_line(outfile_ptr,line(1..last_char));
  355.     end loop;
  356.     close (indata);
  357.  
  358.   exception
  359.     when others =>
  360.     put_line (outfile_ptr,
  361.               "Something is wrong with the existence of file ENVIRON.INF");
  362.     new_line (outfile_ptr);
  363.  
  364. end read_envfile;
  365.  
  366. end help_tools;
  367. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  368. --whetadaa.ada
  369. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  370. -- Filename: WHETADAA.DEC
  371. -- Version 1.1 of benchmark programs               (DS 2.11.85)
  372. -- Ada version of Whetstone Benchmark Program.
  373. -- Reference: "Computer Journal ," February 1976, pages 43-49,
  374. --            for description of benchmark and ALGOL60 version.
  375. -- Note: Procedure POUT is omitted.
  376.  
  377. with CALENDAR; use CALENDAR;
  378. with TEXT_IO; use TEXT_IO;
  379. with HELP_TOOLS; use HELP_TOOLS;
  380. with IO_EXCEPTIONS; use IO_EXCEPTIONS;
  381.  
  382. --Comment out following with use to run with math library stubbed off
  383. --with CORE_FUNCTIONS,TRIG_LIB;use CORE_FUNCTIONS,TRIG_LIB;
  384. --Uncomment the following line to run with math library stubbed off
  385. with MATHSTUB; use MATHSTUB;
  386.  
  387. procedure WHETADAA is
  388. --Comment out following pragma suppresses to run unsuppressed
  389.   --pragma SUPPRESS(ACCESS_CHECK);
  390.   --pragma SUPPRESS(DISCRIMINANT_CHECK);
  391.   --pragma SUPPRESS(INDEX_CHECK);
  392.   --pragma SUPPRESS(LENGTH_CHECK);
  393.   --pragma SUPPRESS(RANGE_CHECK);
  394.   --pragma SUPPRESS(DIVISION_CHECK);
  395.   --pragma SUPPRESS(OVERFLOW_CHECK);
  396.   --pragma SUPPRESS(STORAGE_CHECK);
  397.   --pragma SUPPRESS(ELABORATION_CHECK);
  398.   --
  399.   package  INT_IO is new INTEGER_IO(INTEGER); use  INT_IO;
  400.   package REAL_IO is new   FLOAT_IO(FLOAT)  ; use REAL_IO;
  401.   procedure WHETSTONE (I, NO_OF_CYCLES: in INTEGER;
  402.                      START_TIME, STOP_TIME: out FLOAT) is
  403.     --
  404.     --Calling procedure provides the loop count weight
  405.     --factor, I, and the encompassing loop count, NO_OF_CYCLES.
  406.     --
  407.     type VECTOR is array (INTEGER range <>) of FLOAT;
  408.     X1,X2,X3,X4,X,Y,Z,T,T1,T2: FLOAT;
  409.     E1: VECTOR(1..4);
  410.     J,K,L,N1,N2,N3,N4,N5,N6,N7,N8,N9,N10,N11: INTEGER;
  411.     --
  412.     procedure PA (E: in out VECTOR) is
  413.       --tests computations with an array as a parameter
  414.       J: INTEGER;
  415.       -- T, T2 : FLOAT are global variables.
  416.     begin
  417.       J:=0;
  418.       <<LAB>>
  419.       E(1):= (E(1)+E(2)+E(3)-E(4))*T;
  420.       E(2):= (E(1)+E(2)-E(3)+E(4))*T;
  421.       E(3):= (E(1)-E(2)+E(3)+E(4))*T;
  422.       E(4):= (-E(1)+E(2)+E(3)+E(4))/T2;
  423.       J:=J+1;
  424.       if J < 6 then
  425.         goto LAB;
  426.       end if;
  427.     end PA;
  428.     --
  429.     procedure P0 is
  430.       --tests computations with no parameters
  431.       -- T1,T2: FLOAT are global
  432.       -- E1: VECTOR(1..4) is global
  433.       -- J,K,L: INTEGER are global
  434.     begin
  435.       E1(J):= E1(K);
  436.       E1(K):= E1(L);
  437.       E1(L):= E1(J);
  438.     end P0;
  439.     --
  440.     procedure P3 (X,Y: in out FLOAT; Z: out FLOAT) is
  441.       --tests computations with simple identifiers as parameters
  442.       --   T,T2: FLOAT are global
  443.     begin
  444.       X:= T*(X+Y);
  445.       Y:= T*(X+Y);
  446.       Z:= (X+Y)/T2;
  447.     end P3;
  448.     --
  449.   begin
  450.     --Set constants
  451.     T:= 0.499975;
  452.     T1:= 0.50025;
  453.     T2:= 2.0;
  454.     --Compute the execution frequency for the benchmark modules.
  455.     N1:= 0;  --Module 1 not executed.
  456.     N2:= 12*I;
  457.     N3:= 14*I;
  458.     N4:= 345*I;
  459.     N5:= 0;  --Module 5 not executed.
  460.     N6:= 210*I;
  461.     N7:= 32*I;
  462.     N8:= 899*I;
  463.     N9:= 616*I;
  464.     N10:= 0;  --Module 10 not executed.
  465.     N11:= 93*I;
  466.     --
  467.     START_TIME:= FLOAT(SECONDS(CLOCK)); --Get Whetstone start time
  468.     --
  469.     CYCLE_LOOP:
  470.     for CYCLE_NO in 1..NO_OF_CYCLES loop
  471.       --Module 1: computations with simple identifiers
  472.       X1:= 1.0;
  473.       X2:= -1.0;
  474.       X3:= -1.0;
  475.       X4:= -1.0;
  476.       for I in 1..N1 loop
  477.         X1:= (X1+X2+X3-X4)*T;
  478.         X2:= (X1+X2-X3+X4)*T;
  479.         X3:= (X1-X2+X3+X4)*T;
  480.         X4:= (-X1+X2+X3+X4)*T;
  481.       end loop;
  482.       --end Module 1
  483.       --
  484.       --Module 2: computations with array elements
  485.       E1(1):= 1.0;
  486.       E1(2):= -1.0;
  487.       E1(3):= -1.0;
  488.       E1(4):= -1.0;
  489.       for I in 1..N2 loop
  490.         E1(1):= (E1(1)+E1(2)+E1(3)-E1(4))*T;
  491.         E1(2):= (E1(1)+E1(2)-E1(3)+E1(4))*T;
  492.         E1(3):= (E1(1)-E1(2)+E1(3)+E1(4))*T;
  493.         E1(4):= (-E1(1)+E1(2)+E1(3)+E1(4))*T;
  494.       end loop;
  495.       --end Module 2
  496.       --
  497.       --Module 3: passing an array as a parameter 
  498.       for I in 1..N3 loop
  499.         PA(E1);
  500.       end loop;
  501.       --end Module 3
  502.       --
  503.       --Module 4: performing conditional jumps
  504.       J:=1;
  505.       for I in 1..N4 loop
  506.         if J=1 then
  507.           J:=2;
  508.         else
  509.           J:=3;
  510.         end if;
  511.         if J>2 then
  512.           J:=0;
  513.         else
  514.           J:=1;
  515.         end if;
  516.         if J<1 then
  517.           J:=1;
  518.         else
  519.           J:=0;
  520.         end if;
  521.       end loop;
  522.       --end Module 4
  523.       --
  524.       --Module 5: omitted
  525.       --
  526.       --Module 6: performing integer arithmetic
  527.       J:=1;
  528.       K:=2;
  529.       L:=3;
  530.       for I in 1..N6 loop
  531.         J:= J*(K-J)*(L-K);
  532.         K:= L*K-(L-J)*K;
  533.         L:= (L-K)*(K+J);
  534.         E1(L-1):=FLOAT(J+K+L);
  535.         E1(K-1):=FLOAT(J*K*L);
  536.       end loop;
  537.       --end Module 6
  538.       --
  539.       --Module 7: performing computations using trigonometric
  540.       --           functions
  541.       X:= 0.5;
  542.       Y:= 0.5;
  543.       for I in 1..N7 loop
  544.         X:= T*ATAN(T2*SIN(X)*COS(X)/(COS(X+Y)+COS(X-Y)-1.0));
  545.         Y:= T*ATAN(T2*SIN(Y)*COS(Y)/(COS(X+Y)+COS(X-Y)-1.0));
  546.       end loop;
  547.       --end Module 7
  548.       --
  549.       --Module 8: procedure calls with simple indentifiers as 
  550.       --           parameters
  551.       X:=1.0;
  552.       Y:=1.0;
  553.       Z:=1.0;
  554.       for I in 1..N8 loop
  555.         P3(X,Y,Z);
  556.       end loop;
  557.       --end Module 8
  558.       --
  559.       --Module 9: array references and procedure calls with no
  560.       --           parameters
  561.       J:=1;
  562.       K:=2;
  563.       L:=3;
  564.       E1(1):=1.0;
  565.       E1(2):=2.0;
  566.       E1(3):=3.0;
  567.       for I in 1..N9 loop
  568.         P0;
  569.       end loop;
  570.       --end Module 9
  571.       --
  572.       --Module 10: integer arithmetic
  573.       J:=2;
  574.       K:=3;
  575.       for I in 1..N10 loop
  576.         J:=J+K;
  577.         K:=J+K;
  578.         J:=K-J;
  579.         K:=K-J-J;
  580.       end loop;
  581.       --end Module 10
  582.       --
  583.       --Module 11: performing computations using standard
  584.       --            mathematical functions
  585.       X:=0.75;
  586.       for I in 1..N11 loop
  587.         X:=SQRT(EXP(LOG(X)/T1));
  588.       end loop;
  589.       --end Module 11
  590.     end loop CYCLE_LOOP;
  591.     --
  592.     STOP_TIME:= FLOAT(SECONDS(CLOCK)); --Get Whetstone stop time
  593.     --
  594.   end WHETSTONE;
  595.   --
  596.   --
  597.   procedure COMPUTE_WHETSTONE_KIPS is
  598.     --
  599.     --  Variables used to control execution of benchmark and to 
  600.     --  compute the Whetstone rating:
  601.     --
  602.     NO_OF_RUNS:  INTEGER;  --Number of times the benchmark is executed
  603.     NO_OF_CYCLES:  INTEGER;  --Number of times the group of benchmark
  604.                              --modules is executed
  605.     I: INTEGER;   --Factor weighting number of times each module loops.
  606.                   --A value of ten gives a total weight for modules
  607.                   --of approximately one million Whetstone instructions.
  608.     START_TIME:  FLOAT;   --Time at which execution of benchmark modules
  609.                           -- begins
  610.     STOP_TIME:  FLOAT;   --Time at which execution of benchmark modules 
  611.                          -- ends (time for NO_OF_CYCLES)
  612.     ELAPSED_TIME: FLOAT;    --Time between START_TIME and STOP_TIME
  613.     MEAN_TIME: FLOAT; --Average time per cycle
  614.     RATING: FLOAT;  --Thousands of Whetstone instructions per sec.
  615.     MEAN_RATING: FLOAT; --Average Whetstone rating
  616.     INT_RATING: INTEGER; --Integer value of KWIPS
  617.     DATA_FILE: FILE_TYPE; --File identifier
  618.     FILENAME: STRING (1..13) := "Wnnddhhmm.DAT";
  619.     --
  620.   begin
  621.     TIME_FILENAME (FILENAME);
  622.     CREATE(DATA_FILE, OUT_FILE, FILENAME, "");
  623.     READ_ENVIRON (DATA_FILE);
  624.     PUT_LINE(DATA_FILE," ADA Whetstone benchmark(WHETADAA.DEC)");NEW_LINE(DATA_FILE);
  625.     NEW_LINE; PUT_LINE(" ADA Whetstone benchmark(WHETADAA.DEC)");NEW_LINE;
  626.     --
  627.     MEAN_TIME:=0.0;
  628.     MEAN_RATING:=0.0;
  629.     NO_OF_CYCLES:=10;
  630.     NO_OF_RUNS:=5;
  631.     I:=10;
  632.     --
  633.     RUN_LOOP:
  634.     for RUN_NO in 1..NO_OF_RUNS loop
  635.       --
  636.       -- Call the Whetstone benchmark procedure
  637.       --
  638.       WHETSTONE (I, NO_OF_CYCLES, START_TIME, STOP_TIME);
  639.       --
  640.       -- Write the Whetstone start time
  641.       --
  642.       NEW_LINE; PUT(" Whetstone start time: "); PUT(START_TIME, 5, 2, 0);
  643.       PUT_LINE(" seconds");
  644.       NEW_LINE(DATA_FILE); PUT(DATA_FILE," Whetstone start time: ");
  645.       PUT(DATA_FILE, START_TIME, 5, 2, 0);PUT_LINE(DATA_FILE," seconds");
  646.       --
  647.       -- Write the Whetstone stop time
  648.       --
  649.       NEW_LINE; PUT(" Whetstone stop time: "); PUT(STOP_TIME, 5, 2, 0);
  650.       PUT_LINE(" seconds");
  651.       NEW_LINE(DATA_FILE); PUT(DATA_FILE," Whetstone stop time: ");
  652.       PUT(DATA_FILE, STOP_TIME, 5, 2, 0); PUT_LINE(DATA_FILE," seconds");
  653.       --
  654.       -- Compute and write the elapsed time
  655.       --
  656.       ELAPSED_TIME:= STOP_TIME - START_TIME;
  657.       NEW_LINE; PUT(" Elapsed time for "); PUT(NO_OF_CYCLES, 3);
  658.       PUT(" cycles: "); PUT(ELAPSED_TIME,5,2,0); PUT_LINE(" seconds");
  659.       NEW_LINE(DATA_FILE); PUT(DATA_FILE," Elapsed time for ");
  660.       PUT(DATA_FILE, NO_OF_CYCLES, 3); PUT(DATA_FILE," cycles: ");
  661.       PUT(DATA_FILE,ELAPSED_TIME,5,2,0); PUT_LINE(DATA_FILE," seconds");
  662.       --
  663.       -- Sum time in milliseconds per cycle
  664.       MEAN_TIME:= MEAN_TIME + (ELAPSED_TIME*1000.0)/FLOAT(NO_OF_CYCLES);
  665.       --
  666.       -- Calculate the Whetstone rating based on the time for the number
  667.       --  of cycles just executed and write
  668.       --
  669.       RATING:= (1000.0*FLOAT(NO_OF_CYCLES))/ELAPSED_TIME;
  670.       --
  671.       -- Sum Whetstone rating
  672.       MEAN_RATING:= MEAN_RATING + RATING;
  673.       INT_RATING:= INTEGER(RATING);
  674.       NEW_LINE;PUT(" Whetstone rating: ");PUT(INT_RATING);
  675.       PUT_LINE(" KWIPS");NEW_LINE;
  676.       NEW_LINE(DATA_FILE); PUT(DATA_FILE," Whetstone rating: ");
  677.       PUT(DATA_FILE, INT_RATING); PUT_LINE(DATA_FILE," KWIPS");
  678.       NEW_LINE(DATA_FILE);
  679.       --
  680.       -- Reset NO_OF_CYCLES for next run using ten cycles more
  681.       --
  682.       NO_OF_CYCLES:= NO_OF_CYCLES + 10;
  683.     end loop RUN_LOOP;
  684.     --
  685.     -- Compute average time in milliseconds per cycle and write
  686.     --
  687.     MEAN_TIME:= MEAN_TIME/FLOAT(NO_OF_RUNS);
  688.     NEW_LINE; PUT(" Average time per cycle: "); PUT(MEAN_TIME, 5, 2, 0);
  689.     PUT_LINE(" milliseconds");
  690.     NEW_LINE(DATA_FILE);
  691.     PUT(DATA_FILE," Average time per cycle: ");
  692.     PUT(DATA_FILE,MEAN_TIME,5,2,0); PUT_LINE(DATA_FILE," milliseconds");
  693.     --
  694.     -- Calculate average Whetstone rating and write
  695.     -- 
  696.     MEAN_RATING:= MEAN_RATING/FLOAT(NO_OF_RUNS);
  697.     INT_RATING:= INTEGER(MEAN_RATING);
  698.     NEW_LINE; PUT(" Average Whetstone rating: "); PUT(INT_RATING);
  699.     PUT_LINE(" KWIPS");
  700.     NEW_LINE(DATA_FILE); PUT(DATA_FILE," Average Whetstone rating: ");
  701.     PUT(DATA_FILE, INT_RATING); PUT_LINE(DATA_FILE," KWIPS");
  702.     CLOSE(DATA_FILE);
  703.   end COMPUTE_WHETSTONE_KIPS;
  704.   --
  705. begin
  706.   COMPUTE_WHETSTONE_KIPS;
  707. end WHETADAA;
  708.  
  709. --comment out next line if not VAX Ada version (1.0)
  710.   pragma SUPPRESS_ALL;
  711.  
  712. --###   11458 is the file CHECK-SUM number computed on  2/20/1985 at 14:34
  713. --### CHECK-SUM := sum (ASCII values of all characters in this file) mod 2**16
  714. --### -- (excluding these three lines) --
  715. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  716. --whetadab.ada
  717. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  718. --  Filename: WHETADAB.DEC
  719. --  Version 1.1 of benchmark programs             (DS.2.14.85)
  720. -- Ada version of Whetstone Benchmark Program.
  721. -- Reference: "Computer Journal ," February 1976, pages 43-49,
  722. --            for description of benchmark and ALGOL60 version.
  723. -- Note: Procedure POUT is omitted.
  724.  
  725. with CALENDAR; use CALENDAR;
  726. with TEXT_IO; use TEXT_IO;
  727. with HELP_TOOLS; use HELP_TOOLS;
  728. with IO_EXCEPTIONS; use IO_EXCEPTIONS;
  729.  
  730. --Comment out following with use to run with math library stubbed off
  731. --with CORE_FUNCTIONS,TRIG_LIB;use CORE_FUNCTIONS,TRIG_LIB;
  732. --Uncomment the following line to run with math library stubbed off
  733. with MATHSTUB; use MATHSTUB;
  734.  
  735. procedure WHETADAB is
  736. --Comment out following pragma suppresses to run unsuppressed
  737.   --pragma SUPPRESS(ACCESS_CHECK);
  738.   --pragma SUPPRESS(DISCRIMINANT_CHECK);
  739.   --pragma SUPPRESS(INDEX_CHECK);
  740.   --pragma SUPPRESS(LENGTH_CHECK);
  741.   --pragma SUPPRESS(RANGE_CHECK);
  742.   --pragma SUPPRESS(DIVISION_CHECK);
  743.   --pragma SUPPRESS(OVERFLOW_CHECK);
  744.   --pragma SUPPRESS(STORAGE_CHECK);
  745.   --pragma SUPPRESS(ELABORATION_CHECK);
  746.   --
  747.   package  INT_IO is new INTEGER_IO(INTEGER); use  INT_IO;
  748.   package REAL_IO is new   FLOAT_IO(FLOAT)  ; use REAL_IO;
  749.   procedure WHETSTONE (I, NO_OF_CYCLES: in INTEGER;
  750.                        START_TIME, STOP_TIME: out FLOAT) is
  751.     --
  752.     --Calling procedure provides the loop count weight
  753.     --factor, I, and the encompassing loop count, NO_OF_CYCLES.
  754.     --
  755.     type VECTOR is array (INTEGER range <>) of FLOAT;
  756.     X1,X2,X3,X4,X,Y,Z,T,T1,T2: FLOAT;
  757.     E1: VECTOR(1..4);
  758.     J,K,L,N1,N2,N3,N4,N5,N6,N7,N8,N9,N10,N11: INTEGER;
  759.     --
  760.     procedure PA (E: in out VECTOR) is
  761.       --tests computations with an array as a parameter
  762.       J: INTEGER;
  763.       -- T, T2 : FLOAT are global variables.
  764.     begin
  765.       J:=0;
  766.       <<LAB>>
  767.       E(1):= (E(1)+E(2)+E(3)-E(4))*T;
  768.       E(2):= (E(1)+E(2)-E(3)+E(4))*T;
  769.       E(3):= (E(1)-E(2)+E(3)+E(4))*T;
  770.       E(4):= (-E(1)+E(2)+E(3)+E(4))/T2;
  771.       J:=J+1;
  772.       if J < 6 then
  773.         goto LAB;
  774.       end if;
  775.     end PA;
  776.     --
  777.     procedure P0 is
  778.       --tests computations with no parameters
  779.       -- T1,T2: FLOAT are global
  780.       -- E1: VECTOR(1..4) is global
  781.       -- J,K,L: INTEGER are global
  782.     begin
  783.       E1(J):= E1(K);
  784.       E1(K):= E1(L);
  785.       E1(L):= E1(J);
  786.     end P0;
  787.     --
  788.     procedure P3 (X,Y: in out FLOAT; Z: out FLOAT) is
  789.       --tests computations with simple identifiers as parameters
  790.       --   T,T2: FLOAT are global
  791.     begin
  792.       X:= T*(X+Y);
  793.       Y:= T*(X+Y);
  794.       Z:= (X+Y)/T2;
  795.     end P3;
  796.     --
  797.   begin
  798.     --Set constants
  799.     T:= 0.499975;
  800.     T1:= 0.50025;
  801.     T2:= 2.0;
  802.     --Compute the execution frequency for the benchmark modules.
  803.     N1:= 0;  --Module 1 not executed.
  804.     N2:= 12*I;
  805.     N3:= 14*I;
  806.     N4:= 345*I;
  807.     N5:= 0;  --Module 5 not executed.
  808.     N6:= 210*I;
  809.     N7:= 32*I;
  810.     N8:= 899*I;
  811.     N9:= 616*I;
  812.     N10:= 0;  --Module 10 not executed.
  813.     N11:= 93*I;
  814.     --
  815.     START_TIME:= FLOAT(SECONDS(CLOCK)); --Get Whetstone start time
  816.     --
  817.     CYCLE_LOOP:
  818.     for CYCLE_NO in 1..NO_OF_CYCLES loop
  819.       --Module 1: computations with simple identifiers
  820.       X1:= 1.0;
  821.       X2:= -1.0;
  822.       X3:= -1.0;
  823.       X4:= -1.0;
  824.       for I in 1..N1 loop
  825.         X1:= (X1+X2+X3-X4)*T;
  826.         X2:= (X1+X2-X3+X4)*T;
  827.         X3:= (X1-X2+X3+X4)*T;
  828.         X4:= (-X1+X2+X3+X4)*T;
  829.       end loop;
  830.       --end Module 1
  831.       --
  832.       --Module 2: computations with array elements
  833.       E1(1):= 1.0;
  834.       E1(2):= -1.0;
  835.       E1(3):= -1.0;
  836.       E1(4):= -1.0;
  837.       for I in 1..N2 loop
  838.         E1(1):= (E1(1)+E1(2)+E1(3)-E1(4))*T;
  839.         E1(2):= (E1(1)+E1(2)-E1(3)+E1(4))*T;
  840.         E1(3):= (E1(1)-E1(2)+E1(3)+E1(4))*T;
  841.         E1(4):= (-E1(1)+E1(2)+E1(3)+E1(4))*T;
  842.       end loop;
  843.       --end Module 2
  844.       --
  845.       --Module 3: passing an array as a parameter 
  846.       for I in 1..N3 loop
  847.         PA(E1);
  848.       end loop;
  849.       --end Module 3
  850.       --
  851.       --Module 4: performing conditional jumps
  852.       J:=1;
  853.       for I in 1..N4 loop
  854.         if J=1 then
  855.           J:=2;
  856.         else
  857.           J:=3;
  858.         end if;
  859.         if J>2 then
  860.           J:=0;
  861.         else
  862.           J:=1;
  863.         end if;
  864.         if J<1 then
  865.           J:=1;
  866.         else
  867.           J:=0;
  868.         end if;
  869.       end loop;
  870.       --end Module 4
  871.       --
  872.       --Module 5: omitted
  873.       --
  874.       --Module 6: performing integer arithmetic
  875.       J:=1;
  876.       K:=2;
  877.       L:=3;
  878.       for I in 1..N6 loop
  879.         J:= J*(K-J)*(L-K);
  880.         K:= L*K-(L-J)*K;
  881.         L:= (L-K)*(K+J);
  882.         E1(L-1):=FLOAT(J+K+L);
  883.         E1(K-1):=FLOAT(J*K*L);
  884.       end loop;
  885.       --end Module 6
  886.       --
  887.       --Module 7: performing computations using trigonometric
  888.       --           functions
  889.       X:= 0.5;
  890.       Y:= 0.5;
  891.       for I in 1..N7 loop
  892.         X:= T*ATAN(T2*SIN(X)*COS(X)/(COS(X+Y)+COS(X-Y)-1.0));
  893.         Y:= T*ATAN(T2*SIN(Y)*COS(Y)/(COS(X+Y)+COS(X-Y)-1.0));
  894.       end loop;
  895.       --end Module 7
  896.       --
  897.       --Module 8: procedure calls with simple indentifiers as 
  898.       --           parameters
  899.       X:=1.0;
  900.       Y:=1.0;
  901.       Z:=1.0;
  902.       for I in 1..N8 loop
  903.         P3(X,Y,Z);
  904.       end loop;
  905.       --end Module 8
  906.       --
  907.       --Module 9: array references and procedure calls with no
  908.       --           parameters
  909.       J:=1;
  910.       K:=2;
  911.       L:=3;
  912.       E1(1):=1.0;
  913.       E1(2):=2.0;
  914.       E1(3):=3.0;
  915.       for I in 1..N9 loop
  916.         P0;
  917.       end loop;
  918.       --end Module 9
  919.       --
  920.       --Module 10: integer arithmetic
  921.       J:=2;
  922.       K:=3;
  923.       for I in 1..N10 loop
  924.         J:=J+K;
  925.         K:=J+K;
  926.         J:=K-J;
  927.         K:=K-J-J;
  928.       end loop;
  929.       --end Module 10
  930.       --Module 11: performing computations using standard
  931.       --            mathematical functions
  932.       X:=0.75;
  933.       for I in 1..N11 loop
  934.         X:=SQRT(EXP(LOG(X)/T1));
  935.       end loop;
  936.       --end Module 11
  937.     end loop CYCLE_LOOP;
  938.     --
  939.     STOP_TIME:= FLOAT(SECONDS(CLOCK)); --Get Whetstone stop time
  940.     --
  941.   end WHETSTONE;
  942.   --
  943.   --
  944.   procedure COMPUTE_WHETSTONE_KIPS is
  945.     --
  946.     --  Variables used to control execution of benchmark and to 
  947.     --  compute the Whetstone rating:
  948.     --
  949.     NO_OF_RUNS:  INTEGER;  --Number of times the benchmark is executed
  950.     NO_OF_CYCLES:  INTEGER;  --Number of times the group of benchmark
  951.                              --modules is executed
  952.     I: INTEGER;   --Factor weighting number of times each module loops.
  953.                   --A value of ten gives a total weight for modules
  954.                   --of approximately one million Whetstone instructions.
  955.     START_TIME:  FLOAT;   --Time at which execution of benchmark modules
  956.                           -- begins
  957.     STOP_TIME:  FLOAT;   --Time at which execution of benchmark modules 
  958.                          -- ends (time for NO_OF_CYCLES)
  959.     ELAPSED_TIME: FLOAT;    --Time between START_TIME and STOP_TIME
  960.     MEAN_TIME: FLOAT; --Average time per cycle
  961.     RATING: FLOAT;  --Thousands of Whetstone instructions per sec.
  962.     MEAN_RATING: FLOAT; --Average Whetstone rating
  963.     INT_RATING: INTEGER; --Integer value of KWIPS
  964.     DATA_FILE: FILE_TYPE; --File identifier
  965.     FILENAME: STRING (1..13) := "Wnnddhhmm.DAT";
  966.     --
  967.   begin
  968.     TIME_FILENAME (FILENAME);
  969.     CREATE(DATA_FILE, OUT_FILE, FILENAME, "");
  970.     READ_ENVIRON (DATA_FILE);
  971.     PUT_LINE(DATA_FILE," ADA Whetstone benchmark(WHETADAB.DEC)");NEW_LINE(DATA_FILE);
  972.     NEW_LINE; PUT_LINE(" ADA Whetstone benchmark(WHETADAB.DEC)");NEW_LINE;
  973.     --
  974.     MEAN_TIME:=0.0;
  975.     MEAN_RATING:=0.0;
  976.     NO_OF_CYCLES:=10;
  977.     NO_OF_RUNS:=5;
  978.     I:=10;
  979.     --
  980.     RUN_LOOP:
  981.     for RUN_NO in 1..NO_OF_RUNS loop
  982.       --
  983.       -- Call the Whetstone benchmark procedure
  984.       --
  985.       WHETSTONE (I, NO_OF_CYCLES, START_TIME, STOP_TIME);
  986.       --
  987.       -- Write the Whetstone start time
  988.       --
  989.       NEW_LINE; PUT(" Whetstone start time: "); PUT(START_TIME, 5, 2, 0);
  990.       PUT_LINE(" seconds");
  991.       NEW_LINE(DATA_FILE); PUT(DATA_FILE," Whetstone start time: ");
  992.       PUT(DATA_FILE, START_TIME, 5, 2, 0);PUT_LINE(DATA_FILE," seconds");
  993.       --
  994.       -- Write the Whetstone stop time
  995.       --
  996.       NEW_LINE; PUT(" Whetstone stop time: "); PUT(STOP_TIME, 5, 2, 0);
  997.       PUT_LINE(" seconds");
  998.       NEW_LINE(DATA_FILE); PUT(DATA_FILE," Whetstone stop time: ");
  999.       PUT(DATA_FILE, STOP_TIME, 5, 2, 0); PUT_LINE(DATA_FILE," seconds");
  1000.       --
  1001.       -- Compute and write the elapsed time
  1002.       --
  1003.       ELAPSED_TIME:= STOP_TIME - START_TIME;
  1004.       NEW_LINE; PUT(" Elapsed time for "); PUT(NO_OF_CYCLES, 3);
  1005.       PUT(" cycles: "); PUT(ELAPSED_TIME,5,2,0); PUT_LINE(" seconds");
  1006.       NEW_LINE(DATA_FILE); PUT(DATA_FILE," Elapsed time for ");
  1007.       PUT(DATA_FILE, NO_OF_CYCLES, 3); PUT(DATA_FILE," cycles: ");
  1008.       PUT(DATA_FILE,ELAPSED_TIME,5,2,0); PUT_LINE(DATA_FILE," seconds");
  1009.       --
  1010.       -- Sum time in milliseconds per cycle
  1011.       MEAN_TIME:= MEAN_TIME + (ELAPSED_TIME*1000.0)/FLOAT(NO_OF_CYCLES);
  1012.       --
  1013.       -- Calculate the Whetstone rating based on the time for the number
  1014.       --  of cycles just executed and write
  1015.       --
  1016.       RATING:= (1000.0*FLOAT(NO_OF_CYCLES))/ELAPSED_TIME;
  1017.       --
  1018.       -- Sum Whetstone rating
  1019.       MEAN_RATING:= MEAN_RATING + RATING;
  1020.       INT_RATING:= INTEGER(RATING);
  1021.       NEW_LINE;PUT(" Whetstone rating: ");PUT(INT_RATING);
  1022.       PUT_LINE(" KWIPS");NEW_LINE;
  1023.       NEW_LINE(DATA_FILE); PUT(DATA_FILE," Whetstone rating: ");
  1024.       PUT(DATA_FILE, INT_RATING); PUT_LINE(DATA_FILE," KWIPS");
  1025.       NEW_LINE(DATA_FILE);
  1026.       --
  1027.       -- Reset NO_OF_CYCLES for next run using ten cycles more
  1028.       --
  1029.       NO_OF_CYCLES:= NO_OF_CYCLES + 10;
  1030.     end loop RUN_LOOP;
  1031.     --
  1032.     -- Compute average time in milliseconds per cycle and write
  1033.     --
  1034.     MEAN_TIME:= MEAN_TIME/FLOAT(NO_OF_RUNS);
  1035.     NEW_LINE; PUT(" Average time per cycle: "); PUT(MEAN_TIME, 5, 2, 0);
  1036.     PUT_LINE(" milliseconds");
  1037.     NEW_LINE(DATA_FILE);
  1038.     PUT(DATA_FILE," Average time per cycle: ");
  1039.     PUT(DATA_FILE,MEAN_TIME,5,2,0); PUT_LINE(DATA_FILE," milliseconds");
  1040.     --
  1041.     -- Calculate average Whetstone rating and write
  1042.     -- 
  1043.     MEAN_RATING:= MEAN_RATING/FLOAT(NO_OF_RUNS);
  1044.     INT_RATING:= INTEGER(MEAN_RATING);
  1045.     NEW_LINE; PUT(" Average Whetstone rating: "); PUT(INT_RATING);
  1046.     PUT_LINE(" KWIPS");
  1047.     NEW_LINE(DATA_FILE); PUT(DATA_FILE," Average Whetstone rating: ");
  1048.     PUT(DATA_FILE, INT_RATING); PUT_LINE(DATA_FILE," KWIPS");
  1049.     CLOSE(DATA_FILE);
  1050.   end COMPUTE_WHETSTONE_KIPS;
  1051.   --
  1052. begin
  1053.   COMPUTE_WHETSTONE_KIPS;
  1054. end WHETADAB;
  1055.  
  1056. --###   48743 is the file CHECK-SUM number computed on  2/20/1985 at 14:34
  1057. --### CHECK-SUM := sum (ASCII values of all characters in this file) mod 2**16
  1058. --### -- (excluding these three lines) --
  1059. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1060. --whetadac.ada
  1061. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1062. --  Filename: WHETADAC.DEC
  1063. -- Version 1.1 of benchmark programs               (DS.2.14.85)
  1064. -- Ada version of Whetstone Benchmark Program.
  1065. -- Reference: "Computer Journal ," February 1976, pages 43-49,
  1066. --            for description of benchmark and ALGOL60 version.
  1067. -- Note: Procedure POUT is omitted.
  1068.  
  1069. with CALENDAR; use CALENDAR;
  1070. with TEXT_IO; use TEXT_IO;
  1071. with HELP_TOOLS; use HELP_TOOLS;
  1072. with IO_EXCEPTIONS; use IO_EXCEPTIONS;
  1073.  
  1074. --Comment out following if not use VAX Ada (version 1.0)
  1075. with FLOAT_MATH_LIB;use FLOAT_MATH_LIB;
  1076.  
  1077. --Comment out following with use to run with math library stubbed off
  1078. --with CORE_FUNCTIONS,TRIG_LIB;use CORE_FUNCTIONS,TRIG_LIB;
  1079. --Uncomment the following line to run with math library stubbed off
  1080. --with MATHSTUB; use MATHSTUB;
  1081.  
  1082. procedure WHETADAC is
  1083. --Comment out following pragma suppresses to run unsuppressed
  1084.   --pragma SUPPRESS(ACCESS_CHECK);
  1085.   --pragma SUPPRESS(DISCRIMINANT_CHECK);
  1086.   --pragma SUPPRESS(INDEX_CHECK);
  1087.   --pragma SUPPRESS(LENGTH_CHECK);
  1088.   --pragma SUPPRESS(RANGE_CHECK);
  1089.   --pragma SUPPRESS(DIVISION_CHECK);
  1090.   --pragma SUPPRESS(OVERFLOW_CHECK);
  1091.   --pragma SUPPRESS(STORAGE_CHECK);
  1092.   --pragma SUPPRESS(ELABORATION_CHECK);
  1093.   --
  1094.   package  INT_IO is new INTEGER_IO(INTEGER); use  INT_IO;
  1095.   package REAL_IO is new   FLOAT_IO(FLOAT)  ; use REAL_IO;
  1096.   procedure WHETSTONE (I, NO_OF_CYCLES: in INTEGER;
  1097.                       START_TIME, STOP_TIME: out FLOAT) is
  1098.     --
  1099.     --Calling procedure provides the loop count weight
  1100.     --factor, I, and the encompassing loop count, NO_OF_CYCLES.
  1101.     --
  1102.     type VECTOR is array (INTEGER range <>) of FLOAT;
  1103.     X1,X2,X3,X4,X,Y,Z,T,T1,T2: FLOAT;
  1104.     E1: VECTOR(1..4);
  1105.     J,K,L,N1,N2,N3,N4,N5,N6,N7,N8,N9,N10,N11: INTEGER;
  1106.     --
  1107.     procedure PA (E: in out VECTOR) is
  1108.       --tests computations with an array as a parameter
  1109.       J: INTEGER;
  1110.       -- T, T2 : FLOAT are global variables.
  1111.     begin
  1112.       J:=0;
  1113.       <<LAB>>
  1114.       E(1):= (E(1)+E(2)+E(3)-E(4))*T;
  1115.       E(2):= (E(1)+E(2)-E(3)+E(4))*T;
  1116.       E(3):= (E(1)-E(2)+E(3)+E(4))*T;
  1117.       E(4):= (-E(1)+E(2)+E(3)+E(4))/T2;
  1118.       J:=J+1;
  1119.       if J < 6 then
  1120.         goto LAB;
  1121.       end if;
  1122.     end PA;
  1123.     --
  1124.     procedure P0 is
  1125.       --tests computations with no parameters
  1126.       -- T1,T2: FLOAT are global
  1127.       -- E1: VECTOR(1..4) is global
  1128.       -- J,K,L: INTEGER are global
  1129.     begin
  1130.       E1(J):= E1(K);
  1131.       E1(K):= E1(L);
  1132.       E1(L):= E1(J);
  1133.     end P0;
  1134.     --
  1135.     procedure P3 (X,Y: in out FLOAT; Z: out FLOAT) is
  1136.       --tests computations with simple identifiers as parameters
  1137.       --   T,T2: FLOAT are global
  1138.     begin
  1139.       X:= T*(X+Y);
  1140.       Y:= T*(X+Y);
  1141.       Z:= (X+Y)/T2;
  1142.     end P3;
  1143.     --
  1144.   begin
  1145.     --Set constants
  1146.     T:= 0.499975;
  1147.     T1:= 0.50025;
  1148.     T2:= 2.0;
  1149.     --Compute the execution frequency for the benchmark modules.
  1150.     N1:= 0;  --Module 1 not executed.
  1151.     N2:= 12*I;
  1152.     N3:= 14*I;
  1153.     N4:= 345*I;
  1154.     N5:= 0;  --Module 5 not executed.
  1155.     N6:= 210*I;
  1156.     N7:= 32*I;
  1157.     N8:= 899*I;
  1158.     N9:= 616*I;
  1159.     N10:= 0;  --Module 10 not executed.
  1160.     N11:= 93*I;
  1161.     --
  1162.     START_TIME:= FLOAT(SECONDS(CLOCK)); --Get Whetstone start time
  1163.     --
  1164.     CYCLE_LOOP:
  1165.     for CYCLE_NO in 1..NO_OF_CYCLES loop
  1166.       --Module 1: computations with simple identifiers
  1167.       X1:= 1.0;
  1168.       X2:= -1.0;
  1169.       X3:= -1.0;
  1170.       X4:= -1.0;
  1171.       for I in 1..N1 loop
  1172.         X1:= (X1+X2+X3-X4)*T;
  1173.         X2:= (X1+X2-X3+X4)*T;
  1174.         X3:= (X1-X2+X3+X4)*T;
  1175.         X4:= (-X1+X2+X3+X4)*T;
  1176.       end loop;
  1177.       --end Module 1
  1178.       --
  1179.       --Module 2: computations with array elements
  1180.       E1(1):= 1.0;
  1181.       E1(2):= -1.0;
  1182.       E1(3):= -1.0;
  1183.       E1(4):= -1.0;
  1184.       for I in 1..N2 loop
  1185.         E1(1):= (E1(1)+E1(2)+E1(3)-E1(4))*T;
  1186.         E1(2):= (E1(1)+E1(2)-E1(3)+E1(4))*T;
  1187.         E1(3):= (E1(1)-E1(2)+E1(3)+E1(4))*T;
  1188.         E1(4):= (-E1(1)+E1(2)+E1(3)+E1(4))*T;
  1189.       end loop;
  1190.       --end Module 2
  1191.       --
  1192.       --Module 3: passing an array as a parameter 
  1193.       for I in 1..N3 loop
  1194.         PA(E1);
  1195.       end loop;
  1196.       --end Module 3
  1197.       --
  1198.       --Module 4: performing conditional jumps
  1199.       J:=1;
  1200.       for I in 1..N4 loop
  1201.         if J=1 then
  1202.           J:=2;
  1203.         else
  1204.           J:=3;
  1205.         end if;
  1206.         if J>2 then
  1207.           J:=0;
  1208.         else
  1209.           J:=1;
  1210.         end if;
  1211.         if J<1 then
  1212.           J:=1;
  1213.         else
  1214.           J:=0;
  1215.         end if;
  1216.       end loop;
  1217.       --end Module 4
  1218.       --
  1219.       --Module 5: omitted
  1220.       --
  1221.       --Module 6: performing integer arithmetic
  1222.       J:=1;
  1223.       K:=2;
  1224.       L:=3;
  1225.       for I in 1..N6 loop
  1226.         J:= J*(K-J)*(L-K);
  1227.         K:= L*K-(L-J)*K;
  1228.         L:= (L-K)*(K+J);
  1229.         E1(L-1):=FLOAT(J+K+L);
  1230.         E1(K-1):=FLOAT(J*K*L);
  1231.       end loop;
  1232.       --end Module 6
  1233.       --
  1234.       --Module 7: performing computations using trigonometric
  1235.       --           functions
  1236.       X:= 0.5;
  1237.       Y:= 0.5;
  1238.       for I in 1..N7 loop
  1239.         X:= T*ATAN(T2*SIN(X)*COS(X)/(COS(X+Y)+COS(X-Y)-1.0));
  1240.         Y:= T*ATAN(T2*SIN(Y)*COS(Y)/(COS(X+Y)+COS(X-Y)-1.0));
  1241.       end loop;
  1242.       --end Module 7
  1243.       --
  1244.       --Module 8: procedure calls with simple indentifiers as 
  1245.       --           parameters
  1246.       X:=1.0;
  1247.       Y:=1.0;
  1248.       Z:=1.0;
  1249.       for I in 1..N8 loop
  1250.         P3(X,Y,Z);
  1251.       end loop;
  1252.       --end Module 8
  1253.       --
  1254.       --Module 9: array references and procedure calls with no
  1255.       --           parameters
  1256.       J:=1;
  1257.       K:=2;
  1258.       L:=3;
  1259.       E1(1):=1.0;
  1260.       E1(2):=2.0;
  1261.       E1(3):=3.0;
  1262.       for I in 1..N9 loop
  1263.         P0;
  1264.       end loop;
  1265.       --end Module 9
  1266.       --
  1267.       --Module 10: integer arithmetic
  1268.       J:=2;
  1269.       K:=3;
  1270.       for I in 1..N10 loop
  1271.         J:=J+K;
  1272.         K:=J+K;
  1273.         J:=K-J;
  1274.         K:=K-J-J;
  1275.       end loop;
  1276.       --end Module 10
  1277.       --Module 11: performing computations using standard
  1278.       --            mathematical functions
  1279.       X:=0.75;
  1280.       for I in 1..N11 loop
  1281.         X:=SQRT(EXP(LOG(X)/T1));
  1282.       end loop;
  1283.       --end Module 11
  1284.     end loop CYCLE_LOOP;
  1285.     --
  1286.     STOP_TIME:= FLOAT(SECONDS(CLOCK)); --Get Whetstone stop time
  1287.     --
  1288.   end WHETSTONE;
  1289.   --
  1290.   --
  1291.   procedure COMPUTE_WHETSTONE_KIPS is
  1292.     --
  1293.     --  Variables used to control execution of benchmark and to 
  1294.     --  compute the Whetstone rating:
  1295.     --
  1296.     NO_OF_RUNS:  INTEGER;  --Number of times the benchmark is executed
  1297.     NO_OF_CYCLES:  INTEGER;  --Number of times the group of benchmark
  1298.                              --modules is executed
  1299.     I: INTEGER;   --Factor weighting number of times each module loops.
  1300.                   --A value of ten gives a total weight for modules
  1301.                   --of approximately one million Whetstone instructions.
  1302.     START_TIME:  FLOAT;   --Time at which execution of benchmark modules
  1303.                           -- begins
  1304.     STOP_TIME:  FLOAT;   --Time at which execution of benchmark modules 
  1305.                          -- ends (time for NO_OF_CYCLES)
  1306.     ELAPSED_TIME: FLOAT;    --Time between START_TIME and STOP_TIME
  1307.     MEAN_TIME: FLOAT; --Average time per cycle
  1308.     RATING: FLOAT;  --Thousands of Whetstone instructions per sec.
  1309.     MEAN_RATING: FLOAT; --Average Whetstone rating
  1310.     INT_RATING: INTEGER; --Integer value of KWIPS
  1311.     DATA_FILE: FILE_TYPE; --File identifier
  1312.     FILENAME: STRING (1..13) := "Wnnddhhmm.DAT";
  1313.     --
  1314.   begin
  1315.     TIME_FILENAME (FILENAME);
  1316.     CREATE(DATA_FILE, OUT_FILE, FILENAME, "");
  1317.     READ_ENVIRON (DATA_FILE);
  1318.     PUT_LINE(DATA_FILE," ADA Whetstone benchmark(WHETADAC.DEC)");NEW_LINE(DATA_FILE);
  1319.     NEW_LINE; PUT_LINE(" ADA Whetstone benchmark(WHETADAC.DEC)");NEW_LINE;
  1320.     --
  1321.     MEAN_TIME:=0.0;
  1322.     MEAN_RATING:=0.0;
  1323.     NO_OF_CYCLES:=10;
  1324.     NO_OF_RUNS:=5;
  1325.     I:=10;
  1326.     --
  1327.     RUN_LOOP:
  1328.     for RUN_NO in 1..NO_OF_RUNS loop
  1329.       --
  1330.       -- Call the Whetstone benchmark procedure
  1331.       --
  1332.       WHETSTONE (I, NO_OF_CYCLES, START_TIME, STOP_TIME);
  1333.       --
  1334.       -- Write the Whetstone start time
  1335.       --
  1336.       NEW_LINE; PUT(" Whetstone start time: "); PUT(START_TIME, 5, 2, 0);
  1337.       PUT_LINE(" seconds");
  1338.       NEW_LINE(DATA_FILE); PUT(DATA_FILE," Whetstone start time: ");
  1339.       PUT(DATA_FILE, START_TIME, 5, 2, 0);PUT_LINE(DATA_FILE," seconds");
  1340.       --
  1341.       -- Write the Whetstone stop time
  1342.       --
  1343.       NEW_LINE; PUT(" Whetstone stop time: "); PUT(STOP_TIME, 5, 2, 0);
  1344.       PUT_LINE(" seconds");
  1345.       NEW_LINE(DATA_FILE); PUT(DATA_FILE," Whetstone stop time: ");
  1346.       PUT(DATA_FILE, STOP_TIME, 5, 2, 0); PUT_LINE(DATA_FILE," seconds");
  1347.       --
  1348.       -- Compute and write the elapsed time
  1349.       --
  1350.       ELAPSED_TIME:= STOP_TIME - START_TIME;
  1351.       NEW_LINE; PUT(" Elapsed time for "); PUT(NO_OF_CYCLES, 3);
  1352.       PUT(" cycles: "); PUT(ELAPSED_TIME,5,2,0); PUT_LINE(" seconds");
  1353.       NEW_LINE(DATA_FILE); PUT(DATA_FILE," Elapsed time for ");
  1354.       PUT(DATA_FILE, NO_OF_CYCLES, 3); PUT(DATA_FILE," cycles: ");
  1355.       PUT(DATA_FILE,ELAPSED_TIME,5,2,0); PUT_LINE(DATA_FILE," seconds");
  1356.       --
  1357.       -- Sum time in milliseconds per cycle
  1358.       MEAN_TIME:= MEAN_TIME + (ELAPSED_TIME*1000.0)/FLOAT(NO_OF_CYCLES);
  1359.       --
  1360.       -- Calculate the Whetstone rating based on the time for the number
  1361.       --  of cycles just executed and write
  1362.       --
  1363.       RATING:= (1000.0*FLOAT(NO_OF_CYCLES))/ELAPSED_TIME;
  1364.       --
  1365.       -- Sum Whetstone rating
  1366.       MEAN_RATING:= MEAN_RATING + RATING;
  1367.       INT_RATING:= INTEGER(RATING);
  1368.       NEW_LINE;PUT(" Whetstone rating: ");PUT(INT_RATING);
  1369.       PUT_LINE(" KWIPS");NEW_LINE;
  1370.       NEW_LINE(DATA_FILE); PUT(DATA_FILE," Whetstone rating: ");
  1371.       PUT(DATA_FILE, INT_RATING); PUT_LINE(DATA_FILE," KWIPS");
  1372.       NEW_LINE(DATA_FILE);
  1373.       --
  1374.       -- Reset NO_OF_CYCLES for next run using ten cycles more
  1375.       --
  1376.       NO_OF_CYCLES:= NO_OF_CYCLES + 10;
  1377.     end loop RUN_LOOP;
  1378.     --
  1379.     -- Compute average time in milliseconds per cycle and write
  1380.     --
  1381.     MEAN_TIME:= MEAN_TIME/FLOAT(NO_OF_RUNS);
  1382.     NEW_LINE; PUT(" Average time per cycle: "); PUT(MEAN_TIME, 5, 2, 0);
  1383.     PUT_LINE(" milliseconds");
  1384.     NEW_LINE(DATA_FILE);
  1385.     PUT(DATA_FILE," Average time per cycle: ");
  1386.     PUT(DATA_FILE,MEAN_TIME,5,2,0); PUT_LINE(DATA_FILE," milliseconds");
  1387.     --
  1388.     -- Calculate average Whetstone rating and write
  1389.     -- 
  1390.     MEAN_RATING:= MEAN_RATING/FLOAT(NO_OF_RUNS);
  1391.     INT_RATING:= INTEGER(MEAN_RATING);
  1392.     NEW_LINE; PUT(" Average Whetstone rating: "); PUT(INT_RATING);
  1393.     PUT_LINE(" KWIPS");
  1394.     NEW_LINE(DATA_FILE); PUT(DATA_FILE," Average Whetstone rating: ");
  1395.     PUT(DATA_FILE, INT_RATING); PUT_LINE(DATA_FILE," KWIPS");
  1396.     CLOSE(DATA_FILE);
  1397.   end COMPUTE_WHETSTONE_KIPS;
  1398.   --
  1399. begin
  1400.   COMPUTE_WHETSTONE_KIPS;
  1401. end WHETADAC;
  1402.  
  1403. --Comment out next line if not VAX Ada version (1.0)
  1404.   pragma SUPPRESS_ALL;
  1405.  
  1406. --###   32644 is the file CHECK-SUM number computed on  2/20/1985 at 14:34
  1407. --### CHECK-SUM := sum (ASCII values of all characters in this file) mod 2**16
  1408. --### -- (excluding these three lines) --
  1409. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1410. --whetadad.ada
  1411. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1412. --  Filename: WHETADAD.DEC
  1413. -- Version 1.1 of benchmark programs               (DS.2.14.85)
  1414. -- Ada version of Whetstone Benchmark Program.
  1415. -- Reference: "Computer Journal ," February 1976, pages 43-49,
  1416. --            for description of benchmark and ALGOL60 version.
  1417. -- Note: Procedure POUT is omitted.
  1418.  
  1419. with CALENDAR; use CALENDAR;
  1420. with TEXT_IO; use TEXT_IO;
  1421. with HELP_TOOLS; use HELP_TOOLS;
  1422. with IO_EXCEPTIONS; use IO_EXCEPTIONS;
  1423.  
  1424. --Comment out following with use to run with math library stubbed off
  1425. --if not for VAX Ada (version 1.0)
  1426. with FLOAT_MATH_LIB; use FLOAT_MATH_LIB;
  1427.  
  1428. --Comment out following with use to run with math library stubbed off
  1429. --with CORE_FUNCTIONS,TRIG_LIB;use CORE_FUNCTIONS,TRIG_LIB;
  1430. --Uncomment the following line to run with math library stubbed off
  1431. --with MATHSTUB; use MATHSTUB;
  1432.  
  1433. procedure WHETADAD is
  1434. --Comment out following pragma suppresses to run unsuppressed
  1435.   --pragma SUPPRESS(ACCESS_CHECK);
  1436.   --pragma SUPPRESS(DISCRIMINANT_CHECK);
  1437.   --pragma SUPPRESS(INDEX_CHECK);
  1438.   --pragma SUPPRESS(LENGTH_CHECK);
  1439.   --pragma SUPPRESS(RANGE_CHECK);
  1440.   --pragma SUPPRESS(DIVISION_CHECK);
  1441.   --pragma SUPPRESS(OVERFLOW_CHECK);
  1442.   --pragma SUPPRESS(STORAGE_CHECK);
  1443.   --pragma SUPPRESS(ELABORATION_CHECK);
  1444.   --
  1445.   package  INT_IO is new INTEGER_IO(INTEGER); use  INT_IO;
  1446.   package REAL_IO is new   FLOAT_IO(FLOAT)  ; use REAL_IO;
  1447.   procedure WHETSTONE (I, NO_OF_CYCLES: in INTEGER;
  1448.                       START_TIME, STOP_TIME: out FLOAT) is
  1449.     --
  1450.     --Calling procedure provides the loop count weight
  1451.     --factor, I, and the encompassing loop count, NO_OF_CYCLES.
  1452.     --
  1453.     type VECTOR is array (INTEGER range <>) of FLOAT;
  1454.     X1,X2,X3,X4,X,Y,Z,T,T1,T2: FLOAT;
  1455.     E1: VECTOR(1..4);
  1456.     J,K,L,N1,N2,N3,N4,N5,N6,N7,N8,N9,N10,N11: INTEGER;
  1457.     --
  1458.     procedure PA (E: in out VECTOR) is
  1459.       --tests computations with an array as a parameter
  1460.       J: INTEGER;
  1461.       -- T, T2 : FLOAT are global variables.
  1462.     begin
  1463.       J:=0;
  1464.       <<LAB>>
  1465.       E(1):= (E(1)+E(2)+E(3)-E(4))*T;
  1466.       E(2):= (E(1)+E(2)-E(3)+E(4))*T;
  1467.       E(3):= (E(1)-E(2)+E(3)+E(4))*T;
  1468.       E(4):= (-E(1)+E(2)+E(3)+E(4))/T2;
  1469.       J:=J+1;
  1470.       if J < 6 then
  1471.         goto LAB;
  1472.       end if;
  1473.     end PA;
  1474.     --
  1475.     procedure P0 is
  1476.       --tests computations with no parameters
  1477.       -- T1,T2: FLOAT are global
  1478.       -- E1: VECTOR(1..4) is global
  1479.       -- J,K,L: INTEGER are global
  1480.     begin
  1481.       E1(J):= E1(K);
  1482.       E1(K):= E1(L);
  1483.       E1(L):= E1(J);
  1484.     end P0;
  1485.     --
  1486.     procedure P3 (X,Y: in out FLOAT; Z: out FLOAT) is
  1487.       --tests computations with simple identifiers as parameters
  1488.       --   T,T2: FLOAT are global
  1489.     begin
  1490.       X:= T*(X+Y);
  1491.       Y:= T*(X+Y);
  1492.       Z:= (X+Y)/T2;
  1493.     end P3;
  1494.     --
  1495.   begin
  1496.     --Set constants
  1497.     T:= 0.499975;
  1498.     T1:= 0.50025;
  1499.     T2:= 2.0;
  1500.     --Compute the execution frequency for the benchmark modules.
  1501.     N1:= 0;  --Module 1 not executed.
  1502.     N2:= 12*I;
  1503.     N3:= 14*I;
  1504.     N4:= 345*I;
  1505.     N5:= 0;  --Module 5 not executed.
  1506.     N6:= 210*I;
  1507.     N7:= 32*I;
  1508.     N8:= 899*I;
  1509.     N9:= 616*I;
  1510.     N10:= 0;  --Module 10 not executed.
  1511.     N11:= 93*I;
  1512.     --
  1513.     START_TIME:= FLOAT(SECONDS(CLOCK)); --Get Whetstone start time
  1514.     --
  1515.     CYCLE_LOOP:
  1516.     for CYCLE_NO in 1..NO_OF_CYCLES loop
  1517.       --Module 1: computations with simple identifiers
  1518.       X1:= 1.0;
  1519.       X2:= -1.0;
  1520.       X3:= -1.0;
  1521.       X4:= -1.0;
  1522.       for I in 1..N1 loop
  1523.         X1:= (X1+X2+X3-X4)*T;
  1524.         X2:= (X1+X2-X3+X4)*T;
  1525.         X3:= (X1-X2+X3+X4)*T;
  1526.         X4:= (-X1+X2+X3+X4)*T;
  1527.       end loop;
  1528.       --end Module 1
  1529.       --
  1530.       --Module 2: computations with array elements
  1531.       E1(1):= 1.0;
  1532.       E1(2):= -1.0;
  1533.       E1(3):= -1.0;
  1534.       E1(4):= -1.0;
  1535.       for I in 1..N2 loop
  1536.         E1(1):= (E1(1)+E1(2)+E1(3)-E1(4))*T;
  1537.         E1(2):= (E1(1)+E1(2)-E1(3)+E1(4))*T;
  1538.         E1(3):= (E1(1)-E1(2)+E1(3)+E1(4))*T;
  1539.         E1(4):= (-E1(1)+E1(2)+E1(3)+E1(4))*T;
  1540.       end loop;
  1541.       --end Module 2
  1542.       --
  1543.       --Module 3: passing an array as a parameter 
  1544.       for I in 1..N3 loop
  1545.         PA(E1);
  1546.       end loop;
  1547.       --end Module 3
  1548.       --
  1549.       --Module 4: performing conditional jumps
  1550.       J:=1;
  1551.       for I in 1..N4 loop
  1552.         if J=1 then
  1553.           J:=2;
  1554.         else
  1555.           J:=3;
  1556.         end if;
  1557.         if J>2 then
  1558.           J:=0;
  1559.         else
  1560.           J:=1;
  1561.         end if;
  1562.         if J<1 then
  1563.           J:=1;
  1564.         else
  1565.           J:=0;
  1566.         end if;
  1567.       end loop;
  1568.       --end Module 4
  1569.       --
  1570.       --Module 5: omitted
  1571.       --
  1572.       --Module 6: performing integer arithmetic
  1573.       J:=1;
  1574.       K:=2;
  1575.       L:=3;
  1576.       for I in 1..N6 loop
  1577.         J:= J*(K-J)*(L-K);
  1578.         K:= L*K-(L-J)*K;
  1579.         L:= (L-K)*(K+J);
  1580.         E1(L-1):=FLOAT(J+K+L);
  1581.         E1(K-1):=FLOAT(J*K*L);
  1582.       end loop;
  1583.       --end Module 6
  1584.       --
  1585.       --Module 7: performing computations using trigonometric
  1586.       --           functions
  1587.       X:= 0.5;
  1588.       Y:= 0.5;
  1589.       for I in 1..N7 loop
  1590.         X:= T*ATAN(T2*SIN(X)*COS(X)/(COS(X+Y)+COS(X-Y)-1.0));
  1591.         Y:= T*ATAN(T2*SIN(Y)*COS(Y)/(COS(X+Y)+COS(X-Y)-1.0));
  1592.       end loop;
  1593.       --end Module 7
  1594.       --
  1595.       --Module 8: procedure calls with simple indentifiers as 
  1596.       --           parameters
  1597.       X:=1.0;
  1598.       Y:=1.0;
  1599.       Z:=1.0;
  1600.       for I in 1..N8 loop
  1601.         P3(X,Y,Z);
  1602.       end loop;
  1603.       --end Module 8
  1604.       --
  1605.       --Module 9: array references and procedure calls with no
  1606.       --           parameters
  1607.       J:=1;
  1608.       K:=2;
  1609.       L:=3;
  1610.       E1(1):=1.0;
  1611.       E1(2):=2.0;
  1612.       E1(3):=3.0;
  1613.       for I in 1..N9 loop
  1614.         P0;
  1615.       end loop;
  1616.       --end Module 9
  1617.       --
  1618.       --Module 10: integer arithmetic
  1619.       J:=2;
  1620.       K:=3;
  1621.       for I in 1..N10 loop
  1622.         J:=J+K;
  1623.         K:=J+K;
  1624.         J:=K-J;
  1625.         K:=K-J-J;
  1626.       end loop;
  1627.       --end Module 10
  1628.       --Module 11: performing computations using standard
  1629.       --            mathematical functions
  1630.       X:=0.75;
  1631.       for I in 1..N11 loop
  1632.         X:=SQRT(EXP(LOG(X)/T1));
  1633.       end loop;
  1634.       --end Module 11
  1635.     end loop CYCLE_LOOP;
  1636.     --
  1637.     STOP_TIME:= FLOAT(SECONDS(CLOCK)); --Get Whetstone stop time
  1638.     --
  1639.   end WHETSTONE;
  1640.   --
  1641.   --
  1642.   procedure COMPUTE_WHETSTONE_KIPS is
  1643.     --
  1644.     --  Variables used to control execution of benchmark and to 
  1645.     --  compute the Whetstone rating:
  1646.     --
  1647.     NO_OF_RUNS:  INTEGER;  --Number of times the benchmark is executed
  1648.     NO_OF_CYCLES:  INTEGER;  --Number of times the group of benchmark
  1649.                              --modules is executed
  1650.     I: INTEGER;   --Factor weighting number of times each module loops.
  1651.                   --A value of ten gives a total weight for modules
  1652.                   --of approximately one million Whetstone instructions.
  1653.     START_TIME:  FLOAT;   --Time at which execution of benchmark modules
  1654.                           -- begins
  1655.     STOP_TIME:  FLOAT;   --Time at which execution of benchmark modules 
  1656.                          -- ends (time for NO_OF_CYCLES)
  1657.     ELAPSED_TIME: FLOAT;    --Time between START_TIME and STOP_TIME
  1658.     MEAN_TIME: FLOAT; --Average time per cycle
  1659.     RATING: FLOAT;  --Thousands of Whetstone instructions per sec.
  1660.     MEAN_RATING: FLOAT; --Average Whetstone rating
  1661.     INT_RATING: INTEGER; --Integer value of KWIPS
  1662.     DATA_FILE: FILE_TYPE; --File identifier
  1663.     FILENAME: STRING (1..13) := "Wnnddhhmm.DAT";
  1664.     --
  1665.   begin
  1666.     TIME_FILENAME (FILENAME);
  1667.     CREATE(DATA_FILE, OUT_FILE, FILENAME, "");
  1668.     READ_ENVIRON (DATA_FILE);
  1669.     PUT_LINE(DATA_FILE," ADA Whetstone benchmark(WHETADAD.DEC)");NEW_LINE(DATA_FILE);
  1670.     NEW_LINE; PUT_LINE(" ADA Whetstone benchmark(WHETADAD.DEC)");NEW_LINE;
  1671.     --
  1672.     MEAN_TIME:=0.0;
  1673.     MEAN_RATING:=0.0;
  1674.     NO_OF_CYCLES:=10;
  1675.     NO_OF_RUNS:=5;
  1676.     I:=10;
  1677.     --
  1678.     RUN_LOOP:
  1679.     for RUN_NO in 1..NO_OF_RUNS loop
  1680.       --
  1681.       -- Call the Whetstone benchmark procedure
  1682.       --
  1683.       WHETSTONE (I, NO_OF_CYCLES, START_TIME, STOP_TIME);
  1684.       --
  1685.       -- Write the Whetstone start time
  1686.       --
  1687.       NEW_LINE; PUT(" Whetstone start time: "); PUT(START_TIME, 5, 2, 0);
  1688.       PUT_LINE(" seconds");
  1689.       NEW_LINE(DATA_FILE); PUT(DATA_FILE," Whetstone start time: ");
  1690.       PUT(DATA_FILE, START_TIME, 5, 2, 0);PUT_LINE(DATA_FILE," seconds");
  1691.       --
  1692.       -- Write the Whetstone stop time
  1693.       --
  1694.       NEW_LINE; PUT(" Whetstone stop time: "); PUT(STOP_TIME, 5, 2, 0);
  1695.       PUT_LINE(" seconds");
  1696.       NEW_LINE(DATA_FILE); PUT(DATA_FILE," Whetstone stop time: ");
  1697.       PUT(DATA_FILE, STOP_TIME, 5, 2, 0); PUT_LINE(DATA_FILE," seconds");
  1698.       --
  1699.       -- Compute and write the elapsed time
  1700.       --
  1701.       ELAPSED_TIME:= STOP_TIME - START_TIME;
  1702.       NEW_LINE; PUT(" Elapsed time for "); PUT(NO_OF_CYCLES, 3);
  1703.       PUT(" cycles: "); PUT(ELAPSED_TIME,5,2,0); PUT_LINE(" seconds");
  1704.       NEW_LINE(DATA_FILE); PUT(DATA_FILE," Elapsed time for ");
  1705.       PUT(DATA_FILE, NO_OF_CYCLES, 3); PUT(DATA_FILE," cycles: ");
  1706.       PUT(DATA_FILE,ELAPSED_TIME,5,2,0); PUT_LINE(DATA_FILE," seconds");
  1707.       --
  1708.       -- Sum time in milliseconds per cycle
  1709.       MEAN_TIME:= MEAN_TIME + (ELAPSED_TIME*1000.0)/FLOAT(NO_OF_CYCLES);
  1710.       --
  1711.       -- Calculate the Whetstone rating based on the time for the number
  1712.       --  of cycles just executed and write
  1713.       --
  1714.       RATING:= (1000.0*FLOAT(NO_OF_CYCLES))/ELAPSED_TIME;
  1715.       --
  1716.       -- Sum Whetstone rating
  1717.       MEAN_RATING:= MEAN_RATING + RATING;
  1718.       INT_RATING:= INTEGER(RATING);
  1719.       NEW_LINE;PUT(" Whetstone rating: ");PUT(INT_RATING);
  1720.       PUT_LINE(" KWIPS");NEW_LINE;
  1721.       NEW_LINE(DATA_FILE); PUT(DATA_FILE," Whetstone rating: ");
  1722.       PUT(DATA_FILE, INT_RATING); PUT_LINE(DATA_FILE," KWIPS");
  1723.       NEW_LINE(DATA_FILE);
  1724.       --
  1725.       -- Reset NO_OF_CYCLES for next run using ten cycles more
  1726.       --
  1727.       NO_OF_CYCLES:= NO_OF_CYCLES + 10;
  1728.     end loop RUN_LOOP;
  1729.     --
  1730.     -- Compute average time in milliseconds per cycle and write
  1731.     --
  1732.     MEAN_TIME:= MEAN_TIME/FLOAT(NO_OF_RUNS);
  1733.     NEW_LINE; PUT(" Average time per cycle: "); PUT(MEAN_TIME, 5, 2, 0);
  1734.     PUT_LINE(" milliseconds");
  1735.     NEW_LINE(DATA_FILE);
  1736.     PUT(DATA_FILE," Average time per cycle: ");
  1737.     PUT(DATA_FILE,MEAN_TIME,5,2,0); PUT_LINE(DATA_FILE," milliseconds");
  1738.     --
  1739.     -- Calculate average Whetstone rating and write
  1740.     -- 
  1741.     MEAN_RATING:= MEAN_RATING/FLOAT(NO_OF_RUNS);
  1742.     INT_RATING:= INTEGER(MEAN_RATING);
  1743.     NEW_LINE; PUT(" Average Whetstone rating: "); PUT(INT_RATING);
  1744.     PUT_LINE(" KWIPS");
  1745.     NEW_LINE(DATA_FILE); PUT(DATA_FILE," Average Whetstone rating: ");
  1746.     PUT(DATA_FILE, INT_RATING); PUT_LINE(DATA_FILE," KWIPS");
  1747.     CLOSE(DATA_FILE);
  1748.   end COMPUTE_WHETSTONE_KIPS;
  1749.   --
  1750. begin
  1751.   COMPUTE_WHETSTONE_KIPS;
  1752. end WHETADAD;
  1753.  
  1754. --###   23622 is the file CHECK-SUM number computed on  2/20/1985 at 14:34
  1755. --### CHECK-SUM := sum (ASCII values of all characters in this file) mod 2**16
  1756. --### -- (excluding these three lines) --
  1757. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1758. --dhryadaa.ada
  1759. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1760. -------------------------------------------------------------------------------
  1761. --                                                                           --
  1762. --                   "DHRYSTONE" Benchmark Program                           --
  1763. --                  --------------------------------                         --
  1764. --                                                                           --
  1765. --     Version: ADA/1                                                        --
  1766. --                                                                           --
  1767. --     Date:    04/15/84                                                     --
  1768. --                                                                           --
  1769. --     Author:  Reinhold P. Weicker                                          --
  1770. --                                         --
  1771. --     Filename:  DHRYADAA.DEC                             --
  1772. --                                         --
  1773. --     History:                                     --
  1774. --                                         --
  1775. --       CHANGE MADE                 BY WHOM               DATE             --
  1776. --     -----------            ---------              -------           --
  1777. --                                                                           --
  1778. --       added timing calls         D. Sayon           13 Feb 85         --
  1779. --        to write to file                                                   --
  1780. --                                                                           --
  1781. -------------------------------------------------------------------------------
  1782. --                                                                           --
  1783. --  The following program contains statements of a high-level programming    --
  1784. --  language (Ada) in a distribution considered representative:              --
  1785. --                                                                           --
  1786. --    assignments                53%                                         --
  1787. --    control statements         32%                                         --
  1788. --    procedure, function calls  15%                                         --
  1789.  
  1790. --                                                                           --
  1791. --  100 statements are dynamically executed.  The program is balanced with   --
  1792. --  respect to the three aspects:                                            --
  1793. --                                                                           --
  1794. --    -statement type                                                        --
  1795. --    -operand type (for simple data types)                                  --
  1796. --    -operand access                                                        --
  1797. --        operand global, local, parameter, or constant.                     --
  1798. --                                                                           --
  1799. --  The combination of these three aspects is balanced only approximately.   --
  1800. --                                                                           --
  1801. --  The program does not compute anything meaningful, but it is syntacially  --
  1802. --  and semantically correct.  All variables have a value assigned to them   --
  1803. --  before they are used as a source operand.                                --
  1804. -------------------------------------------------------------------------------
  1805. package Global_Def is
  1806. ------------------
  1807. --  Global type definitions
  1808.  
  1809. type Enumeration is (Ident_1,Ident_2,Ident_3,Ident_4,Ident_5);
  1810.  
  1811. subtype One_To_Thirty is integer range 1..30;
  1812. subtype One_To_Fifty is integer range 1..50;
  1813. subtype Capital_Letter is character range 'A'..'Z';
  1814.  
  1815. type String_30 is array(One_To_Thirty)of character;
  1816.   pragma Pack(String_30);
  1817.  
  1818. type Array_1_Dim_Integer is array(One_To_Fifty)of integer;
  1819. type Array_2_Dim_Integer is array(One_To_Fifty,
  1820.                                   One_To_Fifty)of integer;
  1821.  
  1822. type Record_Type(Discr:Enumeration := Ident_1);
  1823.  
  1824. type Record_Pointer is access Record_Type;
  1825.  
  1826. type Record_Type(Discr:Enumeration := Ident_1)is
  1827.     record
  1828.       Pointer_Comp:      Record_Pointer;
  1829.       case Discr is
  1830.       when Ident_1 =>     -- only this variant is used,
  1831.                           -- but in some cases discriminant
  1832.                           -- checks are necessary
  1833.  
  1834.         Enum_Comp:       Enumeration;
  1835.         Int_Comp:        One_To_Fifty;
  1836.         String_Comp:     String_30;
  1837.       when Ident_2 =>
  1838.         Enum_Comp_2:     Enumeration;
  1839.         String_Comp_2:   String_30;
  1840.       when others =>
  1841.         Char_Comp_1,
  1842.         Char_Comp_2:     character;
  1843.       end case;
  1844.     end record;
  1845.  
  1846. end Global_Def;
  1847.  
  1848.   with Global_Def,Calendar;
  1849.   use Global_Def,Calendar;
  1850.  
  1851. package Pack_1 is
  1852. -------------
  1853.  
  1854.   procedure Proc_0(cycles: in integer; start_time, stop_time: out Float);
  1855.   procedure Proc_1(Pointer_Par_in:  in      Record_Pointer);
  1856.   procedure Proc_2(Int_Par_In_Out:  in out  One_To_Fifty);
  1857.   procedure Proc_3(Pointer_Par_Out: out     Record_Pointer);
  1858.  
  1859.   Int_Glob:        integer;
  1860.  
  1861. end Pack_1;
  1862.  
  1863. with Global_Def;
  1864. use Global_Def;
  1865.  
  1866. package Pack_2 is
  1867. --------------
  1868.  
  1869.   procedure Proc_6 (Enum_Par_In:         in      Enumeration;
  1870.                     Enum_Par_Out:        out     Enumeration);
  1871.   procedure Proc_7 (Int_Par_In_1,
  1872.                     Int_Par_In_2:        in      One_To_Fifty;
  1873.                     Int_Par_Out:         out     One_To_Fifty);
  1874.   procedure Proc_8 (Array_Par_In_Out_1:  in out  Array_1_Dim_Integer;
  1875.                     Array_Par_In_Out_2:  in out  Array_2_Dim_Integer;
  1876.                     Int_Par_In_1,
  1877.                     Int_Par_In_2:        in      integer);
  1878.   function Func_1  (Char_Par_In_1,
  1879.                     Char_Par_In_2:       in      Capital_Letter)
  1880.                                                  return Enumeration;
  1881.   function Func_2  (String_Par_In_1,
  1882.                     String_Par_In_2:     in      String_30)
  1883.                                                    return boolean;
  1884.  
  1885. end Pack_2;      
  1886.  
  1887. with Global_Def,Pack_1,Text_IO, Help_Tools;
  1888. use Global_Def, Text_IO, Help_Tools; 
  1889.  
  1890. procedure Dhryadaa is
  1891. --------------
  1892.  
  1893. package real_io is new float_io(float); 
  1894. use real_io;
  1895.  
  1896. package int_io is new integer_io(integer); 
  1897. use int_io;
  1898.  
  1899. filename:    string (1..13);
  1900.  
  1901. int_rating,
  1902. No_of_Cycles,
  1903. No_of_Runs :    integer;
  1904.  
  1905. mean_rating,
  1906. rating,
  1907. mean_time,
  1908. elapsed_time,
  1909. start_time,
  1910. stop_time:    float;
  1911.  
  1912. data_file:    file_type;
  1913.  
  1914. begin
  1915.  
  1916.  mean_time := 0.0;
  1917.  mean_rating := 0.0;
  1918.  No_of_Runs := 5;
  1919.  
  1920.  time_filename (filename);
  1921.  filename(1) := 'D';
  1922.  create (data_file,out_file,filename,"");
  1923.  
  1924.  read_environ(data_file);
  1925.  
  1926.  put("ADA Dhrystone Benchmark (DHRYADAA.DEC)"); new_line;
  1927.  put(data_file,"ADA Dhrystone Benchmark (DHRYADAA.DEC)");new_line(data_file); 
  1928.  
  1929.  for N in 1..No_of_Runs loop  
  1930.  
  1931.   No_of_Cycles := N*100;  
  1932.  
  1933.   Pack_1.Proc_0(No_of_Cycles,start_time,stop_time);
  1934.         -- Proc_0 is actually the main program, but it is part
  1935.                 -- of a package, and a program within a package can
  1936.                 -- not be designated as the Dhryadaa program for execution.
  1937.                 -- Therefore Proc_0 is activated by a call from "Dhryadaa".
  1938.  
  1939. --
  1940. --  WRITE OUT TIMING RESULTS
  1941. --
  1942. --
  1943. --  write out start time
  1944. --
  1945.  
  1946.   new_line; put (" Dhrystone start time: ");put (start_time, 5, 2, 0);
  1947.   put (" seconds"); new_line;
  1948.   new_line(data_file); put (data_file," Dhrystone start time: ");
  1949.   put (data_file,start_time, 5, 2, 0);
  1950.   put (data_file," seconds"); new_line(data_file);
  1951.  
  1952. --
  1953. --  write out stop time
  1954. --
  1955.  
  1956.   put (" Dhrystone stop time: ");put (stop_time, 5, 2, 0);
  1957.   put (" seconds");new_line; 
  1958.   put (data_file," Dhrystone stop time: ");
  1959.   put (data_file,stop_time, 5, 2, 0);
  1960.   put (data_file," seconds");
  1961.   new_line(data_file);
  1962.  
  1963. --
  1964. --  write out elapsed time
  1965. --
  1966.  
  1967.   elapsed_time := stop_time - start_time;
  1968.   put (" Elapsed time for ");put (no_of_cycles, 3);
  1969.   put (" cycles: ");put(elapsed_time, 5,2,0); put(" seconds ");
  1970.   new_line;
  1971.   put (data_file," Elapsed time for ");
  1972.   put (data_file,no_of_cycles, 3);
  1973.   put (data_file," cycles: ");put(data_file,elapsed_time, 5,2,0); 
  1974.   put (data_file," seconds ");
  1975.   new_line(data_file);
  1976.  
  1977. --
  1978. --  Sum the time in millisecs per cycle 
  1979. --
  1980.  
  1981.   mean_time := mean_time + (elapsed_time*1000.0)/float(no_of_cycles);
  1982.  
  1983. --
  1984. --  Compute the Dhrystone rating based on the time for the number
  1985. --    of cycles just executed and write 
  1986. --
  1987. --   RATING =  (100 statements/cycle * number of cycles)/elapsed time
  1988. --
  1989.  
  1990.   rating := (100.0*FLOAT(NO_OF_CYCLES))/ELAPSED_TIME;
  1991.  
  1992. --
  1993. --  Sum Dhrystone rating
  1994. --
  1995.  
  1996.   mean_rating := mean_rating + rating;
  1997.   int_rating := integer(rating);
  1998.   put (" Dhrystone rating:  "); put(int_rating);
  1999.   put (" statement execution per unit time "); new_line;
  2000.   put(data_file," Dhrystone rating:  ");
  2001.   put(data_file, int_rating);
  2002.   put(data_file," statement execution per unit time ");
  2003.   new_line(data_file);
  2004.  
  2005.  end loop;
  2006.  
  2007. --
  2008. --  Calculate the average time in millisecs per cycle
  2009. --
  2010.  
  2011.  mean_time := mean_time/float(no_of_runs);
  2012.  new_line; put (" Average time per cycle: "); put (mean_time,5,2,0);
  2013.  put_line (" millisecs ");
  2014.  new_line (data_file);
  2015.  put (data_file," Average time per cycle: "); put (data_file,mean_time,5,2,0);
  2016.  put (data_file," millisecs ");
  2017.  
  2018. --
  2019. --  Calculate the average Dhrystone ratings
  2020. --
  2021.  
  2022.  mean_rating := mean_rating/float(no_of_runs);
  2023.  int_rating :=    integer(mean_rating);
  2024.  
  2025.  new_line; put(" Average Dhrystone rating: ");
  2026.  put (int_rating);  put (" statement execution per unit time ");
  2027.  new_line(data_file); put (data_file," Average Dhrystone rating: ");
  2028.  put (data_file,int_rating);
  2029.  put (data_file," statement execution per unit time ");
  2030.  
  2031.  close (data_file);
  2032.  
  2033. end Dhryadaa;
  2034.  
  2035. with Global_Def,Calendar,Pack_2;
  2036. use Global_Def,Calendar;
  2037.  
  2038. package body Pack_1 is
  2039. -----------
  2040.  
  2041.   Bool_Glob:         boolean;
  2042.   Char_Glob_1,
  2043.   Char_Glob_2:       character;
  2044.   Array_Glob_1:      Array_1_Dim_Integer;
  2045.   Array_Glob_2:      Array_2_Dim_Integer;
  2046.   Pointer_Glob,
  2047.   Pointer_Glob_Next: Record_Pointer;
  2048.  
  2049.   procedure Proc_4;
  2050.   procedure Proc_5;
  2051.  
  2052. procedure Proc_0 (cycles: in integer;start_time,stop_time: out float)
  2053. is
  2054.   Int_Loc_1,
  2055.   Int_Loc_2,
  2056.   Int_Loc_3:     One_To_Fifty;
  2057.   Char_Loc:      character;
  2058.   Enum_Loc:      Enumeration;
  2059.   String_Loc_1,
  2060.   String_Loc_2: String_30; 
  2061.  
  2062.  
  2063. begin
  2064.   -- Initializations
  2065.  
  2066.   Pack_1.Pointer_Glob_Next := new Record_Type;
  2067.   Pack_1.Pointer_Glob := new Record_Type
  2068.                          '(
  2069.                          Pointer_Comp =>Pack_1.Pointer_Glob_Next,
  2070.                          Discr        =>Ident_1,
  2071.                          Enum_Comp    =>Ident_3,
  2072.                          Int_Comp     =>40,
  2073.                          String_Comp  =>"DHRYSTONE PROGRAM, SOME STRING"
  2074.                      );
  2075.   String_Loc_1 := "DHRYSTONE PROGRAM, 1'ST STRING";
  2076. -----------------
  2077.  
  2078. -- Start timer --
  2079.  
  2080.    Start_Time := float (seconds (clock));
  2081. -----------------
  2082. for N in 1..cycles loop
  2083.   Proc_5;
  2084.   Proc_4;
  2085.     -- Char_Glob_1 = 'A',Char_Glob_2 = 'B',Bool_Glob = false
  2086.   Int_Loc_1 := 2;
  2087.   Int_Loc_2 := 3;
  2088.   String_Loc_2 := "DHRYSTONE PROGRAM, 2'ND STRING";
  2089.   Enum_Loc := Ident_2;
  2090.   Bool_Glob := not Pack_2.Func_2(String_Loc_1,String_Loc_2);
  2091.    -- Bool_Glob = true
  2092.   while Int_Loc_1 < Int_Loc_2 loop --loop body executed once
  2093.    Int_Loc_3 := 5 * Int_Loc_1 - Int_Loc_2;
  2094.      -- Int_Loc_3 = 7
  2095.    Pack_2.Proc_7 (Int_Loc_1,Int_Loc_2,Int_Loc_3);
  2096.      -- Int_Loc_3 = 7
  2097.    Int_Loc_1 := Int_Loc_1 + 1;
  2098.   end loop;
  2099.     -- Int_Loc_1 = 3
  2100.   Pack_2.Proc_8(Array_Glob_1,Array_Glob_2,Int_Loc_1,Int_Loc_3);
  2101.     -- Int_Glob = 5
  2102.   Proc_1 (Pointer_Glob);
  2103.   for Char_Index in 'A'..Char_Glob_2 loop --loop body executed twice
  2104.     if Enum_Loc=Pack_2.Func_1(Char_Index,'C')
  2105.     then--not executed
  2106.       Pack_2.Proc_6(Ident_1,Enum_Loc);
  2107.     end if;
  2108.   end loop;
  2109.     -- Enum_Loc = Ident_1
  2110.     -- Int_Loc_1 = 3,Int_Loc_2 = 3,Int_Loc_3 = 7
  2111.   Int_Loc_3 := Int_Loc_2 * Int_Loc_1;
  2112.   Int_Loc_2 := Int_Loc_3 / Int_Loc_1;
  2113.   Int_Loc_2 := 7 * (Int_Loc_3 - Int_Loc_2) - Int_Loc_1;
  2114.   Proc_2(Int_Loc_1);
  2115.  
  2116. end loop;
  2117. -----------------
  2118.  
  2119. -- Stop timer --
  2120.  
  2121.    Stop_Time := float (seconds(clock));
  2122. -----------------
  2123.  
  2124. end Proc_0;
  2125.  
  2126. procedure Proc_1 (Pointer_Par_In: in Record_Pointer)
  2127. is--executed once
  2128.   Next_Record: Record_Type
  2129.     renames Pointer_Par_In.Pointer_Comp.all;--=Pointer_Glob_Next.all
  2130. begin
  2131.   Next_Record := Pointer_Glob.all;
  2132.   Pointer_Par_In.Int_Comp := 5;
  2133.   Next_Record.Int_Comp := Pointer_Par_In.Int_Comp;
  2134.   Next_Record.Pointer_Comp := Pointer_Par_In.Pointer_Comp;
  2135.   Proc_3 (Next_Record.Pointer_Comp);
  2136.     -- Next_Record.Pointer_Comp = Pointer_Glob.Pointer_Comp = Pointer_Glob_Next
  2137.   if Next_Record.Discr = Ident_1
  2138.   then -- executed
  2139.      Next_Record.Int_Comp := 6;
  2140.      Pack_2.Proc_6(Pointer_Par_In.Enum_Comp,Next_Record.Enum_Comp);
  2141.      Next_Record.Pointer_Comp := Pointer_Glob.Pointer_Comp;
  2142.      Pack_2.Proc_7(Next_Record.Int_Comp, 10, Next_Record.Int_Comp);
  2143.   else  -- not executed
  2144.      Pointer_Par_In.all := Next_Record;
  2145.   end if;
  2146. end Proc_1;
  2147.  
  2148. procedure Proc_2 (Int_Par_In_Out:in out One_To_Fifty)
  2149. is -- executed once
  2150.    -- In_Par_In_Out = 3,becomes 7
  2151.   Int_Loc: One_To_Fifty;
  2152.   Enum_Loc: Enumeration;
  2153. begin
  2154.   Int_Loc := Int_Par_In_Out + 10;
  2155.   loop -- executed once
  2156.     if Char_Glob_1 = 'A'
  2157.     then -- executed
  2158.       Int_Loc := Int_Loc - 1;
  2159.       Int_Par_In_Out := Int_Loc - Int_Glob;
  2160.       Enum_Loc := Ident_1;
  2161.     end if;
  2162.   exit when Enum_Loc = Ident_1; -- true
  2163.   end loop;
  2164. end Proc_2;
  2165.  
  2166. procedure Proc_3 (Pointer_Par_Out: out Record_Pointer)
  2167. is -- executed once
  2168.    -- Pointer_Par_Out becomes Pointer_Glob
  2169. begin
  2170.   if Pointer_Glob /= null
  2171.   then -- executed
  2172.     Pointer_Par_Out := Pointer_Glob.Pointer_Comp;
  2173.   else -- not executed
  2174.     Int_Glob := 100;
  2175.   end if;
  2176.   Pack_2.Proc_7(10,Int_Glob,Pointer_Glob.Int_Comp);
  2177. end Proc_3;
  2178.  
  2179. procedure Proc_4 -- without parameters
  2180. is -- executed once
  2181.   Bool_Loc: boolean;
  2182. begin
  2183.   Bool_Loc := Char_Glob_1 = 'A';
  2184.   Bool_Loc := Bool_Loc or Bool_Glob;
  2185.   Char_Glob_2 := 'B';
  2186. end Proc_4;
  2187.  
  2188. procedure Proc_5 -- without parameters
  2189. is--executed once
  2190. begin
  2191.   Char_Glob_1 := 'A';
  2192.   Bool_Glob := false;
  2193. end Proc_5;
  2194.  
  2195. end Pack_1;
  2196.  
  2197. with Global_Def,Pack_1;
  2198. use Global_Def;
  2199.  
  2200. package body Pack_2 is
  2201. -------------------
  2202. function Func_3(Enum_Par_In: in Enumeration)return boolean;
  2203.          -- forward declaration
  2204.  
  2205. procedure Proc_6(Enum_Par_In:   in Enumeration;
  2206.                  Enum_Par_Out:  out Enumeration)
  2207. is -- executed once
  2208.    -- Enum_Par_In = Ident_3,Enum_Par_Out becomes Ident_2
  2209. begin
  2210.   Enum_Par_Out := Enum_Par_In;
  2211.   if not Func_3(Enum_Par_In)
  2212.   then -- not executed
  2213.     Enum_Par_Out := Ident_4;
  2214.   end if;
  2215.   case Enum_Par_In is
  2216.     when Ident_1 => Enum_Par_Out := Ident_1;
  2217.     when Ident_2 => if Pack_1.Int_Glob > 100
  2218.                     then Enum_Par_Out := Ident_1;
  2219.                     else Enum_Par_Out := Ident_4;
  2220.                     end if;
  2221.     when Ident_3 => Enum_Par_Out := Ident_2; -- executed
  2222.     when Ident_4 => null;
  2223.     when Ident_5 => Enum_Par_Out := Ident_3;
  2224.   end case;
  2225. end Proc_6;
  2226. procedure Proc_7(Int_Par_In_1,
  2227.                   Int_Par_In_2: in One_To_Fifty;
  2228.                   Int_Par_Out:  out One_To_Fifty)
  2229. is -- executed three times
  2230.    -- first call:     Int_Par_In_1 = 2,Int_Par_In_2 = 3,
  2231.    --                 Int_Par_Out becomes 7
  2232.    -- second call:    Int_Par_In_1 = 6,Int_Par_In_2 = 10,
  2233.    --                 Int_Par_Out becomes 18
  2234.    -- third call:     Int_Par_In_1 = 10,Int_par_In_2 = 5,
  2235.    --                 Int_Par_Out becomes 17
  2236.   Int_Loc: One_To_Fifty;
  2237. begin
  2238.   Int_Loc := Int_Par_In_1 + 2;
  2239.   Int_Par_Out := Int_Par_In_2 + Int_Loc;   
  2240. end Proc_7;
  2241. procedure Proc_8 (Array_Par_In_Out_1:in out Array_1_Dim_Integer;
  2242.                   Array_Par_In_Out_2:in out Array_2_Dim_Integer;
  2243.                   Int_Par_In_1,
  2244.                   Int_Par_In_2:      in     integer)
  2245. is -- executed once
  2246.    -- Int_Par_In_1 = 3
  2247.    -- Int_Par_In_2 = 7
  2248.   Int_Loc:One_To_Fifty;
  2249. begin
  2250.   Int_Loc := Int_par_In_1 + 5;
  2251.   Array_Par_In_Out_1(Int_Loc) := Int_Par_In_2;
  2252.   Array_Par_In_Out_1(Int_Loc+1) :=
  2253.                          Array_Par_In_Out_1 (Int_Loc);
  2254.   Array_Par_In_Out_1(Int_Loc+30) := Int_Loc;
  2255.   for Int_Index in Int_Loc .. Int_Loc+1 loop -- loop body executed twice
  2256.     Array_Par_In_Out_2(Int_Loc,Int_Index) := Int_Loc;
  2257.   end loop;
  2258.   Array_Par_In_Out_2(Int_Loc,Int_Loc-1) :=
  2259.                          Array_Par_In_Out_2(Int_Loc,Int_Loc-1)+1;
  2260.   Array_Par_In_Out_2(Int_Loc+20,Int_Loc) :=
  2261.                          Array_Par_In_Out_1(Int_Loc);
  2262.   Pack_1.Int_Glob := 5;
  2263. end Proc_8;
  2264. function Func_1(Char_Par_In_1,
  2265.                 Char_Par_In_2:in Capital_Letter)
  2266.                                                return Enumeration
  2267. is -- executed three times, returns Ident_1 each time
  2268.    -- first call:  Char_Par_In_1 = 'H', Char_Par_In_2 = 'R'
  2269.    -- second call: Char_Par_In_1 = 'A', Char_Par_In_2 = 'C'
  2270.    -- third call:  Char_Par_In_1 = 'B', Char_Par_In_2 = 'C'
  2271.   Char_Loc_1,Char_Loc_2:Capital_Letter;
  2272. begin
  2273.   Char_Loc_1 := Char_Par_In_1;
  2274.   Char_Loc_2 := Char_Loc_1;
  2275.   if Char_Loc_2 /= Char_Par_In_2
  2276.   then-- executed
  2277.     return Ident_1;
  2278.   else-- not executed
  2279.     return Ident_2;
  2280.   end if;
  2281.   end Func_1;
  2282. function Func_2(String_Par_In_1,
  2283.                 String_Par_In_2:in String_30)return boolean
  2284. is -- executed once, returns false
  2285.    -- String_Par_In_1 = "DHRYSTONE, 1'ST STRING"
  2286.    -- String_Par_In_2 = "DHRYSTONE, 2'ND STRING"
  2287.    Int_Loc:  One_To_Thirty;
  2288.    Char_Loc: Capital_Letter;
  2289. begin
  2290.   Int_Loc := 2;
  2291.   while Int_Loc<=2 Loop -- loop body executed once
  2292.     if Func_1(String_Par_In_1(Int_Loc),
  2293.               String_Par_In_2(Int_Loc+1)) = Ident_1
  2294.     then-- executed
  2295.       Char_Loc := 'A';
  2296.       Int_Loc := Int_Loc + 1;
  2297.     end if;
  2298. end loop;
  2299. if Char_Loc >= 'W' and Char_Loc < 'Z'
  2300. then-- not executed
  2301.    Int_Loc := 7;
  2302. end if;
  2303. if Char_Loc = 'X'
  2304. then-- not executed
  2305.       return true;
  2306.     else -- executed
  2307.       if String_Par_In_1 > String_Par_In_2
  2308.       then -- not executed
  2309.         Int_Loc := Int_Loc + 7;
  2310.         return true;
  2311.     else -- executed
  2312.       return false;
  2313.     end if;
  2314.   end if;
  2315. end Func_2;
  2316.  
  2317. function Func_3(Enum_Par_In: in Enumeration)return boolean
  2318. is -- executed once, returns true
  2319.    -- Enum_Par_In = Ident_3
  2320.   Enum_Loc: Enumeration;
  2321. begin
  2322.   Enum_Loc := Enum_Par_In;
  2323.   if Enum_Loc = Ident_3
  2324.   then -- executed
  2325.     return true;
  2326.   end if;
  2327. end Func_3;
  2328.  
  2329. end Pack_2;
  2330.  
  2331.