Docsity

Computer Science Pipelining: Hazards, Processors, Multithreading, and Tomasulo's Algorithm, Slides of Parallel Computing and Programming

Partial preview of the text

Download Computer Science Pipelining: Hazards, Processors, Multithreading, and Tomasulo's Algorithm and more Slides Parallel Computing and Programming in PDF only on Docsity!

M

Review CS 203A - Pipelining

Load

Instr 1

Instr 2

Instr 3

Instr 4

ALU M (^) Reg M Reg

ALU M (^) Reg M Reg

ALU M (^) Reg M Reg

ALU Reg M^ Reg

ALU M (^) Reg M Reg

  • Can’t read same memory twice in same clock cycle Structural Hazard

I

n

s

t

r.

O

r

d

e

r

Time (clock cycles)

Other Hazards

  • Data Hazards – Due to data dependencies
  • Control Hazards – Due to branches

MIPS R4000 Pipeline

Comparison of Issue Capabilities

Courtesy of Susan Eggers; Used with Permission

Multithreading

  • How can we guarantee no dependencies between

instructions in a pipeline?

  • One way is to interleave execution of instructions from different program threads on same pipeline – Micro context switching

Interleave 4 threads, T1-T4, on non-bypassed 5-stage pipe

T1: LW r1, 0(r2)

T2: ADD r7, r1, r

T3: XORI r5, r4, #

T4: SW 0(r7), r

T1: LW r5, 12(r1)

HW Schemes: Instruction Parallelism

  • Out-of-order execution divides ID stage:

1. Issue—decode instructions, check for structural hazards, Issue in order if

the functional unit is free and no WAW.

  1. Read operands (RO)—wait until no data hazards, then read operands  ADDD would stall at RO, and SUBD could proceed with no stalls.
  • Scoreboards allow instruction to execute whenever 1 & 2 hold, not waiting for prior instructions.

(WAR?)

(WAR?)

IF ISSUE

… RO EX 1 … EXm

RO EX 1 … EXn

… RO EX 1 … EXp

WB?

WB?

WB

…

Four Steps of Speculative Tomasulo

Algorithm

1. Issue— get instruction from FP Op Queue

If reservation station and reorder buffer slot free, issue instr

& send operands & reorder buffer no. for destination (this

stage sometimes called “dispatch”)

2. Execution— operate on operands (EX)

When both operands ready then execute; if not ready, watch

CDB for result; when both in reservation station, execute;

checks RAW (sometimes called “issue”)

3. Write result— finish execution (WB)

Write on Common Data Bus to all awaiting FUs

& reorder buffer; mark reservation station available.

4. Commit— update register with reorder result

When instr. at head of reorder buffer & result present,

update register with result (or store to memory) and remove

instr from reorder buffer. Mispredicted branch flushes

reorder buffer (sometimes called “graduation”)