Carc 07.03
alessandro.bogliolo@uniurb.it
07. Memory
07.03.a Memory Hierarchy
• Reference locality
• Caching
• Virtual memory
Computer Architecture
alessandro.bogliolo@uniurb.it
Carc 07.03
alessandro.bogliolo@uniurb.it
Conflicting requirements
• Requirements:
• Size: Computer systems require an ever increasing amount of main
memory
• Speed: CPUs are designed assuming that memory accesses take 1 CPU
clock cycle
• Cost: The memory system should have a marginal impact on the cost of
a computer system
• Issues:
• For a given technology, the access time of a memory device grows with
its size
• SRAMs are much faster than DRAMs, but they are more expansive and
less dense
• An ideal memory should be large and cheap as a DRAM and
fast as a small SRAM
Carc 07.03
alessandro.bogliolo@uniurb.it
Memory hierarchy
• Locality of memory references:
• Spatial locality: the likelihood of referencing a memory
address is higher if an address near it was just referenced.
• Temporal locality: a memory address that is referenced at
one point in time is likely to be referenced again sometime
in the near future.
• Access time of memory devices:
• Most DRAM devices can work in page mode to provide a
burst of data read from the same row at a speed much
higher than the typical access time of a random access
Carc 07.03
alessandro.bogliolo@uniurb.it
Cache
• A cache is a small and fast memory that duplicates some of the
entries of main memory
• Accesses to the cache are much faster than accesses to the
main memory
• As long as the processor finds in cache the memory entries it
needs, the perceived performance is the performance of the
cache
• The principle of locality is used to decide what to place in
cache
Carc 07.03
alessandro.bogliolo@uniurb.it
0 0 0 1 1 0 1 1
0 0 0 0
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0 A
0 1 0 1
0 1 1 0
0 1 1 1
1 0 0 0
1 0 0 1
1 0 1 0
1 0 1 1
1 1 0 0
1 1 0 1
1 1 1 0 B
1 1 1 1
RAM
Direct-mapped cache
0 1 0 0 1 1
block address
tag index offset
0 0 0 1 1 0 1 1 TAG
0 0 A 0 1
0 1
1 0 B 1 1
1 1
cache
Carc 07.03
alessandro.bogliolo@uniurb.it
0 0 0 1 1 0 1 1
0 0 0 0
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0 A
0 1 0 1
0 1 1 0
0 1 1 1
1 0 0 0
1 0 0 1
1 0 1 0
1 0 1 1
1 1 0 0
1 1 0 1
1 1 1 0 B
1 1 1 1
RAM
0 1 0 0 1 1
tag
block address
offset
Fully associative cache
0 0 0 1 1 0 1 1 TAG 0 0 0 1 1 0 1 1 TAG 0 0 0 1 1 0 1 1 TAG 0 0 0 1 1 0 1 1
A 0 1 0 0 B 1 1 1 0
cache way3 cache way4cache way1 cache way2
Carc 07.03
alessandro.bogliolo@uniurb.it
0 0 0 1 1 0 1 1
0 0 0 0
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0 A
0 1 0 1
0 1 1 0
0 1 1 1
1 0 0 0
1 0 0 1
1 0 1 0
1 0 1 1
1 1 0 0
1 1 0 1
1 1 1 0 B
1 1 1 1
RAM
ind
0 1 0 0 1 1
tag
block address
offset
Set-associative cache
0 0 0 1 1 0 1 1 TAG 0 0 0 1 1 0 1 1 TAG
0 A 0 1 0 0 B 1 1 1
1 1
cache way2cache way1
Carc 07.03
alessandro.bogliolo@uniurb.it
000 00
000 01
000 10
000 11
001 00
001 01
001 10
001 11
010 00
010 01
010 10
010 11
011 00
011 01
011 10
011 11
100 00
100 01
...
111 11
Cache: block identification
log2BlockSize
00000
00001
00010
00011
00100
00101
00110
00111
01000
01001
01010
01011
01100
01101
01110
01111
10000
10001
...
11111
00 000
00 001
00 010
00 011
00 100
00 101
00 110
00 111
01 000
01 001
01 010
01 011
01 100
01 101
01 110
01 111
10 000
10 001
...
11 111
Tag Index Block Offset
Block OffsetBlock Address
log2SetSize
log2Sets
log2Blocks
Direct mapped (DM)
Set associative (SA)
Fully associative (FA)
1-way
2-way
8-way
DM SA FA
Carc 07.03
alessandro.bogliolo@uniurb.it
Cache: block replacement
• Which block should be replaced on a cache miss?
1. Random (RND)
2. Least-Recently Used (LRU)
3. First In First Out (FIFO)
RND and FIFO policies are easier to implement, while LRU
is more coherent with locality
Caches provide a used flag associated with each block to
support an approximation of LRU:
- the flag is periodically reset
- candidates for replacement on a miss are blocks with flag 0 (i.e.,
unused since last reset)
Carc 07.03
alessandro.bogliolo@uniurb.it
Cache performance
yMissPenaltMissRateHitTimeimeAvgAccessT 
MissTimeMissRateHitTimeHitRateimeAvgAccessT 
HitTimeMissTimeyMissPenalt 
)222( yMissPenaltMissRateHitTimeMissRateHitTimeimeAvgAccessT 
Level-1 and Level-2 cache:

More Related Content

PDF
CArcMOOC 07.02 - Non-volatile memory devices
PDF
CArcMOOC 07.01 - Memory devices
PDF
CArcMOOC 07.03b - Memory hierarchy - Virtual memory
PPT
cache memory management
PPTX
Organisation of cache memory
PPTX
Cache memory
PPTX
Address mapping
PPTX
CArcMOOC 07.02 - Non-volatile memory devices
CArcMOOC 07.01 - Memory devices
CArcMOOC 07.03b - Memory hierarchy - Virtual memory
cache memory management
Organisation of cache memory
Cache memory
Address mapping

What's hot (12)

PPT
PPTX
What is Cache and how it works
PPTX
Memory mapping techniques and low power memory design
PPTX
The path through 40G towards 100G
PPTX
Cache management
PPTX
Elements of cache design
PPT
Cache Memory
PPT
04 cache memory...
PDF
NUMA and Java Databases
PPTX
Java one2015 - Work With Hundreds of Hot Terabytes in JVMs
PPTX
Demand paging
What is Cache and how it works
Memory mapping techniques and low power memory design
The path through 40G towards 100G
Cache management
Elements of cache design
Cache Memory
04 cache memory...
NUMA and Java Databases
Java one2015 - Work With Hundreds of Hot Terabytes in JVMs
Demand paging
Ad

Similar to CArcMOOC 07.03a - Memory hierarchy - Caching (20)

PPT
Memory organization including cache and RAM.ppt
PPT
Memory Organization and Cache mapping.ppt
PDF
Lecture 25
PPTX
Cache Presentation for Computer Organization & Assembly Language
PDF
Computer architecture for HNDIT
PPT
Cpu caching concepts mr mahesh
PPT
Ch_4.pptInnovation technology pptInnovation technology ppt
PPT
cache memory
PPT
chapter6.ppt
PPT
04_Cache Memory-computer-architecture.ppt
PPT
04_Cache Memory.ppt
PPT
Cache Memory.ppt
PPT
04_Cache Memory.ppt
PPT
04 cache memory.ppt 1
PPT
Cache Memory from Computer Architecture.ppt
PPT
cache memory.ppt
PPT
cache memory.ppt
PPT
ch5.pptjhbuhugikhgyfguijhft67yijbtdyuyhjh
PDF
Chache memory ( chapter number 4 ) by William stalling
PPT
Cache Memory for Computer Architecture.ppt
Memory organization including cache and RAM.ppt
Memory Organization and Cache mapping.ppt
Lecture 25
Cache Presentation for Computer Organization & Assembly Language
Computer architecture for HNDIT
Cpu caching concepts mr mahesh
Ch_4.pptInnovation technology pptInnovation technology ppt
cache memory
chapter6.ppt
04_Cache Memory-computer-architecture.ppt
04_Cache Memory.ppt
Cache Memory.ppt
04_Cache Memory.ppt
04 cache memory.ppt 1
Cache Memory from Computer Architecture.ppt
cache memory.ppt
cache memory.ppt
ch5.pptjhbuhugikhgyfguijhft67yijbtdyuyhjh
Chache memory ( chapter number 4 ) by William stalling
Cache Memory for Computer Architecture.ppt
Ad

More from Alessandro Bogliolo (20)

PDF
AIXMOOC 2.6 - Come funzionano i Large Language Models
PDF
AIXMOOC 6.1 - Non sono un robot (Dom Holdaway)
PDF
AIXMOOC 5.3 - L'essere umano di fronte all'I.A. (Cristiano Maria Bellei)
PDF
AIXMOOC 4.3 - Geopolitica dell'intelligenza artificiale (Alessandro Aresu)
PDF
AIXMOOC 3.3 - Linguaggio e capacità cognitive (Gabriella Bottini)
PDF
AIXMOOC 3.2 - Linguaggio e memoria (Manuela Berlingeri)
PDF
AIXMOOC 4.2 - IA e informazione (Fabio Giglietto)
PDF
AIXMOOC 2.5 - CPU e GPU per Machine Learning (Luca Benini)
PDF
AIXMOOC 5.2 - IA generativa e creatività
PDF
AIXMOOC 3.1 - L'acquisizione del linguaggio (Mirta Vernice)
PPTX
AIXMOOC 4.1 - Comunicare con l'IA (Giovanni Boccia Artieri)
PDF
AIXMOOC 2.4 - Intelligenza artificiale generativa (Mirco Musolesi)
PDF
AIXMOOC 2.3 - Modelli di reti neurali con esperimenti di addestramento
PDF
AIXMOOC 2.2 - Reti neurali e machine learning (Valerio Freschi)
PDF
AIXMOOC 2.1 - Il modello del neurone (Stefano Sartini)
PDF
AIXMOOC 1.4 - Macchine Calcolatrici e Intelligenza, di A. Turing
PDF
AIXMOOC 5.1 - EU AI Act - Il regolamento europeo (Lucilla Sioli)
PPTX
AIXMOOC 1.2 - Quando le macchine impararono a parlare
PDF
AIXMOOC 1.1 - L'esplosione dell'Intelligenza Artificiale - Introduzione
PDF
BIBMOOC 05.03 - Codici in biblioteca
AIXMOOC 2.6 - Come funzionano i Large Language Models
AIXMOOC 6.1 - Non sono un robot (Dom Holdaway)
AIXMOOC 5.3 - L'essere umano di fronte all'I.A. (Cristiano Maria Bellei)
AIXMOOC 4.3 - Geopolitica dell'intelligenza artificiale (Alessandro Aresu)
AIXMOOC 3.3 - Linguaggio e capacità cognitive (Gabriella Bottini)
AIXMOOC 3.2 - Linguaggio e memoria (Manuela Berlingeri)
AIXMOOC 4.2 - IA e informazione (Fabio Giglietto)
AIXMOOC 2.5 - CPU e GPU per Machine Learning (Luca Benini)
AIXMOOC 5.2 - IA generativa e creatività
AIXMOOC 3.1 - L'acquisizione del linguaggio (Mirta Vernice)
AIXMOOC 4.1 - Comunicare con l'IA (Giovanni Boccia Artieri)
AIXMOOC 2.4 - Intelligenza artificiale generativa (Mirco Musolesi)
AIXMOOC 2.3 - Modelli di reti neurali con esperimenti di addestramento
AIXMOOC 2.2 - Reti neurali e machine learning (Valerio Freschi)
AIXMOOC 2.1 - Il modello del neurone (Stefano Sartini)
AIXMOOC 1.4 - Macchine Calcolatrici e Intelligenza, di A. Turing
AIXMOOC 5.1 - EU AI Act - Il regolamento europeo (Lucilla Sioli)
AIXMOOC 1.2 - Quando le macchine impararono a parlare
AIXMOOC 1.1 - L'esplosione dell'Intelligenza Artificiale - Introduzione
BIBMOOC 05.03 - Codici in biblioteca

Recently uploaded (20)

PPTX
Unit 4 Computer Architecture Multicore Processor.pptx
PPTX
Education and Perspectives of Education.pptx
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
PDF
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
PDF
LIFE & LIVING TRILOGY - PART - (2) THE PURPOSE OF LIFE.pdf
PDF
International_Financial_Reporting_Standa.pdf
PDF
Environmental Education MCQ BD2EE - Share Source.pdf
PDF
My India Quiz Book_20210205121199924.pdf
PDF
semiconductor packaging in vlsi design fab
PDF
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
PPTX
Core Concepts of Personalized Learning and Virtual Learning Environments
PDF
Empowerment Technology for Senior High School Guide
PDF
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
PPTX
Share_Module_2_Power_conflict_and_negotiation.pptx
PPTX
Computer Architecture Input Output Memory.pptx
PPTX
B.Sc. DS Unit 2 Software Engineering.pptx
PDF
Complications of Minimal Access-Surgery.pdf
PDF
Journal of Dental Science - UDMY (2021).pdf
PDF
Hazard Identification & Risk Assessment .pdf
PDF
AI-driven educational solutions for real-life interventions in the Philippine...
Unit 4 Computer Architecture Multicore Processor.pptx
Education and Perspectives of Education.pptx
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
LIFE & LIVING TRILOGY - PART - (2) THE PURPOSE OF LIFE.pdf
International_Financial_Reporting_Standa.pdf
Environmental Education MCQ BD2EE - Share Source.pdf
My India Quiz Book_20210205121199924.pdf
semiconductor packaging in vlsi design fab
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
Core Concepts of Personalized Learning and Virtual Learning Environments
Empowerment Technology for Senior High School Guide
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
Share_Module_2_Power_conflict_and_negotiation.pptx
Computer Architecture Input Output Memory.pptx
B.Sc. DS Unit 2 Software Engineering.pptx
Complications of Minimal Access-Surgery.pdf
Journal of Dental Science - UDMY (2021).pdf
Hazard Identification & Risk Assessment .pdf
AI-driven educational solutions for real-life interventions in the Philippine...

CArcMOOC 07.03a - Memory hierarchy - Caching

  • 1. Carc 07.03 alessandro.bogliolo@uniurb.it 07. Memory 07.03.a Memory Hierarchy • Reference locality • Caching • Virtual memory Computer Architecture alessandro.bogliolo@uniurb.it
  • 2. Carc 07.03 alessandro.bogliolo@uniurb.it Conflicting requirements • Requirements: • Size: Computer systems require an ever increasing amount of main memory • Speed: CPUs are designed assuming that memory accesses take 1 CPU clock cycle • Cost: The memory system should have a marginal impact on the cost of a computer system • Issues: • For a given technology, the access time of a memory device grows with its size • SRAMs are much faster than DRAMs, but they are more expansive and less dense • An ideal memory should be large and cheap as a DRAM and fast as a small SRAM
  • 3. Carc 07.03 alessandro.bogliolo@uniurb.it Memory hierarchy • Locality of memory references: • Spatial locality: the likelihood of referencing a memory address is higher if an address near it was just referenced. • Temporal locality: a memory address that is referenced at one point in time is likely to be referenced again sometime in the near future. • Access time of memory devices: • Most DRAM devices can work in page mode to provide a burst of data read from the same row at a speed much higher than the typical access time of a random access
  • 4. Carc 07.03 alessandro.bogliolo@uniurb.it Cache • A cache is a small and fast memory that duplicates some of the entries of main memory • Accesses to the cache are much faster than accesses to the main memory • As long as the processor finds in cache the memory entries it needs, the perceived performance is the performance of the cache • The principle of locality is used to decide what to place in cache
  • 5. Carc 07.03 alessandro.bogliolo@uniurb.it 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 A 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 B 1 1 1 1 RAM Direct-mapped cache 0 1 0 0 1 1 block address tag index offset 0 0 0 1 1 0 1 1 TAG 0 0 A 0 1 0 1 1 0 B 1 1 1 1 cache
  • 6. Carc 07.03 alessandro.bogliolo@uniurb.it 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 A 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 B 1 1 1 1 RAM 0 1 0 0 1 1 tag block address offset Fully associative cache 0 0 0 1 1 0 1 1 TAG 0 0 0 1 1 0 1 1 TAG 0 0 0 1 1 0 1 1 TAG 0 0 0 1 1 0 1 1 A 0 1 0 0 B 1 1 1 0 cache way3 cache way4cache way1 cache way2
  • 7. Carc 07.03 alessandro.bogliolo@uniurb.it 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 A 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 B 1 1 1 1 RAM ind 0 1 0 0 1 1 tag block address offset Set-associative cache 0 0 0 1 1 0 1 1 TAG 0 0 0 1 1 0 1 1 TAG 0 A 0 1 0 0 B 1 1 1 1 1 cache way2cache way1
  • 8. Carc 07.03 alessandro.bogliolo@uniurb.it 000 00 000 01 000 10 000 11 001 00 001 01 001 10 001 11 010 00 010 01 010 10 010 11 011 00 011 01 011 10 011 11 100 00 100 01 ... 111 11 Cache: block identification log2BlockSize 00000 00001 00010 00011 00100 00101 00110 00111 01000 01001 01010 01011 01100 01101 01110 01111 10000 10001 ... 11111 00 000 00 001 00 010 00 011 00 100 00 101 00 110 00 111 01 000 01 001 01 010 01 011 01 100 01 101 01 110 01 111 10 000 10 001 ... 11 111 Tag Index Block Offset Block OffsetBlock Address log2SetSize log2Sets log2Blocks Direct mapped (DM) Set associative (SA) Fully associative (FA) 1-way 2-way 8-way DM SA FA
  • 9. Carc 07.03 alessandro.bogliolo@uniurb.it Cache: block replacement • Which block should be replaced on a cache miss? 1. Random (RND) 2. Least-Recently Used (LRU) 3. First In First Out (FIFO) RND and FIFO policies are easier to implement, while LRU is more coherent with locality Caches provide a used flag associated with each block to support an approximation of LRU: - the flag is periodically reset - candidates for replacement on a miss are blocks with flag 0 (i.e., unused since last reset)
  • 10. Carc 07.03 alessandro.bogliolo@uniurb.it Cache performance yMissPenaltMissRateHitTimeimeAvgAccessT  MissTimeMissRateHitTimeHitRateimeAvgAccessT  HitTimeMissTimeyMissPenalt  )222( yMissPenaltMissRateHitTimeMissRateHitTimeimeAvgAccessT  Level-1 and Level-2 cache: