+ Random-Access Memory (RAM)

Similar documents
Read-only memory (ROM): programmed during production Programmable ROM (PROM): can be programmed once SRAM (Static RAM)

Foundations of Computer Systems

The Memory Hierarchy /18-213/15-513: Introduction to Computer Systems 11 th Lecture, October 3, Today s Instructor: Phil Gibbons

Locality. CS429: Computer Organization and Architecture. Locality Example 2. Locality Example

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 26, SPRING 2013

Random Access Memory (RAM)

Computer Systems. Memory Hierarchy. Han, Hwansoo

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 26, FALL 2012

The Memory Hierarchy Sept 29, 2006

Giving credit where credit is due

CISC 360. The Memory Hierarchy Nov 13, 2008

Today. The Memory Hierarchy. Random-Access Memory (RAM) Nonvolatile Memories. Traditional Bus Structure Connecting CPU and Memory

Random-Access Memory (RAM) Lecture 13 The Memory Hierarchy. Conventional DRAM Organization. SRAM vs DRAM Summary. Topics. d x w DRAM: Key features

Lecture 15: Caches and Optimization Computer Architecture and Systems Programming ( )

Problem: Processor- Memory Bo<leneck

CS3350B Computer Architecture

Key features. ! RAM is packaged as a chip.! Basic storage unit is a cell (one bit per cell).! Multiple RAM chips form a memory.

The Memory Hierarchy / : Introduction to Computer Systems 10 th Lecture, Feb 12, 2015

CS 153 Design of Operating Systems

Computer Organization: A Programmer's Perspective

Systems Programming and Computer Architecture ( ) Timothy Roscoe

NEXT SET OF SLIDES FROM DENNIS FREY S FALL 2011 CMSC313.

Random-Access Memory (RAM) CISC 360. The Memory Hierarchy Nov 24, Conventional DRAM Organization. SRAM vs DRAM Summary.

Roadmap. Java: Assembly language: OS: Machine code: Computer system:

Today. The Memory Hierarchy. Byte Oriented Memory Organization. Simple Memory Addressing Modes

Random-Access Memory (RAM) Systemprogrammering 2007 Föreläsning 4 Virtual Memory. Locality. The CPU-Memory Gap. Topics

Random-Access Memory (RAM) Systemprogrammering 2009 Föreläsning 4 Virtual Memory. Locality. The CPU-Memory Gap. Topics! The memory hierarchy

CMPSC 311- Introduction to Systems Programming Module: Caching

CS 33. Memory Hierarchy I. CS33 Intro to Computer Systems XVI 1 Copyright 2016 Thomas W. Doeppner. All rights reserved.

Memory Hierarchy. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Storage Technologies and the Memory Hierarchy

CS 240 Stage 3 Abstractions for Practical Systems

The Memory Hierarchy. Computer Organization 2/12/2015. CSC252 - Spring Memory. Conventional DRAM Organization. Reading DRAM Supercell (2,1)

Denison University. Cache Memories. CS-281: Introduction to Computer Systems. Instructor: Thomas C. Bressoud

F28HS Hardware-Software Interface: Systems Programming

CS 33. Architecture and Optimization (3) CS33 Intro to Computer Systems XVI 1 Copyright 2018 Thomas W. Doeppner. All rights reserved.

CMPSC 311- Introduction to Systems Programming Module: Caching

The Memory Hierarchy 10/25/16

CSCI-UA.0201 Computer Systems Organization Memory Hierarchy

General Cache Mechanics. Memory Hierarchy: Cache. Cache Hit. Cache Miss CPU. Cache. Memory CPU CPU. Cache. Cache. Memory. Memory

Problem: Processor Memory BoJleneck

Announcements. Outline

The. Memory Hierarchy. Chapter 6

CS 201 The Memory Hierarchy. Gerson Robboy Portland State University

CS429: Computer Organization and Architecture

CS241 Computer Organization Spring Principle of Locality

CS429: Computer Organization and Architecture

Caches II CSE 351 Spring #include <yoda.h> int is_try(int do_flag) { return!(do_flag!do_flag); }

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2014 Lecture 14

CS 31: Intro to Systems Storage and Memory. Kevin Webb Swarthmore College March 17, 2015

Memory Management. Goals of this Lecture. Motivation for Memory Hierarchy

211: Computer Architecture Summer 2016

Large and Fast: Exploiting Memory Hierarchy

How to Write Fast Numerical Code

Caches Spring 2016 May 4: Caches 1

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

Computer Organization and Assembly Language (CS-506)

Memory Management! Goals of this Lecture!

Memory Hierarchy. Announcement. Computer system model. Reference

Memory Management! How the hardware and OS give application pgms:" The illusion of a large contiguous address space" Protection against each other"

Computer Systems CSE 410 Autumn Memory Organiza:on and Caches

Giving credit where credit is due

CS 261 Fall Mike Lam, Professor. Memory

Memory hierarchies: caches and their impact on the running time

CS 153 Design of Operating Systems

Computer Architecture and System Software Lecture 09: Memory Hierarchy. Instructor: Rob Bergen Applied Computer Science University of Winnipeg

CS356: Discussion #9 Memory Hierarchy and Caches. Marco Paolieri Illustrations from CS:APP3e textbook

211: Computer Architecture Summer 2016

Contents. Memory System Overview Cache Memory. Internal Memory. Virtual Memory. Memory Hierarchy. Registers In CPU Internal or Main memory

How to Write Fast Numerical Code

Random-Access Memory (RAM) CS429: Computer Organization and Architecture. SRAM and DRAM. Flash / RAM Summary. Storage Technologies

Chapter 6 Caches. Computer System. Alpha Chip Photo. Topics. Memory Hierarchy Locality of Reference SRAM Caches Direct Mapped Associative

Roadmap. Java: Assembly language: OS: Machine code: Computer system:

Caches Concepts Review

CS 261 Fall Mike Lam, Professor. Memory

Donn Morrison Department of Computer Science. TDT4255 Memory hierarchies

Computer Architecture and System Software Lecture 08: Assembly Language Programming + Memory Hierarchy

Carnegie Mellon. Carnegie Mellon

Memory Hierarchy. Instructor: Adam C. Champion, Ph.D. CSE 2431: Introduction to Operating Systems Reading: Chap. 6, [CSAPP]

Caches II. CSE 351 Autumn Instructor: Justin Hsia

Module 1: Basics and Background Lecture 4: Memory and Disk Accesses. The Lecture Contains: Memory organisation. Memory hierarchy. Disks.

Lecture 18: Memory Systems. Spring 2018 Jason Tang

Cache Memories. From Bryant and O Hallaron, Computer Systems. A Programmer s Perspective. Chapter 6.

Cache Memories /18-213/15-513: Introduction to Computer Systems 12 th Lecture, October 5, Today s Instructor: Phil Gibbons

Page 1. Multilevel Memories (Improving performance using a little cash )

Caches. Hiding Memory Access Times

UNIT-V MEMORY ORGANIZATION

Computer Systems C S Cynthia Lee Today s materials adapted from Kevin Webb at Swarthmore College

Chapter 6 Objectives

Lecture 12. Memory Design & Caches, part 2. Christos Kozyrakis Stanford University

CS 31: Intro to Systems Caching. Kevin Webb Swarthmore College March 24, 2015

Course Administration

CS 61C: Great Ideas in Computer Architecture. Direct Mapped Caches

Module 5a: Introduction To Memory System (MAIN MEMORY)

CSF Cache Introduction. [Adapted from Computer Organization and Design, Patterson & Hennessy, 2005]

CHAPTER 6 Memory. CMPS375 Class Notes Page 1/ 16 by Kuo-pao Yang

A Computer. Computer organization - Recap. The Memory Hierarchy... Brief Overview of Memory Design. CPU has two components: Memory

Algorithm Performance Factors. Memory Performance of Algorithms. Processor-Memory Performance Gap. Moore s Law. Program Model of Memory I

Grundlagen Microcontroller Memory. Günther Gridling Bettina Weiss

ECE232: Hardware Organization and Design

Transcription:

+ Memory Subsystem

+ Random-Access Memory (RAM) Key features RAM is traditionally packaged as a chip. Basic storage unit is normally a cell (one bit per cell). Multiple RAM chips form a memory. RAM comes in two varieties: SRAM (Static RAM) DRAM (Dynamic RAM)

+ SRAM vs DRAM Summary Trans. Access Needs Needs per bit time refresh? EDC? Cost Applications SRAM 4 or 6 1X No Maybe 100x Cache memories DRAM 1 10X Yes Yes 1X Main memories, frame buffers

+ Nonvolatile Memories DRAM and SRAM are volatile memories Lose information if powered off. Nonvolatile memories retain value even if powered off Read-only memory (ROM): programmed during production Programmable ROM (PROM): can be programmed once Eraseable PROM (EPROM): can be bulk erased (UV, X-Ray) Electrically eraseable PROM (EEPROM): electronic erase capability Flash memory: EEPROMs with partial erase capability Uses for Nonvolatile Memories Firmware programs stored in a ROM (BIOS, controllers for disks, network cards, graphics accelerators, security subsystems, ) Solid state disks aka SSD (replace rotating disks in thumb drives, smart phones, mp3 players, tablets, laptops, )

+ Traditional Bus Structure A bus is a collection of parallel wires that carry address, data, and control signals. Buses are typically shared by multiple devices. CPU chip Register file ALU System bus Memory bus Bus interface I/O bridge Main memory

+ Memory Read Transaction (1) CPU places address A on the memory bus. Register file Load operation: movq A, %rax %rax ALU Bus interface I/O bridge A Main memory 0 x A

+ Memory Read Transaction (2) Main memory reads A from the memory bus, retrieves word x, and places it on the bus. Register file Load operation: movq A, %rax %rax ALU Bus interface I/O bridge A Main memory 0 x A

+ Memory Read Transaction (3) CPU read word x from the bus and copies it into register %rax. Register file Load operation: movq A, %rax %rax x ALU I/O bridge Main memory 0 Bus interface x A

+ Memory Write Transaction (1) CPU places address A on bus. Main memory reads it and waits for the corresponding data word to arrive. Register file Store operation: movq %rax, A %rax y ALU Bus interface I/O bridge A Main memory 0 A

+ Memory Write Transaction (2) CPU places data word y on the bus. Register file Store operation: movq %rax, A %rax y ALU Bus interface I/O bridge y Main memory 0 A

+ Memory Write Transaction (3) Main memory reads data word y from the bus and stores it at address A. Register file Store operation: movq %rax, A %rax y ALU I/O bridge main memory 0 Bus interface y A

+ The CPU-Memory Gap The gap widens between DRAM, disk, and CPU speeds. 100,000,000.0 10,000,000.0 Disk 1,000,000.0 100,000.0 SSD Time (ns) 10,000.0 1,000.0 100.0 10.0 1.0 0.1 DRAM SRAM CPU Disk seek time SSD access time DRAM access time SRAM access time CPU cycle time Effective CPU cycle time 0.0 1985 1990 1995 2000 2003 2005 2010 2015 Year

+ Locality

+ Locality Principle of Locality: Programs tend to use data and instructions with addresses near or equal to those they have used recently Temporal locality: Recently referenced items are likely to be referenced again in the near future Spatial locality: Items with nearby addresses tend to be referenced close together in time

+ Locality Example sum = 0; for (i = 0; i < n; i++) sum += a[i]; return sum; Data references Reference array elements in succession (stride-1 reference pattern). Reference variable sum each iteration. Instruction references Reference instructions in sequence. Cycle through loop repeatedly.

+ Locality Example sum = 0; for (i = 0; i < n; i++) sum += a[i]; return sum; Data references Reference array elements in succession (stride-1 reference pattern). Reference variable sum each iteration. Spatial locality Instruction references Reference instructions in sequence. Cycle through loop repeatedly.

+ Locality Example sum = 0; for (i = 0; i < n; i++) sum += a[i]; return sum; Data references Reference array elements in succession (stride-1 reference pattern). Reference variable sum each iteration. Instruction references Spatial locality Temporal locality Reference instructions in sequence. Cycle through loop repeatedly.

+ Locality Example sum = 0; for (i = 0; i < n; i++) sum += a[i]; return sum; Data references Reference array elements in succession (stride-1 reference pattern). Reference variable sum each iteration. Instruction references Reference instructions in sequence. Cycle through loop repeatedly. Spatial locality Temporal locality Spatial locality

+ Locality Example sum = 0; for (i = 0; i < n; i++) sum += a[i]; return sum; Data references Reference array elements in succession (stride-1 reference pattern). Reference variable sum each iteration. Instruction references Reference instructions in sequence. Cycle through loop repeatedly. Spatial locality Temporal locality Spatial locality Temporal locality

+ Locality Example #1 Question: Does this function have good locality with respect to array a? int sum_array_rows(int a[m][n]) { int i, j, sum = 0; for (i = 0; i < M; i++) for (j = 0; j < N; j++) sum += a[i][j]; } return sum;

+ Locality Example #2 Question: Does this function have good locality with respect to array a? int sum_array_cols(int a[m][n]) { int i, j, sum = 0; for (j = 0; j < N; j++) for (i = 0; i < M; i++) sum += a[i][j]; } return sum;

+ Locality Example #3 Question: Can you permute the loop indices so that the function scans the 3D array a with a stride-1 reference pattern (and thus has good spatial locality)? int sum_array_3d(int a[m][n][n]) { int i, j, k, sum = 0; for (i = 0; i < M; i++) for (j = 0; j < N; j++) for (k = 0; k < N; k++) sum += a[k][i][j]; } return sum;

+ Memory Hierarchies Some fundamental and enduring properties of hardware and software: Fast storage technologies cost more per byte, have less capacity, and require more power (heat!). The gap between CPU and main memory speed is widening. Well-written programs tend to exhibit good locality. These fundamental properties lead to an approach for organizing memory and storage systems known as a memory hierarchy.

+ Memory Hierarchy & Caches

+ Smaller, faster, and costlier (per byte) storage devices L3: L2: L1: L0: Regs L1 cache (SRAM) L2 cache (SRAM) L3 cache (SRAM) CPU registers hold words retrieved from the L1 cache. L1 cache holds cache lines retrieved from the L2 cache. L2 cache holds cache lines retrieved from L3 cache L3 cache holds cache lines retrieved from main memory. Larger, slower, and cheaper (per byte) storage devices L5: L4: Main memory (DRAM) Local secondary storage (local disks) Main memory holds disk blocks retrieved from local disks. Local disks hold files retrieved from disks on remote servers L6: Remote secondary storage (e.g., Web servers)

+ Caches Cache: A smaller, faster storage device that acts as a staging area for a subset of the data in a larger, slower device. Fundamental idea of a memory hierarchy: For each k, the faster, smaller device at level k serves as a cache for the larger, slower device at level k+1. Why do memory hierarchies work? Because of locality, programs tend to access the data at level k more often than they access the data at level k+1. Thus, the storage at level k+1 can be slower, and larger and cheaper per bit. Big Idea: The memory hierarchy creates a large pool of storage that costs as much as the cheap storage near the bottom, but that serves data to programs at the rate of the fast storage near the top.

+ Cache Analogy: Hangry! Option 1: Go to refrigerate Found -> Eat Latency: 1 minute Option 2: Go to deli Found -> Purchase, take home, eat. Latency: 20 minutes Option 3: Grow food Plant, wait. harvest, eat Latency: ~250k minutes (~6 months)

+ General Cache Concepts Cache 84 9 14 10 3 Smaller, faster, more expensive memory caches a subset of the blocks 10 4 Data is copied in block-sized transfer units Memory 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Larger, slower, cheaper memory viewed as partitioned into blocks

+ General Cache Concepts: Hit Cache Request: 14 8 9 14 3 Data in block b is needed Block b is in cache: Hit! Memory 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

+ General Cache Concepts: Miss Cache Request: 12 8 12 9 14 3 Data in block b is needed Block b is not in cache: Miss! 12 Request: 12 Block b is fetched from memory Memory 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Block b is stored in cache Placement policy: determines where b goes Replacement policy: determines which block gets evicted (victim)

+ General Caching Concepts: Cache Miss Types Cold (compulsory) miss Cold misses occur because the cache is empty. Capacity miss When the set of active cache blocks (working set) is larger than the cache. Conflict miss Most caches limit blocks at level k+1 to a small subset of the block positions at level k. E.g. Given our example from previous slides, block i at level k+1 must be placed in block (i mod 4) at level k. Conflict misses occur when the level k cache is large enough, but multiple data objects all map to the same level k block. E.g. Given our example from previous slides, referencing blocks 0, 4, 0, 4, 0, 4,... would miss every time.

+ Examples of Caching in the Mem. Hierarchy Cache Type Registers L1 cache L2 cache Buffer cache Network buffer cache Browser cache What is Cached? 8 bytes words 64-byte blocks 64-byte blocks Parts of files Parts of files Web pages Where is it Cached? CPU core On-Chip L1 On-Chip L2 Main memory Local disk Local disk Latency (cycles) Disk cache Disk sectors Disk controller 100,000 Disk 0 4 10 100 10,000,000 10,000,000 Managed By Compiler Hardware Hardware OS NFS client Web browser Web cache Web pages Remote server 1,000,000,000 Web proxy server

+ Summary The speed gap between CPU, memory and mass storage continues to widen. Well-written programs exhibit a property called locality. Memory hierarchies based on caching close the gap by exploiting locality. Caches are used everywhere in modern systems.