Docsity

Memory Hierarchy and Technologies: Locality and SRAM vs. DRAM, Slides of Computer Science

Partial preview of the text

Download Memory Hierarchy and Technologies: Locality and SRAM vs. DRAM and more Slides Computer Science in PDF only on Docsity!

CS 152: Computer Architecture

and Engineering

Lecture 19

Locality and Memory Technologies

 The Five Classic Components of a Computer

 Today’s Topics:

  • Recap last lecture
  • Locality and Memory Hierarchy
  • Administrivia
  • SRAM Memory Technology
  • DRAM Memory Technology
  • Memory Organization

The Big Picture: Where are We Now?

Control

Datapath

Memory

Processor Input

Output

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

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

19801981198319841985198619871988198919901991199219931994199519961997199819992000

DRAM

CPU

1982

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

Performance

Time

“Moore’s Law”

Processor-DRAM Memory Gap (latency)

Who Cares About the Memory Hierarchy?

“Less’ Law?”

The Goal: Illusion of 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

Memory Hierarchy: Why Does it Work? Locality!

 Temporal Locality (Locality in Time):

=> Keep most recently accessed data items closer to the processor

 Spatial Locality (Locality in Space):

=> Move blocks consists of contiguous words to the upper levels

Lower Level Upper Level Memory Memory

To Processor

From Processor

Blk X Blk Y

(^0) Address Space 2^n - 1

Probability of reference

 Two issues:

  • How do we know if a data item is in the cache?
  • If it is, how do we find it?

 Our first example:

  • block size is one word of data
  • "direct mapped"

For each item of data at the lower level, there is exactly one location in the cache where it might be.

e.g., lots of items at the lower level share locations in the upper level

Cache

 For MIPS:

What kind of locality are we taking advantage of?

Direct Mapped Cache Address (showing bit positions)

20 10

offsetByte

Index Valid Tag Data 0 1 2

1021 1022 1023

Tag Index

Hit Data

(^20 )

31 30 13 12 11 2 1 0

 Taking advantage of spatial locality:

Direct Mapped Cache

Address (showing bit positions)

16 12 Byte offset

V Tag Data

Hit Data

(^16 )

4K entries

16 bits 128 bits

Mux

32 32 32

2

32

Index Block offset

Tag

31 16 15 4 3 2 1 0

 Read hits

  • this is what we want!

 Read misses

  • stall the CPU, fetch block from memory, deliver to cache, restart

 Write hits:

  • can replace data in cache and memory (write-through)
  • write the data only into the cache (write-back the cache later)

 Write misses:

  • read the entire block into the cache, then write the word

Hits vs. Misses

 Read:

  1. Send the address to the appropriate cache from PC  instruction cache from ALU  data cache
  2. Hit: the required word is available on the data lines

Miss: send send full address to the main memory, when the memory returns with the data, we write it into the cache

 Write:

  1. Index the cache using bits 15~2 of the address.
  2. write both the tag portion and the data portion with word
  3. also write the word to main memory using the entire address

Hits vs. Misses (Write through)

Memory Hierarchy: Terminology

 Hit: data appears in some block in the upper level (example: Block X)

  • Hit Rate: the fraction of memory access found in the upper level
  • Hit Time: Time to access the upper level which consists of RAM access time + Time to determine hit/miss

 Miss: data needs to be retrieve from a block in the lower level (Block Y)

  • Miss Rate = 1 - (Hit Rate)
  • Miss Penalty: Time to replace a block in the upper level + Time to deliver the block the processor

 Hit Time << Miss Penalty Lower Level Upper Level Memory Memory

To Processor

From Processor

Blk X Blk Y

Recap: Cache Performance

 CPU time = (CPU execution clock cycles + Memory stall clock cycles) x clock cycle time

 Memory stall clock cycles = (Reads x Read miss rate x Read miss penalty + Writes x Write miss rate x Write miss penalty)

 Memory stall clock cycles = Memory accesses x Miss rate x Miss penalty

 Different measure: AMAT

Average Memory Access time (AMAT) = Hit Time + (Miss Rate x Miss Penalty)

 Note: memory hit time is included in execution cycles.

How is the Hierarchy Managed?

 Registers <-> Memory

  • by compiler (programmer?)

 cache <-> memory

  • by the hardware

 memory <-> disks

  • by the hardware and operating system (virtual memory)
  • by the programmer (files)

Memory Hierarchy Technology

 Random Access:

  • “Random” is good: access time is the same for all locations
  • DRAM: Dynamic Random Access Memory
    • High density, low power, cheap, slow
    • Dynamic: need to be “refreshed” regularly
  • SRAM: Static Random Access Memory
    • Low density, high power, expensive, fast
    • Static: content will last “forever”(until lose power)

 “Non-so-random” Access Technology:

  • Access time varies from location to location and from time to time
  • Examples: Disk, CDROM, DRAM page-mode access

 Sequential Access Technology: access time linear in

location (e.g.,Tape)

 Next two lectures will concentrate on random access

technology

  • The Main Memory: DRAMs + Caches: SRAMs