Given a 1KB set-associative cache with 2 lines per set and 16 bytes per block, with the LRU cache replacement policy,
Question 1: (see above) How many blocks are there in the cache?
Question 2: (see above) How many bits long is the set index?
Question 3: (see above) Assume that the cache is initially empty and we perform 8-byte data reads on the following addresses in the order listed:
0x0000
, 0x0008
, 0x1000
, 0x1028
, 0x0000
, 0x2000
, 0x0008
, 0x1000
, 0x1028
How many cache hits will this access pattern experience?
Question 4 (0 points): Which of the following is probably a bad idea if memory reads have good locality but memory writes do not have locality?
Question 5: The loop order
for(int i = 0; i < N; i += 1)
for(int j = 0; j < N; j += 1)
is the most efficient for which of the following loop bodies? Assume N
is a large number