SlideShare a Scribd company logo
Pipelining.
Pipeline hazards
Sabina Batyrkhanovna
What is pipelining?
โ€ข A technique used in advanced microprocessors where the
microprocessor begins executing a second instruction before the first
has been completed
โ€ข Multiple instructions are overlapped in execution
โ€ข Process of instruction execution is divided into two or more steps, called pipe stages
or pipe segments
โ€ข Different stage are completing different parts of different instructions in parallel
โ€ข The stages are connected one to the next to form a pipe
โ€ข Instructions enter at one end, progress through the stages, and exit at the other end
โ€ข Unlike some speedup techniques, it is not visible to the programmer/compiler.
Characteristics of pipelining
โ€ข Hardware or software implementation โ€“ pipelining can be implemented in either software
or hardware.
โ€ข Large or Small Scale โ€“ Stations in a pipeline can range from simplistic to powerful, and a
pipeline can range in length from short to long.
โ€ข Buffered or unbuffered flow โ€“ One stage of pipeline sends data directly to another one or
a buffer is place between each pairs of stages.
โ€ข Synchronous or asynchronous flow โ€“ A synchronous pipeline operates like an assembly
line: at a given time, each station is processing some amount of information. A
asynchronous pipeline, allow a station to forward information at any time.
โ€ข Automatic Data Feed Or Manual Data Feed โ€“ Some implementations of pipelines use a
separate mechanism to move information, and other implementations require each stage
to participate in moving information
Types of pipelining
โ€ข Software Pipelining
โ€ข Can Handle Complex Instructions
โ€ข Allows programs to be reused
โ€ข Hardware Pipelining
โ€ข Help designer manage complexity โ€“ a complex task can be divided into smaller, more
manageable pieces.
โ€ข Hardware pipelining offers higher performance
Effects of pipelining
โ€ข Time in ns per instruction goes up
โ€ข Number of cycles per instruction goes up (note the increase in clock
speed)
โ€ข Total execution time goes down, resulting in lower time per instruction
โ€ข Average cycles per instruction increases slightly
โ€ข Under ideal conditions:
โ€ข speedup = ratio of elapsed times between successive instruction completions
= number of pipeline stages = increase in clock speed
Instruction pipelining
โ€ข An instruction pipeline increases the performance of a processor by overlapping the
processing of several different instructions
โ€ข Consists of five stages:
โ€ข Instruction fetch (IF): the instruction is fetched from memory and placed in the
instruction register (IR)
โ€ข Instruction decode (ID): identification of the operation to be performed
โ€ข Execution (EX): the instruction is executed
โ€ข Memory read/write (ME): stage is responsible for storing and loading values to and
from memory. It also responsible for input or output from the processor.
โ€ข Write back (WB): The results of the operation are written to the destination register.
Timings
โ€ข Estimated timing for each stage of instruction:
โ€ข Instruction fetch โ€“ 2ns
โ€ข Instruction decode โ€“ 1ns
โ€ข Execution โ€“ 2ns
โ€ข Memory and I/O โ€“ 2ns
โ€ข Write Back โ€“ 1ns
Hazards
โ€ข There are three types of hazards that can happen while pipelined
execution:
โ€ข Structural hazards
โ€ข Data hazards
โ€ข Control hazards
Hazards (cont.)
โ€ข Structural hazards
โ€ข different instructions in different stages (or the same stage) conflicting for the
same resource
โ€ข Data hazards
โ€ข an instruction cannot continue because it needs a value that has not yet been
generated by an earlier instruction
โ€ข Control hazards
โ€ข fetch cannot continue because it does not know the outcome of an earlier
branch โ€“ special case of a data hazard
Data hazard
โ€ข Data hazard caused by data dependences
โ€ข There are three data dependences:
โ€ข Read-After-Write (RAW)
โ€ข Write-After-Write (WAW)
โ€ข Write-After-Read (WAR)
Read-After-Write
IF ID EX M WB
IF ID EX M WB
ADD R1, R2, R3
SUB R4, R1, R5
Read R2 and R3 Add R2 and R3 Write result to R1
Read R1 and R5
Next instruction tries to read an operand before previous instruction writes it Extremely common hazard
Write-After-Write
IF ID EX M M1 M2 M3 WB
IF ID EX M WB
ADD R1, R2, R3
SUB R1, R4, R5
Read R2 and R3 Add R2 and R3 Write result to R1
Write result to R1
Next instruction tries to write an operand before previous instruction writes it
Write-After-Read
IF ID EX M WB
IF ID EX M WB
ADD R1, R2, R3
SUB R2, R1, R5
Read R2 and R3 Write result to R1
Write result to R2
Next instruction tries to write an operand before previous instruction reads it. Happens if pipeline is out-order
Dealing with data hazard
โ€ข We can solve data hazard problem with stalling
โ€ข Stalling
โ€ข halting the flow of instructions until the required result is ready to be used
โ€ข wastes processor time by doing nothing while waiting for the result.
IF ID EX M WB
ADD R1, R2, R3
SUB R4, R1, R5
IF ID EX M WB
IF ID EX M WB
IF ID EX M WB
IF ID EX M WB
STALL
STALL
STALL
Performance of pipelines
๐‘†๐‘๐‘’๐‘’๐‘‘๐‘ข๐‘ ๐‘“๐‘Ÿ๐‘œ๐‘š ๐‘๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘–๐‘›๐‘” =
๐ด๐‘ฃ๐‘” ๐‘–๐‘›๐‘ ๐‘ก๐‘ข๐‘๐‘ก๐‘–๐‘œ๐‘› ๐‘ก๐‘–๐‘š๐‘’ ๐‘ข๐‘›๐‘๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘’๐‘‘
๐ด๐‘ฃ๐‘” ๐‘–๐‘›๐‘ ๐‘ก๐‘Ÿ๐‘ข๐‘๐‘ก๐‘–๐‘œ๐‘› ๐‘ก๐‘–๐‘š๐‘’ ๐‘๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘’๐‘‘
=
๐ถ๐‘ƒ๐ผ ๐‘ข๐‘›๐‘๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘’๐‘‘ ร— ๐ถ๐‘™๐‘œ๐‘๐‘˜ ๐‘๐‘ฆ๐‘๐‘™๐‘’ ๐‘ก๐‘–๐‘š๐‘’ ๐‘ข๐‘›๐‘๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘’๐‘‘
๐ถ๐‘ƒ๐ผ ๐‘๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘’๐‘‘ ร— ๐ถ๐‘™๐‘œ๐‘๐‘˜ ๐‘๐‘ฆ๐‘๐‘™๐‘’ ๐‘ก๐‘–๐‘š๐‘’ ๐‘๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘’๐‘‘
๐ถ๐‘ƒ๐ผ ๐‘๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘’๐‘‘ = ๐ผ๐‘‘๐‘’๐‘Ž๐‘™ ๐ถ๐‘ƒ๐ผ + ๐‘ƒ๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘’ ๐‘ ๐‘ก๐‘Ž๐‘™๐‘™ ๐‘๐‘™๐‘œ๐‘๐‘˜ ๐‘๐‘ฆ๐‘๐‘™๐‘’๐‘  ๐‘๐‘’๐‘Ÿ ๐‘–๐‘›๐‘ ๐‘ก๐‘Ÿ๐‘ข๐‘๐‘ก๐‘–๐‘œ๐‘›
On a pipelined processor Ideal CPI is 1
๐ถ๐‘ƒ๐ผ ๐‘๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘’๐‘‘ = 1 + ๐‘ƒ๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘’ ๐‘ ๐‘ก๐‘Ž๐‘™๐‘™ ๐‘๐‘™๐‘œ๐‘๐‘˜ ๐‘๐‘ฆ๐‘๐‘™๐‘’๐‘  ๐‘๐‘’๐‘Ÿ ๐‘–๐‘›๐‘ ๐‘ก๐‘Ÿ๐‘ข๐‘๐‘ก๐‘–๐‘œ๐‘›
๐‘†๐‘๐‘’๐‘’๐‘‘๐‘ข๐‘ ๐‘“๐‘Ÿ๐‘œ๐‘š ๐‘๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘–๐‘›๐‘” =
๐ถ๐‘ƒ๐ผ ๐‘ข๐‘›๐‘๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘’๐‘‘
1 + ๐‘ƒ๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘’ ๐‘ ๐‘ก๐‘Ž๐‘™๐‘™ ๐‘๐‘™๐‘œ๐‘๐‘˜ ๐‘๐‘ฆ๐‘๐‘™๐‘’๐‘  ๐‘๐‘’๐‘Ÿ ๐‘–๐‘›๐‘ ๐‘ก๐‘Ÿ๐‘ข๐‘๐‘ก๐‘–๐‘œ๐‘›
CPI unpipelined = depth of pipeline
IF ID EX M WB
IF ID EX M WB
IF ID EX M WB
Pipeline depth
๐‘บ๐’‘๐’†๐’†๐’…๐’–๐’‘ ๐’‡๐’“๐’๐’Ž ๐’‘๐’Š๐’‘๐’†๐’๐’Š๐’๐’Š๐’๐’ˆ =
๐‘ท๐’Š๐’‘๐’†๐’๐’Š๐’๐’† ๐’…๐’†๐’‘๐’•๐’‰
๐Ÿ + ๐‘ท๐’Š๐’‘๐’†๐’๐’Š๐’๐’† ๐’”๐’•๐’‚๐’๐’ ๐’„๐’๐’๐’„๐’Œ ๐’„๐’š๐’„๐’๐’†๐’” ๐’‘๐’†๐’“ ๐’Š๐’๐’”๐’•๐’“๐’–๐’„๐’•๐’Š๐’๐’
Advantages and disadvantages
โ€ข Advantages:
โ€ข More efficient use of processor
โ€ข Quicker time of execution of large number of instructions
โ€ข Disadvantages:
โ€ข Pipelining involves adding hardware to the chip
โ€ข Inability to continuously run the pipeline at full speed because of pipeline
hazards which disrupt the smooth execution of the pipeline.

More Related Content

Similar to Computer SAarchitecture Lecture 6_Pip.pdf

notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdfnotes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
SatyamMishra828076
ย 
Simple CPU Instruction Set Design.pptx
Simple CPU Instruction Set Design.pptxSimple CPU Instruction Set Design.pptx
Simple CPU Instruction Set Design.pptx
ssuser3aa461
ย 
03_Top Level View of Computer Function and Interconnection.ppt
03_Top Level View of Computer Function and Interconnection.ppt03_Top Level View of Computer Function and Interconnection.ppt
03_Top Level View of Computer Function and Interconnection.ppt
ChABiDRazZaQ
ย 
Pipelining of Processors Computer Architecture
Pipelining of  Processors Computer ArchitecturePipelining of  Processors Computer Architecture
Pipelining of Processors Computer Architecture
Haris456
ย 

Similar to Computer SAarchitecture Lecture 6_Pip.pdf (20)

pipelining-190913185902.pptx
pipelining-190913185902.pptxpipelining-190913185902.pptx
pipelining-190913185902.pptx
ย 
Processor Organization and Architecture
Processor Organization and ArchitectureProcessor Organization and Architecture
Processor Organization and Architecture
ย 
14 superscalar
14 superscalar14 superscalar
14 superscalar
ย 
14 superscalar
14 superscalar14 superscalar
14 superscalar
ย 
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdfnotes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
ย 
Simple CPU Instruction Set Design.pptx
Simple CPU Instruction Set Design.pptxSimple CPU Instruction Set Design.pptx
Simple CPU Instruction Set Design.pptx
ย 
Pipelining of Processors
Pipelining of ProcessorsPipelining of Processors
Pipelining of Processors
ย 
Instruction Level Parallelism and Superscalar Processors
Instruction Level Parallelism and Superscalar ProcessorsInstruction Level Parallelism and Superscalar Processors
Instruction Level Parallelism and Superscalar Processors
ย 
Pipelining powerpoint presentation
Pipelining powerpoint presentationPipelining powerpoint presentation
Pipelining powerpoint presentation
ย 
Pipelining
PipeliningPipelining
Pipelining
ย 
The Challenges facing Libraries and Imperative Languages from Massively Paral...
The Challenges facing Libraries and Imperative Languages from Massively Paral...The Challenges facing Libraries and Imperative Languages from Massively Paral...
The Challenges facing Libraries and Imperative Languages from Massively Paral...
ย 
12 processor structure and function
12 processor structure and function12 processor structure and function
12 processor structure and function
ย 
03_Top Level View of Computer Function and Interconnection.ppt
03_Top Level View of Computer Function and Interconnection.ppt03_Top Level View of Computer Function and Interconnection.ppt
03_Top Level View of Computer Function and Interconnection.ppt
ย 
Pipeline hazards in computer Architecture ppt
Pipeline hazards in computer Architecture pptPipeline hazards in computer Architecture ppt
Pipeline hazards in computer Architecture ppt
ย 
Pipelining of Processors Computer Architecture
Pipelining of  Processors Computer ArchitecturePipelining of  Processors Computer Architecture
Pipelining of Processors Computer Architecture
ย 
Superscalar processor
Superscalar processorSuperscalar processor
Superscalar processor
ย 
CA UNIT III.pptx
CA UNIT III.pptxCA UNIT III.pptx
CA UNIT III.pptx
ย 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
ย 
Unit - 5 Pipelining.pptx
Unit - 5 Pipelining.pptxUnit - 5 Pipelining.pptx
Unit - 5 Pipelining.pptx
ย 
Pipelining In computer
Pipelining In computer Pipelining In computer
Pipelining In computer
ย 

Recently uploaded

Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
ย 

Recently uploaded (20)

PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
ย 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
ย 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
ย 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
ย 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilotโ„ข
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilotโ„ขLe nuove frontiere dell'AI nell'RPA con UiPath Autopilotโ„ข
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilotโ„ข
ย 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
ย 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
ย 
ะะะ”ะ†ะฏ ะคะ•ะ”ะฎะจะšะž ะ‘ะะฆ ยซะŸั€ะพั„ะตัั–ะธฬ†ะฝะต ะทั€ะพัั‚ะฐะฝะฝั QA ัะฟะตั†ั–ะฐะปั–ัั‚ะฐยป
ะะะ”ะ†ะฏ ะคะ•ะ”ะฎะจะšะž ะ‘ะะฆ  ยซะŸั€ะพั„ะตัั–ะธฬ†ะฝะต ะทั€ะพัั‚ะฐะฝะฝั QA ัะฟะตั†ั–ะฐะปั–ัั‚ะฐยปะะะ”ะ†ะฏ ะคะ•ะ”ะฎะจะšะž ะ‘ะะฆ  ยซะŸั€ะพั„ะตัั–ะธฬ†ะฝะต ะทั€ะพัั‚ะฐะฝะฝั QA ัะฟะตั†ั–ะฐะปั–ัั‚ะฐยป
ะะะ”ะ†ะฏ ะคะ•ะ”ะฎะจะšะž ะ‘ะะฆ ยซะŸั€ะพั„ะตัั–ะธฬ†ะฝะต ะทั€ะพัั‚ะฐะฝะฝั QA ัะฟะตั†ั–ะฐะปั–ัั‚ะฐยป
ย 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
ย 
UiPath New York Community Day in-person event
UiPath New York Community Day in-person eventUiPath New York Community Day in-person event
UiPath New York Community Day in-person event
ย 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
ย 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
ย 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
ย 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
ย 
Dev Dives: Train smarter, not harder โ€“ active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder โ€“ active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder โ€“ active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder โ€“ active learning and UiPath LLMs for do...
ย 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
ย 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
ย 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
ย 
ะšะะขะ•ะ ะ˜ะะ ะะ‘ะ—ะฏะขะžะ’ะ ยซะ•ั„ะตะบั‚ะธะฒะฝะต ะฟะปะฐะฝัƒะฒะฐะฝะฝั ั‚ะตัั‚ัƒะฒะฐะฝะฝั ะบะปัŽั‡ะพะฒั– ะฐัะฟะตะบั‚ะธ ั‚ะฐ ะฟั€ะฐะบั‚...
ะšะะขะ•ะ ะ˜ะะ ะะ‘ะ—ะฏะขะžะ’ะ  ยซะ•ั„ะตะบั‚ะธะฒะฝะต ะฟะปะฐะฝัƒะฒะฐะฝะฝั ั‚ะตัั‚ัƒะฒะฐะฝะฝั  ะบะปัŽั‡ะพะฒั– ะฐัะฟะตะบั‚ะธ ั‚ะฐ ะฟั€ะฐะบั‚...ะšะะขะ•ะ ะ˜ะะ ะะ‘ะ—ะฏะขะžะ’ะ  ยซะ•ั„ะตะบั‚ะธะฒะฝะต ะฟะปะฐะฝัƒะฒะฐะฝะฝั ั‚ะตัั‚ัƒะฒะฐะฝะฝั  ะบะปัŽั‡ะพะฒั– ะฐัะฟะตะบั‚ะธ ั‚ะฐ ะฟั€ะฐะบั‚...
ะšะะขะ•ะ ะ˜ะะ ะะ‘ะ—ะฏะขะžะ’ะ ยซะ•ั„ะตะบั‚ะธะฒะฝะต ะฟะปะฐะฝัƒะฒะฐะฝะฝั ั‚ะตัั‚ัƒะฒะฐะฝะฝั ะบะปัŽั‡ะพะฒั– ะฐัะฟะตะบั‚ะธ ั‚ะฐ ะฟั€ะฐะบั‚...
ย 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
ย 

Computer SAarchitecture Lecture 6_Pip.pdf

  • 2. What is pipelining? โ€ข A technique used in advanced microprocessors where the microprocessor begins executing a second instruction before the first has been completed โ€ข Multiple instructions are overlapped in execution โ€ข Process of instruction execution is divided into two or more steps, called pipe stages or pipe segments โ€ข Different stage are completing different parts of different instructions in parallel โ€ข The stages are connected one to the next to form a pipe โ€ข Instructions enter at one end, progress through the stages, and exit at the other end โ€ข Unlike some speedup techniques, it is not visible to the programmer/compiler.
  • 3.
  • 4. Characteristics of pipelining โ€ข Hardware or software implementation โ€“ pipelining can be implemented in either software or hardware. โ€ข Large or Small Scale โ€“ Stations in a pipeline can range from simplistic to powerful, and a pipeline can range in length from short to long. โ€ข Buffered or unbuffered flow โ€“ One stage of pipeline sends data directly to another one or a buffer is place between each pairs of stages. โ€ข Synchronous or asynchronous flow โ€“ A synchronous pipeline operates like an assembly line: at a given time, each station is processing some amount of information. A asynchronous pipeline, allow a station to forward information at any time. โ€ข Automatic Data Feed Or Manual Data Feed โ€“ Some implementations of pipelines use a separate mechanism to move information, and other implementations require each stage to participate in moving information
  • 5. Types of pipelining โ€ข Software Pipelining โ€ข Can Handle Complex Instructions โ€ข Allows programs to be reused โ€ข Hardware Pipelining โ€ข Help designer manage complexity โ€“ a complex task can be divided into smaller, more manageable pieces. โ€ข Hardware pipelining offers higher performance
  • 6. Effects of pipelining โ€ข Time in ns per instruction goes up โ€ข Number of cycles per instruction goes up (note the increase in clock speed) โ€ข Total execution time goes down, resulting in lower time per instruction โ€ข Average cycles per instruction increases slightly โ€ข Under ideal conditions: โ€ข speedup = ratio of elapsed times between successive instruction completions = number of pipeline stages = increase in clock speed
  • 7. Instruction pipelining โ€ข An instruction pipeline increases the performance of a processor by overlapping the processing of several different instructions โ€ข Consists of five stages: โ€ข Instruction fetch (IF): the instruction is fetched from memory and placed in the instruction register (IR) โ€ข Instruction decode (ID): identification of the operation to be performed โ€ข Execution (EX): the instruction is executed โ€ข Memory read/write (ME): stage is responsible for storing and loading values to and from memory. It also responsible for input or output from the processor. โ€ข Write back (WB): The results of the operation are written to the destination register.
  • 8. Timings โ€ข Estimated timing for each stage of instruction: โ€ข Instruction fetch โ€“ 2ns โ€ข Instruction decode โ€“ 1ns โ€ข Execution โ€“ 2ns โ€ข Memory and I/O โ€“ 2ns โ€ข Write Back โ€“ 1ns
  • 9. Hazards โ€ข There are three types of hazards that can happen while pipelined execution: โ€ข Structural hazards โ€ข Data hazards โ€ข Control hazards
  • 10. Hazards (cont.) โ€ข Structural hazards โ€ข different instructions in different stages (or the same stage) conflicting for the same resource โ€ข Data hazards โ€ข an instruction cannot continue because it needs a value that has not yet been generated by an earlier instruction โ€ข Control hazards โ€ข fetch cannot continue because it does not know the outcome of an earlier branch โ€“ special case of a data hazard
  • 11. Data hazard โ€ข Data hazard caused by data dependences โ€ข There are three data dependences: โ€ข Read-After-Write (RAW) โ€ข Write-After-Write (WAW) โ€ข Write-After-Read (WAR)
  • 12. Read-After-Write IF ID EX M WB IF ID EX M WB ADD R1, R2, R3 SUB R4, R1, R5 Read R2 and R3 Add R2 and R3 Write result to R1 Read R1 and R5 Next instruction tries to read an operand before previous instruction writes it Extremely common hazard
  • 13. Write-After-Write IF ID EX M M1 M2 M3 WB IF ID EX M WB ADD R1, R2, R3 SUB R1, R4, R5 Read R2 and R3 Add R2 and R3 Write result to R1 Write result to R1 Next instruction tries to write an operand before previous instruction writes it
  • 14. Write-After-Read IF ID EX M WB IF ID EX M WB ADD R1, R2, R3 SUB R2, R1, R5 Read R2 and R3 Write result to R1 Write result to R2 Next instruction tries to write an operand before previous instruction reads it. Happens if pipeline is out-order
  • 15. Dealing with data hazard โ€ข We can solve data hazard problem with stalling โ€ข Stalling โ€ข halting the flow of instructions until the required result is ready to be used โ€ข wastes processor time by doing nothing while waiting for the result.
  • 16. IF ID EX M WB ADD R1, R2, R3 SUB R4, R1, R5 IF ID EX M WB IF ID EX M WB IF ID EX M WB IF ID EX M WB STALL STALL STALL
  • 17. Performance of pipelines ๐‘†๐‘๐‘’๐‘’๐‘‘๐‘ข๐‘ ๐‘“๐‘Ÿ๐‘œ๐‘š ๐‘๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘–๐‘›๐‘” = ๐ด๐‘ฃ๐‘” ๐‘–๐‘›๐‘ ๐‘ก๐‘ข๐‘๐‘ก๐‘–๐‘œ๐‘› ๐‘ก๐‘–๐‘š๐‘’ ๐‘ข๐‘›๐‘๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘’๐‘‘ ๐ด๐‘ฃ๐‘” ๐‘–๐‘›๐‘ ๐‘ก๐‘Ÿ๐‘ข๐‘๐‘ก๐‘–๐‘œ๐‘› ๐‘ก๐‘–๐‘š๐‘’ ๐‘๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘’๐‘‘ = ๐ถ๐‘ƒ๐ผ ๐‘ข๐‘›๐‘๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘’๐‘‘ ร— ๐ถ๐‘™๐‘œ๐‘๐‘˜ ๐‘๐‘ฆ๐‘๐‘™๐‘’ ๐‘ก๐‘–๐‘š๐‘’ ๐‘ข๐‘›๐‘๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘’๐‘‘ ๐ถ๐‘ƒ๐ผ ๐‘๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘’๐‘‘ ร— ๐ถ๐‘™๐‘œ๐‘๐‘˜ ๐‘๐‘ฆ๐‘๐‘™๐‘’ ๐‘ก๐‘–๐‘š๐‘’ ๐‘๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘’๐‘‘ ๐ถ๐‘ƒ๐ผ ๐‘๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘’๐‘‘ = ๐ผ๐‘‘๐‘’๐‘Ž๐‘™ ๐ถ๐‘ƒ๐ผ + ๐‘ƒ๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘’ ๐‘ ๐‘ก๐‘Ž๐‘™๐‘™ ๐‘๐‘™๐‘œ๐‘๐‘˜ ๐‘๐‘ฆ๐‘๐‘™๐‘’๐‘  ๐‘๐‘’๐‘Ÿ ๐‘–๐‘›๐‘ ๐‘ก๐‘Ÿ๐‘ข๐‘๐‘ก๐‘–๐‘œ๐‘› On a pipelined processor Ideal CPI is 1 ๐ถ๐‘ƒ๐ผ ๐‘๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘’๐‘‘ = 1 + ๐‘ƒ๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘’ ๐‘ ๐‘ก๐‘Ž๐‘™๐‘™ ๐‘๐‘™๐‘œ๐‘๐‘˜ ๐‘๐‘ฆ๐‘๐‘™๐‘’๐‘  ๐‘๐‘’๐‘Ÿ ๐‘–๐‘›๐‘ ๐‘ก๐‘Ÿ๐‘ข๐‘๐‘ก๐‘–๐‘œ๐‘›
  • 18. ๐‘†๐‘๐‘’๐‘’๐‘‘๐‘ข๐‘ ๐‘“๐‘Ÿ๐‘œ๐‘š ๐‘๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘–๐‘›๐‘” = ๐ถ๐‘ƒ๐ผ ๐‘ข๐‘›๐‘๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘’๐‘‘ 1 + ๐‘ƒ๐‘–๐‘๐‘’๐‘™๐‘–๐‘›๐‘’ ๐‘ ๐‘ก๐‘Ž๐‘™๐‘™ ๐‘๐‘™๐‘œ๐‘๐‘˜ ๐‘๐‘ฆ๐‘๐‘™๐‘’๐‘  ๐‘๐‘’๐‘Ÿ ๐‘–๐‘›๐‘ ๐‘ก๐‘Ÿ๐‘ข๐‘๐‘ก๐‘–๐‘œ๐‘› CPI unpipelined = depth of pipeline IF ID EX M WB IF ID EX M WB IF ID EX M WB Pipeline depth ๐‘บ๐’‘๐’†๐’†๐’…๐’–๐’‘ ๐’‡๐’“๐’๐’Ž ๐’‘๐’Š๐’‘๐’†๐’๐’Š๐’๐’Š๐’๐’ˆ = ๐‘ท๐’Š๐’‘๐’†๐’๐’Š๐’๐’† ๐’…๐’†๐’‘๐’•๐’‰ ๐Ÿ + ๐‘ท๐’Š๐’‘๐’†๐’๐’Š๐’๐’† ๐’”๐’•๐’‚๐’๐’ ๐’„๐’๐’๐’„๐’Œ ๐’„๐’š๐’„๐’๐’†๐’” ๐’‘๐’†๐’“ ๐’Š๐’๐’”๐’•๐’“๐’–๐’„๐’•๐’Š๐’๐’
  • 19. Advantages and disadvantages โ€ข Advantages: โ€ข More efficient use of processor โ€ข Quicker time of execution of large number of instructions โ€ข Disadvantages: โ€ข Pipelining involves adding hardware to the chip โ€ข Inability to continuously run the pipeline at full speed because of pipeline hazards which disrupt the smooth execution of the pipeline.