Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Now you have to implement something like set associative cache. For your conveni

ID: 3706986 • Letter: N

Question

Now you have to implement something like set associative cache. For your convenience, just think your cache is 2-way set associative. your first task would be to implement 2 way set associative cache. To find the set for any ock, assume that disk-block-number % cache-size. assume that, each of the blocks in your code, is 16 byte. And the total size of your cache is 512 bytes. That means, your cache has in total 512(16*2)16 entries (Note that those value would be customized, you should have the ability to give those entry. In case of 2 way set associative, each of the entry can hold 2 blocks). For the second task, consider the following code: int x 21[128]: int i int sum 0; for(i0; i

Explanation / Answer

Given, block size = 16 bytes = 1 entry

Total cache size = 512 bytes

So, number of entries = 512/16 = 32 entries

In two way set associative mapping, 2 entries are present in each set

So, the modified code for previously done set associative cache is as follows

int x[2][16]; // each entry is of 16 bytes

int i;

int sum =0;

for(i = 0; i < 16; i++){

sum + = x[0][i] * x[1][i];

}