You are on page 1of 27

Lecture7

ExceptionHandling
p
g
DynamicScheduling

Quiz Time
QuizTime

EE/CS520 Comp.Archi.

9/20/2012

Exceptions

EE/CS520 Comp.Archi.

9/20/2012

Exceptions:MoreSeverethanHazards
ThereareseveralinstsatatimeinaCPUpipeline

ExceptionoccurringinoneinstcancausetheCPU

t b t ll th
toabortallotherunfinishedinsts
fi i h d i t

EE/CS520 Comp.Archi.

9/20/2012

TypesofExceptions
I/Odevicerequest
InvokinganOSservicefromauserprogram
I
ki
OS
i f
Breakpoints(programmerrequestedinterrupt)
Integerarithmeticoverflow
Integer arithmetic overflow
FParithmeticanomaly
Pagefault(instordatanotinmainmemory)
Memoryprotectionviolation
Undefinedopcode
Hardwaremalfunction
Hardware malfunction
Powerfailure
Soon
5

EE/CS520 Comp.Archi.

9/20/2012

ClassificationofExceptions
Synchronousvs.Asynchronous
Synchronous:Ifeventoccursatsameplaceeverytimeina
S h
If
l

programexecutionwithsamedataandmemoryallocation
Asynchronous:
Viceversa,causedbydevicesexternaltoCPUandmemory
Canbedelayeduntilaftercurrentinst

User
Userrequested
requestedvs.coerced
vs. coerced
Userrequested:iftheeventisdirectlyaskedbyausertask
Coerced:
causedduetosomehardwareeventnotcontrolledbytheuser
dd
h d
ll d b h
program
Hardertohandle

EE/CS520 Comp.Archi.

9/20/2012

ClassificationofExceptions
Maskablevs.NonMaskable
Maskable:Ifeventcanbemaskedordisabledbyuser
NonMaskable:Viceversa

Withinvs.betweeninstructions(intra/interinst)
Within:ifeventpreventsaninsttobecompleted
p
p
Normallysynchronousascausedbyinstitself
Hardertohandleasinsthastobeterminatedandrestarted
Between:
Between:occursbetweentwoinsts.
occurs between two insts
Easiertohandleaspreviousinstcanbecompletedbefore
exception

EE/CS520 Comp.Archi.

9/20/2012

ClassificationofExceptions
Resumevs.Terminate:
Resume:ifprogramexecutioncontinuesaftertheexception
Terminate:ifprogramexecutionalwaysstopsafterthe

exception

EE/CS520 Comp.Archi.

9/20/2012

ClassificationofExceptions
Mostdifficultinterruptshavetwoproperties:
1) withininstruction
2) Resumeable
Needexternalprogram(suchasOS)tobeinvoked

EE/CS520 Comp.Archi.

9/20/2012

HandlingResumeableExceptions
Shutthepipelinebyconvertingallinstsafterthe

faultinginsttoNOPs
Saveprocessorstate
S
CallHandler
C ll H dl
ResumeState
Resume State

10

EE/CS520 Comp.Archi.

9/20/2012

PreciseException
Ifpipelinecanbestoppedsuchthat
AllInstructions,beforefaultinginst,arecompleted
Insts,aftertheexception,canberestartedfromscratch

ThefaultinginstdoesnotaffecttheCPUstate
FPexceptions(multicycleexecution)
ChangetheCPUstatebysavingintermediateresult
Change the CPU state by saving intermediate result
Originaloperandshavetoberetrievedaftersuchexceptions

11

EE/CS520 Comp.Archi.

9/20/2012

ExceptionsinSimpleMIPSPipeline

12

EE/CS520 Comp.Archi.

9/20/2012

HowtoHandlePreciseException?
Inst i

LD

Inst i+1
Insti+1

DADD

IF

ID

EX

MEM

WB

IF

ID

EX

MEM

Arith.Overflow

DMEMPageFault
g
Inst i

LD

Inst i+1
Insti+1

DADD

IF

WB

ID

EX

MEM

WB

IF

ID

EX

MEM

IMEMPage
Fault
IMEMPageFault

WB

DMEM
P
F lt
DMEMPageFault

Important to keep the exception handling in order


Importanttokeeptheexceptionhandlinginorder
13

EE/CS520 Comp.Archi.

9/20/2012

HowtoHandlePreciseException?
Pipelinesdonthandleexceptionsimmediately
Exceptionsarepostedtoastatusvectorassociated

witheachinst
Exceptionstatusvectorisupdatedineverystage
E
d d
Onceanexceptionisregistered,theinstcantchange

CPU state
CPUstate
AllexceptionsarehandledinorderatWBstage

14

EE/CS520 Comp.Archi.

9/20/2012

DynamicInstructionScheduling

15

EE/CS520 Comp.Archi.

9/20/2012

DynamicScheduling
Tillnowexecutionisinorder(followstheinstorder)
Insts,thathavenodependencesbutarebehindthe

stalledinst,havetobestalled
Greatlycompromisestheefficiency
Greatly compromises the efficiency

16

EE/CS520 Comp.Archi.

9/20/2012

DynamicScheduling

S.D

F3, 0(R2)

ProblemswithInOrderInstIssue

17

EE/CS520 Comp.Archi.

9/20/2012

DynamicScheduling
Tillnowexecutionisinorder(followstheinstorder)
Insts,thathavenodependencesbutarebehindthestalled

inst,havetobestalled
Greatlycompromisestheefficiency
Greatly compromises the efficiency
Whatcanbedone???
Solution: Allowoutoforder executionofinsts
Eitherstatically:Compilerchangestheinstorder
Wellseeincominglectures
Ordynamically:ProcessorhasaHWtodoso

18

EE/CS520 Comp.Archi.

9/20/2012

OutOfOrder(OOO)Execution
SplitIDstage
Issue:WAW/Struct.

IF

ID

EX

MEM

WB

ReadOperands:RAW

WRstage
WR t
delaythewritebackto

resolveWARhazards

IF

IS

RO

EX

MEM

WR

Keepinmind:IFandISareinorder,theexecutioncanbeOOO
ifanearlierinstisstalledinROstage

19

EE/CS520 Comp.Archi.

9/20/2012

MIPSwithaScoreboard

IF

IS

RO

EX

WR

FPMUL
FPMUL

FPDIV
RegisterFile
FPADD

INT

Control/ Status
Control/Status

Scoreboard

Control/ Status
Control/Status

(firstusedbyCDC6600in1964)
20

EE/CS520 Comp.Archi.

9/20/2012

MIPS with a Scoreboard


MIPSwithaScoreboard
Issue:
If afunctionalunit(FU) isfree toexecutetheinst
Andif there isnoother active instruction has thesame
register destination:
Thenscoreboardissuestheinst
Updatesitsdatastructure
Otherwise,theinstisstalleduntilhazardisremoved
,

ADD
SUB

21

R0 R1,
R0,
R1 R2
R0, R3, R4

EE/CS520 Comp.Archi.

Instruction SUB suspended


(not-issued)
Until result of ADD is written in R0

9/20/2012

MIPSwithaScoreboard
ReadOperands:
A sourceoperand isavailable ifnoother activeinst started earlier is

going tochangeit
Whenalltheoperandsareavailable,theinstcanbeexecuted

ADD
SUB

22

EE/CS520 Comp.Archi.

R0, R1, R2
R4, R3, R0

Instruction SUB blocked


(waiting for operand R0)
Until ADD writes result in R0

9/20/2012

MIPSwithaScoreboard
InstructionExecution:
WhenaFUfinishestheinstexecution,itsignalsthescoreboard
FUdoesnotimmediatelywriteinthedestinationregister
Nodataforwarding(RegistersareonlyreadinROstage)
g( g
y
g )

WriteResult:
Thescoreboardverifies
Th
b d
ifi thatthereisnopreviouslyissuedinst
h h
i
i
l i
di

thathasnotreaditsoperands(WAR hazard)

MUL
SUB

23

EE/CS520 Comp.Archi.

R0, R1, R2
R2, R3, R4

Instruction SUB blocked


(Destination operand not written)
Until MUL reads its src operands

9/20/2012

ScoreboardDataStructure
Instruction Status
Read
Issue
Operand

Instruction
i

Execution
Complete

Write
Result

C
Comments
t

Functional Unit Status


FU no.

24

R0

R1

Name

R2

Busy

R3

Op

R4

EE/CS520 Comp.Archi.

Dest (Fi) Src1 (Fj) Src2 (Fk) FU1 (Qj) FU2 (Qk) Src1 rdy (Rj) Src2 rdy (Rk)

R5

Register Status
R6 R7 R8 R9

R10 R11 R12 R13 R14 R15


9/20/2012

ScoreboardDataStructure
InstructionStatus
Showswhichofthe4stagesinstisin

RegisterStatus
IndicatewhichFUwillwritetothatregisterifan

activeinsthasitasdest.
ti i t h it d t
FUStatus

25

Indicates
IndicatesFUStatus,has9fields
FU Status has 9 fields
Busy:ifFUisfreeorbusy
Op:Operationtoperform
Fi:DestReg
Fj,Fk:SrcReg1,2
Qj,Qk:FUproducingFj,Fk
Rj,Rk:FlagsindicatingifFj,Fkareready?SettoNoafter
operandsareread
EE/CS520 Comp.Archi.

9/20/2012

Assignment2:PaperReading
ParallelOperationintheControlData6600byJamesE.Thorntonin

ProceedingsofAFIPS,1964

ArticlemanuscriptwillbeattachedwiththeassignmentonLMS
Available:Thursday20th September201212:00pm
Deadline:Thursday27th September201212:00pm

LateSubmission:25%markdeductionperday
Late Submission: 25% mark deduction per day
Plagiarismwillresultinatleast 0marks
Format:Softcopy: 1to2page review.Focusshouldbeonthe

contributionoftheworkdoneandyour
contribution
of the work done and your analysis!Anydrawbacks(in
analysis! Any drawbacks (in
youropinion)?
A4,TimesNewRoman,11,1LineSpacingandStandardPageMargins
Beconcise!additionalpage(s)willresultinmarkdeduction
Be concise! additional page(s) will result in mark deduction

26

EE/CS520 Comp.Archi.

9/20/2012

Tutorial:ReviewofPipelinedExecution

27

EE/CS520 Comp.Archi.

9/20/2012

You might also like