Вы находитесь на странице: 1из 34

UNIVERSIDAD NACIONAL MAYOR DE SAN MARCOS

FACULTAD DE INGENIERA DE SISTEMAS E INFORMATICA

Decana de America

SISTEMAS DIGITALES Mg. JUAN CARLOS GONZALES SUAREZ 2013-I

Principios Generales de las Memorias


Localidad Temporal: Datos recientes => Memorias Rpidas Espacial : Datos recientes => Memorias mas cercanas
Definiciones Bloque Block address Acierto (Hit) Tiempo de Acierto (Hit time) Razon de No acierto (Miss rate) Localidad + HW pequeo-mas rpido = Jerarqua de Memoria Niveles: < tamao, > rapidez, > costo/byte que nivel bajo Inclusive: Datos se ubican en nivel alto como en bajo
Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Tecnologa de Memoria
Memoria
SRAM DRAM Magnetic disk
CPU

Tiempo de acceso (ns)


0.22 2040 2,000,00010,000,000

$ per GB
$400$1,000 $20$40 $0.08$0.1

Processor

Level 1

Niveles en la Jerarqua de Memoria

Level 2

Incremento de tiempo de acceso desde cpu

Data are transferred

Level n

Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Jerarquia de Memoria
Referencias
CPU L1 cache L2 cache 1 cycle ~1-5 cycles ~5-20 cycles ~40-80 cycles

Main memory
Clave de Estrategia de performance:

Desplazar datos e instrucciones lo mas cerca posible del uP.


Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Memoria Cache
Son de tamao pequeo, Basadas en Fast SRAM, Buffer entre CPU y Memoria principal (Niveles) Utilizan los principios de Localidad Son administradas por controladores Basadas en accesos por bloques
CPU chip register file L1 cache cache bus ALU system bus memory bus I/O bridge main memory

L2 cache

bus interface

Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Colocando una Cache L1 entre CPU and Memoria principal


Unidad de Transferencia entre registros de CPU y cache is Bloque de 4-bytes. Unidad de Transferencia entre Cache y RAM es Bloque de 4 palabras (16 bytes). Registros de CPU Palabra de 4-bytes

line 0 line 1

Cache L1 para dos bloques de 4-palabras.

block 10

abcd

...
block 21

pqrs

...
block 30 wxyz

RAM tiene muchos bloques de 4 palabras .

...

Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Organiz. General una memoria Cache


Cache es un arreglo de conjuntos(Conj.). Cada conjunto tiene una o mas lineas. Cada linea contine un bloque de datos. 1 valid bit t tag bits por linea por linea B = 2b bytes por boque de cache

valid
Conj. 0: valid

tag
tag

0
0

1
1

B1
B1 B1 B1 E lineas por Conj.

valid Conj. 1: S = 2s Conj. valid

tag tag

1 1

0 valid tag tag 0 valid 0 1 B1 1 B1

Conj. S-1:

Tamao Cache : C = B x E x S bytes de dato

Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Direccionando Cache
Address A: t bits
v Conj. 0: v v Conj. 1: v tag tag tag tag 0 0 0 0 v tag 0 0 1 B1 1 1 1 1 B1 B1 B1 B1
m-1

s bits

b bits
0

<tag> <set index> <block offset>

Conj. S-1: v tag

B1

El dato est en la cache si el tag de una lnea vlida en ese conjunto coincide con el tag de la direccin solicitada

Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Cache de Mapeo Directo


Clase ms simple de Cache Una lnea por cada conjunto.

Conj. 0: Conj. 1:

valid valid

tag tag

cache block cache block

E=1 lines per set

Conj. S-1:

valid

tag

cache block

Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Accesando una Cache de Mapeo Directo Seleccin del Conjunto


Usa el Indice de Conjunto(set index) para la ubicacin.
Conj. 0: valid

tag tag

cache block cache block

Conj. seleccionado

Conj. 1:

valid

Conj. S-1: valid

tag

cache block

t bits
m-1

tag

s bits b bits 00 001 set index block offset0 Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Accesando una Cache de Mapeo Directo


Encontrada la lnea (set index) con igual tag se extrae el dato en base al desplazamiento (offset)
(1) =?
0 1 2 3 4 5 6 7

Conj. Selecc. (i):

0110
(2)= ?

w0

w1 w2

w3

m-1

t bits 0110 tag

(3) If (1) y (2), Then cache hit, y extraigo datos s bits b bits desde block offset i 100 Else, set index block offset0 ir a buscar en memoria principal. Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Cache de Mapeo Directo

1 2

3 5 4 5

Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Cache de Mapeo Directo


Linea de cache

data

tag 2k lines

memoria

p-k-m

CPU

p-k-m
tag
Direccin de Memory

k
cache address

Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Cache de Mapeo Directo


Mem. Cach
0 1 2

Mem.Principal
Tag.0

0 0 0 0 0 0

1021 1022 1023

0 1 0 0 0 0 0 1 1

Tag.1

VD

Tag

Datos (n bytes=01 pagina)

Tag.2

Linea 0 1 2 . . 1021 1022 1023 0 1 2 . . 1021 1022 1023 0 1 2 . . 1021 1022 1023

Direccin 0 7 8 15 16 23 . . 8168 8176 8184 8192 8200 8208 . . 16360 16368 16376 16384 16392 16400 . . 24552 24560 24568

Direccin: 16360 Operacin: Read 003FE8h => 00000000001 1111111101 000 V D 1 0 Tag 1 Line Index 1021 Offset 0
0 1 2 4294959104 4294959112 4294959120

Tag.2047
1021 1022 1023 4294967272 4294967280 4294967288

Direccin: 16383 Operacin: Write 003FFFh => 00000000001 1111111111 111 V D 1 1 Tag 1 Line Index 1023 Offset 7

Direccin: 24572 Operacin: Read 005FFCh => 00000000010 1111111111 100


Guarda Pag.1023,Tag1 y obtiene la nueva

Direccin: 16382 Operacin: Read 003FFEh => 00000000001 1111111111 110 V D 1 1 Tag 1 Line Index 1023 Offset 6

V D 1 0

Tag 2

Line Index 1023

Offset 4

Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Porqu usar los bits del medio como ndices?


4-line Cache 00 01 10 11
Indexando por Bit de Mayor peso Lineas adyacentes se podran mapear a la misma entrada de cache Uso pobre de localidad espacial Indexando por bits de Orden medio Lineas consecutivas de la memoria se mapean en diferente lugar en la cache Puede mantenerse cierta regin en un mismo tiempo

High-Order Bit Indexing 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

Middle-Order Bit Indexing

Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Cache de Mapeo Asociativo


Mas de una lnea por conjunto

Conj. 0:

valid valid

tag tag

cache block cache block E=2 lines per set

valid
Conj. 1: valid

tag
tag

cache block
cache block

valid Conj. S-1: valid

tag tag

cache block cache block

Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Dieccionando en Cache de Mapeo Asociativo


Seleccin identica al mapeo direto
valid Conj. 0: valid tag tag cache block cache block

Conj. Selecc.

valid
Conj. 1: valid

tag
tag

cache block
cache block

valid Conj. S-1: valid t bits


m-1

tag tag

cache block

cache block

tag

s bits b bits 00 001 set index block offset0 Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Dieccionando en Cache de Mapeo Asociativo


Encontrada la lnea (set index) con igual tag se extrae el dato en base al desplazamiento (offset)
=1?
(1) Valid bit.
0 1 2 3 4 5 6 7

1 selected set (i): 1

1001 0110 w0 w1 w2 w3

=?
(2) t bits 0110 tag

m-1

(3) If (1) y (2), Then cache hit, y extraigo datos (block offset ) s bits b bits Else, i 100 ir a memoria principal. set index block offset0
Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Mapeo de Cache Asociativo

Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Mapeo de Cache Asociativo


Mem. Cach
0 1 2

Mem.Principal
Tag.0

1021 1022 1023

Tag.1

VD

Tag

Datos(n bytes=01 pagina)

Tag.2

Linea 0 1 2 . . 1021 1022 1023 0 1 2 . . 1021 1022 1023 0 1 2 . . 1021 1022 1023

Direccin 0 7 8 15 16 23 . . 8168 8176 8184 8192 8200 8208 . . 16360 16368 16376 16384 16392 16400 . . 24552 24560 24568

Direccin: 16360 Operacin: Read 003FE8h => 000000000011111111101 000 V D 1 0 Tag 2045 Offset 0
0 1 2 4294959104 4294959112 4294959120

Tag.2047
1021 1022 1023 4294967272 4294967280 4294967288

Direccin: 16383 Operacin: Write 003FFFh => 000000000011111111111 111

V D 1 1

Tag 2045

Offset 7

Direccin: 16377 Operacin: Read 003FF9h => 000000000011111111111 001


V D 1 0 Tag 2047 Offset 1

Direccin: 16382 Operacin: Read 003FFEh => 000000000011111111111 110 V D 1 1 Tag 2045 Offset 6

Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Example: 2-way Set Associative Cache


tag

index

offset

address

Valid Cache Tag Cache Data Block 0

Cache Data Cache Tag Valid Block 0

mux Cache Block

Hit

Mapeo de Cache Asociativa por conjuntos

Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Algoritmos de Reemplazo
Algoritmo implementado en Hardware (veloz)

First in first out (FIFO)


Least frequently used (LFU)

Least Recently used (LRU)


Random

Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Write Strategies
On a Hit Write Through. Escribe en cache y memoria. Write Back. Escribe cuando se reemplaza pgina de cache. On a miss:
Write Allocate. Asigna linea para escritura. Write NoAllocate. No asigna linea para escritura

Some processors buffer writes.


Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Metricas de Performance de Cache


Miss Rate Tipico: 3-10% for L1 Puede ser pequeo (e.g., < 1%) for L2, depende del tamao, etc. Hit Time Tipico: 1 ciclo de clock for L1 3-8 ciclo clock for L2 Miss Penalty Tiempo adicional por no acierto(miss) Tipico 25-100 ciclos para memoria principal Average Access Time = Hit Time + Miss Rate * Miss Penalty
Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Ejemplo: Memoria Cache Alpha 21264

Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Intel Caches
80386 no on chip cache 80486 8k using 16 byte lines and four way set associative organization Pentium (all versions) two on chip L1 caches Data & instructions Pentium 3 L3 cache added off chip Pentium 4 L1 caches 8k bytes 64 byte lines four way set associative L2 cache Feeding both L1 caches 256k 128 byte lines 8 way set associative L3 cache on chip

Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Diagrama de Bloques del Pentium 4

Sistemas Digitales Mg. Juan Carlos Gonzales Surez

PowerPC Cache Organization (AppleIBM-Motorola)


601 single 32kb 8 way set associative 603 16kb (2 x 8kb) two way set associative 604 32kb 620 64kb G3 & G4 64kb L1 cache 8 way set associative 256k, 512k or 1M L2 cache two way set associative G5 32kB instruction cache Sistemas Digitales 64kB data cache Mg. Juan Carlos Gonzales Surez

Diagramas de Bloques del PowerPC G5

Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Multi-core Architecture
AMD ARCHITECTURE

L1
L2

L3

Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Particionamiento Adaptativo de Cache en modo Compartido/Privado

Cache Architecture Framework


Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Gracias

Juan Carlos Gonzales Suarez juancgonzaless@yahoo.com

Example
32-word memory 8-word cache (The addresses below are word addresses.)
Address Binary Cache block Hit or miss 22 10110 110 26 11010 010 22 10110 110 26 11010 010 16 10000 000 3 00011 011 16 10000 000 18 10010 010

Index Valid Tag Data 000 001 010 011 100 101 110 111

Sistemas Digitales Mg. Juan Carlos Gonzales Surez

Вам также может понравиться