DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: B T

⟦c745278b5⟧ TextFile

    Length: 3769 (0xeb9)
    Types: TextFile
    Names: »B«

Derivation

└─⟦180fe333a⟧ Bits:30000405 8mm tape, Rational 1000, SW CATALOG, 10_20_0
└─⟦180fe333a⟧ Bits:30000537 8mm tape, Rational 1000, SW Catalog 10_20_0
    └─⟦5cb1d1d7f⟧ »DATA« 
        └─⟦3b1ee7bd8⟧ 
            └─⟦this⟧ 

TextFile

with Instrument;
use Instrument;

-----------------------
-- Parallel Recursive Call
-----------------------

-- This test evaluates the code efficiency of a parallel recursive call to
-- a procedure that has no formal parameters.  The term parallel is used
-- to suggest that the call is executed from a procedure that is declared
-- immediately within the same declarative region as is the recursive
-- procedure being called.

-- The parameterless procedure Parallelis used to make a recursive call to
-- the enclosing procedure Parallel_Recursive_Procedure that initially
-- calls Parallel.  Both procedures use two Boolean variables, Recursion
-- and Test, declared in the outer scope to control their execution.  The
-- variable Recursion is initialized to the value of Test, which is
-- initialized to TRUE for the test version and FALSE for the noise version.
-- When Recursion is TRUE, Parallel_Recursive_Procedure calls Parallel which
-- assigns Recursion the value FALSE and then executes a recursive call
-- to Parallel_Recursive_Procedure.  Because Recursion is then FALSE and
-- Test is then still TRUE, the parallel call returns immediately after
-- evaluating the conditional, and the test version is completed.

-- When Recursion is initially FALSE, Parallel_Recursive_Procecure calls
-- Parallel, which assigns Test the value FALSE, evaluates the conditional
-- that guards the execution of the recursive call, and returns without
-- having executed the recursive call.  The presence of the nonexecuted
-- text ensures that when the recursive call is removed from the noise
-- version, the compiler must still assume the potential for recursion
-- and not perform any optimization that would compromise the code
-- efficiency metrics.  In addition, the evaluation of the guarding
-- conditional ensures that the same number of if statements are executed
-- in both the test and noise versions.

-- The purpose of embedding the call to Parallel in an if-elsif construct
-- is to guarantee a single parallel recursive call in the test version
-- and to balance the number of if statements executed in the test and
-- noise versions.  The accompanying camouflaged assignments to different
-- local variables, Local_1 and Local_2, preclude optimizations by the
-- compiler that might eliminate the if-elsif construct or sink the
-- assignment to a single local variable.

procedure Prpca2 is
    package Ps_Cs is new Procs (Integer);
    use Ps_Cs;
    package B is new Procs (Boolean);

    Ttrue : B.T := B.T (True);
    Tfalse : B.T := B.T (False);
    Test : B.T := B.Ident (Ttrue);  -- included in test version
    --  Test      : B.T := B.Ident(TFALSE); -- included in noise version
    Recursion : B.T := B.Ident (Test);

    procedure Parallel; -- Parallel_Recursive_Procedure calls Parallel

    procedure Parallel_Recursive_Procedure is

        Local_1 : T;
        Local_2 : T;

    begin
        if Boolean (Recursion) then
            Let (Local_1, Ident (Init));
            Parallel;
        elsif not Boolean (Test) then
            Let (Local_2, Ident (Init));
            Parallel;
        end if;
    end Parallel_Recursive_Procedure;

    procedure Parallel is
    begin

        if Boolean (Recursion) then
            B.Let (Recursion, B.Ident (Tfalse));
            Parallel_Recursive_Procedure;      -- included in test version
        else
            B.Let (Test, B.Ident (Tfalse));
            if Boolean (Test) then
                -- Always FALSE
                Parallel_Recursive_Procedure;
            end if;
        end if;
    end Parallel;

begin
    Start ("PRPCA2", "Parallel Recursive Procedure Call (Test)");
    for I in 1 .. 10000 loop

        Parallel_Recursive_Procedure;

    end loop;
    Stop;

end Prpca2;