Docsity

Basic Components: The Memory - Lecture Slides | CSE 141, Study notes of Computer Architecture and Organization

Toggle sidebar
bg1
Page 1
Chien CSE141 1 November 19, 2002
Memory Hierarchies
Last Time
– Advanced Pipelining
• Superpipelining, Superscalar, VLIW, Dynamic Pipelining
This Time
– Quiz #7
– Memory Hierarchies and Locality
• why do they work? How do they work?
– Cache basics
Reminders/Announcements
– Read Chapter 7
– Midterm Solutions on the web
– Homework #4, Due Thursday, November 21 in lecture
– Lab #3, Due Wednesday, November 20
– Lab #4 on the web, due Friday, December 6
Chien CSE141 2 November 19, 2002
Basic Components: the Memory
Computer
Memory
Datapath
Control
Output
Input
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Basic Components: The Memory - Lecture Slides | CSE 141 and more Study notes Computer Architecture and Organization in PDF only on Docsity!

Chien CSE141 1 November 19, 2002

Memory Hierarchies

„ Last Time

  • Advanced Pipelining
    • Superpipelining, Superscalar, VLIW, Dynamic Pipelining

„ This Time

  • Quiz #
  • Memory Hierarchies and Locality
    • why do they work? How do they work?
  • Cache basics

„ Reminders/Announcements

  • Read Chapter 7
  • Midterm Solutions on the web
  • Homework #4, Due Thursday, November 21 in lecture
  • Lab #3, Due Wednesday, November 20
  • Lab #4 on the web, due Friday, December 6

Chien CSE141 2 November 19, 2002

Basic Components: the Memory

Computer

Memory

Datapath

Control

Output

Input

Chien CSE141 3 November 19, 2002

Component Speeds

„ Processor Speeds

  • Intel Pentium IV : 2,800 Mhz = 0.4ns
  • HP/Compaq Alpha 21364: 1,000 Mhz = 1ns
  • Others?

„ Memory Speeds

  • Mac/PC/Workstation DRAM: 50 ns
  • Disks are even slower....

„ How can we span this “access time” gap?

  • 1 instruction fetch per instruction
  • 15/100 instructions also do a data read or write (load or

store)

Chien CSE141 4 November 19, 2002

Locality

„ Property of memory references in “typical programs”

„ Tendency to favor a portion of their address space at any given

time

„ A key element in computer organization for high performance

Processor

For some period, most of the references are in the shaded regions

Chien CSE141 7 November 19, 2002

Temporal Locality (in time)

„ Program Reference Stream (instruction and data) 110 264 111 112 272 113

110 264 111 112 292 113

reuse t

Sources of temporal locality

Instruction fetch (loops)

Locals (loops, repeated invocations)

Data Structures

xxx Instruction fetches (IF) xxx Data Memory Access

Chien CSE141 8 November 19, 2002

Spatial Locality (in space)

„ Sources of spatial

locality

  • Instruction sequence
  • Indexing Arrays
  • Locals in a stack frame
  • Contiguous allocation

xxx Instruction fetch xxx Data memory access

Chien CSE141 9 November 19, 2002

Importance of Locality

„ Why does locality matter?

  • An opportunity for the computer designer.... make the

computer cheaper, faster, etc.

Processor

Memory

  • process needs 256MB
  • processor can run at 1,000MHz
  • 1ns memory?
    • expense
    • feasibility

What does locality buy us?

Chien CSE141 10 November 19, 2002

Memory Locality

„ Memory hierarchies take advantage of memory

locality.

„ Memory locality is the principle that future memory

accesses are near past accesses.

„ Memories take advantage of two types of locality

  • Temporal locality -- near in time => we will often access

the same data again very soon

  • Spatial locality -- near in space/distance => our next access

is often very close to our last access (or recent accesses).

Chien CSE141 13 November 19, 2002

How to exploit locality?

Registers

Caches; what we’ll talk about.

Q: How do we use a memory hierarchy to exploit locality?

P Fast Mem Slow Mem

put things likely to use here

remainder of things here How do we decide?

**- explicit control

  • implicit control**

Chien CSE141 14 November 19, 2002

Caches: The Idea

„ Processor accesses “Memory hierarchy”

„ Accesses first check small, fast “cache”

„ If “miss” in cache, retrieve data from main memory

„ Cache exploits locality to provide high performance

P (^) Cache

Main Memory

Chien CSE141 15 November 19, 2002

Implicit Control

„ Hardware controlled (or OS) data movement

„ Generic Memory/Address operation interface

„ Examples:

  • Caches -- implicitly managed memory hierarchies
  • design HW to exploit locality
  • fast, concurrent movement
  • no need for addressing changes
  • “performance visible only!”

lw $s1, F0($s0) sw $s2, 6F($s3)

interface view

physical org.

Chien CSE141 16 November 19, 2002

Amortized Access Cost (Average)

„ Measure set of access costs

„ Weight by frequency

P Fast Mem

Slow Mem

Latency 1 cycle 10 cycles

Assumptions:

  • 90% accesses to 10% of addresses
  • magic 10% in fast memory
  • remainder in slow memory

Avg.

Access =

Cost

= (frac. of fast mem refs) * (fast mem access cost) + (frac. of slow mem refs) * (slow mem access cost)

Chien CSE141 19 November 19, 2002

Cache Design Issues

„ Data is copied into the cache.

„ Where to put the data? (which location)

„ Which data to replace? (later)

Main Memory

Cache

Chien CSE141 20 November 19, 2002

Cache Organization (Basic)

„ Map each region of address space to a single

cache location

  • Direct Mapped Cache
  • Mapping: Discard some address bits
  • Discard lowest (shown above)
  • Discard highest is more typical (interleaved)

Main Memory Cache

Chien CSE141 21 November 19, 2002

Finding Cache Data

„ For fast access, must be able to find data quickly

„ Lookup: discard a few address bits, access the fast

memory

„ Tags indicate the data that’s really there

„ Why does this work?

  • Memory location + tag -> complete address

Access + Lookup:

Memory Address

Cache Index

Cache Tag

Cache

Data Tags

Chien CSE141 22 November 19, 2002

Cache Access

„ Part of Memory Address applied to cache

„ Tags checked against remaining address bits

„ If match -> Hit!, use data

„ No match -> Miss, retrieve data from memory

„ This works pretty well... but there are some

complications...

Data Tags

Memory address lines

= Hit?