Docsity

Memory Hierarchy and Cache Systems: Understanding the Basics, Slides of Computer Science

Partial preview of the text

Download Memory Hierarchy and Cache Systems: Understanding the Basics and more Slides Computer Science in PDF only on Docsity!

Memory Subsystem and Cache

The Big Picture

Control

Datapath

Memory

Processor Input

Output

Technology Trends [contd…]

μProc 60%/yr. (2X/1.5yr)

DRAM 9%/yr. (^1) (2X/10 yrs)

19801981198319841985198619871988198919901991199219931994199519961997199819992000

DRAM

CPU

1982

Processor-Memory Performance Gap: (grows 50% / year)

Time

“Moore’s Law”

Processor-DRAM Memory Gap (latency)

“Less’ Law?”

The Goal: Large, Fast, Cheap

Memory !!!

  • Fact
    • Large memories are slow
    • Fast memories are small
  • How do we create a memory that is large,

cheap and fast (most of the time)?

  • Hierarchy
  • Parallelism

Today’s Situation

  • Rely on caches to bridge gap
  • Microprocessor-DRAM performance gap
  • time of a full cache miss in instructions executed

1st Alpha (7000): 340 ns/5.0 ns = 68 clks x 2 or 136 instructions 2nd Alpha (8400): 266 ns/3.3 ns = 80 clks x 4 or 320 instructions

Memory Hierarchy (1/4)

  • Processor
    • executes programs
    • runs on order of nanoseconds to picoseconds
    • needs to access code and data for programs: where are these?
  • Disk
    • HUGE capacity (virtually limitless)
    • VERY slow: runs on order of milliseconds
    • so how do we account for this gap?

Memory Hierarchy (3/4)

Processor

Size of memory at each level

Increasing

Distance

from Proc.,

Decreasing

cost / MB

Level 1 Level 2

Level n

Level 3

...

Higher

Lower

Levels in

memory

hierarchy

Memory Hierarchy (4/4)

  • If level is closer to Processor, it must be:
    • smaller
    • faster
    • subset of all higher levels (contains most recently used data)
    • contain at least all the data in all lower levels
  • Lowest Level (usually disk) contains all

available data

Analogy : Library [contd…]

  • Open books on table are cache
    • smaller capacity: can have very few open books fit on table; again, when table fills up, you must close a book
    • much, much faster to retrieve data
  • Illusion created: whole library open on the

tabletop

  • Keep as many recently used books open on table as possible since likely to use again
  • Also keep as many books on table as possible, since faster than going to library Docsity.com

Memory Hierarchy Basics

  • Disk contains everything.
  • When Processor needs something, bring it

into to all lower levels of memory.

  • Cache contains copies of data in memory

that are being used.

  • Memory contains copies of data on disk that

are being used.

  • Entire idea is based on Temporal Locality: if

we use it now, we’ll want to use it again

soon (a Big Idea)

Cache Design Issues

  • How do we organize cache?
  • Where does each memory address map to?

(Remember that cache is subset of memory,

so multiple memory addresses map to the

same cache location.)

  • How do we know which elements are in

cache?

  • How do we quickly locate them?

Direct Mapped Cache

  • In a direct-mapped cache, each memory

address is associated with one possible block

within the cache

  • Therefore, we only need to look in a single location in the cache for the data if it exists in the cache
  • Block is the unit of transfer between cache and memory

Issues with Direct Mapped Cache

  • Since multiple memory addresses map to

same cache index, how do we tell which one

is in there?

  • What if we have a block size > 1 byte?
  • Result: divide memory address into three

fields

ttttttttttttttttt iiiiiiiiii oooo

tag to check if you index to byte have correct block select block offset

Example of a direct mapped cache

  • For a 2^N byte cache:
    • The uppermost (32 - N) bits are always the Cache Tag
    • The lowest M bits are the Byte Select (Block Size = 2^M)

Cache Index

0 1 2 3 :

Cache Data Byte 0

31 4 0

:

Cache Tag Example: 0x Ex: 0x

0x

Stored as part of the cache “state” Valid Bit

: 31

Byte 31^ : Byte 1 Byte 63^ : Byte 33 Byte 32

Byte 1023^ : Byte 992

Cache Tag

Byte Select Ex: 0x

9

Block address