Presentation is loading. Please wait.

Presentation is loading. Please wait.

7장 : 캐시와 메모리.

Similar presentations


Presentation on theme: "7장 : 캐시와 메모리."— Presentation transcript:

1 7장 : 캐시와 메모리

2 메모리 계층 사용자들은 값싸고 빠른 메모리를 크면 클수록 갖고 싶어한다! - 나에게 하드디스크 (300GB) 만큼의, 속도는 RAM 정도이고 비휘발성 메모리가 있다면….. 그런데 돈이 없다. 2008년 현재 RAM은 1GB/15,000원 HD는 500GB/9만원 (1GB/180원) 캐시 가격을 정확히 산정하기는 어려우나 2MB/2만원 (1GB/1000만원) 이 된다. 캐시는 DRAM에 비해 몇십배 빠르고, DRAM의 액세스 속도는 몇십 ns 이며 HDD보다 수백배 빠르다. 이러니, 캐시는 HDD보다 수천배 이상 빠르다. 컴퓨터 메모리 시스템 설계의 핵심은 어떻게 이 다양한 성능, 가격비를 갖는 메모리를 조합해서, 가장 적은 돈을 써서 용량은 HDD같이 많게 하고, 성능은 캐시같이 빠르게 할 수 있는가이다.

3 메모리 계층 저장용량 크기 성능 가격 C P U L e v e l 1 L e v e l s i n t h e L e v e l
2 m e m o r y h i e r a r c h y L e v e l n 저장용량 크기

4 Locality (지역성) : 메모리 액세스는 지역성을 갖는다
Our initial focus: 우리는 인접한 두 메모리 계층 ( 상위 (upper), 하위(lower) )간의 메모리 액세스 특성을 다룬다. 블록 (block): 두 계층에 존재 또는 이동하는 데이터의 최소 단위 (minimum unit of data) 적중 (hit): access 하려는 데이터가 상위 계층에 있을 때 실패 (miss): access 하려는 데이터가 상위 계층에 없을 경우

5 캐시 : 데이터나 인스트럭션 모두 담을 수 있다. Two issues:
우리가 원하는 아이템 (데이터, 인스트럭션)이 캐시에 있는지? 캐시에 있으면 어디에 있는지? 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

6 Direct Mapped Cache Mapping: address is modulo the number of blocks in the cache C a c h e 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 M e m o r y

7 Direct Mapped Cache For MIPS:
What kind of locality are we taking advantage of?

8 Direct Mapped Cache Taking advantage of spatial locality: A d r e s (
w i n g b t p ) 1 6 2 B y f V T a D H 3 4 K 8 M u x l c k I 1 6 1 5 4 3 2 1

9 찾는 아이템이 캐시에 있는지, 없는지 : Hits vs. Misses
this is what we want! 읽기 miss 이면 stall the CPU, fetch block from memory, deliver to cache, restart Write hit 이면: can replace data in cache and memory (write-through) write the data only into the cache (write-back the cache later) Write miss 이면: read the entire block into the cache, then write the word

10 Hardware Issues Make reading multiple words easier by using banks of memory It can get a lot more complicated... C P U a c h e B u s M m o r y . O n - w d i g z t b W l p x k 1 M e m o r y M e m o r y b a n k k 2 b a n k 3 c . I n t e r l e a v e d m e m o r y o r g a n i z a t i o n

11 Performance Increasing the block size tends to decrease miss rate:
Use split caches because there is more spatial locality in code:

12 캐시 성능 Simplified model: execution time = (execution cycles + stall cycles)  cycle time stall cycles = # of instructions  miss ratio  miss penalty 성능을 향상하려면: miss 율을 줄여야 하며 miss 했을 시 손실 (miss penalty) 을 줄여야 한다. What happens if we increase block size?

13 캐시를 또다시 몇 단계로 나누어 캐시 미스 시 부담을 줄인다.
Add a second level cache: often primary cache is on the same chip as the processor use SRAMs to add another cache above primary memory (DRAM) miss penalty goes down if data is in 2nd level cache Example: CPI of 1.0 on a 5 Ghz machine with a 5% miss rate, 100ns DRAM access Adding 2nd level cache with 5ns access time decreases miss rate to .5% Using multilevel caches: try and optimize the hit time on the 1st level cache try and optimize the miss rate on the 2nd level cache  요즈음 CPU는 그 내부에 멀티레벨 캐시를 갖고 있다. 인텔 코어2쿼드 켄츠필드 : L1 캐쉬 ; 8way data cache 32KB x 2, & 8way Instruction cache 32KB x 2 L2 캐쉬 ; 4MB x 2

14 Virtual Memory (가상 메모리) : 운용체제에서 중요
하드디스크와 메모리사이에서 어떻게 하면 하드디스크를 메모리와 같이 사용할 수 있을까 하는 요구에서 나왔음. 즉 캐시-RAM 관계를 RAM-HDD에 적용 Advantages: illusion of having more physical memory program relocation protection V i r t u a l a d d r e s s e s P h y s i c a l a d d r e s s e s A d d r e s s t r a n s l a t i o n D i s k a d d r e s s e s

15 Pages: virtual memory blocks
Page faults: the data is not in memory, retrieve it from disk huge miss penalty, thus pages should be fairly large (e.g., 4KB) reducing page faults is important (LRU is worth the price) can handle the faults in software instead of hardware using write-through is too expensive so we use writeback 3 2 1 9 8 5 4 7 P a g e o f s t V i r u l p n m b d h y c T r a n s l a t i o n a l a d d r e s s

16 Page Tables P h y s i c a l m e o r D k t g V d 1 b u p n

17 Modern Systems Things are getting complicated!

18 앞으로는 어떻게 될 것 같은가? CPU 속도가 계속 빨라져 메모리 특히 HDD와 격차 커짐
저장 장치간의 속도 격차가 더욱 커짐에 따라 이들을 어떻게 조합하여 최적의 메모리 구조를 설계할 것인가? 트랜드: redesign DRAM chips to provide higher bandwidth or processing (DDR, DDR2, RAMBUS) restructure code to increase locality : 항상 해 왔던 것 use prefetching (make cache visible to ISA) HDD 시대가 마감되고 FLASH 메모리시대로? 값싸고 성능 좋은 비휘발성의 Solid State 메모리가 많이 등장하고 있음.


Download ppt "7장 : 캐시와 메모리."

Similar presentations


Ads by Google