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

-------------------------------------------- C programming coding problem. Most

ID: 3712307 • Letter: #

Question

--------------------------------------------

C programming coding problem. Most are introductive parts so it seems long.

please read carefully with patience & Only FULL ANSWERS will get positive rate.

Let me know if it's not clear

Thank you

you have to implement something like set associative cache. For your convenience, just think your cache is 2-way set associative. 1. So your first task would be to implement 2 way set associative cache. To find the set for any block, assume that disk-block-number % cache-size. 2. Now, 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(i-0; K128;i++) sum +-x[O][i] * x Modify the above code base, so that it can work with your previously done set associative cache. Say for example, the total size of x is 2 128 41024 bytes, so those value would reside in the disk in 1024/16- 64 blocks. Note that, the size of the disk would be much more higher than 64, but you are considering the arrays resides in the disk in the sequential manner. The address translation for the array element to block could be xl00] floor( (i 128+j)4) Find out the cache hit rate and cache miss rate, using your implemented set associative cache (LRU would be fine)

Explanation / Answer

ANS:-

PROGRAM:-

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];

}