logo

Crowdly

Consider the following two pieces of pseudocode: // CODE 1: const int N ...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Consider the following two pieces of pseudocode:

// CODE 1: 

const int N = ...;

int X

[ n ] , Y [ N ] ; // (sizeof(int) = 1 word)

for ( int i = 0 ; i < N ; i ++ )

    Y

[ i ] = X [ i ] + i ;

// CODE 2:

const int N = ...;

int X

[ N ] , Y [ N ] ; // (sizeof(int) = 1 word)

for ( int i = 0 ; i < N ; i ++ )

    Y

[ i ] = X [ 0 ] + i ;

 

  • Let us illustrate, in general, the concepts of spatial and temporal locality in the execution of programs.
  • Which of the two code fragments exhibits greater locality of each kind?
  • What happens if the processor wants to access a memory word already present in the cache? And what happens if it isn't present?
  • What parameters should be considered when evaluating the performance of cache memories?
  • In a cache-based architecture, which of the two code fragments results in a greater number of cache hits?

More questions like this

Want instant access to all verified answers on informatica.i-learn.unito.it?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!