Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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], 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Value at Risk The New Benchmark for Managing Financial Risk

Authors: Philippe Jorion

3rd edition

0070700427, 71464956, 978-0071464956

More Books

Students also viewed these Programming questions

Question

discuss the use of exercise as an adjunct to therapy.

Answered: 1 week ago