i know hit rate is the percentage of found data in cache. but i have no idea how to find the hit for an algorithm. i was thinking that for code 1 i will have 11 blocks each with 4 elements and for code 2 i'll have 4 blocks each with 11 elements and each time i see 4 elements missed. not sure if that make sense at all. any advise is welcomed
Suppose a 2-dimensional array A with 11 rows by 4 columns, stored in memory like this [0][0], [0][1], [0][2], [0][3], [1][0], [1][1], …[10][2], [10][3]
Also suppose a fully associative single level cache of 10 memory blocks, with each memory block holding 4 bytes, and a FIFO replacement policy.
Each row fits exactly into one cache block and rather unluckily, the whole array cannot fit into cache. the cache is one row too small...
Now given the 2 following codes, 1- how do i calculate the hit rate 2- given that cache access time is 5ns and memory access time is 70ns, and assuming overlapping access to memory and cache, how do i calculate the EAT for each code?
Code 1:
for (int row = 0; row < 11; row ++)
{
for (int column = 0; column < 4; column ++)
{
myByte = A [ row, column ];
}
}
Code 2:
for (int column = 0; column < 4; column ++)
{
for (int row = 0; row < 11; row ++)
{
myByte = A [ row, column ];
}
}
Any help is appreciated. Thanks