** Final Report

NASA Grant NAG-3-232

Stefan Feyock and W. Robert Collins

Department of Computer Science

College of William and Mary

Williamsburg, Virginia 23185

A HIGH-ORDER LANGUAGE FOR A SYSTEM OF

CLOSELY COUPLED PROCESSING ELEMENTS

July 1986

(NASA-CE-177280) A HIGH-OBDEE LANGUAGE DOR ' N86-27930

A SYSTEM OF CLOSELY COUPLED PEOCESSING

ELEMENTS Final Eeport (College of William

and Mary) 67. p EC AOU/ftF A01 CSCL 09B Unclas

G3/61 43226
ABSTRACT

The research reported in this paper was occasioned by the

requirements on part of the Real-Time Digital Simulator (RTDS)

project under way at NASA Lewis Research Center. The RTDS

simulation scheme employs a network of CPUs running lock-step

cycles in the parallel computations of jet airplane simulations.

Their need for a high order language (HOL) that would allow

non-experts to write simulation applications and that could be

•implemented on a possibly varying network can best be fulfilled

by using the programming language Ada*. We describe how the

simulation problems can be modeled in Ada, how to map a single,

multi-processing Ada program into code for individual

processors, regardless of network reconfiguration, and why some

Ada language features are particularly well-suited to network

simulations.

Ada is a trademark of the Department of Defense

Page 1
INTRODUCTION

The need for ever more detailed information about systems

whose sophistication and complexity is continually growing

inevitably places increasingly rigorous demands on the

simulation models on which this information depends. The work

described in this report was occasioned by the efforts of

workers at NASA/Lewis Research Center to develop

high-performance computer hardware to support real-time

simulation of jet engines, both for the purpose of detailed

analysis of system dynamics, and to support the development of

digital controls for such propulsion systems [1]. The hardware

is structured in the form of a network of communicating

microprocessors running in parallel. The need for a

higher-order language capability for programming such a network

has led to the research described in this report.

HARDWARE CONSIDERATIONS

We will begin by describing the hardware being developed; a

more detailed discussion may be found in [2], on which our

description is based.

Page 2
V

The development of complex digital electronic controls for

aircraft propulsion systems requires engine simulations that run

in real time and provide a high degree of accuracy and user

interaction. In addition, the use of propulsion system

simulations in many hardware-in-the-loop applications adds the

further requirement that these simulations be implemented on

dedicated, portable, and reli*able hardware. The advent of

microcomputer technology has made compact, low cost, portable

computing power readily available. Currently available

off-the-shelf microcomputers, however, do not of themselves

possess the necessary computational speeds to perform accurate

real-time simulations of complex dynamic systems such as

aircraft propulsion systems. The approach to this problem

adopted by NASA Lewis Research Center in its Real-Time Digital

Simulator (RTDS) project is the use of microcomputers in

parallel. By using parallel processing it is possible to retain

the cost, size, and portability advantages of microcomputers and

achieve the accuracy necessary for real-time simulation by

increasing the number of computations per unit time.

As work on this project progressed, it became clear that it

was not necessary for the program model to reflect low-level

details of the computer hardware on which it was to run. By

means of progressive abstraction it was possible to create a

high-level model that can be effectively mapped to a variety of

Page 3
hardware configurations. ranging from the lock-step regime

originally envisioned to the more sophisticated data-flow

architecture that js currently being investigated. To lay the

groundwork, we first present the hardware plan as originally

conceived, and then indicate how it can be abstracted to obtain

a more general model of network computation.

The original structure of the simulator is shown in Figure 1

(from [2]). The core of the system consists of a transfer

schema which synchronizes up to 1O 16-bit processing elements

(PEs) on a high-speed transfer bus. All but two of the PEs

perform simulation computations. One of the remaining PEs is of

the same architecture but dedicated to input/output functions.

The last PE is a special-purpose processor to link low-speed,

operator-type functions with the high-speed simulator core. The

Front End Processor provides an operator interface as well as

handling of peripheral communications and other simulator

overhead, such as downloading of programs to the simulator's

PEs.

Page U
ANALOG

Figure 1

The simulator operation is separated into two basic cycles -

a compute cycle and a transfer cycle. During the compute cycle,

each PE performs the numerical computations for a pre-defined

part of the simulator task. Upon completion of these

computations, the PE sets a transfer flag to indicate that it is

Page 5
ready to enter the transfer cycle. The transfer schema

initiates a transfer cycle when all PEs have set their transfer

flags. Operator control over the simulator is accomplished via

the Front-End Processor and the Real-Time Executive. Such

functions as simulator programming, mode control, operator

advisories, and commands are provided. The Front-End Processor

handles the peripheral communications for the simulator (CRT,

keyboard, floppy disk, etc.). There is also a host computer

interface which allows uplinking and downlinking of data to and

from the host.

Page 6
The Abstract Model

It is immediately clear that several aspects of this

configuration can be generalized; there is no reason that the

model should remain specific to, say, ten 16-bit processors.

The step to a system of arbitrary processors undergoing a

synchronized series of compute and data transfer cycles under

the supervision of a transfer schema is not difficult to make.

It is less obvious, however, that the transfer schema need not

be an actual piece of hardware, but may be virtual: the

embodiment within the program model of the data transfer

discipline that is in effect. Once this has been realized, it

becomes clear that the requirement of lock-step cycles can be

relaxed: the program model has been abstracted to a set of

modules specifying the code for each processor, and the

discipline for transferring data among them. A data flow

architecture is thus among the possible instantiations of this

model; the data transfer discipline in this case becomes

begin computation when all required input has arrived;

transmit data to all specified recipients when computation

of this data is complete.

It is important to keep this "virtuality" of the transfer schema

in mind during the subsequent discussion.

Page 7
PROGRAMMING LANGUAGE CONSIDERATIONS

The use of programming languages of an abstraction level

higher than that of assembly language is now so widespread both

for systems and applications program development that it is

difficult to recall how controversial such use was until recent

years. The ability of the assembly language programmer to

maximize program efficiency by means of direct control of

machine operations was deemed more important than the

convenience and programming speed gained by use of high-order

programming languages (HOLs).

The change in programming practice in recent years leading

away from this state of affairs is well known. Hardware costs

have dropped drastically, both in absolute terms and with

respect to software development costs. Software systems have

increased in size and complexity, emphasizing the need for code

clarity and maintainability. Finally, the development of

integrated microelectronic digital circuitry has led to the

widespread use of embedded computer systems in military and

aerospace environments that require absolute software

reliability.

The result of these developments has been to make the use of

HOLs standard practice in an overwhelming number of software

Page 8
development efforts. The urgency of the requirement for

reliable and maintainable code has produced intensive research

efforts in the area of programming languages and systems. with

the result that modern HOLs not only encourage and facilitate

the development of high-quality software while achieving

efficiency levels competetive with hand-coded assembly language

programs, but can be implemented expeditiously by means of the

powerful compiler construction t"ools that have been developed in

recent years. The resulting availability of (cross-)compilers

has made programming even quite rudimentary microcomputers in a

HOL common practice.

The advent of networks of microcomputers, however, has

resulted in a software lag once again. While compilers can be

generated for single machines quite rapidly, each configuration

of a network is logically equivalent to a different computer,

requiring a new compiler to distribute code among the nodes. An

additional problem is the dependence of the HOL itself upon the

network. Allowing the different microcomputers to communicate

among each other is a hardware implementation problem. How the

HOL facilitates the generation of efficient code to provide for

rapid communication and synchronous behavior is a software

problem which is just beginning to be addressed.

Page 9
RESEARCH OBJECTIVES

Any HOL being considered has to satisfy a host of constraints

and requirements necessitated by the general properties of

simulation practices and the particular microcomputer network.

Some of these requirements are:

1. The HOL must be implementable on any computer or

combination of computers. In particular, it is useful to

be able to run the simulation on a uniprocessor.

2. The HOL must have the capability for specifying

communicating parallel processes.

3. The HOL must support the special requirements of

interactive-mode simulations applications.

An evaluation of existing HOLs led to the choice of Ada [3]

as best suited to these requirements. A discussion of this

evaluation and the considerations influencing this decision is

contained in [&]. In the present report we describe

A. A determination of suitable means of mapping the abstract

structures of Ada into the hardware configuration.

B. A precompiler that performs this mapping.

C. Advantages of using Ada as the programming vehicle for

this project.

Page 10
PROGRAMMING MODEL REQUIREMENTS

A consideration in the suitability of Ada for the RTDS

project is how well the language allows the expression of a good

programming model of the underlying physical reality. We

imposed several constraints on the programming model itself:

1. The program model must be executable directly on a

uniprocessor.

2. The program model must be as simple and natural as

possible, since it must be readily programmed by

non-experts and should not, therefore, involve

complicated synchronization concepts.

3. The program model must be safe, that is, modules

contained within should not be able to tamper with or be

affected by other modules' data or execution.

ti. The program model should be standardized sufficiently in

order that it can easily be mapped to the individual

programs suitable for the nodes of specific distributed

networks.

Any solution to the problem of modeling a simulator network

in terms of Ada must fulfill the basic requirements imposed by

the application: it must be efficient and it must be independent

of the particular structure of the network. Our approach was to

tailor the program to reflect the structure of the problem, not

of the hardware. Since the hardware itself is presumably

Page 11
designed with efficient execution of this class of problems in

mind, efficiency is a natural consequence of this approach. Our

solution fulfills the machine-independence requirement as well:

the resulting program can be run equally well on a time-slicing

uniprocessor, and, by employing the techniques to be discussed,

on the network that is the ultimate target machine.

As indicated, our approach is based on having program

structure mirror problem structure as closely as possible. A

representative case employs concurrent processes running in

parallel to perform the requisite computations, transmit data to

each other when done, and then resume. Our Ada model'program

follows this structure exactly: an independent concurrent

program unit corresponds to each independent process of the

problem, and these units follow the compute/transfer cycle just

outlined.

A central idea of our model was to collect all information

pertaining to any one processor into a coherent, self-contained

module, allowing a clear and elegant notation for specifying

both computation and data transfers. As will be seen, the Ada

package concept appears tailor-made for this purpose, and the

Ada task concept is a natural implementation of concurrency.

Page 12
Ada Tasks

Processes that can execute concurrently are specified in Ada

by tasks. The process specified by a task begins execution when

the task's declarations are elaborated; in this sense tasks

resemble main programs rather than subroutines. Concurrently

active tasks can communicate with each other by means of entry

calls. An entry of a task is specified by means of an accept

statement, which has the (simplified) synta.x

accept <entry> ( <parameters> ) do

<statement_sequence>

end;

A task Tl can call an entry E in another task T2 by specifying

the name of the called task and entry:

T2. E;

The effect of such a call is to force process synchronization:

if T2 has not reached the corresponding

accept E;

statement, then Tl must queue up until T2 does. If, on the

other hand, T2 reaches the

accept E;

statement before another task has called entry E, T2 must wait i

until an entry call to this entry occurs. Once either condition

is satisfied, a rendesvous takes place: the code specified in

<statement_sequence> is executed, with inter-task data transfer

occurring via the entry parameters. Upon completion of the

Page 13
rendesvous the tasks resume independent concurrent operation.

Tasks are usually declared as a two-part entity in Ada

programs: the task specification and the task body. The task

specification specifies the names of the task's entries and the

names and types of the paramenters. It constitutes at once a

"forward declaration" and a user interface for the subsequent

task body.

The task body, in turn, contains the code specifying the

process's activity. Outside entities may in general communicate

with this code solely via entries; the task body is closed to

them otherwise. Figure 6 gives an example of a task

specification, while Figure 7 contains the corresponding body.

Ada Packages

Data/Process _ Encapsulation .

The prospect of multiple processes running in parallel

involves certain problems with respect to data access. In

particular, obvious difficulties arise if two processes are

allowed to update the same data simultaneously, or if one tries

to read data that another is updating. The need to impose

discipline on such contention led to the concept of data

encapsulation. Data subject to contention is placed inside

Page
programming language constructs that force processes to access

the data using a set of strictly circumscribed functions.

Packages are the encapsulation mechanism provided by Ada.

Program resources may be collected into a coherent unit by means

of this facility, and made available to tasks and subprograms

that require access to these resources. It is important to note

that the ecapsulated resources may include not only type and

data declarations but also subprograms and tasks.

As is the case with other Ada program units, packages are

specified in two parts: the package specification and the

package body. The package specification contains all the

information that is to be accessible ("visible") to the user, in

particular the data he may manipulate, and the specifications of

subprograms and tasks he may reference. It should be emphasised

that for tasks it is only the task entries that are specified in

the task specification part, which in turn is the only part of

the task that is present in the package specification. Figure H

illustrates a package specification.

A package body contains all the machinery needed to implement

the subprograms and tasks whose specifications are to be found

in the package specification: the subprogram and task bodies, as

well as any variables and types required by this machinery.

Constructs within a package body are in general invisible to the

Page 15
user, who may access only what has been made available to him in

the package specification. Figure 5 depicts a package body

containing the task body for CODE; it also illustrates the

mechanism for making a package available to a pro gram unit: the

with statement. In this case it is the package TRANSFER_SCHEMA

that is made available to package body FAN_INLET.

THE ADA MODEL

The Ada model combines the two distinct Ada constructs, tasks

and packages, for the two programming requirements of

concurrency and efficient data transfer. The code for each of

the hardware processing elements is specified by an Ada task,

which we call the hardware task pertaining to that processor.

Using packages and visibility commands, the flow of data between

concurrent processes can be specified and controlled by a single

process, called the transfer schema. Consequently, if the

transfer schema is designed and programmed correctly, then all

communications are correct.

As indicated above, the best way to model the processing

elements is to use a single package for each processing element.

The package body (normally invisible to other programming

modules) contains the hardware task which corresponds to the

code to be executed on the processing element. The package

Page 16
specification (or visible part) contains all the variables

needed for import/export and the task entries needed for

synchronization. The major benefit of this standardization and

data hiding is that the conversion of the model to a program

suitable for a network is made tractable.

MAPPING THE MODEL TO THE HARDWARE

Many of the advantages of using a suitable HOL in distributed

programming will be lost unless a good way is found to map the

programming model constructed in the HOL to the individual nodes

in the hardware network. There does not exist any compiler that

will translate abstract programming models into code for any

RTDS network. Such a compiler would be expensive to construct

and would have limited utility, for any change to the network

would necessitate major changes in the compiler. If, however, a

single program (or compilation) is written for a network and a

series of programs, one for each node in the network, is

desired, then a solution is to convert the program text for the

whole network into a series of individual program texts suitable

for each processor. At that point a standard compiler for the

HOL for the individual processor may be employed to derive code

for the processor. The conversion from a single text to

multiple texts is accomplished by a program called a

precompiler.

Page 17
The elegance, utility, and power of the Ada model

synergistically coupled with especially useful Ada constructs

argue convincingly in favor of a precompiler with Ada source and

target texts as the best solution to the HOL-network problem.

The expected proliferation of Ada compilers also makes the

Ada-to-Ada precompiler solution attractive, obviating the

construction of code generators for each kind of target

computer. There will be more Ada compilers available for

different processors than for any other real-time language. The

Ada language itself is particularly well-suited to the

precompiler solution. One of Ada's useful features in

bare-computer, real-time computing is the representation

specification. The programmer is allowed to insert machine

dependencies into Ada code; for^ example, he may specify the

absolute address of variables or insert assembly language code.

The ability to reach through the HOL virtua.l computer to the

actual hardware is generally considered harmful because of

potential programmer abuse. However, applications programmers

will not be employing these representation specifications; the

precompiler will use them to convert rendezvous code and other

machine-dependent code into the code necessary to effect bus

communications. Bus communication usually involves knowing

absolute addresses and manipulating bits, both of which are

difficult or impossible in most HOLs. However, the precompiler

will have no trouble inserting such code, and will still produce

an Ada program rather than an assembly language program.

Page 18
A second feature of Ada well-suited to the precompiler

solution is the pragma, or compiler directive. Programmers may

use pragmas almost anywhere in Ada text for almost any purpose.

Some pragmas are built in the language, for example, the pragma

OPTIMIZE. which takes one of two parameters. TIME or SPACE.

Other pragmas are allowed by particular implementations. If an

implementation does not recognize a pragma, the pragma is

ignored. We intend that the Ada program model contain pragmas

(for example, CODE_MAP) meant for the precompiler to aid the

precompiler in its execution. These same pragmas will have no

effect when compiled by a uniprocessor compiler, thus allowing

the exact same text to work on a uniprocessor directly (with

simulated parallelism) or on a network after precompiling.

THE OPERATION OF THE PRECOMPILER

The precompiler was generated from a LALR(l) grammar for Ada

by the PARGEN parser generator component of the Mystro

Translator Writing System [5] developed at the College of

William and Mary. It employs two passes to delineate precisely

which variables are intended for transfer, which variables must

be placed in absolute memory locations, which constructs

correspond to the hardware tasks, and so on. Its final pass

produces a series of text files corresponding to uniprocessor

Ada programs.

Page 19
The precompiler operates on two assumptions. The first is

that the coding conventions dictated by the programming model

are followed. For example, each separate processing element must

appear in a distinct package. the first task in that package is

the code for the element, all interprocess communication is done

via calls to the transfer controller package. etc. These

conventions are tailored to the problem to be solved. Changes to

the conventions may necessitate changes to the precompiler. The

precompiler can therefore only be used in simulations which

conform to the programming model. This is not unduly

restrictive, since the programming model is general enough to

encompass a large class of simulations.

The second major assumption is that all processing elements

must synchronize after each computation cycle. This

synchronicity is exploited to simplify the structure of the

transfer controller package and the loops in the resulting

single processor code.

The 'precompiler splits a multitasking program which satisfies

the programming model into a set of single-processor programs.

The two conceptual steps the translator must perform are:

Determine the names of packages that represent processing

elements and the transfer controller.

Page 20
For each processor package that represents a processing

element, create a procedure to run on a separate processor.

This procedure is formed from information obtained from -the

original processor package and the transfer controller.

The collection of separate programs (Ada procedures) produced

by the precompiler must be functionally equivalent to the

original multitasking program. As has been described above, the

original package used to represent a processing element

communicates its values to other packages via a package called

the transfer controller. After splitting, communication must be

accomplished via a bus. The transfer logic resident in the

transfer controller must thus be distributed to the split

procedures. This is accomplished by the precompiler replacing

waits for the transfer controller by calls to a bus package,

followed by a wait in a busy loop. These calls explicitly pass

or receive the values to be transferred and the destination

address.

PRECOMPILER EXAMPLES

Details of how these steps are performed are given in a

subsequent section. We first illustrate these steps for two

sample processing element packages A and B, and a transfer

controller package called TRANSFER_CONTROLLER. These packages

Page 21
are 'identified to the precompiler via the pragma compiler

directive. We then show the effect of the precompiler on the fan

inlet example of Figures H, 5. 6, and 7.

Here is the original Ada program. This program will run

correctly on a uniprocessor, or can be processed by the

precompiler to produce the split procedures shown below.

pragma code_map(internal => A, actual => "CPU_A");

pragma code_map(internal => B, actual => "CPU_B");

-- the above pragmas tell the precompiler which package

-- ("hardware task") will be mapped to which actual machine

pragma transfer(TRANSFER_CONTROLLER) ;

-- This pragma tells the transfer controller that the data

-- transfers are specified in the package named TRANSFER_CONTROLLER

package A is

x, y: integer := 1; -- moved to split procedure

task A_code is

entry START_UP; -- replaced by precompiler

entry RESUME; — replaced by precompiler

end A_CODE;

end A;

package body A is

task body A_CODE is

begin

accept START_UP; -- replaced by precompiler

loop

x := x -i- y; — or any arbitrary computation

TRANSFER_CONTROLLER.SIGNAL; -- signal completion

accept RESUME; -- replaced by precompiler

end loop;

end A_CODE;

end A;

Figure 2.a

Page 22
package B is

x, y: integer := 1; -- moved to split procedure

task B_code is

entry START_UP; -- replaced by precompiler

entry RESUME; -- replaced by precompiler

end B_CODE;

end B;

package body B is

task body B_CODE is

begin

accept START_UP; -- replaced by precompiler

loop

x := x + y; — or any arbitrary computation

TRANSFER_CONTROLLER.SIGNAL; -- signal completion

accept RESUME; -- replaced by precompiler

end loop;

end B_CODE;

end B;

Figure 2.b

Page 23
task TRANSFER_CONTROLLER is

entry SIGNAL;

end TRANSFER_CONTROLLER;

task body TRANSFER_CONTROLLER is

No_of_processors: constant = 2;

Signal_count: integer range O . . No_of_processors;

begin

— start up both processes:

A.START_UP;

B.START_UP.

loop

Signal_count := No_of_processors;

while Signal_count > 0 loop

accept SIGNAL;

Signal_count := Signal_count - 1;

end loop; — busy wait for everybody to finish

A.y := B.x; -- moved to split procedure

B.y := A.x; -- moved to split procedure

A_CODE.RESUME;

B_CODE.RESUME;

end loop;

end TRANSFER_CONTROLLER;

Figure 2.c

The packages shown in Figures 2.a, b, and c will run

perfectly well on a uniprocessor, simulating concurrency and

allowing the programs in question to be debugged. When

desired, they can be mapped by the precompiler to Ada code

that will run on separate machines, communicating via a

hardware bus. The precompiler produces as output the

following Ada programs:

Page 2U
with BUS; use BUS;

procedure A is

x, y: integer := 1; -- moved from original package

begin

-- the following loop ±s created and inserted by

-- the precompiler

loop

exit when INPUT_READY;

-- busy loop, waiting for signal

— corresponds to accept START_UP in original

end loop;

loop

MOVE(TO => y, FROM => x_LOC);

— MOVE is a bus package procedure. This call is

__ created and inserted by the precompiler

x : = x -•- y;

-- TRANSFER is a bus package procedure. This call is

-- created and inserted by the precompiler

TRANSFER(VALUE => x, SEND_TO => B. ADDRESS => y_LOC);

-- the following loop is created and inserted by

-- the precompiler

loop

exit when INPUT_^EADY;

— busy loop, waiting for signal

-- corresponds to accept RESUME in original

end loop;

end loop;

end A;

Figure 3.a

Page 25
The procedure for B Is similar:

procedure B is

x, y: integer := 1;

begin

loop

exit when INPUT_READY;

-- busy loop, waiting for signal

-- corresponds to accept START_UP in original

end loop;

loop

MOVE(TO => y. FROM => x_LOC);

x : = x + y;

loop

exit when INPUT_READY;

-- busy loop, waiting for signal

-- corresponds to accept RESUME in original

end loop;

TRANSFER(VALUE => x, SEND_TO => A, ADDRESS => y_LOC);

end loop;

end B;

Fit <re 3- b

Page 26
A JET ENGINE SIMULATION EXAMPLE

We now give a more realistic example, representing a portion

of an actual Jet engine simulation. Suppose that the code for

the FAN_INLET computations of a det engine simulation is to be

assigned to hardware processor "I. This assignment is specified

by means of the pragma shown in Figure U. The code depicted

there corresponds to the visible part of the FAN_INLET routine.

The entries START_UP and RESUME are needed for synchronization.

When either is called (like a subroutine), the execution of the

code for FAN_INLET can start or resume. Each of these package

specifications can and should be compiled separately.

Page 27
pragma CODE_MAP(INTERNAL => FAN_INLET,

ACTUAL => "processor 1");

— Informs the precompiler that

-- code for FAN_INLET will be

-- on CPU node processor 1

pragma transfer(TRANSFER_SCHEMA);

package FAN_INLET is

— Here are the declarations of

-- the transfer variables.

-- They will need addresses for

-- bus transfer and the data base:

A, B, C : VECTOR;

-- Here is the task specification

— with synchronization entries:

task CODE is

entry START_UP;

entry RESUME;

end CODE;

end FAN_INLET;

Figure 4

The Ada compilation unit which contains the code for

FAN_INLET is given in Figure 5. The with statement is a

directive to the compiler that this package body should be

compiled with the specification of the transfer schema task.

This is necessary since entry SIGNAL of the transfer schema is

called. The body of the package consists of the task body only.

The task body contains three rendezvous which are the Ada

constructs used for communications between tasks.

Page 28
with TRANSFER_SCHEMA;

package body FAN_INLET is

-- Here is the body of the task:

task body CODE is

— Here are local declarations

-- not involved with data transfer.

-- These will need addresses:

TEMP : VECTOR;

begin

accept START_UP;

loop

TEMP := A;

A : = A + B;

B := TEMP - C;

TRANSFER_SCHEMA.SIGNAL;

accept RESUME;

end loop;

end CODE;

end FAN_INLET;

Figure 5

The text for CODE has these semantics: Task CODE is suspended

until it receives a call (from the transfer schema) to the entry

START_UP.| The task then enters an infinite loop which consists

of its calculations, a call to an entry of the transfer schema

indicating that its calculations are done and its export

variables are ready for export, and suspension until it receives

a call (from the transfer schema) to the entry RESUME indicating

that the variables necessary for the next cycle have been

imported.

As can be seen from the models for the hardware processing

elements, a critical cog in the overall model is the transfer

Page 29
schema task. Its specification, given in Figure 6, must be

compiled with the task bodies described in Figure 5. The body

of TRANSFER_SCHEMA, given in Figure 7. must be compiled with the

package specifications corresponding to the processing elements

since the transfer schema task must be aware of the

import/export variables and the synchronization entries.

task TRANSFER_SCHEMA is

entry SIGNAL;

end TRANSFER_SCHEMA;

Figure 6

The body of, the transfer schema contains two local

declarations: a constant TOTAL indicating the total number of

processing elements to be synchronized and a counter variable

COUNT to tell when all the processing elements have completed

their calculations.

Page 3O
with FAN_INLET;

with REAR_DUCT;

with FORWARD_SENSOR;

task body TRANSFER_SCHEMA is

No_of_processors : constant := 3;

Signal_count : INTEGER range 0..No_of_processors;

begin

-- start up all three processes:

FAN_INLET.CODE.START_UP;

REAR_DUCT.CODE.START_UP;

FORWARD_SENSOR.CODE.START_UP;

loop

Signal_count := No_of_processors;

while Signal_count > 0 loop

accept SIGNAL;

Signal_count := Signal_count - 1;

end loop; -- busy wait for everybody to finish

FORWARD_SENSOR.W := FAN_INLET.A;

REAR_DUCT.X ' := FAN_INLET.C;

FAN_INLET.CODE.RESUME;

REAR_DUCT.CODE.RESUME;

FORWARD_SENSOR.CODE.RESUME;

end loop;

end TRANSFER_SCHEMA;

Figure 7

The code for the transfer schema has these semantics: all the

hardware tasks are started by calls to the START_UP entry in

each hardware task. Then the transfer schema enters an infinite

loop in which it awaits entry calls from the hardware tasks

indicating that they have finished their computations. The

"accept SIGNAL" in the transfer schema is matched with the

"TRANSFER_SCHEMA.SIGNAL" entry calls in the tasks for

rendezvous.

Page 31
After all the tasks have signaled completion, the transfer

schema transfers the variables.

FORWARD_SENSOR.W := FAN_INLET.A

means that the value of variable A in FAN_INLET is to be stored

in the location of the variable W in FORWARD_SENSOR. In a

uniprocessor. this is a straightforward assignment. In a

network, the assignment will be converted to instructions (calls

to a bus handler package) to allow the value of A to be

communicated by the bus to the location of W. After the

variables have been transferred, the transfer schema signals

each hardware task to resume execution by calling the RESUME

entry of the task. Recall that the tasks have been suspended

while the variables were transfered because of the "accept

RESUME" statements. This completes the cycle of execution in

the transfer schema.

The Ada program model for a processing element in Figures H

and 5 will be converted by the precompiler to the main program

given in Figure 8. The two busy loops are broken either by

interrupts or a switched bit (depending on the nature of the bus

communications) to synchronize the startup and the import of

data. The system library function INPUT_READY may be coded

independently of the precompiler to accomodate changes in the

network configuration or basic design. The system library

procedures MOVE and TRANSFER control the moving of data from the

Page 32
bus depot to their memory locations and the moving of data from

memory to the bus depot and then through the bus itself. The

code for these system library routines may be high-level Ada

code, assembly language, a call to a hardware procedure, or a

combination of these that moves the export variables to the bus

depot and signals that the import variables have all arrived.

The three routines are located in the package BUS, and may be

named directly because of the "with" and "use" clauses

preceeding the main program FAN_INLET. The rest of the code

mimics that of the original hardware task.

Page 33
with BUS; use BUS;

procedure FAN_INLET is

A. B. C : VECTOR;

for A use at 16#AO#;

for B use at l6#A8#;

for C use at 16#BO#;

for TEMP use at l6#B8#;

-- 1&# indicates that the

-- addresses are hexadecimal

begin

-- the following loop is created and inserted by

— the precompiler

loop

exit when INPUT_READY;

-- Busy loop, waiting for signal

-- that input arrived at depot.

-- Corresponds to START_UP.

end loop;

loop

-- Move variables from bus depot

-- to their memory locations.

MOVE(TO => A. FROM => A_LOC);

MOVE(TO => B, FROM => B_LOC);

MOVE(TO => C. FROM => C_LOC);

TEMP := A;

A : = A + B;

B := TEMP - C;

-- The value of A will be sent

--t o FORWARD_SENSOR to be

-- stored in the bus depot

-- for variable W there.

TRANSFER(VALUE => A,

SEND_TO => FORWARD_SENSOR,

ADDRESS => W_LOC);

TRANSFER(VALUE => B.

SEND_TO => REAR_DUCT,

ADDRESS => X_LOC);

Page 3*1
-- the following loop is created and inserted by

-- the precompiler

loop

exit when INPUT_READY;

-- Corresponds to RESUME in original

end loop;

end loop;

end FAN_INLET;

Figure 8

PRECOMPILER CONSTRUCTION TOOLS

The MYSTRO translator .writing system [5] was used to

implement the precompiler. Many of the problems encountered in

constructing compilers or, in this case, a precompiler, admit

the same solutions regardless of the specific language being

translated. MYSTRO employs several skeleton compilers

appropriate to most programming languages. Except for minor,

clearly-marked areas, any skeleton's code can be used to produce

a complete listing, read lines for parsing, produce symbolic

cross-references, and so on. The particular skeleton chosen for

this project also includes hashing routines and multi-level

error recovery.

The initial precompiler was generated by the MYSTRO parser

generator PARGEN, which computed and merged parse tables for a

complete Ada grammar into the skeleton compiler. Pascal

semantics were included in the input grammar, and automatically

inserted into the SYNTHESIZE procedure. which associates

semantics with the appropriate syntax.

Page 35
OPERATION OF THE PRECOMPILER

In order to split the original multiprocessing input program

into separate uniprocessing programs that will run on the nodes

of the network, the precompiler makes two passes: an

information-gathering first pass. and an output second pass.

While gathering information, the precompiler must know which

packages represent processing elements and mark sections of

their code. It does this by creating, as part of its semantics

for the CODE_MAP pragma, a list of the packages that represent

processing elements. Each element of this list holds information

needed to split the program into the intended separate programs.

Once a processing element package specification is found, the

location of the start of the specification is noted in that

package's descriptor. The first task specification encountered

after processing the package specification designator is marked

in the descriptor and designates the end of information needed

from the package specification. At this point the precompiler

also records in the descriptor the names of all the entries

declared within the nested task specification.

When the body of a processing element package is found, the

package descriptor is stacked to allow for package nesting, thus

preventing erroneous location information. The task body's

Page 36
location inside the package body is recorded in that package's

descriptor. This task body corresponds to the nested task

X

specification found in the package specification. Inside this

task body, the loop and end loop for the outermost loop are both

recorded in the descriptor to allow for the transfer of bus

variables in and out of the simulated processor. Throughout the

task body, entry names found in accept statements are compared

with the entry list within "the package's descriptor. The

locations of those that match are recorded and the rest ignored.

These accept statements will be converted to busy loops in the

rewriting phase of the precompiler. The end of the package body

is also recorded as the end of the information needed to

complete this processing element package.

Information regarding the bus variables and the synchronizing

entries must also be gathered during this first pass; they are

found inside the specification and body of the transfer

controller. Several lists are created during the first pass:

entries declared within the transfer controller's specification,

variables to be moved into each processor at each loop iteration

within the processor, and variables to be transferred to the bus

depot for use in another processor at the end of each loop

iteration.

The information-gathering first pass is by far the more

complex of the two passes. It is a straightforward matter to

Page 37
separate the file containing the input program into several

files containing processing element programs.

The complexity of the first pass is mitigated by the fact

that the precompiler is syntax-directed. The Ada grammar

consists of nearly five hundred rules, only a small portion of

which affect the precompiler's task. Each rule is like a. small

program; the programmer need only concern himself with

developing correct semantics for that rule and passing

information through the semantics stack to other rules. For

example, the rule

<pragma> ::= pragma <identifier>

can be used to associate with CODE_MAP semantics. that enquire

about the identifier. In fact, the SYNTHESIZE procedure contains

the following case:

(* <pragma> ::= pragma <identifier> *)

if <identifier>.id = 'CODE_M'\P ' then

<pragma>.flag : = true

else

<pragma>.flag := false;

MYSTRO contains utilities to translate notation such as

<identifier>.id into the appropriate stack references.

Page 38
ADVANTAGES OF ADA

In addition to representation specifications and pragmas. Ada

has a variety of programming features especially suited to

interactive-mode simulation applications. Some of these are

described below.

Safety in the Multi-Programming Mode. Ada encourages two of

the main software engineering techniques to facilitate the rapid

construction of reliable software for large and complex software

projects. These two techniques, data encapsulation and safe

separate compilation, are employed in the packages that mimic

network nodes. The package body (normally invisible to other

programming modules) conta'.ns the hardware task which

corresponds to the code t be executed on the processing

element. The package specification (or visible part) contains

all the variables needed fo; import/export and the task entries

needed for synchronizatioi . Finally, use of Ada separate

compilation facilities guarantees that processing elements

cannot communicate directly with each other, that is, a

programmer cannot make use of the "innards" of one processing

element when describing the behavior of another. This frees the

programmer of the responsibility of effecting the bus

communications directly and also allows the Ada programs to run

on uniprocessors without any change in code. Such orthogonality

Page 39
allows programmers and engineers to concentrate on individual

processing element correctness and efficiency without worrying

about ripple effects on the other processing elements.

Abstract Data Types . Ada's abstract data type capability

diminishes the distance between the programming model and the

original simulation applications. Through the generic and

package constructs, new data types specific to the application

can be created together with the operations necessary to

manipulate these types. These operations are allowed to have

standard forms such as •*• , -, <, and so on. For example, in a

package specification we may create a type VECTOR together with

plus operations (all denoted by + ) for various combinations or

scalar and vector addition. It is expected that many packages

particularly suited to real-time simulation applications will be

constructed and sold by cotimercial vendors (perhaps in Ada

Package Stores). Consequently program systems may be partially

built with off-the-shelf components instead of being

hand-crafted each time.

Real-Time Constructs. Ada has a variety of real-time

features which allow real-time constraints to be employed in

simulation applications. These include the ability to

deactivate a task for a specified period of time, as well as

wait a specified time before aborting a prospective rendezvous.

Moreover, a predeclared package CALENDAR allows arithmetic on

Page
wall-clock times and durations, as well as access to the system

clock. One specific application is to monitor lock-step

compute-data cycles.

CONCLUSION

The concept of implementing a higher-order language on a

computer network by means of a precompiler has proven to be

extremely fruitful. Not only was it possible to map programs

for the original lock-step network design onto the hardware, but

it now appears feasible to apply this technique to more general

network designs. Moreover, many of the system facilities

required for interactive-mode simulation can be implemented by

means of precompilation. Our research has demonstrated the

usefulness of this approach both on the original hardware design

and on networks of more general structure.

Page Hi
REFERENCES

1. Krosel, Susan M. and Milner, Edward J., "Application of

Integration Algorithms in a Parallel Processing Environment

for the Simulation of Jet Engines", Proceedings of the 15th

Annual Simulation Symposium, Tampa, March 1982, pp. 121-lUil.

2. Blech, Richard A. and Arpasi, Dale J., "An Approach to

Real-Time Simulation using Parallel Processing", NASA Lewis

Research Center, Cleveland, Ohio.

3. Ichbiah, Jean et al., Reference Manual for the Ada

Programming Language, United States Department of Defense,

July, 1980.

ft. Feyock, Stefan and Collins, W. Robert, "Ada and

Multi-processor Real-time Simulation", Proceedings of the

16th Annual Simulation Symposium, Tampa, March 1983.

5- Collins, W. Robert and Noonan, Robert E., The Mystro Parser

Generator User's Manual, Version 6.3, College of William and

Mary, Williamsburg, Virginia, October 1982.

Page U2
APPENDIX

EXAMPLE PRECOMPILER RUNS
ORIGINAL PROGRAM INPUT TO PRECOMPILER

The following program is the result of translating a sample

FORTRAN simulation program furnished by NASA/Lewis into Ada. As

can be seen, the format of this Ada program conforms to the Ada

model described in the report. It consists of tasks A, B, C, D,

and IOP, and a TRANSFER_CONTROLLER to move data among them. This

program will run on any machine with a full Ada compiler. It was

processed by the precompiler, which split it into separate

procedures intended to run on the nodes of a network.

A.I
ORIGINAL PA££

 5

-S

POOR QUALITY

Coll,

Lina?

1

2

6

7

r. -3

i i

12

-. *. A *r

17

• •»

1'i

L. (J

21

25

3 a of W i 11 i a m one! M r r y Sourca Listin g 27/11/84 14:36:43

'Sourc a Lin"•=

pra^.-nci cocU_-n^p (intarncii = > ft , rctUeil = > " _

pr£jT: > cocl-3_-ns.p '( s c t u ? 1 => "ccu_!"t i n't e r n a 1 => B);

ijrs-:-!!? coc l = _T.np ("ccu_C", intern? 1 => C);

pr-ig-n?. code_-ncip (intern?,! => D,":DU_D");

pr 0-3-1 a coc!s_x3p '(intern?! => IG°» actual => "IQP_thin g") ;

prng-n? transfer C ON7RCL LSR> :

is

typs CC-G'DTNiTt: is (V, Y):

type VECTO R is" ?rrr,y CC30K-IHi'T6) 'of ' FLOAT :

ORIGI N : constant VECTOR := CX => O.C. Y => 0.0):

function""*" CC, j : V=CTG?) -eturn VECTOR :

. function "-" CC, j : VrrCTj?) return VECTOP:

' tur.ction "*" (C : =LOi7! " : V^CT C R) return VECTOR :

p 5 c k r- g = body V t C T C :~ S i s

function "+" CC, r : V = CT.O_3) return VHCTG R is

to e ~3 i n

raturr. CX => CCX ) + OCX), Y => CCY) + 3CY)):

function "-" CC, : : VECTC" ) return V5CT0 5 is

o 9 •:; i n

return CX => CCX ) - 3CX) , Y => CCY ) - DCY)) :

9 r. c: " - " :

: =L-"-r: I : V=C'! --: C < ) return VECTO R is

r 3 t u - n C X = > C :': " C X ) , Y = > C * CCY)) :

3 n :l " -- " :

A.2
ORIGINAL

OF POOR QUALITY

Co

Li

1 1 e 5 a ot'Wiilia-n and '•'•. -? r y Source L i =

nev Source Lin 3

3 9

40

/ *

«* ^

42

43

44

45

46

4 7

4 3

49

50

51 •

52

5 3

54

5 5

56

57

5 6

5 3

60

61

62

62

64

63

6 c

67

end V 5C7~?3 :

u; i t n V J: C 7 C N S ; " u s s V = C T C ? S I

package ~ L 3 ~ ~ L is

A ."LCAT = l.CO

c . rLCiT = l.C?

*" T c i .- «. r — .*> r = VI • » - * ' — -j m •.'• .

i

 r L 3 - T - 0 . C -

L

Z t r: * r _ ' ^ A i* .^

. i_ U ^ I — .* ..- • V -

>t ^»i^»»TM — n _ » > i ir — r* ** f i y^T^*

*, i i . i r. -j r r. - • i ; < T •; o •- C L / vv i J •

JN rL'jiT = l.CC

t u n - 1 i.o r. 2 " - : v " 1 1 v : c : v : c T :

t n ci G L •" 2- i L :

p a c 1< a ; -2 !: o c! y j L " ~. A L is

r >j n c t i o n ". : -. 1 V 2 T T V r C C : v " C T ?

Uecin

r a turn CX => CCY) , Y => Cl.

a n c! •?• E P I V i T I V 5 :

end G L C t i L I

27/11/84 14:36:48

69

70

7 i

73

.' •»

75

return VECTOR :

) return V E C T 0 ? is

/3) * CUM - C(X)> - (3/A) * CCY) ):

* i t n V r C T r -, S : u 2 -9 V - C T C -> S

i-it.". SL:;IL: u = = ^LO^AL :

x 11 n T : X " _ i T :

A.3 PAGE BUNK WOT
Coliega of Williar, arc! Ksry

L i n e ~ Source Lin?

Source Listing 27/11/84 14:36:48

77

75

75

SO

81

52

£3

5 •»

35

26

57

£ 3

3 9

30

91

92

95

94

93

96

9 7

9 3

9 9

100

1C1

102

1 C3

i 'f "*

103

1C 6

107

1C 5

1C J

110

ill

?ntry STi"T_1j

•3 n t r y ~:~S U .'•' £ :

9 n cl A _ C 2 0 ' ;

3 n c! i ;

P e. c !< s •; s 3 is

M, xporiP : VECTOR :

task :_CDDE is

entry ST4PT_UP :

3 n t r v " i: S U M E J

X N ° 3 , X ? C '•;, X ? D M ? : V = C T D P J

XCN i XN : VECTG P := ORIGIN1:

te.sk C_CC-C E is

=ntry STiST_UP :

3 r, t r y R = S U M 3 J

9 n c; C :

pscks-j e 2- is

X N ? : vicro r : = ORIGIN ;

t?.5k C_C3C = is

?ntry 5TS S*_U n:

s n c! C . C ? " = :

3 n ci D :

p c, c !< - .,' ? : 3 c i s

x-•:•( ,

A.4

 x
PR1GJNAL PAQE ?S

POOR QUALITY

C o 1 i e g a o f . .'.-; i 1 1 i ?, m

Line* So''jrc a ' L i

115

116

117

113

119

120

121

122

123

124

125

126

•127

12 5

12 »

120

121

132

122

i 3*»

135

126

137

133

139

140

141

i •» _

143

144

145

146

147

14;

14 J

1:1

XP- i

to s

end

a n d 10

task T

en*.

a n c T ,v

c a c !< a 5

tc-15

bsg

end

3 p. :' A :

p a c k a g

t-r.5

!3 -r rj

.?; n cl •'•; ?, r y S c '.

n e

X2 : VfCTOK :

!< I C .- _ C C ? 2 .1 ?

an try STiF. T_U?'.

antry S.= SU«=:

IOF-.CODE:

3;

": A ?; 3 = = - _C C '.'

 T ~ C L L

r/ SIGNAL ;

a?;Ss :R_CCNTROLL=:

-. '3ody i is

k i: o r! y i _ C 0 3 ~z is

in

accept STA^T^U3 ;

1 o c p

x - N x 2 : = x ••; -

X ? \. •'.' X 2 t = C T "

T'ii^SrE^.CC-M

3 c c a p t sr!SUv -

o n ci 1 o o c t

i _ c c D : ;

..- i:o:*y = is

k liorty 3_CC"" is

i n

r - c i - *. 3 7 - ? T _ ' j ~ ',

1 co.:

f^;:^:: ;;?;

L i = * i n g 27/11/84 14:35:48

V ~ C XPNX? )

K . ? IC-f-'ALJ

A.5
College

Line?

152

154

155

156

157

158

159

160

161

162

163

164

165

166

167

165

169

270

171

172

172

174

175

176

177

175

179

1 c G

lol

1 c 2

182

1£4

155

of Willia.ii and Msry

S o u r c 9 L i P. a

accept r = SL---'Z:

Source Listin g 27/11/84 14:36:43

end loop

ancl 3_C'"CE;

and ? :

D ii c l< s .3 9 I: o cl y C l s

task boc'y C _ C G 2 £ is

b a 5 i n

sccao't START_u= ;

loop

XN := XN?2 - 1 ,

one! loop;

- 2.0*XPONP);

4 n cl C :

z :• ck5 ^* !?o-::y - is

t a s l< b o c) y r _ C G ~ r is

i: a 3 i n

c-,ccsct STi-"T- u =;

loop

x •; - : = x••; P 2 ^ :. 0 ••:- -< - X ?':p 2

X1- t'i ? : = " " i" I v,' TI v' E C xv!

 3):

7" i'; 3 = : ? _ C c.': T - c L L = ?." IG ^: - L ;

?ccept r = <;u-.^:

.? n c; 1 o o q :

N,- ? c k r. c .3 !: o ;l y I •"! P is

A.6
ORIGJNAL PAGE SS

OF POOR QUALITY

Col 1953 ot .'.<il.lic.rc iinci M-.ry

Line* Source Lino

Sourc= Listing 27/11/84 14:36:48

191

132 -

193

154

195

196

197

193

199

200

2G1

2C2

203

20*

205

206

20.7

205

209

210

211

212

213

214

215

215

217

21 E

219

220

221

222

222

2 2 4

223

C. _ 3

217

C .1 C

*.*•='.< |50C!

use

u -a c '<

r- - c k ->

use

51

T

IV

T V

xv :

!D •? g i n

?. C C -i 3

T V C 1 )

T ~ * *i! C

for I

? C

XV

X V

7 :

it

er.

TV

SI

sr.ci 1

3'JT(?

r%'^r_L

TOT I

°L

?l

?L

_ ^ 1 ^

-> r. ;! I C- - _

? n ;i 13

 ? :

t:isic ::0':;y

 T

is

;a 3 = AL_:C is nsu, = LC A T_IO Ce LC AT ) :

,7_:o, ^EAL.IO:

rrr-r.y C1..500) o* =LCAT;

array C 1. . S 3.0 ) of FL2AT;

for I in 1 . . N 1 o o o

Rr$U(/c:

) := rISSTCXPNX);

1) : = ?:^STCXONX25:

T?;-.\!S.= =

 ::_CCM?CLL=.:?.S IGMAL ;

:iT > 1 t^-s-n

T V C 3 1 ) :- T V C S 1 - 1 ) + H :

5 r. c! i * ;

TVCS 1 * 1} t= TVCSl ) + HI

: = S i- * 2 :

in oop

°L'TCTV( 15):

PUTCXV C :3):

UT_LI.';~ :

loop:

A.7
:*•

College

Line*

2 2 5

220

231

222

2 2 3

234

2 2 5

2 2 6

227

23 8

235

240

241

242

243

244

245

246

247

243

20

'j -

 r

-

£->'•_!

251

c. ; i.

2 5 3

2 5 4

2 5 5

2 5 6

23?

2 5 3

25S

260

261

2 6 2

2 £ :

2 6 4

24 =

or nillirrn enci K^ry

Sou re e Lin F

u s 3 a , 3 , C , '

.VC^'Tr^P^tC'ESSC

s::-r:^L_CGU.\'T :

basin

""for NT In" 1. ,f

A . X H ? I

r.x'':'11: " :

c.x*;?;-

r*. Y ^ ' r ^? ' _ • A -x r .3

, — . wiP 7 ~ *

.* • A j , t r ^ t

5.x?Dr; °

•C.XP3N?

• V O "* »"• — « ^ .- '^' 1 »

C YD-"* •••'

,. • A • — - 1 1

^ v ** *^ '

•^ • A - ; *

rc-p.xpNX - •

1 .3 r . X ? N X 2 '

i C OD£ .'R-'S'

= .:.::£ . - = si

C_COOE: . s?s'

' •C - COO=. R = SI

T ** P r i* **. r~ ?

SIG'-ii'L_CC-Ui

•r h i 1 a S I <~> '•:

?• C C -3 C *

SIGNAL.

end looo I

•3rd 1 c o r; J

ar.;! T? ;r; S c ~^_C."!';

us^in -- r:i!j-p-.-y -nri

r. -j 1 1 :

= nci;

Sourca Listing 27/11/34 14:3

s : G P ;

•5S : constr.r.Hr := 5:

rf;T5-jE^ r^nqe C . . fiG.O F_?RQ C E S SQR S ;

i loop

•m f V HI •

— v • A .4 «

_ /"• y » i •

= (. • A • S I

- n v 1,1 p — i- • A < K

— .~ V • ' 3

— W • A 14 .

— ' t* V ^ *.!

= C . X :..

;

 M

= ? . x * ^ > •• x :

= 9 . X 3 2 N X :

= A.XPCMX2 ;

:= i.x?^MX2:

•= j.x^o.'jx::

= E.XPNX ;

= A.XPNX2 :

J.'-'-H:

j ••••- : ;

J

M ^ •

••". - »

j M - :

M

pftt*^ * _

: SU'.^ .

vT" :=

 >!C_:"_ = r ccES5Qps :

-L,C(:;J-:T~> o looo

s l •' f ; .•» i_ :

:o;jr^T := ?. :*-'M L_COUNT - i;

-

r^LLCc :

i o r o c ? n -j r •?

A. 8
OUTPUT OF THE PRECOMPILER

The following Ada procedures A, B, C, D, and IOP were

produced as output by the precompiler processing the previous

program. The intent is that " each of these procedures be

assigned to a processor of the network, as specified by the

pragmas of the original program. Note that the the precompiler

has replaced the data transfers specified in TRANSFER_CONTROLLER

by calls to the MOVE and TRANSFER entries of the bus package.

A. 9
pros.ciur- i «s ORIGINAL &

OF POOR QUALITY

procedure i is

X'.'P:, X?:''. : '/ECTCV;

X^KXZ , x?c.'.x2 : V.-CTC^ := c'l":;.;

b a j i n

loop

exit when I ,'J.C!JT_R = A ? Y :

— 5 u = y 1 o o p » u: a i t i n .•; for = i ~ r r!

--corresponds to v T - •-. T_L'?

e n :i loop;

loop

/iCVrCT C => JCPCf-J, F-.?,v => X?r-?:_L1C

NDVECT C -> XMP2 , "^"M => X,"J?:~L

 p

.C

x?NX 2 := xr.?2 + <-. j:•-•-':•:x':;•:•;:

x

3

 :• N xa : = c ^ s I v: T i v - c x ? -i x"):

72i:;S"~C ViLu: => Xr':x: .

5rr:0_T Q => I-P,

• iOCRr5 5 => XP:;X:_L? C 3 :

TRA?-.'SF-L :^ C VALU E = > X 3 D-.'X2 ,

S='/C_T ? => 'C ,

i::r.-s's => x er'!_!_:c ):

T.Qi'-j3 r:~(VALU " . => x ?o-;x: ,

S^NC.T^ => s,

AD-'SrS S => X^DS'_L2 C ):

TSiNSFS^CVALUi : = > X=>DNX2 ,

SE';o_rn => j,

i:o?:' :5s=>x?:.'j_Lcc5 :

loop

exit a h a n I ?-i ? U T _ S E A D Y :

--Susy loo,:, iirsitin- for- si^nr-l

--ccrr asooncis to

 r

 = SU"1

anci loop ;

e n :l i o c p :

end A!

A.10
J

ORIG3MAL PAGE IS

OF POOR QUALITY

procedure 2 is

procedure 3 is

X

O I' V V D ~ *' V ? I« X t A r j . < X

b a g i n

i

loop

exit (a ", 6 n I N1 ? U 7 _ K ? A D Y :

--Susy loos, ' CTiitin ; fc r si=n? l

--cor r 35^ c n:!s TO S71R7_U "

end loop:

loop

1*1 W * W V t '_ ~" * --\ . i^ •' « f ITM" K / • : *~ ? \ f ' '. '* '— '—' O

MCVIC7 3 = > X??N^ , -•'JC'V - > X 32')"_L !

MCv:C7- : => Xi-i = 2, =A'?. M • => X'^Z.LPC

X?N X := x (; c 2 * l. i=:-H:x v--v; - Y?D I

X»^N X := D = "i VA" :v"(x = -;X) :

7=:ii\-5= ":.-C V A LU" -> X'TV'X t

S-'JJ.T - = > C ,

7 A AMS = ;3( VALL! ? •-> X- ~'J V ,

loop

- - £• u s y 1 o o c . r r. i t i r r f c

--c cr r-s 2.->or.cis to "ZSU'-' v

e n c! 1 o o rj :

s? n cl loop:

ana £ ;

A.11
SE S3

POOR QJJAUTY

procac'ur? C 1.5

procedure C is

x:;?2, x?:?:,

x:?., x:.

begin

loop

- -3 u s y i o c .- i U ?. i t .1 n g Tor 5 i r r. ? 1

--corr a spends to S7iRT_U?

end loop 5

loop

MGVECT Q => XPC-fi, r"QM => X3 ?N_LOC )T

MOVE: (TO => XPCN?,

 CRC'-1 => X?CN'?_LnC )!

:j>.CV = (T2 => Xi;?3, r K:.H--> X=;3 3_L^C ):

TSi'^SFr^ C ViLU: => XTN ,

s:r-;r-_TG => o,

A^OSSS S => Xdls°2_LO C ) :

T^iNSF^P'CViLU r = > XM ,

SvV:C_T C => 3 ,

iCD^.~S S => XNPZ.LO C 5:

TCAIiSc^CVALU 1: => Xf l

iOD?. "-SS => X\P2_LC. C ^:

loop

exit * h ? n I 'I ? U T _ ' = : ^ Y :

- - :: L 3 y loop, '.u a i t '. n : for signal

--c err 9 sponci's to >~5U''1:;

e n cl loop;

e nci 1 oop ; •

end C;

,A.12
OF POOR

procedure . D is

a u e _ s

x D ? N 2 i x ; : ~ : : . v ? c T •• r :

loop

exit *• h •:• n I '.' = U T _ R E L 3 Y :

--i-Ls y I oop » TT'ltin.!

 for .-i.in?

--corr93;;on cis to 5Tip T_ U ?

e n ci 1 o c p '•

loop

^ov c( T j => v^.-pz, F^C V => XOW P

."ifTVi-CT j => XN?3 ,

 c "Qf-' => X\! D 3_

x;i ^ := x:v- 3 -*• :.o -> H ^- x?:<°2'-

XD-J P := :- -.: V-IT I v-cxr.' ) :

S=MC_T C => D,

iD"^ = 33 => X'J??_LC C ):

viLu:: => X';*,

S^N:_T - ^> c ,

-J:R:SS => XM=-?_LC C •):

sxit 'ir. sr> l::?'JT_^'5":-Y:

- - ; u s y 1 o o 3 > f ? i t i n :: for s i c r, ? I

- - c o r r = -s a o n «! s to P. r " U '•' '~

•9 n :i 1 o c p '

end j ',

A: 13
procacura I G P is

X-;;X ,

< = i.xz : V-3CT2'. :

uss T5XT..IO;

pc-.ckjise INT_

packag e REAL_I T is r\sv FLC .- T_ I •? ( CL Ci T )

'

SI • i • <• * "J : ~ £ T— il

rirj : FLGiT := o.C3 :

TV .: cirr?y (1..500 ) of =LC.-T:

XV : arrtiy < 1 . . f OH ) o f = L ' i * : ,

i r.

r. ccsc t sHS'Jw? :

TVC1) := TIN1;

TRANSFE R CONTROLLE R . SIoNAL :

/or I in 1 -. . ; . loo p

rtCVSCTG => x.-':x:, •=?"••' => x = !;x.2

MCVrCT C = > X-'JX . --•:•>' - > XP'JX. L

loop

= xit -'hsn INFUT_ ^ -i?Y :

- - £ u s y loco, mritin: for s i 5 r. ? 1

- - c o r r 3 3 p o n :i s to " = .5 U "• r

sr\c. loop!

x v c s : ) : -

 c : ? s T c x .- < •. •* ) :

XVC3 1 * 15 := rI-STC X = --:X2) :

it M > 1 then

T v ( s i ; : = T v c s i - i) * H :

and if;

T V C 5 i •* 15 : = T V C 3 1 5 * H :

Si := s: * 2:

9 n ;l I D o ^ J

? U T C f; ) ;

«• 1 1070

r U T C T V ( I ) ) I

r u T c x v c:)) :

:.:- i T •; - •

c r o c e c.' u r a IG P is

end loop!

n ci I j = ;

A.14
RUN OF THE PRECOMPILER OUTPUT ON A SIMULATED NETWORK

The procedures output by the precompiler were run on a

network simulated by a set of Ada tasks running on a WICAT

computer on which a large subset of Ada is implemented. Each

task of the following program represents a processor node of a

network.

After the original program was split by the preprocessor, the

components were moved to the WICAT and all non-supported Ada

features were removed (manually). The components were then

recombined into the following program, compiled using the WICAT

Ada compiler, and run.

A.15
ORIGJW&L PAQE 5S

QCTOOR QUALITY

This i a => arogrcin consist s of s a v 9 r a 1 co-npilr.tion units and compiles

-- This Ada program consist s of savars l compilation units and compiles

-- . on tne..Wic.a.t .Ada ...c.omp.il.e.r..._ _ _.

It a'as produced by running the precompiler written by Laurie King

on the file Another. ac!«i which contr, ir.s the source (almost) equivalent to

tne Ada pr og.r a.-Ti. .or i -.3in al.ly run stiCfiSE.. . ._ ._

Aftar splitting the program the- coupons nt-s mere moved to the Wicat and all

— .non.-suppo.r tad-Ads—f .ea t.ur es (usr.e .re'mova:!. ..... .T.he_. component s were-then

reconibinad and coriipi laci. Two discrepancies from the 1C A SE-cor rec t version

-- oiere discovered ?.nc! correct?d? V?rirbl-?s mere mistyped resulting in

oth^r. progr am v.cir.iri!:! 9 n?nes.. .. . ...

with global ? u s 9 -51 o ia 3 11

u/ith vec tors ; ...use.. v = c tors ; ... . . ... . . ... . _...

with bus; use bus I

win T;XT_I:; us=3 T"xT _ic;

. --WITH :NT:GE5_!G.,

—FLCAT_IOCFLCAT)!

^) ' Use intsjer_iotflo?! t_ioJ

._ r.ro.c.edur.e_jiiai.n... is ...... . ... ._ ._ .

task A is end

,j task Sis enc!

task C i s . 5 n c!

task D is end

^) task I OP is end;

task body A is

x N P :, *?DI; : VECTOR ;

. XPNX2 , X?Ci\X2 : VECTO R := C^IGIP.1 ;-

b e .3 i n

loop

c x i t u; h e n IN "' J T _ ^ E A D Y t

! - - 2 u s y _ 1 o o p i T ? i t i n 3 for.sijn?!

--corresponds to ST1P"_UP

andlooo l

loop

v, -j v' c x ? c:<, x P 2-:•;_ L co;

A.16
This Aclr, progrs-n consist s of sevsr.-.l CD-n o i 1 ? t i on units and compiles

M2VECXNP2 , XN?I_LCC )I -

XPUX 2 := XMP 2 * i.O^H-XPDM:

^ X ? D f-i X 2 : = D 5 R I V A T I V •; ( X P H X 2 >,:

T.R ANS.r E.rL.C_X?.'i.X.2.» _

I0?_task,

*' XPNX2 LDC );

5_tssk,

l.tcisk,

YA r o - ">'• .! • ' _ n u f. > J •- • ) •

.loop _____________ ___________________________ ........

sxi-t u;han I\'PUT_R = AOY :

-.- 3 u s y 1 o o p f a- 5 i t i n g for 3 i •- n

end loop!

end loop;

end A; ............. _ ......

task body 3 is

XMP.2, X?2U,...X.?3rL=.....:_....V3C.T3?>:

X?NX , x

3

o-:-;x : VHCTC - : = G^IS I

begin ..... _ . . ...... .. ________

loop

exit uh<?r> :NPUT_<?S.IOY:

r-.Susy .looo., . u;.aitin3 for siGn

--corresponds to STi^ T_

:

J-: >

c n •;! 1 o c p ;

. loop ......... . .. . ..... .

CX?D;.!, XPON.LCC ):

XN?2_L!Ti C

A.17
OR2GISW,

OF POOR QUALFTY

Tnis Ac!a pro^ra^i consists of s^v?r?. 1 compilation units and compiles

I3P_tssk,

X°ON?_LOC ): ,

- ...7?lA.MSF.= .

!?C.X?r-.NX.,._. ....... -

3 _ t c. s !< ,

'

;'$ XPDf,'^_LCC )!

' . lo.Op _._ _

exit when INPUT_R5AOY :

» —Susy loop » • waiting "for =ign?l

' . -_ .--conrasponda _to ..R.E.SUME.._ _

end loop J

% e nd 1oop J

en.a,_3.; _

. ..ta.sk.. body..... C.._i.s _

X N ? 3 t X ? D N , X P D \\ ? : V " C T C P I

XON, XN : VECTC ^ := ORIGIN:

begin

loop

...._ A.xXt..Ji'.b.e-n.. IWE'-'T._"=.?.?Y.» _

--3usy loop, uniting for signsi

--corresponds to STftRT_U?

...e.n_d_ loop;

loop

MO_V.c(X.?DN.,_..XFj3N_L.CC_..>.; ..

?UT_LIN=("C"):

MGVECX ? ji-.'F, X?DNP_LGC ):

_^cy = cxfi?3i xr;-P3_LGC ):

XN := Xf.;?3 - 1.5*H*CXPON' - 3.0

XON := OcRIV*TIV£(XN'):

TRANSfcLCXON.......

D_t£!Sk,

X^f.1?. LGC )!

A.18
This Ada p r o g r ?. -i consists o * sever?! compilation units and compiles

TRANSr^CXM ,

__________________ 3_.task.,_ .......

X.N?2_LCC ):

7RANSF5SCX.N ,

XNP2_LOC );

loop

. .. sxit...-u;h-2.n.. INPU7_?:r.OY :

- - 5 u s y 1 o c p » a- s i t i r, a for ? i ? n r I

--corresponds to 3 = 5 U •'•'• I

......... end .loop.; ____________ ..... _____

end loop!

end C J

t a s k body 3 is

X ON- P. 2 i _X.M?.3..:...yrC7c:.? ;

Xf-iP : VECTO " := o<?ZGir.':

. bagin ...... '.

loop

exit 'i'hop .','F'j7_q vAD Y :

..... --3usy. . Iocs ». .u.-c>i.tin- for sig

--corresponds to STiR T_U?

e n d 1 o o p J

• . loop ........ . .....

MOV;CXDf;P2 , XDN?2_LCC ):

~ \ 1 7 i T ?x' r r 'i f " > j

MOV=CXN?5 , XNe 3_LDC );

x N P : = x N c 2 + z . o =" h ~ x : ?i ?

TRiHSFERCXfJP ,

xr.^3 LOG ):

loop

. sxit u.hen.. I'JF.'J.T.^r i.DY;

--3usy loop, aT.itinj tor ^I'j

- - c c r r ~ 5 p c n a s to -1 E S U .'•'•:

A.19
ORIGINAL PAGE IS

OF POOR QUALITY

This Ada program consists of = s v a r £ 1 compilation units and compiles

end loop :

....... end. lo.ap:._

e n d D ;

task body I OP is

* XFNX ,

. . XPNX.2...:. V.Z.C.T.O.R: .

? SI : I N T s G S R : = 1:

• „ II_N...:. JiLC..Al_:.=._G...O.«:

TV : arrc-y C1..50G) of FLOAT ;

."> XV : ?rrsy C1..500) of "L?iT;

d loo p

.e.x.i.t.._u)i.eo....I.N.P_U.T_R5APY;

--Susy loop » (jnitin- j fo r signa l

0 --corr a sponcls to STAR!_tl ?

. _. .end ..l.o.op.5

--accept RESUME :

0 T V C l) : = T: N;

. _ _.r-TRA.NS.£E.R_C..C.MI!::CLLE.R . SIGNA L : ..

0

for . I__in-..l...{'!.. looo. . . . . ..

?UT_L:N=C"?") :

0 --accept RSSU-'-'E:

. .MCV;CX.pNX 2 , XPNXZ^LO C ):

M^VECXPNX , X D'.'X_LO C ) J

0 loop

.; _....s.xi.t...ui.h.en.INFUT_R.EADY:

--Susy loop » uj^.iti n j tor sisnsl

0 --corr esnoncls to -vSU'i" .

_encl. .loop.!. _ .. ...

XVCS 1 ) : = FIKST(X°NX) :

tf x'vcsi + i) := FiRST(x?r:x2) ;

_ __i.f__I. _>.. 1 ..then

TVCS1 ) := TVCS I - l) * H;

0 s n d 11 ;

A 20 *
This Ada program consists of several CD ^pilr.tion units and compiles

-. ..si

end loop J

PUTCrJ);

for I in 1 . . f .' + 1 loop

PUTCTV(I));

puicx.vc i )..).; __________________ .....

s n d I o o p !

..... and I.C.PJ .....

begin

NULL ; . _ __

P L'T _ LI ?.' £ C " X X X " ) ; pu t_l i ne C " M a i n " ) :

A. 2.1
ORIGINAL ...PA3E IS.

OF POOR QUALITY

<l i t h global! u s a global!

9 • With global; use

with .v.ec.to.r_s.5 _.u.s.e.._v..e.c.tors.; . . .... _

} package EDS is

INPUT_REAOY f boolesTnTM : = true 5 " -

typ9_3.U.S_A_ODR. ..is _C XP.PH_LO.C , X?.;JX2_L.?_C t.XO.MP.2_LO.C ».. XNP2.LQC,

YPC-\'P_LCC , XPN'Xlt?C, XNP3ILOC):

^lJYv~T~"Tp7RAY'"~C3U3~a"odRy'of VtCTOKJ' "

• _pr,o.ce..d.ur.9....tl.O.VE_ C. .T.O..: .out. VECTOR ; _ _.. L

. proc.ecl.ur.3. ..T?A N3F E =:.. CValu s : V-CTC^ t

•end 3US:

-uitn ..tex.t_io ; .usa...t sxt_io : _

package body 3US is

.. p.roc.edur.e_..M.CV.c...C._TQ : out V5CT.G.R J '. "..._...

' " R : M : ~. U 5 _ £. D D R ) i s

..begi n . .

put_lin«C"r,;ov-3") I

p ?UT_L:NIE CI IL ") ;

?uT_L;r;EC"L") :

P end mova ?

procedure T"A?.'5F E- CVIL'JE V'CTC?:

9 S".M3_TC T£SK_N£V.E:

— ADDRES S 3US_AD.DR) .is

b s i i n

9 put_line("trsnsfar"):

- • • • A.,22 - -.--
Wit h global ; us e global ;

•3USV C ADDRESS ) t = VfiLUE!

._. null.; _ ._

and;

end 5US; ....

I

I

A.2 3

PRECEDING PAGE BLANK NOT