컴퓨터 구조 2 - 02

2019-09-13

즐거운 추석에 안즐거운 컴퓨터 구조2 수업내용 포스팅

추석인데 배가 고프다…먹을게 없다.

추석이 금요일인데 월화수에만 수업이 있으니 뭔가 엄청 손해보는거같다.


예제 1) Bits in a Cache

Direct-mapped cache에서 (16 KiB of data, 4-word blocks, 32-bit address)에 필요한 총 bits는?


16KiB 는 (2^4 * 2^10)byte = (2^12)words.

블록 사이즈는 (2^2)words이므로 총 1024(2^10)개의 블록이 있다.

tag는 32에서 block offset 2, byte offset 2, index 10을 뺀 18

각 블록은 4 words(4 * 32) + tag(18) + valid bit(1) = 147 bits

즉, 총 캐시 사이즈는

2^10 x 147 = 147 Kbits = 18.4 kbytes


예제 2) Mapping an Address to a Multiword Cache Block

사이즈가 16 bytes인 블록 64개로 구성된 캐시가 있다.

address 1200을 map한 block number는?


공식 (Block address) modulo (# of Blocks in the cache) 와

Block address = [Byte address / Bytes per block] 을 활용한다.

1) 1200 / 16 = 75

2) 75 modulo 64 = 11

이므로 block number = 11이다.


Miss rate vs. Block size

Larger blocks

  • Increased spatial locality

  • Decreased miss rate

ca21

Too large blocks

  • Small number of blocks in the cache

  • Increased miss rate

  • Increased miss penalty

Miss penalty

Miss penalty = block fetch time + cache load time

Block fetch time은 두 파트로 나뉘어진다.

첫번째는 first word에 대한 지연이고, 두번째는 남은 블록들의 전송 시간이다.

전송 시간은 블록 사이즈에 비례하므로, miss penalty는 블록 사이즈가 커지면 그에 따라 증가한다.