I have been trying to solve questions like this before but I have stumbled in difficulty to track the the space of the cache. so there is an example of a question like this:
Given the code:
int A[1024,1024],B[1024,1024],C[1024,1024]
for(int i=0;i<1024;i++){
for(int j=0;j<1024;j++){
for(int k=0;k<1024;k++){
A[i,j]+=B[i,k]+C[k,j];
}
}
}
That runs on a proccessor with data cache that has LRU(least recently used feature of the cache) and is fully associative. the cache has total size of 32KB and each block has size of 64B. size of int is 4 bytes. arrays are placed continously on memory.
what is the percentge miss rate(approximately) of cache in this program?
what I know: when we retrieve an element from the array we also bring all the block, for example for first element in B we bring the rest 64(Bytes)/4(size of int) =16 elements to the cache and thus we will have one miss at first but for the rest(15 elements of B) we wont have a miss cause they are in the cache. for array C we go to the main memory each time because the block that was brought is not the same block to the row after it.
thank you very much in advance!