Homework 1
Homework 1
Homework 1
Consider computing the overall CPI for a machine A for which the following
performance measures were recorded when executing a set of benchmark
programs. Assume that the clock rate of the CPU is 200 MHz.
Instruction category Percentage of occurrence No. of cycles per
instruction
ALU 38 1
Load & store 15 3
Branch 42 4
Others 5 5
Assuming the execution of 100 instructions,
- What is machine A’s CPI?
- What is machine A’s MIPS?
Given data:
+, clock rate 200 MHz
Find: CPI and MIPS
CPI (Cycles Per Instruction) = ∑(Execution Time / Instruction Count)
Overall CPI = 0.38*1 + 0.15*3 + 0.42*4 + 0.05*5 = 2.76
MIPS= Clock Rate (MHz) / CPI = 200 / 2.76 = 72.46
2. Suppose that the same set of benchmark programs considered above were executed
on another machine, call it machine B, for which the following measures were
recorded.
Instruction category Percentage of occurrence No. of cycles per
instruction
ALU 35 1
Load & store 30 2
Branch 15 3
Others 20 5
What is the MIPS rating for the machine considered in the previous example
(machine A) and machine B assuming a clock rate of 400 MHz?
Given data:
+, Machine A : Clock rate of 200Mhz
+, Machine B : Clock rate of 400 MHz
Find: CPI(B) and MIPS(A)
CPI (Cycles Per Instruction) = ∑(Execution Time / Instruction Count)
Overall CPI = 0.35*1 + 0.3*2 + 0.15*3 + 0.2*5 = 2.4
MIPS = Clock Rate (MHz) / CPI
For machine A : 400 / 2.76 = 144.93
For machine B : 400 / 2.4 = 166.67
3. Consider a machine with three instruction classes and CPI measurements as follows:
Instruction class CPI of the instruction class
A 2
B 5
C 7
Suppose that we measured the code for a given program in two different compilers and
obtained the following data:
Instruction counts (in millions)
Code sequence
A B C
1 15 5 3
2 25 2 2
Assume that the machine’s clock rate is 500 MHz.
a. Which code sequence will execute faster according to MIPS?
b. How much according to the execution time of each code sequence?
Given data:
+, Machine clock rate is 500 Mhz
Find:
Total Number of Cycles for Each Code Sequence:
Code Sequence 1:
1. Class A cycles: 15 * 2=30 (million cycles)
2. Class B cycles: 5 * 5 = 25 (million cycles)
3. Class C cycles: 3 * 7 = 21 (million cycles)
Total cycles for Code sequence 1: 30 + 25 + 21 = 76 (million cycles)
Code Sequence 2:
1. Class A cycles: 25 * 2 = 50 (million cycles)
2. Class B cycles: 2 * 5 = 10 (million cycles)
3. Class C cycles: 2 * 7 = 14 (million cycles)
Total cycles for Code sequence 1: 50 + 10 + 14 = 74 (million cycles)
Execution Time = Clock Rate / Total Cycles
Execution Time for Code Sequence 1:
4. A compiler designer is trying to decide between two code sequences for a particular
machine. The hardware designers have supplied the following facts:
Instruction class CPI of the instruction class
A 1
B 3
C 4
For a particular high-level language, the compiler writer is considering two sequences that
require the following instruction counts:
Instruction counts (in millions)
Code sequence
A B C
1 2 1 2
2 4 3 1
a. What is the CPI for each code sequence?
b. Which code sequence is faster? By how much?
ANS:
CPI = SUM of INSTRUCTION COUNTS of EACH CLASS
a.
- EXECUTION TIME per PROCESSOR =
TOTAL CYCLE/FREQUENCY
= 1.8342*10^10/(2*10^9)
= 9.216(s)
- With 1 processor: 9.216(s)
- With 2 processors: 4.608(s)
- With 4 processors: 2.304(s)
- With 8 processors: 1.152(s)
c.
- We consider L/S CPI before adjusting is
CPI1; after adjusting is CPI2
- In order to find CPI2, execution time
on single processor with CPI2 =
execution time on 4 processors with
CPI1
*With CPI1
- Based on the results in a., we know the
execution time = 2.304(s) → (1)
*With CPI2
- Execution time = [A.C + B.C
+L/S.C(new)]/(2*10^9) →(2)
6. Assume that a switching component such as a transistor can switch in zero time. We
propose to construct a disk-shaped computer chip with such a component. The only
limitation is the time it takes to send electronic signals from one edge of the chip to
the other. Make the simplifying assumption that electronic signals can travel at
300,000 kilometers per second.
a.What is the limitation on the diameter of a round chip so that any computation
result can be used anywhere on the chip at a clock rate of 1 GHz?
b.What are the diameter restrictions if the whole chip should operate at 1THz =
1012Hz?
c. Is such a chip feasible?
a. From the given data, we know that each clock lasts for 1/1GHz = 10^-9 (s)
- We know that MAXIMUM DISTANCE = Speed * Time, whereas Time is the delay for
the electronics signal from one edge to other
=> MAXIMUM DISTANCE = 300,000 * 10^-9 = 0.3 (mm)
b. Time = 1/10^12=10^-12(s)
=> Maximum distance = 0.3*10^-6(m)
=> Diameter = 0.6*10^-6(m)
c. No since with the current technology, we cannot create a chip with a specified
diameter restriction for operation at 1Thz
7. Consider having a program that runs in 50 s on computer A, which has a 500 MHz
clock. We would like to run the same program on another machine, B, in 20 s. If
machine B requires 2.5 times as many clock cycles as machine A for the same
program, what clock rate must machine B have in MHz?
8. Suppose that we have two implementations of the same instruction set architecture.
Machine A has a clock cycle time of 50 ns and a CPI of 4.0 for some program, and
machine B has a clock cycle of 65 ns and a CPI of 2.5 for the same program. Which
machine is faster and by how much?
We know that CPU time = Instruction counts * CPI * Clock cycle time
At here because we don’t know exactly how many instructions are there and two
implementations of the same instruction set, so I will call N is the number of
instructions in this case
Plug it to formula:
- CPU time of A = N * 4.0 * 50 * 10^-9 = 2 * 10^-7
- CPU time of B = N * 2.5 * 65 * 10^-9 = 1.625 * 10^-7
To know which machine is faster, we can calculate ratio of two CPU times:
=> A / B = 1.23 time
=> Machine B is faster 1.23 time than machine A
9. Consider three different processors P1, P2, and P3 executing the same instruction
set. P1 has a 3 GHz clock rate and a CPI of 1.5. P2 has a 2.5 GHz clock rate and a CPI
of 1.0. P3 has a 4.0 GHz clock rate and has a CPI of 2.2.
a. Which processor has the highest performance expressed in instructions per
second?
- Way 1 (my solution):
And we know that, the smaller CPU time is, the faster and more efficient machine is,
so from that we can decide that P2 has the highest performance
You can see that IPS1 = IPS2, from here we will base on CPI and you already know
that the smaller CPI, the better machine is
=> P2 has the highest performance
b. If the processors each execute a program in 10 seconds, find the number of cycles
and the number of instructions.
N1 = 2 * 10^10
N2 = 2.5 * 10^10
N3 = 1.81 * 10^10
c. We are trying to reduce the execution time by 30% but this leads to an increase of
20% in the CPI. What clock rate should we have to get this time reduction?
10. Consider two different implementations of the same instruction set architecture. The
instructions can be divided into four classes according to their CPI (class A, B, C, and
D). P1 with a clock rate of 2.5 GHz and CPIs of 1, 2, 3, and 3, and P2 with a clock rate
of 3 GHz and CPIs of 2, 2, 2, and 2. Given a program with a dynamic instruction count
of 1.0E6 instructions divided into classes as follows: 10% class A, 20% class B, 50%
class C, and 20% class D, which implementation is faster?
a. What is the global CPI for each implementation?
To calculate the global CPI, we consider the average CPI weighted by the percentage
of instructions in each class.
+ Implementations P1
● Instruction classes and CPIs:
○ A: 1 CPI
○ B: 2 CPI
○ C: 3 CPI
○ D: 3 CPI
● Instruction mix:
○ A: 10%
○ B: 20%
○ C: 50%
○ D: 20%
P1 CPI = 2.6
+ Implementations P2
P2 CPI = 2
We have a formula:
CPI (Cycles Per Instruction) = Execution Time * Clock Cycle / Instruction Count
→ For Compiler A:
= 1.1 cycles/instruction
→ For Compiler B:
= 1.25 cycles/instruction
b. Assume the compiled programs run on two different processors. If the execution
times on the two processors are the same, how much faster is the clock of the
processor running compiler A’s code versus the clock of the processor running
compiler B’s code?
If the execution time on the two processors are the same, then the clock cycles for
each processor can be calculated using the formula:
→ Therefore, the clock of the processor running Compiler A's code is 1.37 times
faster than the clock of the processor running Compiler B's code.
c. A new compiler is developed that uses only 6.0E8 instructions and has an average
CPI of 1.1. What is the speedup of using this new compiler versus using compiler A or
B on the original processor?
= 6.6 ns
Speedup:
● Speedup is the ratio of the original execution time to the new execution time.
● Speedup_A = Original Execution Time_A / New Compiler Execution Time
→ The new compiler offers significant speedup compared to both Compiler A and B.
12. Assume for arithmetic, load/store, and branch instructions, a processor has CPIs of 1,
12, and 5, respectively. Also assume that on a single processor a program requires
the execution of 2.56E9 arithmetic instructions, 1.28E9 load/store instructions, and
256 million branch instructions. Assume that each processor has a 2 GHz clock
frequency.
Assume that, as the program is parallelized to run over multiple cores, the number of
arithmetic and load/store instructions per processor is divided by 0.7 x p (where p is
the number of processors) but the number of branch instructions per processor
remains the same.
a. Find the total execution time for this program on 1, 2, 4, and 8 processors, and
show the relative speedup of the 2, 4, and 8 processor result relative to the
single processor result.
n
We have formula: Clock Cycles = ∑ ❑(CPI i∗Instruction Count i )
i=1
Clock Cycles
Execution Time per processor =
Clock frequency
CPI (Cycles Per Instruction) is a measure of how many clock cycles a processor takes to
execute one instruction.
a)
Given:
Assuming the original instruction count for the SPEC benchmark was 2.389 * 10^12:
b)
The Cycle per Instruction (CPI) is based on the architecture of the processor and the
Program
13) The results of the SPEC CPU2006 bzip2 benchmark running on an AMD Barcelona has
an instruction count of 2.389E12, an execution time of 750 s, and a reference time of 9650 s.
a) Find the CPI if the clock cycle time is 0.333 ns.
b) Find the SPECratio.
c) Find the increase in CPU time if the number of instructions of the benchmark is
increased by 10% without affecting the CPI.
d) Find the increase in CPU time if the number of instructions of the benchmark is
increased by 10% and the CPI is increased by 5%.
e) Find the change in the SPECratio for this change.
f) Suppose that we are developing a new version of the AMD Barcelona processor
with a 4 GHz clock rate. We have added some additional instructions to the
instruction set in such a way that the number of instructions has been reduced by
15%. The execution time is reduced to 700 s and the new SPECratio is 13.7. Find
the new CPI.
g) This CPI value is larger than obtained in 1.11.1 as the clock rate was increased from
3 GHz to 4 GHz. Determine whether the increase in the CPI is similar to that of the
clock rate. If they are dissimilar, why?
h) By how much has the CPU time been reduced? 58 Chapter 1 Computer
Abstractions and Technology
i) For a second benchmark, libquantum, assume an execution time of 960 ns, CPI of
1.61, and clock rate of 3 GHz. If the execution time is reduced by an additional 10%
without affecting the CPI and with a clock rate of 4 GHz, determine the number of
instructions.
j) Determine the clock rate required to give a further 10% reduction in CPU time while
maintaining the number of instructions and with the CPI unchanged.
k) Determine the clock rate if the CPI is reduced by 15% and the CPU time by 20%
while the number of instructions is unchanged
c) Find the increase in CPU time if the number of instructions is increased by 10%
without affecting the CPI.
d) Find the increase in CPU time if the number of instructions is increased by 10% and
the CPI is increased by 5%.
f) Find the new CPI for the new version of the AMD Barcelona processor.
g) Determine whether the increase in the CPI is similar to that of the clock rate. If they
are dissimilar, why?
The increase in CPI (from 0.942 to 1.38) is not proportional to the increase in clock rate
(from 3 GHz to 4 GHz). Possible reasons include:
● Total Clock Cycles = Execution Time * Clock Rate = 960 x 10^-9 s * 3 x 10^9
cycles/s = 2880 cycles
● Number of Instructions = Total Clock Cycles / CPI = 2880 cycles / 1.61 = 1790
instructions
j) Determine the clock rate required to give a further 10% reduction in CPU time while
maintaining the number of instructions and with the CPI unchanged.
k) Determine the clock rate if the CPI is reduced by 15% and the CPU time by 20%
while the number of instructions is unchanged.