Question

In: Computer Science

Computer archieture 1. Assume that the cache size is 512kB, and each cache line is 128...

Computer archieture

1. Assume that the cache size is 512kB, and each cache line is 128 Bytes.

  1. If it’s a 4-way associative cache, how many sets are there? If it’s a 2-way associative cache, how many sets are there?
  2. Let’s assume the cache is initially empty, and LRU policy is used for cache line replacement. If the following memory blocks are accessed:

Mem-block # 7, 1031, 2055, 4103, 1031, 7, 2055, 3079, 1031, 3079

What is the cache hit/miss rate if the cache is 4-way associative? Put “Hit” or “Miss” in the blanks in the table below. (5%)

7

1031

2055

4103

1031

7

2055

3079

1031

3079

  1. Given the same conditions as the question above, what is the cache hit/miss rate if the cache is 2-way associative? Put “Hit” or “Miss” in the blanks in the table below. (5%)

7

1031

2055

4103

1031

7

2055

3079

1031

3079

Solutions

Expert Solution

Cache size : 512 kB= 2^19 bytes

Size of cache line : 128Bytes=2^7bytes

Number of cache lines= 2^19/2^7=2^12

With 4-way associative cache, i.e. 4 cache lines per set, number of sets= 2^12/2^2=2^10 = 1024 sets

With following memory blocks 7, 1031, 2055, 4103, 1031, 7, 2055, 3079, 1031, 3079:

To place a block in a particular set following formula is used

Set j= (memory block number) mod ( number of sets)

For memory block 7, it will be placed in set:

7 mod 1024= 7,

Memory block 7 will be allocated in one of the 4 lines of set 7 which are empty.

1031 mod 1024=7,

Memory block 1031 will be allocated in one of the 3 lines of set 7 which are empty.

2055,4103 memory blocks are also allocated to the set 7 in the rest of two lines that are empty.

1031,7,2055 are next following blocks that are refered which are present cache resulting in hit.

3079 mod 1024 =7, as the set is full, one of the block has to be replaced using LRU policy to place 3079. As 4103 is the leat recently used block, it selected for replacement.

1031,3079 are the blocks next refered which are already present in cache resulting in hit.

7 1031 2055 4103 1031 7 2055 3079 1031 3079
M M M M H H H M H H

Therefore miss rate = 5/10=0.5

Hit rate=1-0.5=0.5

B. With 2-way set associative:

All the calculations till number of cache lines are same.

But as it is 2-way set, there will be only 2 lines per set. Therefore number of sets will be: 2^12/2=2^11 sets= 2048 sets.

The formula for finding the set for a memory block will become:

i mod 2048, where i is memory block number

7 mod 2048=7, placed in set 7,

1031 mod 2048=1031, placed in set 1031

2055 mod 2048=7, placed in set 7

4103 mod 2048=7, has to be placed in set 7. But all the 2 lines of set 7 are occupied. Hence using LRU block 7 which is least recently used is replaced with block 4103.

1031 is already present in set 1031,

7 is a miss, by using LRU, block 2055 is replaced by 7.

Again 2055 is a miss, by using LRU, block 4103 is replaced by 2055.

3079 mod 2048=1031, placed in set 1031.

Next blocks refered are 1031, 3079 which are already present in set 1031.

7 1031 2055 4103 1031 7 2055 3079 1031 3079
M M M M H M M M H H

Miss rate= 7/10=0.7

Hit rate=1-0.7=0.3


Related Solutions

Assume a computer with a cache that holds 64 bytes and has a block size of...
Assume a computer with a cache that holds 64 bytes and has a block size of 32 bytes. Direct address mapping is used and from the beginning the cache is empty. The following program sequence is executed: for (col = 0; col < 2; col++) { for (row = 0; row < 4; row++) A[row][col] = B[row] * C[col]; } Assume that for the variables row and col registers are used. The matrix A consists of 4 rows and 4...
Consider a 4-way set-associative cache, 4 rows, a line size of 128 bytes and a write-back...
Consider a 4-way set-associative cache, 4 rows, a line size of 128 bytes and a write-back policy. The following requests are made to memory: Load: 0b0011111001000101 Load: 0b1000111110110100 Load: 0b0110101111110100 Store: 0b0010110000000110 Store: 0b1111001001110101 Store: 0b1110000111000001 Load: 0b0000000010100110 Load: 0b0101001001001101 Assuming the machine is in cold-start, profile the contents to the cache after all of the requests have been made. State any assumption you make (if needed).
A direct mapped cache has 32 cache lines.Each cache line consists of 4 words, and each...
A direct mapped cache has 32 cache lines.Each cache line consists of 4 words, and each word is four bytes.The address bus consists of 16 bits. How many bits are required for the tag in this direct-mapped cache?
Below are listed parameters for different direct-mapped cache designs. Cache Data Size: 32 KiB Cache Block...
Below are listed parameters for different direct-mapped cache designs. Cache Data Size: 32 KiB Cache Block Size: 2 words Cache Access Time: 1 cycle Word: 4 bytes. Calculate the total number of bits required for the cache listed above, assuming a 32-bit address. Given that total size, find the total size of the closest direct-mapped cache with 16-word blocks of equal size or greater. Explain why the second cache, despite its larger data size, might provide slower performance than the...
Suppose a computer using direct mapped cache has 232 bytes of main memory and a cache...
Suppose a computer using direct mapped cache has 232 bytes of main memory and a cache of 1024 blocks, where each block contains 32 bytes. [2] How many blocks of main memory does this computer have? [4] Show the format of a memory address as seen by cache; be sure to include the field names as well as their sizes. [3] Given the memory address 0x00001328, to which cache block will this address map? (Give you answer in decimal.) A...
Part 1) (a) Find the size of each of two samples (assume that they are of...
Part 1) (a) Find the size of each of two samples (assume that they are of equal size) needed to estimate the difference between the proportions of boys and girls under 10 years old who are afraid of spiders. Assume the "worst case" scenario for the value of both sample proportions. We want a 9999% confidence level and for the error to be smaller than 0.08.0.08. Answer: (b) Again find the sample size required, as in part (a), but with...
(1 point) (a) Find the size of each of two samples (assume that they are of...
(1 point) (a) Find the size of each of two samples (assume that they are of equal size) needed to estimate the difference between the proportions of boys and girls under 10 years old who are afraid of spiders. Assume the "worst case" scenario for the value of both sample proportions. We want a 99% confidence level and for the error to be smaller than 0.08. Answer: (b) Again find the sample size required, as in part (a), but with...
(1 point) (a) Find the size of each of two samples (assume that they are of...
(1 point) (a) Find the size of each of two samples (assume that they are of equal size) needed to estimate the difference between the proportions of boys and girls under 10 years old who are afraid of spiders. Use the conservative estimate for the value of both sample proportions. We want a 9696% confidence level and for the error to be smaller than 0.05.0.05. Answer: (b) Again find the sample size required, as in part (a), but with the...
(1 point) (a) Find the size of each of two samples (assume that they are of...
(1 point) (a) Find the size of each of two samples (assume that they are of equal size) needed to estimate the difference between the proportions of boys and girls under 10 years old who are afraid of spiders. Use the conservative estimate for the value of both sample proportions. We want a 9696% confidence level and for the error to be smaller than 0.05.0.05. Answer: (b) Again find the sample size required, as in part (a), but with the...
(1 point) (a) Find the size of each of two samples (assume that they are of...
(1 point) (a) Find the size of each of two samples (assume that they are of equal size) needed to estimate the difference between the proportions of boys and girls under 10 years old who are afraid of spiders. Assume the "worst case" scenario for the value of both sample proportions. We want a 99% confidence level and for the error to be smaller than 0.02. Answer: (b) Again find the sample size required, as in part (a), but with...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT