CSE331 Computer Organization
Problem Session #1
23/10/2023
Prepared by: Res. Asst. Sibel Gülmez
Computer Performance: Clock Cycle
1 Clock Cycle Positive Edge Negative Edge
Time
Computer Performance: Vocabulary
CPU Time: The time period CPU requires to complete a task.
CPU Clock Cycles: The number of clock cycles CPU requires to
complete a task.
Clock Rate (or Clock Speed): The number of clock cycles per
second.
Clock Cycle Time: Seconds per clock cycle.
CPI (Cycle per Instruction): The number of clock cycles the CPU
needs to execute an instruction.
Computer Performance: Formulas
Clock Cycle Time = 1 / (Clock Rate)
Clock Rate = 1 / (Clock Cycle Time)
CPI = (CPU Clock Cycles) / (Instruction Count)
CPU Time = (CPU Clock Cycles) * Clock Cycle Time
= (CPU Clock Cycles) / Clock Rate
= (CPI * Instruction Count)
* Clock Cycle Time = (CPI * Instruction Count)
/ Clock Rate
Computer Performance: CPU Time
CPU Time = (Instructions / Program) * (Clock Cycles / Instruction) * (Seconds / Clock Cycle)
How many instructions does the program has?
How many clock cycles are needed to execute an instruction?
How many seconds are needed for a clock cycle?
Computer Performance: Example 1
Question:
- CPU clock rate is 500 MHz
- Program takes 45 million cycles to execute
What’s the CPU time?
Computer Performance: Example 1
Question:
- CPU clock rate is 500 MHz
- Program takes 45 million cycles to execute
What’s the CPU time?
Answer:
500 MHz CR means that the CPU can execute 500 * 10^6 clock cycles per second.
Computer Performance: Example 1
Question:
- CPU clock rate is 500 MHz
- Program takes 45 million cycles to execute
What’s the CPU time?
Answer:
500 MHz CR means that the CPU can execute 500 * 10^6 clock cycles per second.
CPU Time = Clock Cycles / Clock Rate
Computer Performance: Example 1
Question:
- CPU clock rate is 500 MHz
- Program takes 45 million cycles to execute
What’s the CPU time?
Answer:
500 MHz CR means that the CPU can execute 500 * 10^6 clock cycles per second.
CPU Time = Clock Cycles / Clock Rate = 45 M / 500 M = 0,09
Computer Performance: Example 1
Question:
- CPU clock rate is 500 MHz
- Program takes 45 million cycles to execute
What’s the CPU time?
Answer:
500 MHz CR means that the CPU can execute 500 * 10^6 clock cycles per second.
CPU Time = Clock Cycles / Clock Rate = 45 M / 500 M = 0,09
Unit of Measure?
Computer Performance: Example 1
Question:
- CPU clock rate is 500 MHz
- Program takes 45 million cycles to execute
What’s the CPU time?
Answer:
500 MHz CR means that the CPU can execute 500 * 10^6 clock cycles per second.
CPU Time = Clock Cycles / Clock Rate = 45 M / 500 M = 0,09
Unit of Measure?
CPU Time = (45 M cycles) / (500 M cycles/second) = 0,09 seconds
Computer Performance: Example 2
Question:
Compute CPI for Program A and Program B considering the following information.
Instruction Type R Type I Type J Type
CPI 4 3 2
Program A 5 Instructions 2 Instructions 2 Instructions
Program B 2 Instructions 5 Instructions 5 Instructions
Computer Performance: Example 2
Question:
Compute CPI for Program A and Program B considering the following information.
Instruction Type R Type I Type J Type
CPI 4 3 2
Program A 5 Instructions 2 Instructions 2 Instructions
Program B 2 Instructions 5 Instructions 5 Instructions
Answer (Program A):
5 R Type Instructions
2 I Type Instructions
2 J Type Instructions
Computer Performance: Example 2
Question:
Compute CPI for Program A and Program B considering the following information.
Instruction Type R Type I Type J Type
CPI 4 3 2
Program A 5 Instructions 2 Instructions 2 Instructions
Program B 2 Instructions 5 Instructions 5 Instructions
Answer (Program A):
5 R Type Instructions -> Requires 5*4 = 20 cycles
2 I Type Instructions -> Requires 2*3 = 6 cycles
2 J Type Instructions -> Requires 2*2 = 4 cycles
Computer Performance: Example 2
Question:
Compute CPI for Program A and Program B considering the following information.
Instruction Type R Type I Type J Type
CPI 4 3 2
Program A 5 Instructions 2 Instructions 2 Instructions
Program B 2 Instructions 5 Instructions 5 Instructions
Answer (Program A):
5 R Type Instructions -> Requires 5*4 = 20 cycles
2 I Type Instructions -> Requires 2*3 = 6 cycles
2 J Type Instructions -> Requires 2*2 = 4 cycles
Program A has 5 + 2 + 2 = 9 instructions and it requires 20 + 6 + 4 = 30 cycles.
Computer Performance: Example 2
Question:
Compute CPI for Program A and Program B considering the following information.
Instruction Type R Type I Type J Type
CPI 4 3 2
Program A 5 Instructions 2 Instructions 2 Instructions
Program B 2 Instructions 5 Instructions 5 Instructions
Answer (Program A):
5 R Type Instructions -> Requires 5*4 = 20 cycles
2 I Type Instructions -> Requires 2*3 = 6 cycles
2 J Type Instructions -> Requires 2*2 = 4 cycles
Program A has 5 + 2 + 2 = 9 instructions and it requires 20 + 6 + 4 = 30 cycles.
CPI = (Clock Cycles) /(Instruction Count)
Computer Performance: Example 2
Question:
Compute CPI for Program A and Program B considering the following information.
Instruction Type R Type I Type J Type
CPI 4 3 2
Program A 5 Instructions 2 Instructions 2 Instructions
Program B 2 Instructions 5 Instructions 5 Instructions
Answer (Program A):
5 R Type Instructions -> Requires 5*4 = 20 cycles
2 I Type Instructions -> Requires 2*3 = 6 cycles
2 J Type Instructions -> Requires 2*2 = 4 cycles
Program A has 5 + 2 + 2 = 9 instructions and it requires 20 + 6 + 4 = 30 cycles.
CPI = (Clock Cycles) /(Instruction Count) = 30 / 9 = 3,333
Computer Performance: Example 2
Question:
Compute CPI for Program A and Program B considering the following information.
Instruction Type R Type I Type J Type
CPI 4 3 2
Program A 5 Instructions 2 Instructions 2 Instructions
Program B 2 Instructions 5 Instructions 5 Instructions
Answer (Program B):
2 R Type Instructions
5 I Type Instructions
5 J Type Instructions
Computer Performance: Example 2
Question:
Compute CPI for Program A and Program B considering the following information.
Instruction Type R Type I Type J Type
CPI 4 3 2
Program A 5 Instructions 2 Instructions 2 Instructions
Program B 2 Instructions 5 Instructions 5 Instructions
Answer (Program B):
2 R Type Instructions -> Requires 2*4 = 8 cycles
5 I Type Instructions -> Requires 5*3 = 15 cycles
5 J Type Instructions -> Requires 5*2 = 10 cycles
Computer Performance: Example 2
Question:
Compute CPI for Program A and Program B considering the following information.
Instruction Type R Type I Type J Type
CPI 4 3 2
Program A 5 Instructions 2 Instructions 2 Instructions
Program B 2 Instructions 5 Instructions 5 Instructions
Answer (Program B):
2 R Type Instructions -> Requires 2*4 = 8 cycles
5 I Type Instructions -> Requires 5*3 = 15 cycles
5 J Type Instructions -> Requires 5*2 = 10 cycles
Program B has 2 + 5 + 5 = 12 instructions and it requires 8 + 15 + 10 = 33 cycles.
CPI = (Clock Cycles) /(Instruction Count)
Computer Performance: Example 2
Question:
Compute CPI for Program A and Program B considering the following information.
Instruction Type R Type I Type J Type
CPI 4 3 2
Program A 5 Instructions 2 Instructions 2 Instructions
Program B 2 Instructions 5 Instructions 5 Instructions
Answer (Program B):
2 R Type Instructions -> Requires 2*4 = 8 cycles
5 I Type Instructions -> Requires 5*3 = 15 cycles
5 J Type Instructions -> Requires 5*2 = 10 cycles
Program B has 2 + 5 + 5 = 12 instructions and it requires 8 + 15 + 10 = 33 cycles.
CPI = (Clock Cycles) /(Instruction Count) = 33 / 12 = 2,75
Computer Performance: Example 3
Question: Assume Program A is being executed on a 500 MHz CPU and Program B
on a 400 MHz CPU. Calculate which Program is faster and how much faster?
Instruction Type R Type I Type J Type
CPI 4 3 2
Program A 5 Instructions 2 Instructions 2 Instructions
Program B 2 Instructions 5 Instructions 5 Instructions
Computer Performance: Example 3
Question: Assume Program A is being executed on a 500 MHz CPU and Program B
on a 400 MHz CPU. Calculate which Program is faster and how much faster?
Instruction Type R Type I Type J Type
CPI 4 3 2
Program A 5 Instructions 2 Instructions 2 Instructions
Program B 2 Instructions 5 Instructions 5 Instructions
Answer: CPU Time= (CPU Clock Cycles) / Clock Rate
Computer Performance: Example 3
Question: Assume Program A is being executed on a 500 MHz CPU and Program B
on a 400 MHz CPU. Calculate which Program is faster and how much faster?
Instruction Type R Type I Type J Type
CPI 4 3 2
Program A 5 Instructions 2 Instructions 2 Instructions
Program B 2 Instructions 5 Instructions 5 Instructions
Answer: CPU Time= (CPU Clock Cycles) / Clock Rate
Clock Rate (A) = 400 MHz = 400*10^6 seconds
Computer Performance: Example 3
Question: Assume Program A is being executed on a 500 MHz CPU and Program B
on a 400 MHz CPU. Calculate which Program is faster and how much faster?
Instruction Type R Type I Type J Type
CPI 4 3 2
Program A 5 Instructions 2 Instructions 2 Instructions
Program B 2 Instructions 5 Instructions 5 Instructions
Answer: CPU Time= (CPU Clock Cycles) / Clock Rate
Clock Rate (A) = 500 MHz = 500*10^6 seconds
Clock Rate (B) = 400 MHz = 400*10^6 seconds
Computer Performance: Example 3
Question: Assume Program A is being executed on a 500 MHz CPU and Program B
on a 400 MHz CPU. Calculate which Program is faster and how much faster?
Instruction Type R Type I Type J Type
CPI 4 3 2
Program A 5 Instructions 2 Instructions 2 Instructions
Program B 2 Instructions 5 Instructions 5 Instructions
Answer: CPU Time= (CPU Clock Cycles) / Clock Rate
Clock Rate (A) = 500 MHz = 500*10^6 seconds
Clock Rate (B) = 400 MHz = 400*10^6 seconds
CPU Time (A) = 30 / 500*10^6 = 0,600*10^-7 seconds
CPU Time (B) = 33 / 400*10^6 = 0,825*10^-7 seconds
Computer Performance: Example 3
Question: Assume Program A is being executed on a 500 MHz CPU and Program B
on a 400 MHz CPU. Calculate which Program is faster and how much faster?
Instruction Type R Type I Type J Type
CPI 4 3 2
Program A 5 Instructions 2 Instructions 2 Instructions
Program B 2 Instructions 5 Instructions 5 Instructions
Answer: CPU Time= (CPU Clock Cycles) / Clock Rate
Clock Rate (A) = 500 MHz = 500*10^6 seconds
Clock Rate (B) = 400 MHz = 400*10^6 seconds
CPU Time (A) = 30 / 500*10^6 = 0,600*10^-7 seconds -> Program A is faster.
CPU Time (B) = 33 / 400*10^6 = 0,825*10^-7 seconds
Computer Performance: Example 3
Question: Assume Program A is being executed on a 500 MHz CPU and Program B
on a 400 MHz CPU. Calculate which Program is faster and how much faster?
Instruction Type R Type I Type J Type
CPI 4 3 2
Program A 5 Instructions 2 Instructions 2 Instructions
Program B 2 Instructions 5 Instructions 5 Instructions
Answer:
CPU Time (A) = 0,600*10^-7 seconds
CPU Time (B) = 0,825*10^-7 seconds
Computer Performance: Example 3
Question: Assume Program A is being executed on a 500 MHz CPU and Program B
on a 400 MHz CPU. Calculate which Program is faster and how much faster?
Instruction Type R Type I Type J Type
CPI 4 3 2
Program A 5 Instructions 2 Instructions 2 Instructions
Program B 2 Instructions 5 Instructions 5 Instructions
Answer:
CPU Time (A) = 0,600*10^-7 seconds
CPU Time (B) = 0,825*10^-7 seconds
CPU Time (A) / CPU Time (B) =
Computer Performance: Example 3
Question: Assume Program A is being executed on a 500 MHz CPU and Program B
on a 400 MHz CPU. Calculate which Program is faster and how much faster?
Instruction Type R Type I Type J Type
CPI 4 3 2
Program A 5 Instructions 2 Instructions 2 Instructions
Program B 2 Instructions 5 Instructions 5 Instructions
Answer:
CPU Time (A) = 0,600*10^-7 seconds
CPU Time (B) = 0,825*10^-7 seconds
CPU Time (A) / CPU Time (B) = (0,600*10^-7 seconds) / (0,825*10^-7 seconds)
Computer Performance: Example 3
Question: Assume Program A is being executed on a 500 MHz CPU and Program B
on a 400 MHz CPU. Calculate which Program is faster and how much faster?
Instruction Type R Type I Type J Type
CPI 4 3 2
Program A 5 Instructions 2 Instructions 2 Instructions
Program B 2 Instructions 5 Instructions 5 Instructions
Answer:
CPU Time (A) = 0,600*10^-7 seconds
CPU Time (B) = 0,825*10^-7 seconds
CPU Time (A) / CPU Time (B) = (0,600*10^-7 seconds) / (0,825*10^-7 seconds)
~0,7273
Computer Performance: Example 3
Question: Assume Program A is being executed on a 500 MHz CPU and Program B
on a 400 MHz CPU. Calculate which Program is faster and how much faster?
Instruction Type R Type I Type J Type
CPI 4 3 2
Program A 5 Instructions 2 Instructions 2 Instructions
Program B 2 Instructions 5 Instructions 5 Instructions
Answer:
CPU Time (A) = 0,600*10^-7 seconds
CPU Time (B) = 0,825*10^-7 seconds
CPU Time (A) / CPU Time (B) = (0,600*10^-7 seconds) / (0,825*10^-7 seconds)
~0,7273
Program A works 1 / 0,7273 ~ 1,375 times faster than Program B.