Given the following code sequence calculating a matrix norm. with a and c being
ID: 3870288 • Letter: G
Question
Given the following code sequence calculating a matrix norm.
with a and c being arrays of floating point numbers with each element being 4 bytes. No element of a or c is in the cache before executing this code. Please assume row-major ordering. Assuming that the cache is large enough to hold both a and c, and has a cache block size of 64 bytes, determine the number of cache misses (6 pts) and the cache miss rate (4 pts) for this code sequence.
Given the following code sequence calculating a matrix norm double c[128], a[128] [128]; with a and c being arrays of floating point numbers with each element being 4 bytes. No element of a or c is in the cache before executing this code. Please assume roW-major ordering. Assuming that the cache is large enough to hold both a and c, and has a cache block size of 64 bytes, determine the number of cache misses (6 pts) and the cache miss rate (4 pts) for this code sequence.Explanation / Answer
Solution:
So at first when the code will start to execute there will be nothing inside the cache memory but as the program executes further some elements will start to stored in the memory.
at i= 0,
c[0] = c[0] + a[0][0]*a[1][1] + a[0][1]*a[1][0];
now ithe indices for array a 00, 01, 11, 10 are in cache
so total 5 misses here,
and at i= 1
c[1] = c[1] + a[1][1]*a[2][2] + a[1][2]*a[2][1];
c[1], 22, 12, and 21 are new elements and 4 miss operaions
as the program executes further
cache will be full at i= 15
but there is only one hit at each step
so the number of misses= 5+ 127*4= 513
total number of operations= 6*128= 768
Miss rate= (513/768)*100= 66.79%
I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.