1. The following code is written in C, where elements of an array are allocated contiguously. Arrays a has 1024x1024 elements. Arrays b and c have 1024 elements respectively. Assume each element of arrays is a 4-byte (32-bit) integer. The data type of all variables is a 4-byte integer also. Cache blocks are allocated on write miss, and the size of a cache line is 64 bytes. Assume that cache size is infinite (what?). (Hint: in this code, there are 6 variables: a, b, c, i, j, and sum) [12 pts total]
int sum;
for (int i = 0; i < 1024; i++)
{
sum = 0;
for (int j = 0; j < 1024; j++)
sum += a[j+i*1024] + b[j];
c[i] = sum;
}
(a) Which variable references exhibit temporal locality? [3 pts]
(b) Which variable references exhibit spatial locality? [3 pts]
(c) Let's focus on the data transfers for arrays a, b, and c. How many 1w and sw instructions are issued while executing this code? [3 pts]
Array a:
Array b:
Array c: