Given CPU with:
L1 cache: 4-ways, block size = 32 bytes , cache size = 64KB , LRU (Cache replacement policy).
L2 cache: 2-ways, block size = 32 bytes , cache size = 512KB , LRU (Cache replacement policy).
Array: int32_t A[2048][128]; so element size is 4 bytes.
for(int k=0, k<50, k++)
for(int i=0; i<2048; i+=Di)
for(int j=0; j<128; j+=Dj)
S += A[i][j]^k;
For which values of the constants Di and Dj can I get L1 hit rate = 75% and L2 hit rate bigger than 90%?
I tried to do the following:
I know that for L1 cache the address is: offset = 5 bits, set = 9 bits.
And hence, after 2^14 B = 2^12 elements we arrive to same set (but in other way).
and in L2 cache: offset = 5 bits, set = 13 bits.
And hence, after 2^18 B = 2^16 elements we arrive to same set (but in other way).
And because that we want L1 hit rate = 3/4 . So we will take Dj=2. And so we will get for any 4 elements: miss, hit, hit, hit. (any block of L1 can contain 8 elements).
But I don't know how to decide value for Di.