memory hierarchy design, basics, cache optimization, address translation

28

Upload: farwa-ansari

Post on 15-Apr-2017

115 views

Category:

Education


1 download

TRANSCRIPT

Page 1: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation
Page 2: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

Memory HierarchyDesign

Page 3: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

Group Members

Ammarah Khalid (12-CS-01) Farwa Abdul Hanan (12-CS-13) Zainab Khalid (12-CS-33) Aniqa Javed (12-CS-34)

Page 4: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

Introduction

Programmers want unlimited amounts of memory with low latency

Fast memory technology is more expensive per bit than slower memory

Solution: organize memory system into a hierarchy

Page 5: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

Memory Hierarchy

The memory hierarchy is a concept used for storing & discussing performance issues in computer architectural design

The goal is to provide a memory system with cost per byte almost as low as the cheapest level of memory and speed almost as fast as the fastest level

Page 6: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

Memory Hierarchy Design

Main Memory

Disk Storage

Back Storage

Cache

Registers

Page 7: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

Back Storage• Offline memory• Used for Backup

Back Storage

Page 8: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

Disk Storage• Online memory• Secondary Storage

Disk Storage

Back Storage

Page 9: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

Main Memory• Primary Memory• Instructions

resides in main memory Main Memory

Disk Storage

Back Storage

Page 10: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

Cache• High speed memory• Costly but Fast• Store CPU executed

outputMain Memory

Disk Storage

Back Storage

Cache

Page 11: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

Registers• Part of CPU• Temporary memory

Main Memory

Disk Storage

Back Storage

Cache

Registers

Page 12: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

Principle of locality

Principle of locality, also known as the, locality of reference it is a term for the phenomenon in which the same values, or related

storage locations, are frequently accessed.

Page 13: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

Memory Hierarchy Basics

Page 14: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

Memory Performance Gap

Page 15: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

Memory Hierarchy Basics

When a word is not found in the cache The word must be fetched from the memory and placed in the cache

before continuing Each cache block includes a tag to see which memory address it

corresponds to. Most popular scheme is set associative, where a set is a group of blocks

in the cache Then place block into cache in any location within its set, determined by

address(block address) MOD (number of sets)

Page 16: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

Memory Hierarchy Basics

n sets => n-way set associative Direct-mapped cache => one block per set Fully associative => one set

Writing to cache: two strategies Write-through

A write-through cache updates the item in the cache and writes through to update main memory Write-back

A write-back cache only updates the copy in the cache. When the block is about to be replaced, it is copied back to memory

Both write strategies can use a write buffer to allow the cache to proceed as soon as the data is placed in the buffer

Page 17: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

Memory Hierarchy Basics

Miss rate Fraction of cache access that result in a miss

Causes of misses Compulsory

First reference to a block Compulsory misses are those that occur even if you had an infinite cache.

Capacity Capacity misses (in addition to compulsory misses) will occur because of blocks being discarded and

later retrieved. Conflict

Conflict misses (in addition to compulsory and capacity misses) will occur because a block may be discarded and later retrieved if conflicting blocks map to its set.

Page 18: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

Memory Hierarchy Basics

where Hit time is the time to hit in the cache and Miss penalty is the time to replace the block from memory (that is, the cost of a miss). Average memory access time is still an indirect measure of performancealthough it is a better measure than miss rate, it is not a substitute for execution time

Page 19: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

Cache Optimization

Page 20: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

Basic Cache Optimizations

Larger block size to reduce miss rate Increase the block size so that more and more data from

frequently used addresses can be stored Drawbacks – Miss Penalty

Bigger caches to reduce miss rate Increase the cache size Drawbacks - potentially longer hit time of the larger cache

memory and higher cost and power.

Page 21: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

Continue…

Higher associativity to reduce miss rate Increasing associativity to reduce conflict misses Cost of increased hit time

Multilevel caches to reduce miss penalty Adding another level of cache between cache and memory First level – to match the fast clock cycle in order to keep

pace with the increasing clock rate of the processor Second level – large enough to capture many accesses that

would go to main memory

Page 22: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

Continue…

To avoid read after write hazards give priority to read misses over writes to reduce miss penalty and check the contents of the write buffer if no data conflicts then let the memory to read

Avoiding address translation during indexing of the cache to reduce hit time

Page 23: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

Address translation

Page 24: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

Virtual Memory

Virtual memory is a feature of an operating system (OS) that allows a computer to compensate for shortages of physical memory by temporarily transferring pages of data from random access memory (RAM) to disk storage. It contains virtual addresses

Page 25: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

Translation Lookaside Buffer (TLB)

The translation lookaside buffer (TLB) is a cache for page table entries. It works in much the same way as the data cache: it stores recently accessed page table entries.

Page 26: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation
Page 27: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation
Page 28: Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

The END