In the following C code elements of each row are stored cont
Solution
a) As we know Each 32-bit integer requires 4 bytes to store,
therefore EIGHT 32-bit integers can be stored in the 32-byte block. [8*32 = 32*8]
So the answer is 8.
b) During each iteration of the code A[j][i] = B[j][0] + A[i][j] . As we can see
The variables i and j and B[j][0] are constantly accessed, and they will remain in the cache for the entire duration when the code is executing because the CPU will assume, correctly, that is a piece of data is accessed, it will likely be accessed again very soon.
Note : B[j][0] is accessed 8000 times in a row and it is loaded multiples times in a cache.
c) Variables A[j][i] and B[j][0] exhibit spatial locality because multiple of them are loaded into cache on a single miss
Comsider the access sequence of A[j][i] and B[j][0]
A(0,0)=B(0,0)+A(0,0)
A(0,1,)=B(0,0)+A(1,0)
A(0,2)=B(0,0)+A(2,0)
Multiples of them will be loaded in Cache on A signle Miss , So it exhibit spatial locality.
Thanks, let me know if there is any concern.
