We can think 512* 512 2d array like 512 1d array each of size 512 element
It is given that element size is 8 byte so each 1d array size is 512 * 8 byte so 4KB
cache size given 32kb and 128 byte block size so,
total line in cache is 2^15/2^7 is 2^8
so we find out that their are 2^8 line in cache so at a time max 2^8 cache misses can happen then cache will filled up
we already find out that one 1d array size is 4KB and we know cache size is 32kb so number of 1d array we can load into cache at a time is 32kb/4kb = 8.
so 8 1d array at a time then total how many round needed to finish up all the 1d array ?
so their are 512 1d array and we can load 8 at a time so total round is 512/8 = 64 round
lets count now cache miss for this 64 round
ok so how many misses in 1 round?
so in our case in 1st round we are feeling the cache total then in 2nd round we are overriding all the cache data. so for every round 2^8 misses so
64 round 64*2^8 = 2^14 misses so M1 = 16384
Lets move to column major access( i.e. M2) and data store in raw major order by default is C language
so for M2 we have to know when we store the 1d array how many element store per block and how many block it can take to store only one 1d array and their are 512 such 1d array keeping in mind.
Mistake i did when i was solving the question
i think like their are 2^14 misses for 64 round means for here we done with 2^14 cause what we load we access them all and we got to next
but due to column major order we unnecessarily load a whole row and access one element and load one more raw. so their are 512 element are their in a raw so we have to do 512*2^14 that is M2 but this is wrong
Their are 512 element in one 1d array it is correct but at a time all 512 not loaded because we load one block and 512 element we can’t fit into one block so how many element we can fit into one block?
element size is 8 byte block size is 128 byte so number of element is 2^7/2^3 = 2^4
so only 16 element we will load up for misses that is not 512* 2^14 that is 2^4*2^14
so M2 is 2^18
then M1/M2 = 2^14/2^18 = 1/2^4 = 1/16
so answer is option B