cache, set associative, write-through, write-back

19
Page 1 Dive Into Cache by 레레레

Upload: -

Post on 12-Jun-2015

716 views

Category:

Devices & Hardware


2 download

DESCRIPTION

Cache, Set Associative, Write-Through, Write-Back

TRANSCRIPT

Page 1: Cache, Set Associative, Write-Through, Write-Back

Page 1

Dive Into Cache

by 레쓰비

Page 2: Cache, Set Associative, Write-Through, Write-Back

Page 2

Direct Mapping

31 Tag 15 14 Index 6 5 Offset 0

Page 3: Cache, Set Associative, Write-Through, Write-Back

Page 3

Fully Associative

31 Tag 6

5 Offset 0

Page 4: Cache, Set Associative, Write-Through, Write-Back

Page 4

N-Way Set Associative

31 Tag 12 11 Set 6 5 Offset 0

Page 5: Cache, Set Associative, Write-Through, Write-Back

Page 5

Mapping method Summary종류 장점 단점

Direct Mapping

구조가 간단 (Cheap) 해당 Index 에 하나의 주소만 넣을 수 있기에 , Cache 공간을 효율적으로 사용하지 못한다 .

Fully Associative

Cache 의 남는 공간 어디에든 주소를 넣을 수 있어서 Cache 공간을 효율적으로 사용한다

구조가 복잡하고(Expensive) 해당 주소가 Cache 에 있는지 검사할 때마다 모든 Slot 을 검사해야 한다 .

N-Way Associative

Direct Mapping 과 Fully Associative 의 타협점으로 , Fully Associative 보다덜 복잡하고 (less expensive)Direct Mapping 보다공간을 보다 효율적으로 사용한다

Direct Mapping 처럼 Index 를 통해서 한번에 접근할 수 있지만 여전히 N 번의 비교가 필요하며 , 여전히 공간을 완전히 효율적으로 사용하지는 못한다 .

Page 6: Cache, Set Associative, Write-Through, Write-Back

Page 6

Direct Mapping

Page 7: Cache, Set Associative, Write-Through, Write-Back

Page 7

Page 8: Cache, Set Associative, Write-Through, Write-Back

Page 8

Page 9: Cache, Set Associative, Write-Through, Write-Back

Page 9

Page 10: Cache, Set Associative, Write-Through, Write-Back

Page 10

Page 11: Cache, Set Associative, Write-Through, Write-Back

Page 11

4-Way Associative

Page 12: Cache, Set Associative, Write-Through, Write-Back

Page 12

4-Way Associative

Page 13: Cache, Set Associative, Write-Through, Write-Back

Page 13

4-Way Associative

Page 14: Cache, Set Associative, Write-Through, Write-Back

Page 14

4-Way Associative

Page 15: Cache, Set Associative, Write-Through, Write-Back

Page 15

4-Way Associative

Page 16: Cache, Set Associative, Write-Through, Write-Back

Page 16

Write-Through & No-Write-Allocate

Read:1.Cache 내 해 당 Memory 존재여부 검사2. 있을 때는 Cache 값을 사용3. 없을 때는 Memory 에서 읽어서 할당

Write:1.Cache 내 해 당 Memory 존재여부 검사2. 있을 때는 Cache 와 Memory 동시기록3. 없을 때는 Memory 에만 기록 [No-Write-Allocate 방식 ]

Page 17: Cache, Set Associative, Write-Through, Write-Back

Page 17

Write-Back & Write-AllocateRead:1.Cache 내 해 당 Memory 존재여부 검사2. 있을 때는 Cache 값을 사용3. 없을때는 사용할 Cache 블럭 할당4. 할 당 된 블 록 이 Dirty-Flag-Setted 라면 해당블럭 Memory 에 쓰기 수행5. 방금 쓰기를 수행한 Memory 를 다시 Cache 에 적재 [Write-Allocate 방식 ]6. 해당 Cache 블록의 Dirty-Flag 를 해제

Write:1.Cache 내 해 당 Memory 존재여부 검사2. 있을 때는 Cache 에만 기록하고 Dirty-Flag 를 할당3. 없을때는 사용할 Cache 블럭 할당4. 할 당 된 블 록 이 Dirty-Flag-Setted 라면 해당블럭 Memory 에 쓰기 수행5. 방금 쓰기를 수행한 Memory 를 다시 Cache 에 적재 [Write-Allocate 방식 ]6.Cache 블 록 에 새 로 운 데 이 터 를 기록7.Cache 블 록 에 Dirty-Flag 를 할당

Page 18: Cache, Set Associative, Write-Through, Write-Back

Page 18

Write on Cache :Write-Through : 바로 Memory 에 접근하여 쓰기를 수행 -> 매번 Stall 을 유발

Write-Back : Cache 에만 쓰기를 하며 해당 Cache Slot 에는 Dirty-Bit 를 Set 한다 . -> 실제로 Memory 에 쓰기를 수행할 때만 Stall 이 발생 실제로 Memory 에 변경 사항이 적용되는 경우는 다음과 같다 . 1) Dirty-Bit 가 Set 된 Cache 를 읽으려 시도한 경우 , 2) Dirty-Bit 가 Set 된 Cache 를 대상으로 쓰기를 시도한 경우 ,

Write-Allocate : 만약 어떤 Memory 에 대해 쓰기를 수행하려 할때 해당 Memory 가 Cache 에 없는 경우 Memory 에 쓰기를 완료한 후 , 이를 다시 읽어들여 Cache 에 할당해 준다 . [Write-Back 과 함께 사용 ]

No-Write-Allocate : Memory 에 대한 쓰기가 완료된 후 해당 내용을 Cache 로 다시 가져오지 않는다 . [Write-Through 와 함께 사용 ]

Page 19: Cache, Set Associative, Write-Through, Write-Back

Page 19

Thank You