Question: 3. Suppose you are given code to analyze and optimize. The code consists of two functions f1() and f2(). Upon running a code profiler, the

3. Suppose you are given code to analyze and optimize. The code consists of two functions f1() and f2(). Upon running a code profiler, the analysis shows that 70% of the execution time is used by f1() and the remainder by f2(). You now have a choice to modify one of the functions to speed up your codes performance.

Using Excel, create a spreadsheet as shown to show the overall speedup when f1() and f2() are optimized to run faster (Speedup is defined by Amdahls law). Show the overall speedup as the individual functions are optimized to run 1x, 2x, 3x, 20x their original speed.

Plot a line chart depicting the speedup of both f1() and f(2). (X-axis: Optimization level; Y-axis: Overall speedup)

4. Consider the following nested loop code:

for i=1:4

for j=1:2

code to execute

end

end

For the inner loop, use each of the following branch predictors, compute the number of mis-predictions for each and determine the best predictor.

a. An always take Static Predictor

b. A (1,1) dynamic predictor that initially does not take the branch.

c. A (1,2) dynamic predictor that initially does not take the branch.

d. A (1,1) dynamic predictor that initially takes the branch.

e. A (1,2) dynamic predictor that initially takes the branch.

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 Databases Questions!