Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Code Fragmant With Exceptions Preserved-Advance Computer Architecture-Lecture Slides, Slides of Advanced Computer Architecture

This course focuses on quantitative principle of computer design, instruction set architectures, datapath and control, memory hierarchy design, main memory, cache, hard drives, multiprocessor architectures, storage and I/O systems, computer clusters. This lecture includes: code, Fragment, Speculation, Register, Code, Instructions, Branch, Exeptions, Poison, If, Then, Else

Typology: Slides

2011/2012

Uploaded on 08/06/2012

amrusha
amrusha 🇮🇳

4.4

(32)

149 documents

1 / 21

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Revised Code fragment with
Exceptions preserved
Now in order to preserve the
speculation we use a temporary
register say R14, to avoid
destroying R1 when B is being
loaded as in initial code
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15

Partial preview of the text

Download Code Fragmant With Exceptions Preserved-Advance Computer Architecture-Lecture Slides and more Slides Advanced Computer Architecture in PDF only on Docsity!

Revised Code fragment with

Exceptions preserved

Now in order to preserve the

speculation we use a temporary

register – say R14, to avoid

destroying R1 when B is being

loaded as in initial code

Revised Code fragment with

Exceptions preserved

LD R1,0(R3) ;load A LD R14,0(R2) ;speculative load B BEQZ R1,L3 ;other branch of if DADDUI R14,R1,#4 ;else clause

L3: SD R14,0(R3) ;non-speculative store

L2: SD R1,0(R3) ;store A

Method 2: Speculative Instructions

This approach introduces speculative version of instructions, such as

  • Speculative Load sLD
  • Speculative Check SPECCK

These instructions are used to preserve exception behavior exactly rather than speculatively

Method 2: Speculative Instructions These instructions

Don’t generate terminating exception; rather these instructions check for such exceptions The combined used of two or more speculative instructions, such as sLD and SPECCK, preserve the exception behavior exactly

Revised code using speculative instructions

LD R1,0(R3) ;load A sLD R14,0(R2) ;speculative, no termination BNEZ R1, L1 ;test A SPECCK 0(R2) ;speculative check J L2 ;skip else L1: DADDUI R1,R1,#4 ;else clause L2: SD R1,0(R3) ;store A

Speculate Branch taken/not-taken (in this example Not-Taken) and save value B at 0(R2) in temporary register R14; i.e., the basic block for THEN (in this case the value B) is maintained

Check if the speculation is correct or not, i.e., Branch has taken or otherwise

Example 2: Explanation

Here, the load instruction speculate in respect of the branch instruction whether it will be taken or not-taken

The speculation check requires to maintain a basic block for THEN clause, thus preserve the exception behavior

Notice that extra code is required to check for possible exception thus, result in overhead

Method 3: Poison Bit

Here, a set of bits called “poison - bits” is attached to every instruction and to every result register to indicate whether the instruction is speculative

These bits are used to track exceptions as they occur; but postpones any terminating exception until a value is actually used

Method 3: Poison Bit

The speculative bits are simply

propagated by speculative

instructions

When a bit is set in the result

register it indicates that an

exceptional condition has

occurred

Sequence of steps to preserve exception behavior using poison bits

1. The poison bit of the destination

register is set whenever a

speculative instruction results in

terminating exception

2. All other exceptions are handled

immediately

Sequence of steps …… Cont’d

  1. IF the speculative instruction uses a register with poison-bit turned ON; the destination register of the instruction simply has its poison-bit turned ON
  2. IF the normal instruction attempts to use a register source with poison-bit turned ON, the instruction causes a fault

Example 3: Poison Bits Approach

Let us once again consider our earlier example and:

See how it would be compiled with speculative instructions SLD and register R14 with poison-bit; and Show where an exception for the speculative memory reference would be recognized

Example 3: IF-THEN-ELSE

Statement Reconsidered

IF (A==0) THEN A = B;

ELSE A = A + 4;

Assume A is at 0(R3) and B is at 0(R2); and that R14 is unused and available

Explanation: Example 3

Note here, If the speculative sLD generates a terminating exception, the poison bit of the R14 will be turned on

When the non-speculative SW instruction occurs, it will raise an exception if the poison bit for R14 is turned on

Explanation: Example 3

Furthermore, to facilitate the

operating system to save the

user register on a context switch

if the poison bit is set,

a special instruction is included

in the in the instruction-set to

set/save the state of the poison-

bit