Module IV Memory Organization.

Slides:



Advertisements
Similar presentations
Lecture 8: Memory Hierarchy Cache Performance Kai Bu
Advertisements

Cache Here we focus on cache improvements to support at least 1 instruction fetch and at least 1 data access per cycle – With a superscalar, we might need.
How caches take advantage of Temporal locality
CS 333 Introduction to Operating Systems Class 11 – Virtual Memory (1)
Memory Problems Prof. Sin-Min Lee Department of Mathematics and Computer Sciences.
The Memory Hierarchy II CPSC 321 Andreas Klappenecker.
1  1998 Morgan Kaufmann Publishers Chapter Seven Large and Fast: Exploiting Memory Hierarchy.
EENG449b/Savvides Lec /13/04 April 13, 2004 Prof. Andreas Savvides Spring EENG 449bG/CPSC 439bG Computer.
Virtual Memory and Paging J. Nelson Amaral. Large Data Sets Size of address space: – 32-bit machines: 2 32 = 4 GB – 64-bit machines: 2 64 = a huge number.
COEN 180 Main Memory Cache Architectures. Basics Speed difference between cache and memory is small. Therefore:  Cache algorithms need to be implemented.
Memory Systems Architecture and Hierarchical Memory Systems
CACHE MEMORY Cache memory, also called CPU memory, is random access memory (RAM) that a computer microprocessor can access more quickly than it can access.
Lecture 19: Virtual Memory
In1210/01-PDS 1 TU-Delft The Memory System. in1210/01-PDS 2 TU-Delft Organization Word Address Byte Address
Computer Architecture Memory organization. Types of Memory Cache Memory Serves as a buffer for frequently accessed data Small  High Cost RAM (Main Memory)
CPE432 Chapter 5A.1Dr. W. Abu-Sufah, UJ Chapter 5A: Exploiting the Memory Hierarchy, Part 2 Adapted from Slides by Prof. Mary Jane Irwin, Penn State University.
1 Virtual Memory Main memory can act as a cache for the secondary storage (disk) Advantages: –illusion of having more physical memory –program relocation.
Virtual Memory 1 1.
11 Intro to cache memory Kosarev Nikolay MIPT Nov, 2009.
1  2004 Morgan Kaufmann Publishers Chapter Seven Memory Hierarchy-3 by Patterson.
Page Table Implementation. Readings r Silbershatz et al:
Additional Slides By Professor Mary Jane Irwin Pennsylvania State University Group 1.
Memory Management Continued Questions answered in this lecture: What is paging? How can segmentation and paging be combined? How can one speed up address.
LECTURE 12 Virtual Memory. VIRTUAL MEMORY Just as a cache can provide fast, easy access to recently-used code and data, main memory acts as a “cache”
Cache Small amount of fast memory Sits between normal main memory and CPU May be located on CPU chip or module.
CS203 – Advanced Computer Architecture Virtual Memory.
نظام المحاضرات الالكترونينظام المحاضرات الالكتروني Cache Memory.
COSC2410: LAB 19 INTRODUCTION TO MEMORY/CACHE DIRECT MAPPING 1.
Computer Orgnization Rabie A. Ramadan Lecture 9. Cache Mapping Schemes.
Associative Mapping A main memory block can load into any line of cache Memory address is interpreted as tag and word Tag uniquely identifies block of.
Cache Memory Yi-Ning Huang. Principle of Locality Principle of Locality A phenomenon that the recent used memory location is more likely to be used again.
CSCI206 - Computer Organization & Programming
Chapter 19 Translation Lookaside Buffer
Memory: Page Table Structure
Translation Lookaside Buffer
Memory Hierarchy Ideal memory is fast, large, and inexpensive
Cache Memory.
CSE 351 Section 9 3/1/12.
The Memory System (Chapter 5)
Memory COMPUTER ARCHITECTURE
Memory and cache CPU Memory I/O.
Lecture 12 Virtual Memory.
Improving Memory Access 1/3 The Cache and Virtual Memory
CSC 4250 Computer Architectures
Memory Hierarchy Virtual Memory, Address Translation
Cache Memory Presentation I
Consider a Direct Mapped Cache with 4 word blocks
Lecture: Large Caches, Virtual Memory
William Stallings Computer Organization and Architecture 7th Edition
CS510 Operating System Foundations
Exploiting Memory Hierarchy Chapter 7
CSCI206 - Computer Organization & Programming
CS 704 Advanced Computer Architecture
CSCI206 - Computer Organization & Programming
Memory and cache CPU Memory I/O.
FIGURE 12-1 Memory Hierarchy
Systems Architecture II
Module IV Memory Organization.
Chapter 6 Memory System Design
Cache Memory.
How can we find data in the cache?
Virtual Memory Overcoming main memory size limitation
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CS703 - Advanced Operating Systems
Cache - Optimization.
Cache Memory and Performance
Overview Problem Solution CPU vs Memory performance imbalance
Virtual Memory 1 1.
Presentation transcript:

Module IV Memory Organization

Elements of Cache Design It includes: Cache Addresses Cache Size Mapping Function Replacement Algorithms Write Policy Line Size Number of Caches

Cache Addresses When virtual addresses are used, the system designers have two options to place the cache between the processor and the MMU (Logical Cache) or between the MMU and main memory (Physical Cache)

Logical Cache It is also known as a virtual cache. It stores data using virtual addresses. The processor accesses cache directly, without going through MMU. Advantage: It is faster than physical cache, because the cache can respond before the MMU performs an address translation.

Logical Cache Disadvantage: Most virtual memory systems supply each application with the same virtual memory address space(that starts at address 0). Thus, the same virtual address in two different applications refers to two different physical addresses. The cache memory must therefore be completely flushed with each application context switch, or extra bits must be added to each line of the cache to identify which virtual address space this address refers to.

Logical Cache

Physical Cache It stores data using main memory physical addresses.

Cache Size Size of the cache to be small enough so that the overall average cost per bit is close to that of main memory alone and large enough so that the overall average access time is close to that of the cache alone.

Mapping Function Main memory and cache are both divided into same size blocks It deals with how a cache with numerous entries search quickly and report a hit if a match is found. Cache may be organized in different hardware configurations.

Cache Organization The 3 main designs are: Directly Mapped Fully Associative & Set Associative

Direct Mapped Cache It uses a portion of incoming physical address to select an entry. Suppose a cache has 27 = 128 lines, each with 16 bytes. Suppose the memory has a 16-bit address and hence (216 = 64KB) address space. Each memory line j maps to cache line j mod 128 and the memory address looks like:   Tag Line Word 5bits 7 bits 4bits

Mapping Cache line size = 16 byte Cache Memory = 2KB No. of cache lines = 128 Main Memory = 64KB No of main memory lines = 64KB/16B = 216/24 = 212 =4096

Direct Mapping

Example Suppose we want to read or write a byte at the address 357A Tag = 6 Line = 87 Word = 10 If line 87 in cache has tag 6, then data at 357A is in cache. Else, a miss has occurred Contents of cache line 87 is replaced by contents of memory line 001101010111 = 855

Simulation Consider line size of 4 bytes No. of cache memory lines is 8 and No. of main memory lines is 24

Simulation Main Memory Line Tag Data 1 2 3 4 5 6 7 Cache Memory References: 2,7,15,22,17,16, 14,18,8,4,15,17 Main Memory Line Tag Data 1 2 3 4 5 6 7 Cache

Simulation 2 mod 8 =2 Main Memory Line Tag Data 1 2 98 3 4 5 6 7 Cache Memory References: 2,7,15,22,17,16, 14,18,8,4,15,17 Main Memory Line Tag Data 1 2 98 3 4 5 6 7 Cache 2 mod 8 =2 MISS !!!

Simulation 7 mod 8 =7 Main Memory Line Tag Data 1 2 98 3 4 5 6 7 1283 Memory References: 2,7,15,22,17,16, 14,18,8,4,15,17 Main Memory Line Tag Data 1 2 98 3 4 5 6 7 1283 Cache 7 mod 8 =7 MISS !!!

Simulation 15 mod 8 =7 Main Memory Line Tag Data 1 2 98 3 4 5 6 7 15 Memory References: 2,7,15,22,17,16, 14,18,8,4,15,17 Main Memory Line Tag Data 1 2 98 3 4 5 6 7 15 993 Cache 15 mod 8 =7 MISS !!!

Simulation 22 mod 8 =6 Main Memory Line Tag Data 1 2 98 3 4 5 6 22 Memory References: 2,7,15,22,17,16, 14,18,8,4,15,17 Main Memory Line Tag Data 1 2 98 3 4 5 6 22 1232 7 15 993 Cache 22 mod 8 =6 MISS !!!

Simulation 17 mod 8 =1 Main Memory Line Tag Data 1 17 12 2 98 3 4 5 6 Memory References: 2,7,15,22,17,16, 14,18,8,4,15,17 Main Memory Line Tag Data 1 17 12 2 98 3 4 5 6 22 1232 7 15 993 Cache 17 mod 8 =1 MISS !!!

Simulation 16 mod 8 =0 Main Memory Line Tag Data 16 982 1 17 12 2 98 3 Memory References: 2,7,15,22,17,16, 14,18,8,4,15,17 Main Memory Line Tag Data 16 982 1 17 12 2 98 3 4 5 6 22 1232 7 15 993 Cache 16 mod 8 =0 MISS !!!

Simulation 14mod 8 =6 Main Memory Line Tag Data 16 982 1 17 12 2 98 3 Memory References: 2,7,15,22,17,16, 14,18,8,4,15,17 Main Memory Line Tag Data 16 982 1 17 12 2 98 3 4 5 6 14 7 15 993 Cache 14mod 8 =6 MISS !!!

Simulation 18mod 8 =2 Main Memory Line Tag Data 16 982 1 17 12 2 18 Memory References: 2,7,15,22,17,16, 14,18,8,4,15,17 Main Memory Line Tag Data 16 982 1 17 12 2 18 1123 3 4 5 6 14 7 15 993 Cache 18mod 8 =2 MISS !!!

Simulation 8mod 8 =0 Main Memory Line Tag Data 8 1232 1 17 12 2 18 Memory References: 2,7,15,22,17,16, 14,18,8,4,15,17 Main Memory Line Tag Data 8 1232 1 17 12 2 18 1123 3 4 5 6 14 7 15 993 Cache 8mod 8 =0 MISS !!!

Simulation 4mod 8 =4 Main Memory Line Tag Data 8 1232 1 17 12 2 18 Memory References: 2,7,15,22,17,16, 14,18,8,4,15,17 Main Memory Line Tag Data 8 1232 1 17 12 2 18 1123 3 4 8172 5 6 14 7 15 993 Cache 4mod 8 =4 MISS !!!

Simulation 15mod 8 =7 Main Memory Line Tag Data 8 1232 1 17 12 2 18 Memory References: 2,7,15,22,17,16, 14,18,8,4,15,17 Main Memory Line Tag Data 8 1232 1 17 12 2 18 1123 3 4 8172 5 6 14 7 15 993 Cache 15mod 8 =7 HIT !!!

Simulation 17mod 8 =1 Main Memory Line Tag Data 8 1232 1 17 12 2 18 Memory References: 2,7,15,22,17,16, 14,18,8,4,15,17 Main Memory Line Tag Data 8 1232 1 17 12 2 18 1123 3 4 8172 5 6 14 7 15 993 Cache 17mod 8 =1 HIT !!!

Fully Associative Cache It allows main memory block to be placed anywhere in cache It uses larger tags and does not use index. Here the upper bits of incoming address is compared with every tag in cache. This require more extensive hardware But it is more flexible

Fully Associative Cache Suppose a cache has 27 = 128 lines, each with 16 bytes. Suppose the memory has a 16-bit address and hence (216 = 64KB) address space. Each memory address looks like:   Tag Word 12bits 4bits

Associative Cache Memory

Example Suppose we want to read or write a byte at the address 357A Tag = 855 Word = 10 Tag 855 has to be searched in entire cache and if found then data at 357A is in cache. Else, place contents of memory line 855 in the empty space in cache or apply LRU to replace.

Simulation Consider line size of 4 bytes No. of cache memory lines is 8 and No. of main memory lines is 24

Simulation Main Memory Line Tag Data 1 2 3 4 5 6 7 Cache Memory References: 2,7,15,22,17,16, 14,18,8,4,15,18 Main Memory Line Tag Data 1 2 3 4 5 6 7 Cache

Simulation Main Memory Line Tag Data 2 98 1 3 4 5 6 7 Cache MISS !!! Memory References: 2,7,15,22,17,16, 14,18,8,4,15,18 Main Memory Line Tag Data 2 98 1 3 4 5 6 7 Cache MISS !!!

Simulation Main Memory Line Tag Data 2 98 1 7 1283 3 4 5 6 Cache Memory References: 2,7,15,22,17,16, 14,18,8,4,15,18 Main Memory Line Tag Data 2 98 1 7 1283 3 4 5 6 Cache MISS !!!

Simulation Main Memory Line Tag Data 2 98 1 7 1283 15 993 3 4 5 6 Memory References: 2,7,15,22,17,16, 14,18,8,4,15,18 Main Memory Line Tag Data 2 98 1 7 1283 15 993 3 4 5 6 Cache MISS !!!

Simulation Main Memory Line Tag Data 2 98 1 7 1283 15 993 3 22 1232 4 Memory References: 2,7,15,22,17,16, 14,18,8,4,15,18 Main Memory Line Tag Data 2 98 1 7 1283 15 993 3 22 1232 4 5 6 Cache MISS !!!

Simulation Main Memory Line Tag Data 2 98 1 7 1283 15 993 3 22 1232 4 Memory References: 2,7,15,22,17,16, 14,18,8,4,15,18 Main Memory Line Tag Data 2 98 1 7 1283 15 993 3 22 1232 4 17 12 5 6 Cache MISS !!!

Simulation Main Memory Line Tag Data 2 98 1 7 1283 15 993 3 22 1232 4 Memory References: 2,7,15,22,17,16, 14,18,8,4,15,18 Main Memory Line Tag Data 2 98 1 7 1283 15 993 3 22 1232 4 17 12 5 16 982 6 Cache MISS !!!

Simulation Main Memory Line Tag Data 2 98 1 7 1283 15 993 3 22 1232 4 Memory References: 2,7,15,22,17,16, 14,18,8,4,15,18 Main Memory Line Tag Data 2 98 1 7 1283 15 993 3 22 1232 4 17 12 5 16 982 6 14 Cache MISS !!!

Simulation Main Memory Line Tag Data 2 98 1 7 1283 15 993 3 22 1232 4 Memory References: 2,7,15,22,17,16, 14,18,8,4,15,18 Main Memory Line Tag Data 2 98 1 7 1283 15 993 3 22 1232 4 17 12 5 16 982 6 14 18 1123 Cache MISS !!!

Simulation Main Memory Line Tag Data 8 1232 1 7 1283 2 15 993 3 22 4 Memory References: 2,7,15,22,17,16, 14,18,8,4,15,18 Main Memory Line Tag Data 8 1232 1 7 1283 2 15 993 3 22 4 17 12 5 16 982 6 14 18 1123 Cache MISS !!!

Simulation Main Memory Line Tag Data 8 1232 1 4 8172 2 15 993 3 22 17 Memory References: 2,7,15,22,17,16, 14,18,8,4,15,18 Main Memory Line Tag Data 8 1232 1 4 8172 2 15 993 3 22 17 12 5 16 982 6 14 7 18 1123 Cache MISS !!!

Simulation Main Memory Line Tag Data 8 1232 1 4 8172 2 15 993 3 22 17 Memory References: 2,7,15,22,17,16, 14,18,8,4,15,18 Main Memory Line Tag Data 8 1232 1 4 8172 2 15 993 3 22 17 12 5 16 982 6 14 7 18 1123 Cache HIT !!!