A compiler designer is deciding between two code snips [ # 1 and #2] for a certa
ID: 3692059 • Letter: A
Question
A compiler designer is deciding between two code snips [ # 1 and #2] for a certain setup. The hardware designers have this data about the CPI for each class, and instruction counts for each code sequence
CLASS CPI for this instruction class
A 2
B 3
code instruction counts for
snips instruction classes
1 A=2, B = 6
2 A=7, B =4
How many cycles are required for each code snips?
Which is faster and by how much?
What is the CPI for each code snip?
Explanation / Answer
1 code snip has A=2 and B=6 so total time will be 2/2 + 6/3 = 3 units
2 code snip has A=7 and B=4 so total 7/2 + 4/3=4.83 units.
To execute snip 1 we will need 3 units of time.
For snip 2 we will need 4.83 units of time.
Snip 1 is faster to execute compared to snip 2.
cpi for snip 1 will be 8/3=2.66
cpi for snip 2 will be 11/4.83 = 2.27
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.