Docsity

Precise Interrupts in Computer Architecture: In-Order Completion and Reorder Buffer, Papers of Electrical and Electronics Engineering

Toggle sidebar
bg1
IMPLEMENTATION OF PRECISE INTERRUPTS IN PIPELINED PROCESSORS
James E.
Smith
Department of Electrical and Computer Engineering
University of Wisconsin-Madison
Madison, 14'1 53706
Andrew R. Pleszkun
Computer Sciences Department
University of Wisconsin-Madison
Madison. WI 53706
Abstract
An interrupt is precise if the saved process state corresponds with
the sequential model of program execution where one instruction com-
pletes before the next begins. In a pipelined processor, precise inter-
rupts are difficult to achieve because an instruction may be initiated
before its predecessors have been completed. This paper describes and
evaluates solutions to the precise interrupt problem in pipelined proces-
sors.
The precise interrupt problem is first described. Then five solu-
tions are discussed in detail. The first forces instructions to complete
and modify the process state in architectural order. The other four
allow instructions to complete in any order, but additional hardware is
used so that a precise state can be restored when an interrupt occurs.
All the methods are discussed in the context of a parallel pipeline struc-
lure. Simulation results based on the CR.AY-IS scalar architecture are
used to show that, at best, the first solution results in a performance
degradation of about 16~. The remaining four solutions offer similar
performance, and three of them result in as litlle as a 3% performance
loss. Several extensions, including virtual memory and linear pipeline
structures, are briefly discussed.
1.
Introduction
Most current computer architectures are based on a sequential
model of program execution in which an architectural program counter
sequences through instructions one-by-one, finishing one before start-
ing the next. In contrast, a high performance implementation may be
pipelined, permining several instructions to be in some phase of execu-
tion at the same time. The use of a sequential architecture and a pipe-
lined implementation clash at the time of an interrupt; pipelined
instructions may modify the process state in an order different from that
defined by the sequential architectural model. At the time an interrupt
condition is detected, the hardware may not be in a state that is con-
sistent with any specific program counter value.
When an interrupt occurs, the state of an interrupted process is
typically saved by the hardware, the software, or by a combination of
the two. The process state generally consists of the program counter,
registers, and memory. If the saved process state is consistent with the
sequential architectural model then the interrupt is
precise.
To be more
specific, the saved state should reflect the following conditions.
(1) All instructions preceding the instruction indicated by the saved
program counter have been executed and have modified the pro-
oess state correctly.
(2) All instructions following the instruction indicated by the saved
program counter are unexecuted and have not modified the pro-
cess state.
(3) If the interrupt is caused by an exception condition raised by an
instruction in the program, the saved program counter points to
the interrupted instruction. The interrupted instruction may or
may not have been executed, depending on the definition of the
architecture and the cause of the interrupt. Whichever is the
case, the interrupted instruction has either completed, or has not
started execution.
If the saved process state is inconsistent with the sequential architec-
tural model and does not satisfy the above conditions, then the interrupt
is
imprecise.
This paper describes and compares ways of implementing precise
interrupts in pipelined processors. The methods used are designed to
modify the state of an executing process in a carefully controlled way.
The simpler methods force all instructions to update the process state in
the architectural order. Other, more complex methods save portions of
the process state so that the proper state may be restored by the
hardware at the time an interrupt occurs.
l,l, C|assification of Interrupts
We consider interrupts belonging to two classes.
(1)
Program interrupts,
sometimes referred to as "traps', result from
exception conditions
detected during fetching and execution of
specific instructions. These exceptions may be due m software
errors, for example trying to execute an illegal opcode, numerical
errors such as overflow, or they may be part of normal execution,
for example page faults.
(2)
Exwrnal inwrrupls
are not caused by specific instructions and are
often caused by sources outside the currently executing process,
sometimes completely unrelated to it. I/O interrupts and timer
interrupts are examples.
For a specific architecture, all interrupts may be defined to be
precise or only a proper subset. Virtually every architecture, however,
has some types of interrupts that must be precise. There are a number
of conditions under which precise interrupts are either necessary or
desirable.
(1) For I/O and timer interrupts a precise process state makes res-
tarting possible.
(2) For software debugging it is desirable for the saved state to be
precise. This information can be helpful in isolating the exact
instruction and circumstances that caused the exception condition.
(3) For graceful recovery from arithmetic exceptions, software rou-
tines may be able to take steps, re-scale floating point numbers
for example, to allow a process to continue. Some end cases of
modern floating point arithmetic systems might best be handled
by software; gradual underflow in the proposed IEEE floating
point standard [Stev81], for example.
(4) In virtual memory systems precise interrupts allow a process m
be correctly restarted aher a page fault has been serviced.
(5) Unimplemented opcodes can be simulated by system software in a
0149-7111/85/0000/0036501.00 © 1985 IEEE
36
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Precise Interrupts in Computer Architecture: In-Order Completion and Reorder Buffer and more Papers Electrical and Electronics Engineering in PDF only on Docsity!

I M P L E M E N T A T I O N O F P R E C I S E I N T E R R U P T S I N P I P E L I N E D P R O C E S S O R S

James E. S m i t h

Department of Electrical and Computer Engineering University of Wisconsin-Madison Madison, 14'1 53706

Andrew R. Pleszkun

Computer Sciences Department University of Wisconsin-Madison Madison. WI 53706

Abstract

An interrupt is precise if the saved process state corresponds with the sequential model of program execution where one instruction com- pletes before the next begins. In a pipelined processor, precise inter- rupts are difficult to achieve because an instruction may be initiated before its predecessors have been completed. This paper describes and evaluates solutions to the precise interrupt problem in pipelined proces- sors.

The precise interrupt problem is first described. Then five solu- tions are discussed in detail. The first forces instructions to complete and modify the process state in architectural order. The other four allow instructions to complete in any order, but additional hardware is used so that a precise state can be restored when an interrupt occurs. All the methods are discussed in the context of a parallel pipeline struc- lure. Simulation results based on the CR.AY-IS scalar architecture are used to show that, at best, the first solution results in a performance degradation of about 1 6 ~. The remaining four solutions offer similar performance, and three of them result in as litlle as a 3% performance loss. Several extensions, including virtual memory and linear pipeline structures, are briefly discussed.

1. Introduction Most current computer architectures are based on a sequential model of program execution in which an architectural program counter sequences through instructions one-by-one, finishing one before start- ing the next. In contrast, a high performance implementation may be pipelined, permining several instructions to be in some phase of execu- tion at the same time. The use of a sequential architecture and a pipe- lined implementation clash at the time of an interrupt; pipelined instructions may modify the process state in an order different from that defined by the sequential architectural model. At the time an interrupt condition is detected, the hardware may not be in a state that is con- sistent with any specific program counter value.

When an interrupt occurs, the state of an interrupted process is typically saved by the hardware, the software, or by a combination of the two. The process state generally consists of the program counter, registers, and memory. If the saved process state is consistent with the sequential architectural model then the interrupt is precise. To be more specific, the saved state should reflect the following conditions.

(1) All instructions preceding the instruction indicated by the saved program counter have been executed and have modified the pro- oess state correctly.

(2) All instructions following the instruction indicated by the saved program counter are unexecuted and have not modified the pro- cess state.

(3) If the interrupt is caused by an exception condition raised by an instruction in the program, the saved program counter points to

the interrupted instruction. The interrupted instruction may or may not have been executed, depending on the definition of the architecture and the cause of the interrupt. Whichever is the case, the interrupted instruction has either completed, or has not started execution. If the saved process state is inconsistent with the sequential architec- tural model and does not satisfy the above conditions, then the interrupt is imprecise. This paper describes and compares ways of implementing precise interrupts in pipelined processors. The methods used are designed to modify the state of an executing process in a carefully controlled way. The simpler methods force all instructions to update the process state in the architectural order. Other, more complex methods save portions of the process state so that the proper state may be restored by the hardware at the time an interrupt occurs.

l , l , C|assification of I n t e r r u p t s We consider interrupts belonging to two classes. (1) Program interrupts, sometimes referred to as "traps', result from exception conditions detected during fetching and execution of specific instructions. These exceptions may be due m software errors, for example trying to execute an illegal opcode, numerical errors such as overflow, or they may be part of normal execution, for example page faults. (2) Exwrnal inwrrupls are not caused by specific instructions and are often caused by sources outside the currently executing process, sometimes completely unrelated to it. I/O interrupts and timer interrupts are examples. For a specific architecture, all interrupts may be defined to be precise or only a proper subset. Virtually every architecture, however, has some types of interrupts that must be precise. There are a number of conditions under which precise interrupts are either necessary or desirable. (1) For I/O and timer interrupts a precise process state makes res- tarting possible. (2) For software debugging it is desirable for the saved state to be precise. This information can be helpful in isolating the exact instruction and circumstances that caused the exception condition. (3) For graceful recovery from arithmetic exceptions, software rou- tines may be able to take steps, re-scale floating point numbers for example, to allow a process to continue. Some end cases of modern floating point arithmetic systems might best be handled by software; gradual underflow in the proposed IEEE floating point standard [Stev81], for example. (4) In virtual memory systems precise interrupts allow a process m be correctly restarted aher a page fault has been serviced. (5) Unimplemented opcodes can be simulated by system software in a

0149-7111/85/0000/0036501.00 © 1985 IEEE

way transparent to the programmer if interrupts are precise. In this way, lower performance models of an architecture can main- rain compatibility with higher performance models using extended instruction sets. (6) Virtual machines can be implemented if privileged instruction faults cause precise interrupts. Host software can simulate these instructions and return to the guest operating system in a user- transparent way.

1.2. Historical Survey' The precise interrupt problem is as old as the first pipelined com- puter and is mentioned as early as Stretch [Buch62]. The IBM 360191 [Ande67] was a well-known computer that produced imprecise inter- rupts under s o m e circumstances, floating ix~int exceptions, for exam- ple. Imprecise interrupts were a break with the IBM 360 architecture which made them even more noticeable. All subsequent IBM 360 and 370 implementations have used less aggressive pipeline designs where instructions modify the process state in strict program order, and all interrupts are precise, t A more complete description of the method used in these "linear" pipeline implementations is in Section 8.4. Most pipelined implementations of general purpose architectures are similar to those used by IBM. These pipelines constrain all instructions to pass through the pipeline in order with a stage at the end where exception conditions are checked before the process state is modified. Examples include the Amdahl 470 and 5 8 0 [AmdhS1,AmdhS0] and the Gould/SEL 32187 [Ward82]. The high performance CDC 6600 [Thor70J, CDC 7600 [Bons69]. and Cray Research [Russ78. Cray79] computers allow instructions to complete out of the architectural sequence. Conse- quently, they have some exception conditions that result in imprecise interrupts. In these machines, the advantages of precise interrupts have been sacrificed in favor of maximum parallelism and design simplicity, I/O interrupts in these machines are precise, and they do not imple- ment virtual memory.

The CDC STAR-100 [HiTa72] and CYBER 200 [CDCSI] series machines also allow instructions to complete out of order, and they do support virtual memory. In these machines the use of vector instructions further compficates the problem, and all the difficulties were not fully recognized until late in the development of the STAR-

  1. The eventual solution was the addition o f an invisible excha~tge package [CDCSI]. This captures machine-dependent state information resulting from partially completed instructions. A similar approach has more recently been suggested in MIPS [Henri82] where pipeline infor- mation is dumped at the time of an interrupt and restored to the pipeline when the process is resumed. This solution makes a process restartable although it is arguable whether it has all the features and advantages of an architecturally precise interrupt. For example, it might be neces- sary to have implementa'tion-dependent software sift through the machine-dependent state in order to provide complete debug informa- tion. The recently-announced CDC CYBER 180/990 [CDC84] is a pipelined implementation of a new architecture that supports virtual. memory, and offers roughly the same performance as a CRAY-IS. To provide precise interrupts, the CYBER 180/990 uses a history buffer, to be described later in this paper, where state information is saved just prior to being modified. Then when an interrupt occurs, this "history" information can be used to back the system up into a precise state.

1.3. P a p e r Overview This paper concentrates on explaining and discussing basic methods for implementing precise interrupts in pipelined processors. We emphasize scalar architectures (as opposed to vector architectures) because of their applicabilit 3, to a wider range of machines. Section 2

IExcept for the models95 and 195 which were derived from the original model 91 design. Also. the models 85 and 165 had imprecise interrupts for the cgse of protection exceplions and .addressingexceptionscaused b)' store oIx'rations.

describes the model architecture to be used in describing precise inter- rupt implementations. The model architecture is very simple so that the fundamentals of the methods can be clearlv described. Sections 3 through 6 describe methods for implementing precise interrupts. Sec- tion 3 describes a simple method thal is easy to implement, but which reduces performance. It forces instructions to complete'in architectural order which sometimes inhibits the degree of parallelism in a pipelined system. Section 4 describes a higher performance variation where results may be bypassed to other instructions before the results are used to modify the process state. Sections 5 and 6 describe methods where instructions are allowed to complete in any order, but where state infor- mation is saved so that a precise state may be restored when an inter- rupt occurs. The descriptions of these methods assume that the only state information is the program counter, general purpose registers, and main memo~-. The methods are also discussed in the absence of a data cache. Section 7 presents simulation results. Experimental results based on these CRAY-IS simulations are presented and discussed. Section 8 contain a brief discussion of 1) saving additional state infor- mation, 2) supporting virlual memory, 3) precise interrupts when a data cache is used, and 4) linear pipeline structures.

2. Preliminaries

2,1. Model Architecture

For describing the various techniques, a model architecture is chosen so that the basic methods are not obscured by details and unnecessary complications brought about by a specific architecture. We choose a'register-register architecture where all memory accesses are through registers and all functional operations involve registers. In this respect it bears some similarity to the CDC and Cray architectures, but has only one set of registers. The load instructions are of the form: Ri = (Rj+disp). That is, the content of Rj plus a dis- placement given in the instruction are added to form an effective address. The content of the addressed memory location is loaded into Ri. Similarly, a store is of the form: (Rj + disp) = RJ, where Ri is stored at the address found by adding the content of Rj and a displace- ment. The functional instructions are of the form Ri = Rj up Rk, where up is the operation being performed. For unary operations, the degenerate form Ri s up Rk is used. Conditional instructions are of the form P = disp : Ri up Rj, where the displacement is the address of the branch target; up is a relational operator, = , > , < , etc. The only process state in the model architecture consists of the program counter, the general purpose registers and main memory. The architecture is simple, has a minimal amount of process state, can be easily pipelined, and can be implemented in a straightforward way with parallel" functional units like the CDC and Cray architectures. Hence, implementing precise interrupts for the model architecture presents a realistic problem. Initially. we assume no operand cache. Similarly, condition codes are not used. They add other problems beyond precise interrupts when a piperined intplementation is used. Extensions for operand cache and condition codes are discussed in Section 8. • The implementation for the simple architecture is shown in Fig.

  1. It uses an instruction fetch/decode pipeline which processes instruc- tions in order. The last stage of the fetch/decode pipeline is an issue register where all register interlock conditions are checked. If there are no register conflicts, an instruction issues to one of the parallel functional units. Here, the memory access function is implemented as one of the functional units. The operand registers are read at the time an instruction issues. There is a single result bus that returns results to the register file. This bus may be reserved at the time an instruction issues or when an instruction is approaching, completion. This assumes the functional unit times are deterministic. A new instruction can issue every clock period in the absence of register or result bus conflicts.

3.1. Registers

To implement precise interrupts with respect to registers using the above pipeline control structure, the control should "reserve" stages i < j as well as stage j. That is, the stages i < j that were not previ- ously reserved by other instructions are reserved, and they are loaded with null control information so that they do not affect the process state. This guarantees that instructions modifying registers finish in order.

There is logic on the result bus that checks for exception condi- lions in instructions as thev complete. If an instruction contains a non-masked exception condition, then control logic "cancels" all subse- quent instructions coming on the result bus so that they do not modif the process stale.

Example 3

For our sample section of code given in Example 1, assuming the the result shift register is initially empty, such a policy would have the floating point add instruction reserve stages 1 through 6 of the result shift register. When, on the next clock cycle, the integer add is in the issue register, it would normally issue and reserve stage 2. However, this is now prohibited from happening because stage 2 is alread)- reserved. Thus, the integer add must wait at the issue stage until stage 2 of the result shift register is no longer reserved. This would be 5 clock periods after the issue of the floating point add.

A generalization of this method is to determine, if possible, that an instruction is free of exception conditions prior to the time it is com- plete. Only result shift register stages that will finish before exceptions are detected need to be reserved (in addition to the stage thai controls the result).

3.2. Main ~lemory Store instructions modify the pot-lion of process state that resides in main memory. To implemenl precise interrupts with respect to+ memory, one solution is to force store instructions to wait for the result shift register to be empty before issuing. Alternatively, stores can issue and be held in the load/store pipeline until all preceding instructions are known to be exception-free. Then the store can be released to memory. To implement the second alternative, recall that memory can be treated as a special functional unit. Thus, as with any other instruc- lion, the store can make an entry in the result shift register. This entry is defined as a dummy store. The dummy store does not cause a result to be placed in the registers, but is used for controlling the memory pipeline. The dummy store is placed in the result shift register so that it will not reach stage ] until the store is known to be exception-free. When the dummy store reaches stage 1, all previous instructions have completed without exceptions, and a signal is sent to the load/store unit to release the store to memory. If the store itself contains an exception condition, then 'the store is cancelled, all following load/store instruc- tions are cancelled, and the store unit signals the pipeline control so that all instructions issued subsequent to the store are cancelled as they leave the result pipeline.

3.3. Program Counter To implement precise interrupts with respect to the program counter, the result shift register is widened to include a field for the program counter of each instruction (see Fig. 2). This field is filled as the instruction issues. When an instruction with an exception condition appears at the result bus. its program counter is available and becomes parl of the saved slate.

4, The Reorder Buffer The primary disadvantage of the above method is that fast instruc- lions may sometimes get held up at the issue register even though the) have no dependencies and would otherwise issue. In addition, the)' block the issue register while slower instructions behind them could conceivably issue.

This leads us to a more complex, but more general solution. Instructions are allowed to finish out of order, bul a special buffer calico the reorder buffer is used to reorder them before the), modify the process slate.

4.1. Basic Method The overall organization is shown in Fig. 3a. The reorder buffer, Fig. 3b, is a circular buffer with head and tail pointers. Entries between the head and tail are considered valid. At instruction issue time the next available reorder buffer entry, pointed to by the 'tail pointer, is given to the issuing instruction. The tail pointer value is used as a lag to idemify the entry in the buffer reserved for the instruction. The tag is placed in the result shift register along with the other control informa- lion, The tail pointer is then incremented, modulo the buffer size. The result shift register differs from the one used earlier because there is a field containing a reorder tag instead of a field specifying a destina- tion register.

REGISTER

FILE

I

REORDER L / BUFFER

SOURCE DATA T O FUNCTIONAL UNIT

RESULT SHIFT REGISTER

L CONTROL

RESULT BU

(a)

ENTRY BEST. IZXCEP-! PROGRf~M NUMBER REG, RESULT rIONS UALID (^) COUNTER

3 HEAD-~ 4 4 B 5 e B TAIL--~ S

REORDER BUFFER

STAGE FUNCTIONAL UNIT SOURCE 1

3 DIRECTIO 4 OF / 5 MOVEMENT i N

UALIB TAG

INTEGER ADD £ B B FLT PT A D D I

i •

- 9

RESULT SHIFT REGISTER

(b)

Figure 3. (a) Reorder Duffer Organization. (b) Reorder Buffer and associated Result Shift Register.

When an instruction completes, both results and exception condi- tions are sent to the reorder buffer. The tag from the result shift regis- ter is used to guide them to the correct reorder buffer entry. When the entry at the head of the reorder buffer contains valid results (its instruc- tion has finished) then its exceptions are checked. If there are none, the results are written into the registers. If an exception is detected, issue is stopped in preparation for the interrupt, and all further writes into the register file are inhibited.

Example 4 The entries in the reorder buffer and result shift register shown in Figure 3b reflect their state after the integer add from Example 2 has issued. Notice that the result shift register entries are vet3, similar to those in the Figure 2. The integer add will complete execution before the floating point add and its results will be placed in entry 5 of the reorder buffer. These results, however, will not be wrhaen into R until the floating point result, found in entry 4, has been placed in R4.

4.2. M a i n M e m o r y Preciseness with respect to memory is maintained in manner similar to that in the in-order completion scheme (Section 3.2). The simplest method holds stores in the issue register until all previous instructions are known to be free of exceptions. In the more complex method, a store signal is sent to the memor3, pipeline as a "dummy" store is removed from the reorder buffer. Stores are allowed to issue, and block in the store pipeline prior to being committed to memory while they wait for their dummy counterpart.

,4.3, P r o g r a m C o u n t e r To maintain preciseness with respect to the program counter, the program counter can be sent to a reserved space in the reorder buffer at issue time (shown in Figure 3b). While the program counter could be sent to the result shift register, it is expected that the result shift register will contain more stages than the reorder buffer and thus require more hardware. The length of the result shift register must be as long as the longest pipeline stage. As will be seen in Seclion 7, the number of entries in the reorder buffer can be quite small. When an instruction arrives at the head of the reorder buffer with an exception condition, the program counter found in the reorder buffer emrx, becomes part of the saved precise state.

4.4. Bypass Paths

While an improvement over the method described in Section 3, the reorder buffer still suffers a performance penalty. A computed result that is generated out of order is held in the reorder buffer until previous instructions, finishing later, have updated the register file. An instruction dependent on a result being held in the reorder buffer can- not issue until the result has been wrirten into the register file. The reorder buffer may, however, be modified to minimize some of the drawbacks of finishing strictly in order. For results to be used early, bypass paths may be provided from the entries in the reorder buffer to the register file ourput latches, see Fig. 4. These paths allow data being held in the reorder buffer to be used in place of register data. The implementation of this method requires comparators for each reorder buffer stage and operand designator. If an operand register designator of an instruction being checked for issue matches a register designator in the reorder buffer, then a multiplexer is set to gaie the data from the reorder buffer to the register output latch. In the absence of other issue blockage conditions, the instruction is allowed to issue, and the data from the reorder data is used prior to being written into the register file. There may be bypass paths from some or all of the reorder buffer entries. If multiple bypass paths exist, it is possible for more than one destination entry in the reorder buffer to correspond to a single regis- t e l Clearly only the latest reorder buffer entry" that corresponds to an operand designator should generate a bypass path to the register output latch. To prevent muhiple bypassing of the same register, when an

EGISTER _ ~

- ~ ~ C E ~ T R

FILE TO F~CTIONRL UNITS

' f

~MPARATORS/ RESULT

I B Y P A ~ SHIFT

I E T N ~ K REGISTER

tll I I

BUFFER RESULT BUS

Figure 4. Reorder Buffer Method with Bypasses.

instruction is placed in the reorder buffer, an}' entries with the same destination register designator must be inhibited from malching a bypass check. W h e n bypass paths are added, preciseness with respect to the memory and the program counter does not change from the previous method. The greatest disadvantage with this method is the n u m b e r of bypass comparators needed and the amount of circuitr 3' required for the multiple bypass check. While Ibis circuitry is conceptually simple, there is a great deal of it.

5, History Buffer The methods presented in this section and the next are intended to reduce or eliminate performance losses experienced with a simple reorder buffer, but without all the control logic needed for multiple bypass paths. Primarily, these methods place computed results in a working register file, but retain enough state information so a precise state can be restored if an exception occurs. Fig. 5a illustrates the histo~' buffer method. The history buffer is organized in a manner verx similar to the reorder buffer. At issue time, a buffer entry is loaded with control information, as with the reorder buffer, but the value of the destination register (soon to be overwritten) is also read from the register file and written into the buffer entry. Results on the result bus are written directly into the register file when an instruction completes. Exception reports come back as an instruction completes and are written into the history buffer. As with the reorder buffer, the exception reports are guided to the proper history buffer entry through the use of tags found in the result shift register. When the history buffer contains an element at the head that is known to have finished without exceptions, the history buffer entry is no longer needed and that buffer location can be re-used (the head pointer is incremented). As with the reorder buffer, the history buffer can be shorter than the maximum number of pipeline stages. If all history buffer entries are used (the buffer is too small), issue must be blocked until an entry becomes available. Hence the buffer should be long enough so that this seldom happens. The effect of the history buffer on performance is determined in Section 7.

E x a m p l e 5 'The entries in the history buffer and result shift register shown Fig. 5b correspond to our code in Example 1, after the integer add has issued. The only differences between this and the reorder buffer method shown in Fig. 3b are the addition of an "old value" field in the history buffer and a "destination register" field in the result shift regis- ter. The result shift register now looks like the one shown in Fig. 2.

  1. P e r f o r m a n c e Evaluation To evaluate the effectiveness of our precise interrupt schemes, we use a CRAY-1S simulation system developed at the University of Wisconsin [PaSmg3]. This trace-driven simulator is extremely accu- rate, due to the highly deterministic nature of the CRAY-1S, and gives the number of clock periods required to execute a program. The scalar portion of the CRAY-1S is verx similar to the model architecture described in Section 2.1. Thus, casting the basic approaches into the CRAY-IS scalar architecture is straightforward. For a simulation workload, the first fourteen Lawrence Liver- more Loops ~McMa72] were used. Because we are primarily interested in pipelined implementations of conventional scalar architec- tures, the loops were compiled by the Crav FORTRAN compiler with the vectorizer turned off. In the preceding sections, five methods were described thal could be used for guaranteeing precise interrupts. To evaluate the effect of these methods on system performance, the methods were partitioned into three groups. The first and second group respectively contain the in-order method and the simple reorder buffer method. The third group is composed of the reorder buffer with bypasses, the history buffer, and the future file. This partitioning was performed because the methods in the third group result in identical system performance. This is because the future file has a reorder buffer embedded as part of its implementation. And the history buffer length constrains perfor- mance in the same way as a reorder buffer: when the buffer fills, issue must stop. All the simulation results are reported as for the reorder buffer with bypasses. They apply equally well for the history buffer and future file methods. The selection of a particular method depends not only on its effect on system performance but also the cost of imple- mentation and the ease with which the precise CPU state can be restored. For each precise interrupt method, two methods were described for handling stores, Simulations were run for each of these methods. For those methods other than the in-order completion method, the size o f the reorder buffer is a parameter. Sizing the buffer with too few entries degrades performance since instructions thal might issue could block at the issue register. The blockage occurs because there is no room for a new entry in the buffer. Table 1 shows the relative performance of the In-order, Reorder Buffer, and Reorder Buffer with bypass methods when the stores are held until the result shift register is empty. The results in the table indicate the relative performance of these methods with respect to the CRAY-IS across the first 14 Lawrence Livermore Loops; real CRAY- 1S performance is 1.0. A relative performance greater than 1.0 indi- cates a degradation in performance. The number of entries in the reorder buffer was varied from 3 to 10.

Table 1. Relative Performance for the first I4 Lawrence Livermore Loops, with stores blocked until the results pipeline is empt 3.

I N u m b e r o f (^) I Envies l ln-order Reorder R w / B P

3 4

5

8

10

The simulation results for the In-order column are constant since this method does not depend on a buffer that reorders instructions. For all the methods, there is some performance degradation. Initially, when the reorder buffer is small, the In-order method produces the least performance degradation. A small reorder buffer (less than 3 entries) limits the number of instructions that can simultaneously be in some stage of execution. Once the reorder buffer size is increased beyond 3 entries, either of the other methods results in belier perfor- mance. As expected, the reorder buffer ~ith bypasses offers superior performance when compared with the simple reorder buffer. When the size of the buffer was increased beyond 10 entries, simulation results indicated no further performance improvements. (Simulations were also run for buffer sizes of 15, 16, 20, 25, and 60.) At best, one can expect a 12% performance degradation when using a reorder buffer with bypasses and the first method for handling stores. Table 2 indicates the relative performance when stores issue and wait at the same memory pipeline stage as for m e m o ~ ' bank conflicts in the original CRAY-IS. After issuing, stores wait for their counterpart d u m m y store to signal that all previously issued register instructions have finished. Subsequent loads and stores are blocked from issuing.

Table 2. Relan\e Pertormance tor the first 14 Lavrence Li\ermore Loops, w'ith store.- held in the memor 3, pipeline after issue.

Number of { Entries In-order Reorder R w / B P

3 4

5

8

10

As in Table 1, the In-order results are constant across all entries. For the simple reorder buffer, the buffer must have at least 5 entries before it results in beuer performance than the In-order method. The reorder buffer with bypasses, however, requires only 4 entries before it is performing more effectively than the In-order m e t h o d.. l u s t as in Table l, having more than 8 entries in the reorder buffer does not result in improved performance. Comparing Table 1 to Table 2, the second method for handling stores offers a clear improvement over the first method, If the second method is used with an 8 entry re,order buffer that has bypasses, a performance degradation of only 3% is experienced. Clearly there is a trade-off be~'een performance degradation and the cost of implementing a method. For essentially no cost, the In- order method can be combined with the first method of handling stores. Selecting this 'cheap' approach results in a 23% performance degrada- tion. If this degradation is too great, either the second store method must be used with the In-order method or one of the more complex methods must be used. If the reorder buffer method is used, one must use a buffer with at least 3 or 4 entries.

8. E x t e n s i o n s In previous sections, we described methods 'that could be used to guarantee precise interrupts with respect to the registers, the main memory, and the program counter of our simple architectural model. In the following sections, we extend the previous methods to handle additional state information, virtual memory, a cache, and linear pipe- lines. Effectively, some of lhese machine features can be considered to be functional units with non-deterministic execution times.

8.1. Handling O t h e r State Values Most architectures have more state information than we have assumed in the model architecture. For example, a process may have state registers that point to page and segment tables, indicate interrupt mask conditions, etc. This additional state information can be precisely maintained with a method similar to that used for stores to memory. If using a reorder buffer, an instruction that changes a state regisfer reserves a reorder buffer entry and proceeds to the pan of the machine where the state change will be made. The instruction then waits there until receiving a signal to continue from the reorder buffer. When its entry arrives at the head of the buffer and is removed, then a signal is sent to cause the state change. In architectures that use condition codes, the condition codes are state information. Although the problem condition codes present to conditional branches is not totally unrelated to the topic here, solutions to the branch problem are not the primary topic of this paper. It is assumed thin the conditional branch problem has been solved in some way, e.g. [Ande67]. If a reorder buffer is being used, condition codes can be placed in the reorder buffer. That is, just as for data. the reorder buffer is made sufficiently wide to hold the condition codes. The condition code entry is then updated ',,,'hen the condition codes associated with the execution of an instruction are computed. Just as with data in the reorder buffer, a condition code entry is not used to change processor state until all previous instructions have completed without error (however condition codes can be bypassed to the instruc- tion fetch unit to speed up conditional branches).

Extension of the history buffer and future file methods to handle condition codes is very similar to that of the reorder buffer. For the history buffer, the condition code settings at the time of instruction issue must be saved in the history buffer. The saved condition codes can then be used to restore the processor state when an exception is detected. Since the future file method uses a reorder buffer, the above discussion indicates how condition codes may be saved.

8,2, Virtual Memory Virtual memory is a very important reason for supporting precise interrupts; it must be possible to recover from page faults. First, the address translation pipeline should be designed so that all the load/store instructions pass through it in order. This has been assumed throughout this paper. Depending on the method being used, the load/store instructions reserve time slots in the result pipeline and/or re-order buffer that are read no earlier than the time at which the instructions have been checked for exception conditions (especially page faults). For stores, these entries are not used for data; just for exception reporting and/or holding a program counter value. If there is an addressing fault, then the instruction is cancelled in the addressing pipeline, and all subsequent load/store instructions are cancelled as they pass through the addressing pipeline. This guaran- tees that no additional loads or stores modify the process state. The mechanisms described in the earlier sections for assuring preciseness with respect to registers guarantee that non-load/store instructions fol- lowing the faulting load/store will not modify the process state; hence the interrupt is precise. For example, if the reorder buffer method is being used, a page fault would be sent to the reorder buffer when it is detected. The tag assigned to the corresponding load/store instruction guides it to the correct reorder buffer entry. The reorder buffer entry is removed from the buffer when it reaches the head. The exception condition in the entry causes all further entries of the reorder buffer to be discarded so that the process state is modified no further (no more registers are writ- ten). The program counter found in the reorder buffer entry is precise with respect to the fault.

8.3. Cache-Memory Thus far we have assumed systems that do not use a cache memory. Inclusion of a cache in the memory hierarchy affects the implementation of precise interrupts. As we have seen, an important

part of all the methods is that stores are held until all previous instruc- tions are known to be exception-free. With a cache, stores may be

macle into the cache earlier, and for performance reasons should be.

The actual updating of main memory, however, is still subject to the same constraints as before.

8.3.1. Store-through Caches With a store-through cache, the cache can be updated intmedi- ately, while the store-through to main memory is handled as in previ- ous sections. That is, all previous instructions must first be known to be exception-free. Load instructions are free to use the cached copy, however, regardless of whether the store-through has taken place. This means that main memory is always in a precise state, but the cache contents may "run ahead" of the precise state. If an interrupt should occur while the cache is potentially in such a state, then the cache should be flushed. This guarantees that prematurely updated cache. locations will not be used. However, this can lead to performance problems, especially for larger caches. Another alternative is to treat the cache in a way similar to the register files. One could, for example, keep a history buffer for the cache. Just as with registers, a cache location would have to be read just prior to writing it with a new value. This does not necessarily mean a performance penalty because the cache must be checked for a hit prior to the write cycle. In many high performance cache organiza- tions, the read cycle for the history data could be done in parallel with the bit check. Each store instruction makes a buffer entry indicating the cache location it has written. The buffer entries can be used to restore the state of the cache. As instructions'complete without excep- tions, the buffer entries are discarded. The future file can be extended in a similar way.

8.3.2. Write-Back Cache A write-back cache is perhaps the cache type most compatible with implementing precise interrupts. This is because stores in a write-back cache are not made directly to memory; there is a built-in delay betweenupdating the cache and updating main memory. Before an actual write-back operation can be performed, however, the reorder buffer should be emptied or should be checked for data belonging to the line being written back. If such data should be found, the write-back must wait until the data has made its way into the cache. If a history buffer is used, either a cache line must be saved in the history buffer, or the write-back must wait until the associated instruction has made its way to the end of the buffer. Notice that in any case, the write-back will sometimes have to wait until a precise state is reached.

8,4. Linear Pipeline Structures An alternative to the parallel functional unit organizations we have been discussing is a linear pipeline organization. Refer to Fig. 7.

II[I INSTRUCTI ON FETCH/DECODE

t REGISTER FILE

&4RITE TO MEMORZ

Ili []

EI"lE

RESULT BUS

Figure 7. Example of a linear pipeline implementation.