typedef int array[2][2];
void transpose(array dst, array src) {
int i, j;
for (j = 0; j < 2; j++) {
for (i = 0; i < 2; i++) {
dst[i][j] = src[j][i];
}
}
}
src array starts at address 0 and the dst array starts at address 0x10.
L1 data cache, direct map, write-allocate, 8 byte block size.
cache total size is 16 data bytes.
What is the hit or miss on each entry of src and dst array?
The answer is:
src:
[0][0] -> miss,
[0][1] -> miss,
[1][0] -> miss,
[1][1] -> hit
dst:
[0][0] -> miss,
[0][1] -> miss,
[1][0] -> miss,
[1][1] -> miss
If the cache total size is 32 data bytes, the answer is:
src:
[0][0] -> miss,
[0][1] -> hit,
[1][0] -> miss,
[1][1] -> hit
dst:
[0][0] -> miss,
[0][1] -> hit,
[1][0] -> miss,
[1][1] -> hit
I am unsure of both outcomes. I don't really understand the concept with arrays and caching.