How Bill would solve "The Performing CPU" problem.
We could go with the answer is yes by inspection, but I don't think Dr. Hugue would be pleased.
A. Where do the numbers in the top table come from?
A bunch of programs, or a single program, are run on this ISA. The number of each instruction is counted and the number of clock cycles each instruction required is measured. A table is then created to show the frequency of each instruction type as a percentage and the average number of clock cycles each instruction type took.
So we get:
Instruction Type Frequency
Clock cycles
ALU
. 44
1
Load
. 21
2
Store
. 12
2
Branch
. 23
2
B. How Dr. Hugue looks at it.
She has a doctorate. She is theoretical. She taught math. She wants to give you a framework that can be used to solve any problem.
C. How Bill looks at it.
I don't have a doctorate. I live in the real world. I get dirt under my fingernails. I don't like working with fractions or percentages. I want to solve problems of this specific type as quickly and easily as possible. Did I say I don't like working with fractions or percentages.
D. How Bill solves this type of problem.
To get rid of the percentages, I create an "average" program with 100 instructions. My table the becomes:
Instruction Type Number
Clock cycles
ALU
44
1
Load
21
2
Store
12
2
Branch
23
2
Now I look at the rest of the problem and pull out the needed information. Warning! This was the hardest part of taking Dr. Hugue's exams for me. Cut out the fluff and read what the question is really asking.
The ISA modification
1. Replaces one fourth of
ALU instructions with new ALU instruction paired with a load operand.
What this means to me.
New ISA looks like this
ALU
ALU2
Store
Branch
Modifying my "average" program numbers for the new ALU2 instruction:
Instruction Type Number
(old) Number (new)
ALU
44
33
Lost one fourth, replaced by ALU2
ALU2
did not exist
11
The replaced instructions
Load
21
10
The 11 ALU2's replace 11 of the Loads
Store
12
12
No Change
Branch
23
23
No Change
2. The average number of
cycles needed for a Branch instruction is increased to 3
Remember this for later!
3. An optimizing compiler
gets rid of one third of the remaining ALU (not ALU2) instructions.
Instruction Type Number (old)
Number(new) Number (new with compiler optimization)
ALU
44
33
22
One third optimized out
ALU2
did not exist
11
11
Load
21
10
10
Store
12
12
12
Branch
23
23
23
4. My old table with the
new table. (note: Dr. Hugue did all of the above and this for you, but
she might not for the
exam. That is why
I did it as well.
Instruction Type Number (final new)
Clock Cycles
ALU
22
1
ALU2
11
1
Load
10
2
Store
12
2
Branch
23
3
Instruction Type Number
Clock cycles
ALU
44
1
Load
21
2
Store
12
2
Branch
23
3
E. Plug and chug in equations
Exec Time (old)
IC(old) * CPI(old) * CCT(old)
Speed Up = ---------------------
= ---------------------------------------------
Exec Time(new)
IC(new) * CPI(new) * CCT(new)
This problem did not change the clock cycle time or clock rate so:
CCT(old) = CCT(new) and this cancels out of our equation.
Exec(old) IC(old)
* CPI(old)
Speed Up = -------------
= ----------------------------
Exec(new) IC(new) * CPI(new)
We could figure out the average CPI for both the old and the new ISA, but I hate fractions, so let's do it this way.
Note: all the CPI's are average.
Exec Time =
{IC(alu) * CPI(alu) + IC(load) * CPI(load) + IC(store) * CPI(store) + IC(branch)
*CPI(branch)} * CCT
We know the CCT cancelled out.
Exec(old)
44 * 1 + 21 * 2 * + 12 * 2 + 23 * 2
156
Speed Up = -------------
= ---------------------------------------------------
= ---- = 1.068
Exec(new)
22 * 1 + 11 * 1 + 10 * 2 + 12 * 2 + 23 * 3
146
Speed up is greater than one, so the answer is yes.