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

This is a question Problem 4[10 pts]: Calculate the average access time (AMAT) f

ID: 3895024 • Letter: T

Question

This is a question

Problem 4[10 pts]: Calculate the average access time (AMAT) for given C codes. Assume the following direct-mapped cache configuration. Also, cache is initially empty Cache size Cache block size Hit time Miss penalty 16KB 64 bytes 1 cycle 128 cycles (a) Calculate AMAT for this code. int array[8192);// Assume this array saves elements int i, num-0 for(i 0; 1 8192; i++) num += arravril; b) Calculate AMAT for this code. int array 8192);// Assume this array saves elements int i, j, num 0; fori 08192; i++) js (i*16)% 8192; num array[j

Explanation / Answer

Cache size=16KB

block size=64 B

Number of blocks in cache=16KB/64B=16*210/64=28=256

Here we have solved by assuming int size =4B

Each block contains 64B/4B=16 integers

(a) This program segemnt access array starting from index 0 to 8192 sequentially.

Thus each time we read a block(we have Miss) we read 16 consecutive integers of array, So next 15 access of array are Hit.

Array size =8192 *4=32768B

Number of blocks=32768/64=512.

Now, for each block we have 512 Miss(512/8192=0.0625) and 512*15=7680 (7680/8192=0.9375)Hit.

AMAT=(128*0.0625)+(1*.9375)=8+0.9375=8.9375

(b) In this program segemnt we access 8192 elements of array, but first 256 access are 256 blocks (for i=0 to 256 Miss), Our cache size is 256 blocks, So all 0 to 256 blocks are in cache.256/8192=0.03125

then we can calculate for each acces we only access blocks within 0 to 256, So all are Hit for a total of 8192-256=7936(7936/8192=0.96875).

AMAT=(128*0.03125)+(1*0.96875)=4+.96875=4.96875

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote