Question: Consider the following segment of C code #define SIZE 1000 int a[SIZE], b[SIZE]; int i, j; for (i = 0; i < SIZE; i++)

 Consider the following segment of C code #define SIZE 1000 int a[SIZE],  

Consider the following segment of C code #define SIZE 1000 int a[SIZE], b[SIZE]; int i, j; for (i = 0; i < SIZE; i++) { j = SIZE - Ei; a[i] = b[j]; } for (i = 0; i < SIZE; i++) { (i + SIZE/2) % SIZE; a[i]= a[i] b[j]; j } Assume that an ints are 32 bits long. (a) References to which variable(s) exhibit temporal locality in this code? Remember that each element of an array is a variable. (b) References to which variable(s) exhibit spatial locality in this code? (c) The cache of the system executing this code consists of 256 blocks, and each block can hold 16 bytes. How many bytes can fit into this cache at one time? (d) Ignoring instructions, and assuming that a and b are stored adjacent to each other in memory, how large would the cache have to be to hold the entire contents of both arrays at the same time? Give your answer in bytes, KiB, or MiB, as appropriate.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!