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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started