Docsity

Basic and Intermediate Concept - Advanced Computer Architecture - Lecture Slides, Slides of Computer Science

Toggle sidebar
bg1
Appendix A. Pipelining: Basic and
Intermediate Concept
•What is Pipelining?
–Pipelining is an implementation technique whereby multiple instructions
are overlaped in execution.
–Pipe stage (pipe segment)
–Throughput
–Machine cycle: The time required between moving an instruction one step
down the pipeline. This time is equal to the time required for the slowest
pipe stage.
–In a computer, the machine cycle is usually one clock cycle.
–The pipeline designer‘s goal is to balance the length of each pipe stage.
–If the stages are perfectly balanced,
stages pipe ofNumber
machine dunpipelineon n instructioper Time
n instructioper Time =
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35

Partial preview of the text

Download Basic and Intermediate Concept - Advanced Computer Architecture - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

Appendix A. Pipelining: Basic and

Intermediate Concept

  • What is Pipelining?
    • Pipelining is an implementation technique whereby multiple instructions

are overlaped in execution.

  • Pipe stage (pipe segment)
  • Throughput
  • Machine cycle: The time required between moving an instruction one step

down the pipeline. This time is equal to the time required for the slowest

pipe stage.

  • In a computer, the machine cycle is usually one clock cycle.
  • The pipeline designer‘s goal is to balance the length of each pipe stage.
  • If the stages are perfectly balanced,

Numberof pipe stages

Timeperinstructionon unpipelinedmachine Time perinstruction=

A Simple Implementation of A RISC ISA

  • Five-cycle implementation
    • Instruction fetch cycle (IF)
    • Instruction decode/register fetch cycle (ID)
      • Operand fetches;
      • Sign-extending the immediate field;
      • Decoding is done in parallel with reading registers. This technique is known as fixed-field decoding;
      • Test branch condition and computed branch address; finished branching at the end of this cycle.
    • Execution/effective address cycle (EX)
      • Memory reference;
      • Register-Register ALU instruction;
      • Register-Immediate ALU instruction;
    • Memory access/branch completion cycle (MEM)
    • Write-back cycle (WB)
      • Register-Register ALU instruction;
      • Register-Immediate ALU instruction;
      • Load instruction;

The Classic Five-Stage Pipeline for a RSIC

Processor

The RISC Pipeline with Registers

Basic Performance Issues in Pipelining

  • Pipelining increasing instruction execution throughput,

but it does not reduce the execution time of an

individual instruction due to pipeline overhead.

  • Register delay
  • Clock skew
  • The limitation of pipeline depth is due to
  • Pipeline latency
  • Pipe stage imbalance
  • Pipeline overhead
  • Example in A-10.

The Major Hurdle of Pipelining -

Pipelining Hazards

  • A hazard is a situation that prevents the next instruction

in the instruction stream from executing during its

designated clock cycle.

  • Three classes of hazards
    • Structural hazard : Arise from resource conflicts.
    • Data hazard : Arise when an instruction depends on the results

of a previous instruction.

  • Control hazard : Arise from branches and other instructions that

change the PC.

  • A pipeline can be stalled by a hazard. To eliminate hazards,
    • Instructions issued later than the stalled instruction are also

stalled.

  • Instructions issued earlier than the stalled one must continue.
  • Note that a cache miss stalls the whole pipeline.
  • When pipelining is thought of as improving the

clock cycle time,

Clockcyclepipelined

Clockcycleunpipelined

1 Pipelinestallcycles

Speedup ×

1 Pipelinestallcyclesperinstructio n

Pipelinedepth

Structural Hazards

  • Due to resource conflicts (Example in A-14)
    • Due to some functional unit being not fully pipelined.
    • When some resources have not been duplicated enough.

Forwarding (Bypassing) ALU Results To

Minimize Hazards

Forwarding (Bypassing) Results to

Store

Data Hazard Classification

  • Consider two instructions i and j , with i occurring

before j , the possible hazards are,

  • RAW (read after write) : j tries to read a source before i

writes it.

  • WAW (write after write): j tries to write an operand before it

is written by i. For example,

LW R1, 0(R2) IF ID EX MEM1 MEM2 WB

DADD R1, R2, R3 IF ID EX WB

  • WAR (write after read): j tries to write a destination before it

is read by i. For example, if read is done in the second half

of MEM2, and write is done in the first half of WB.

SW 0(R1), R2 IF ID EX MEM1 MEM2 WB

DADD R2, R3, R4 IF ID EX WB

  • RAR (read after read): not a hazard.

Data Hazards Requiring Stalls

– Pipeline interlock

  • A piece of hardware that detects a hazard and stalls the

pipeline until the hazard is cleared.

– Load interlock

  • Example (Fig. A.10 at A-21)

Branch Penalty

  • Branch delay : The length of a control hazard.
  • Branch penalty : The branch delay, unless it is dealt

with, turns into branch penalty.

  • The deeper the pipeline, the worse the branch penalty.
  • The number of branch stalls can be reduced by two

steps

  • Find out whether the branch is taken or not taken earlier in

the pipeline.

  • Compute the taken PC (i.e., the address of the branch target)

earlier.

  • Branch behavior in programs
    • Average frequency of taken branches : 67%
      • 60% of the forward branches are taken.
      • 85% of the backward branches are taken.

Reducing Pipeline Branch Penalties

  • Static branch prediction methods (Compile-time guess).
    • Free or flush the pipeline
      • Holding or deleting any instructions after the branch until the branch destination is known.
    • Predict-not-taken (untaken) (Fig. A.12 in A-23)
    • Predict-taken
      • Does it have any advantage? Ans: no.
    • Delayed branch:
      • The execution cycle with a branch delay n is
      • Branch instruction
      • Sequential successor 1
      • Sequential successor 2
      • …
      • Sequential successor n (n=1 for MIPS)
      • Branch target if taken