Question: Homework Description This problem focuses on execution time analysis. Consider the C program listed below: ` ` ` int arr 1 [ 2 5 6

Homework Description
This problem focuses on execution time analysis. Consider the C program listed below:
```
int arr1[256];
int arr2[256];
int foo(int flag){
int i;
int sum =0;
if (flag){
for(i=0;i256;i++){
arr1[i]= i;
arr2[i]=2*i;
}
}
for(i=0;i256;i++)
sum += arr2[i]-arr1[i];
return sum;
}
```
Assume that this program is run on a processor with a data cache of 4096 bytes. Each block of the cache is 128 bytes. Memory addresses are of 32 bits. Data in arr1 and arr2 are stored in contiguous memory locations, i.e., in a sequence as arr1[0], arr1[1],...., arr1[255], arr2[0], arr2[1],.., arr2[255].
(a) How many paths does the function foo() of this program have? Describe what they are.
(b) If the cache is a direct mapped cache, how many bits in a 32-bit address are used for block offset, set index and tag, respectively?
(c) Let \( T \) denote the execution time of the second for loop in the program. How does executing the first for loop affect the value of \( T \)? Explain your answer.
The following question is for EECE. 5520 students only:
(d) if the cache is a two-way associative cache (which has two cache blocks in a set), would the cache benefit this foo() function? Explain your answer.
Requirement
Please show your work and include as much details as possible.
Homework Description This problem focuses on

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!