Академический Документы
Профессиональный Документы
Культура Документы
Solution:
MM size = 512K 16 = 223
(i) Fully Associative:
1. # MM address bits = log2 MM size = log2 223 = 23 bits
2. # WORDs per block = 16 words
# SETs = 1
# TAGs = # MM blocks / # SETs = 512K / 1 = 512K = 219
= 4 bits
= 0 bits
= 19 bits
(ii) Direct:
1. # MM address bits = log2 MM size = log2 223 = 23 bits
2. # WORDs per block = 16 words
# SETs = 64
# TAGs = # MM blocks / # SETs = 512K / 64 = 8K = 213
= 4 bits
= 6 bits
= 13 bits
= 4 bits
= 2 bits
= 17 bits
= 4 bits
= 8 bits
= 20 bits
Address
000 53272105
000 53502120
000 53271130
000 53272106
000 53502124
000 53261130
000 53272104
TAG SET
53272 10
53502 12
53271 13
53272 10
53502 12
53261 13
53272 10
WORD
5
0
0
6
4
0
4
Hit/Miss
Miss
Miss
Miss
Hit
Hit
Miss
Hit
Comment
Same
Same
Same
Same
SET
SET
SET
SET
& TAG
& TAG
as 3rd
& TAG
as 1st reference
as 2nd reference
reference but different TAG
as 1st reference
C0
0
0
1
2
3
0
1
0
1
2
0
1
2
C1
0
1
0
1
2
3
0
1
2
3
3
0
1
C2
0
1
2
0
1
2
3
3
0
1
2
3
0
C3
0
1
2
3
0
1
2
2
3
0
1
2
3
Subsequent actions
Block
Block
Block
Block
Block
Block
Block
Block
Block
Block
Block
Block
0
1
2
3
0
1
0
2
3
0
1
2
filled
filled
filled
filled
accessed
replaced
accessed
accessed
replaced
accessed
replaced
replaced
TAG
Block
2
0
3
2
1
0
6
1
0
0
0
0
Comment
3
2
1
0
1
0
0
1
0
0
9
2
3
2
1
0
2
0
1
1
0
1
3
2
1
0
3
2
1
0
Comment
LRU Blk
3
2
1
0
3
0
0
0
1
1
F
0
A
1
3
1
2
0
9
2
6
3
2
0
TAG
Block
1
1
F
3
0
0
LRU Blk
1
1
1
0
0
1
Comment
3
2
1
0
2
0
LRU Blk
TAG
Block
7
3
3
2
1
0
3
0
0
0
0
0
R
2
A
2
7
1
4
2
0
0
1
0
0
R
2
3
2
1
0
3
0
1
0
0
1
A
3
0
1
0
0
1
R
3
3
2
1
0
3
2
1
0
3
1
1
0
1
1
R
1
3
2
1
0
3
0
0
0
1
1
A
1
Problem # 5 (20 points): Consider a 4 8 array of numbers, A. Assume that each number in the array occupies one
word in MM and that the array elements are stored column-major in MM starting from location 1008 to location 1039.
The cache consists of 8 blocks each consisting of just two words. The cache is initially empty. Assume also that
whenever needed, LRU replacement policy is used. Analyze the cache for the following segment of a program:
sum = 0;
For i = 0 to 1
For j = 0 to 7
sum = sum + A(i, j)
EndFor
EndFor
Fill out the following assuming (i) direct mapping, then (ii) fully associative mapping. Also, calculate the hit ratio, the
number of block replacements, and the percentage of cache utilization in each case.
Solution:
(i) Direct Mapping locations 1008 & 1009 map to cache block number 0 (i.e. MM will be divided into blocks of 2 with 1008 & 1009
having block # 504 that maps to block (504 mod 8) = block 0 in cache)
Request
A(0, 0)
A(0, 1)
A(0, 2)
A(0, 3)
A(0, 4)
A(0, 5)
A(0, 6)
A(0, 7)
A(1, 0)
A(1, 1)
A(1, 2)
A(1, 3)
A(1, 4)
A(1, 5)
A(1, 6)
A(1, 7)
Cache
Hit/
Miss
Miss
Miss
Miss
Miss
Miss
Miss
Miss
Miss
Miss
Miss
Miss
Miss
Miss
Miss
Miss
Miss
MM
Address
1008
1012
1016
1020
1024
1028
1032
1036
1009
1013
1017
1021
1025
1029
1033
1037
Cache
Block
number
0
2
4
6
0
2
4
6
0
2
4
6
0
2
4
6
Cache Content
00
00
00
00
04
04
04
04
00
00
00
00
04
04
04
04
B0
10
10
10
10
14
14
14
14
10
10
10
10
14
14
14
14
B1
B2
01
01
01
01
05
05
05
05
01
01
01
01
05
05
05
B3
11
11
11
11
15
15
15
15
11
11
11
11
15
15
15
B4
02
02
02
02
06
06
06
06
02
02
02
02
06
06
B5
B6
12
12
12
12
16
16
16
16
12
12
12
12
16
16
03
03
03
03
07
07
07
07
03
03
03
03
07
B7
13
13
13
13
17
17
17
17
13
13
13
13
17
Hit ratio = 0 / 16 = 0, # block replacements = 12 (shaded areas in the table), Cache utilization% = 4 / 8 = 50%
(ii) Fully Associative Mapping
Request
MM
Addr.
A(0, 0)
A(0, 1)
Cache
Hit/
Miss
Miss
Miss
1008
1012
Cache
Block
number
0
1
A(0, 2)
Cache Content
00
00
B0
10
10
Miss
1016
00
10
A(0, 3)
Miss
1020
00
10
A(0, 4)
Miss
1024
00
10
A(0, 5)
Miss
1028
00
10
A(0, 6)
Miss
1032
00
10
A(0, 7)
Miss
1036
00
10
A(1, 0)
Hit
1009
00
10
A(1, 1)
Hit
1013
00
10
B1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
B2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
2
0
2
0
2
0
2
0
2
0
2
0
2
0
B3
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
3
0
3
0
3
0
3
0
3
0
3
0
B4
1
3
1
3
1
3
1
3
1
3
1
3
1
0
4
0
4
0
4
0
4
0
4
0
B5
1
4
1
4
1
4
1
4
1
4
1
0
5
0
5
0
5
0
5
0
1
5
1
5
1
5
1
5
1
B6
0
6
0
6
0
6
0
B7
1
6
1
6
1
6
1
0
7
0
7
0
17
17
17
A(1, 2)
Hit
1017
00
10
A(1, 3)
Hit
1021
00
10
A(1, 4)
Hit
1025
00
10
A(1, 5)
Hit
1029
00
10
A(1, 6)
Hit
1033
00
10
A(1, 7)
Hit
1037
00
10
1
0
1
0
1
0
1
0
1
0
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
0
2
0
2
0
2
0
2
0
2
0
2
2
1
2
1
2
1
2
1
2
1
2
1
2
3
0
3
0
3
0
3
0
3
0
3
0
3
3
1
3
1
3
1
3
1
3
1
3
1
3
4
0
4
0
4
0
4
0
4
0
4
0
4
4
1
4
1
4
1
4
1
4
1
4
1
4
5
0
5
0
5
0
5
0
5
0
5
0
5
5
1
5
1
5
1
5
1
5
1
5
1
5
6
0
6
0
6
0
6
0
6
0
6
0
6
6
1
6
1
6
1
6
1
6
1
6
1
6
7
0
7
0
7
0
7
0
7
0
7
0
7
17
17
17
17
17
17