You are on page 1of 25

CPU BASICS AND

ORGANISATION
*Additional Performance Metrics
*Problem Solving

CompOrg 101 - Lec05 1


Common Prefixes used in
Measurements

CompOrg 101 - Lec05 2


Common Prefixes used in Measurements

CompOrg 101 - Lec05 3


Common Prefixes used in Measurements
Why do we use prefixes in measuring?

Some quantities are very, very large, or


very, very small. Using prefixes allows us
to write quantities in a faster/efficient
way, instead of writing down multiple 0s
or digits.

Vendors write down 5GHz, instead of


5,000,000,000 Hz. The former is easier to
read, even though both quantities are
equal.

CompOrg 101 - Lec05 4


Clocks
Clock Rate or Clock Speed
Clock Time or Clock Period

CompOrg 101 - Lec05 5


Clock Rates
▪ Clock rate refers to the frequency in which the processor’s clock
generator can generate pulses. These are used to synchronize the
operation of the computer
▪ It is measured in clock cycles per second or Hertz (Hz, 1/s, ccs)
▪ Personal computers (PCs) of the 1970s have clock rates in the MHz
range; clock rates of recent are in the GHz range.
▪ Specs related to the clock rate: instructions per cycle, cycles per
instruction, floating points per second

CompOrg 101 - Lec05 6


Clock Rates
▪ Discrete time intervals are called clock cycles (or ticks, clock ticks,
clock periods, clocks, cycles). Designers refer to the length of a clock
period both as the time for a complete clock cycle (e.g., 250 picoseconds,
or 250 ps) and as the clock rate (e.g., 4 gigahertz, or 4 GHz), which is the
inverse of the clock time.

▪ Q. Prefix pico- refers to how many zeros? ☺

CompOrg 101 - Lec05 7


Clock Rates
▪ Clock speed is measured in clock cycles per second or Hertz (Hz, 1/s)
▪ Clock speed (or clock rate) is inversely proportional to clock time.

1 1
𝑐𝑙𝑜𝑐𝑘 𝑟𝑎𝑡𝑒 =
𝑠 𝑐𝑙𝑜𝑐𝑘 𝑐𝑦𝑐𝑙𝑒 𝑡𝑖𝑚𝑒 𝑠

CompOrg 101 - Lec05 8


Clock Rates
▪ What is the clock rate/clock speed/frequency unit?
Hertz [Hz], clock cycles per second (ccs)

▪ Q. A 4GHz clock speed is equal to _____ ccs.


▪ A. The 4GHz clock speed has 4*10^9 ccs.

9
𝑐𝑙𝑜𝑐𝑘 𝑐𝑦𝑐𝑙𝑒𝑠 9
4 𝐺𝐻𝑧 = 4 ∗ 10 𝐻𝑒𝑟𝑡𝑧 = 4 ∗ 10 = 4 ∗ 109 𝑐𝑐𝑠
𝑠

CompOrg 101 - Lec05 9


Clock Rates
▪ Q. The clock rate of a PC is 12MHz. How many clock cycles per second
are there?
▪ A. A PC with a 12MHz clock rate has 12*10^6 ccs.

6
𝑐𝑙𝑜𝑐𝑘 𝑐𝑦𝑐𝑙𝑒𝑠 6
12 𝑀𝐻𝑧 = 12 ∗ 10 𝐻𝑒𝑟𝑡𝑧 = 12 ∗ 10 = 12 ∗ 106 𝑐𝑐𝑠
𝑠

CompOrg 101 - Lec05 10


Clock Time
▪ Clock rate refers to the frequency in which the processor’s clock
generator can generate pulses. Clock time refers to the clock period; it
is the reciprocal of clock rate.

1
𝑐𝑙𝑜𝑐𝑘 𝑡𝑖𝑚𝑒 𝑠 =
1
𝑐𝑙𝑜𝑐𝑘 𝑟𝑎𝑡𝑒
𝑠

CompOrg 101 - Lec05 11


Clock Time
▪ What is the clock time unit?
Clock time uses time units; most of the time, seconds is used, with an
addition of a prefix if the clock time is really small.

1
𝑐𝑙𝑜𝑐𝑘 𝑡𝑖𝑚𝑒 𝑠 =
1
𝑐𝑙𝑜𝑐𝑘 𝑟𝑎𝑡𝑒
𝑠

CompOrg 101 - Lec05 12


Clock Time
▪ Q. A 1 GHz processor has a clock time of _____ s.
▪ A. The clock time is 1ns.

1 1 1
𝑐𝑙𝑜𝑐𝑘 𝑡𝑖𝑚𝑒 𝑠 = = = = 1 ∗ 10−9 𝑠 = 1 𝑛𝑎𝑛𝑜𝑠𝑒𝑐𝑜𝑛𝑑
1 1 𝐺𝐻𝑧 1
𝑐𝑙𝑜𝑐𝑘 𝑟𝑎𝑡𝑒 1 ∗ 109
𝑠 𝑠

CompOrg 101 - Lec05 13


Instructions
IPC/CPI

CompOrg 101 - Lec05 14


Instructions
▪ An instruction is a set of steps within a program.
▪ There are two performance metrics for instructions: Instruction per
Clock (IPC), and Clock per Instruction.
▪ IPC is the reciprocal of CPI. The average instruction to be executed takes
a number of CPI to be completed.

1
𝐶𝑃𝐼 =
𝐼𝑃𝐶
𝐶𝑙𝑜𝑐𝑘 1
=
𝑖𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛 𝐼𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛
𝐶𝑙𝑜𝑐𝑘

CompOrg 101 - Lec05 15


Instructions
▪ Q. A program running on a specific machine has a CPI of 2.5 clocks/instruction.
That means that one instruction needs 2.5 clocks to be executed.

▪ Q. A CPU has an IPC of 2.5 instruction/clock. What is the CPI of the CPU?
The CPI is the reciprocal of the IPC. Therefore, we need to get the inverse of IPC.
A. 2.5 IPC is equivalent to 0.4 CPI.

1
𝐶𝑃𝐼 =
𝐼𝑃𝐶
𝐶𝑙𝑜𝑐𝑘 1
=
𝑖𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛 𝐼𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛
𝐶𝑙𝑜𝑐𝑘
1
# 𝐶𝑃𝐼 = = 0.4 𝐶𝑃𝐼
2.5 𝐼𝑃𝐶

CompOrg 101 - Lec05 16


Program
CPU Time/Execution Time

CompOrg 101 - Lec05 17


Program
▪ A program is a collection of instructions performed by the processor for
a specific task.
▪ Q. A program can have n number of instructions, say, n = 10,000,000
▪ Therefore, we have 1/10,000,000 program/instruction.
▪ 1/10,000,000 = 100*10^-9

1 𝑝𝑟𝑜𝑔𝑟𝑎𝑚 1 𝑝𝑟𝑜𝑔𝑟𝑎𝑚 1 𝑝𝑟𝑜𝑔𝑟𝑎𝑚


= ∗ =
𝑛 𝑖𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛𝑠 𝑛 𝑖𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛 10,000,000 𝑖𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛

CompOrg 101 - Lec05 18


Execution Time
▪ CPU Time (or CPU Execution Time) is an important performance metric
for computer systems. This refers to the time between the start and the
end of execution of a given program.
▪ CPU Time depends on the following:
▪ CPU clock time (in s, seconds/cycle)
▪ CPI for the program (in cycles/instruction)
▪ Instruction count (no. of instructions within a program)

𝑒𝑥𝑒𝑐𝑢𝑡𝑖𝑜𝑛 𝑡𝑖𝑚𝑒 = 𝑖𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛 𝑐𝑜𝑢𝑛𝑡 ∗ 𝐶𝑃𝐼 ∗ 𝑐𝑙𝑜𝑐𝑘 𝑡𝑖𝑚𝑒

𝑖𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛𝑠 𝑐𝑦𝑐𝑙𝑒𝑠 𝑠𝑒𝑐𝑜𝑛𝑑𝑠 seconds


𝑒𝑥𝑒𝑐𝑢𝑡𝑖𝑜𝑛 𝑡𝑖𝑚𝑒 = ∗ ∗ =
𝑝𝑟𝑜𝑔𝑟𝑎𝑚 𝑖𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛 𝑐𝑦𝑐𝑙𝑒 program

CompOrg 101 - Lec05 19


Execution Time
▪ Q. (From previous examples). A program on a specific machine ABC has
the following parameters:
▪ 1 nanosecond clock time
▪ CPI of 4
▪ Instruction count = 10,000,000 instructions per program
▪ What is the execution time?
𝑒𝑥𝑒𝑐𝑢𝑡𝑖𝑜𝑛 𝑡𝑖𝑚𝑒 = 𝑖𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛 𝑐𝑜𝑢𝑛𝑡 ∗ 𝐶𝑃𝐼 ∗ 𝑐𝑙𝑜𝑐𝑘 𝑡𝑖𝑚𝑒

𝑖𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛𝑠 𝑐𝑙𝑜𝑐𝑘𝑠 𝑠𝑒𝑐𝑜𝑛𝑑


𝑒𝑥𝑒𝑐𝑢𝑡𝑖𝑜𝑛 𝑡𝑖𝑚𝑒 = 10𝑀 ∗ 4 ∗ 1𝑛
𝑝𝑟𝑜𝑔𝑟𝑎𝑚 𝑖𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛 𝑐𝑙𝑜𝑐𝑘
= 0.04 𝑠𝑒𝑐𝑜𝑛𝑑𝑠 𝑝𝑒𝑟 𝑝𝑟𝑜𝑔𝑟𝑎𝑚

CompOrg 101 - Lec05 20


Execution Time
▪ Q. (From previous examples). A program on a specific machine ABC has
the following parameters:
▪ 1 nanosecond clock time
▪ CPI of 4
▪ Instruction count = 10,000,000 instructions per program
▪ What is the execution time?
▪ A. Execution time = 0.04 seconds per program

CompOrg 101 - Lec05 21


Execution Time
▪ Q. A program on a specific machine XYZ has the following parameters:
▪ 4 GHz CPU
▪ 1 instruction per 6 clocks
▪ 12,000,000 instructions per program
▪ What is the execution time?
▪ Get the inverse of the clock speed and IPC.
𝑖𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛𝑠 𝑐𝑙𝑜𝑐𝑘𝑠 1 𝑠𝑒𝑐𝑜𝑛𝑑
𝑒𝑥𝑒𝑐𝑢𝑡𝑖𝑜𝑛 𝑡𝑖𝑚𝑒 = 12𝑀 ∗6 ∗
𝑝𝑟𝑜𝑔𝑟𝑎𝑚 𝑖𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛 4𝐺 𝑐𝑙𝑜𝑐𝑘
𝑠𝑒𝑐𝑜𝑛𝑑𝑠
= 0.018
𝑝𝑟𝑜𝑔𝑟𝑎𝑚

CompOrg 101 - Lec05 22


Execution Time
▪ Q. A program on a specific machine XYZ has the following parameters:
▪ 4 GHz CPU
▪ 1 instruction per 6 clocks
▪ 12,000,000 instructions per program
▪ What is the execution time?
▪ Get the inverse of the clock speed and IPC.
▪ The execution time is 0.018 seconds per program.

CompOrg 101 - Lec05 23


Performance
▪ We are primarily concerned with execution time when it comes to
computer performance.
▪ Performance is inversely proportional to the execution time. As
execution time decreases, the processor executes the program faster;
therefore, we have a high performing processor.

1
𝑃𝑒𝑟𝑓𝑜𝑟𝑚𝑎𝑛𝑐𝑒 =
𝑒𝑥𝑒𝑐𝑢𝑡𝑖𝑜𝑛 𝑡𝑖𝑚𝑒

CompOrg 101 - Lec05 24


Performance
▪ (From previous examples) A program has an execution time of 0.04
seconds on machine ABC. The same program has an execution time of
0.018 seconds on machine XYZ.
▪ Which has better performance?
Execution time for machine XYZ is less than the execution time for machine ABC; XYZ,
therefore, has better performance.
▪ How many seconds faster is XYZ than ABC?
|𝑒𝑥𝑒𝑐𝑢𝑡𝑖𝑜𝑛 𝑡𝑖𝑚𝑒𝑋𝑌𝑍 − 𝑒𝑥𝑒𝑐𝑢𝑡𝑖𝑜𝑛 𝑡𝑖𝑚𝑒𝐴𝐵𝐶 | = 0.018 − 0.04
= 0.022 𝑠𝑒𝑐𝑜𝑛𝑑𝑠 𝑜𝑟 22 𝑚𝑖𝑐𝑟𝑜𝑠𝑒𝑐𝑜𝑛𝑑𝑠
XYZ is 22 microseconds faster than ABC.
▪ How many times faster is XYZ than ABC?
𝑝𝑒𝑟𝑓𝑜𝑟𝑚𝑎𝑛𝑐𝑒𝑋𝑌𝑍 𝑒𝑥𝑒𝑐𝑢𝑡𝑖𝑜𝑛 𝑡𝑖𝑚𝑒𝐴𝐵𝐶 0.04𝑠
= = = 2.22
𝑝𝑒𝑟𝑓𝑜𝑟𝑚𝑎𝑛𝑐𝑒𝐴𝐵𝐶 𝑒𝑥𝑒𝑐𝑢𝑡𝑖𝑜𝑛 𝑡𝑖𝑚𝑒𝑋𝑌𝑍 0.018𝑠
XYZ is 2.22x faster than ABC.

CompOrg 101 - Lec05 25

You might also like