0% found this document useful (0 votes)
23 views22 pages

Chapter 2 Performance and Number Systems

Uploaded by

10423063
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views22 pages

Chapter 2 Performance and Number Systems

Uploaded by

10423063
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

9/23/2024

Number Systems
Dr. Truong Dinh Huy

Last week

• Components of a computer: CPU, Memory, input/output devices.

• Basics of Computer Architecture.

• Instruction Set Architecture (ISA): the hardware/software interface.

• Below your program.

1
9/23/2024

Defining Performance
• Which airplane has the best performance?

Response Time and Throughput


• Response time (execution time)
• How long it takes to do a task
• Throughput
• Total work done per unit time
• e.g., tasks/transactions/… per hour
• How are response time and throughput affected by
• Replacing the processor with a faster version?
• Adding more processors for separate tasks?
• We’ll focus on response time for now…

2
9/23/2024

Relative Performance
• Define Performance = 1/Execution Time
• “X is n time faster than Y”

Performanc e X Performanc e Y
 Execution time Y Execution time X  n

 Example: time taken to run a program


 10s on A, 15s on B
 Execution TimeB / Execution TimeA
= 15s / 10s = 1.5
 So A is 1.5 times faster than B

Measuring Execution Time


• Elapsed time
• Total response time, including all aspects
• Processing, I/O, OS overhead, idle time
• Determines system performance
• CPU time
• Time spent processing a given job
• Discounts I/O time, other jobs’ shares
• Comprises user CPU time and system CPU time
• Different programs are affected differently by CPU and system performance

3
9/23/2024

CPU Clocking
• Operation of digital hardware governed by a constant-
rate clock
Clock period

Clock (cycles)

Data transfer
and computation
Update state

 Clock period: duration of a clock cycle


 e.g., 0.25ns = 250×10–12s
 Clock frequency (rate): cycles per second
 e.g., 4.0GHz = 4000MHz = 4.0×109Hz
 Clock frequency = 1/clock period

CPU Time
CPU Time  CPU Clock Cycles  Clock Cycle Time
CPU Clock Cycles

Clock Rate
• Performance improved by
• Reducing number of clock cycles
• Increasing clock rate
• Hardware designer must often trade off clock rate against
cycle count

4
9/23/2024

CPU Time Example


• Computer A: 2GHz clock, 10s CPU time for a program
• Designing Computer B, with same program
• Aim for 6s CPU time
• Can do faster clock, but causes 1.2 × clock cycles
• How fast must Computer B clock be?
Clock CyclesB 1.2  Clock Cycles A
Clock RateB  
CPU Time B 6s
Clock Cycles A  CPU Time A  Clock Rate A
 10s  2GHz  20  10 9
1.2  20  10 9 24  10 9
Clock RateB    4GHz
6s 6s

Instruction Count and CPI


Clock Cycles  Instructio n Count  Cycles per Instructio n
CPU Time  Instructio n Count  CPI  Clock Cycle Time
Instructio n Count  CPI

Clock Rate
• Instruction Count for a program
• Determined by program, ISA and compiler
• Average cycles per instruction
• Determined by CPU hardware
• If different instructions have different CPI
• Average CPI affected by instruction mix

5
9/23/2024

CPI Example
• Computer A: Cycle Time = 250ps, CPI = 2.0
• Computer B: Cycle Time = 500ps, CPI = 1.2
• Same program, Same ISA
• Which is faster, and by how much?
CPU Time  Instruction Count  CPI  Cycle Time
A A A
 I  2.0  250ps  I  500ps A is faster…
CPU Time  Instruction Count  CPI  Cycle Time
B B B
 I  1.2  500ps  I  600ps
CPU Time
B  I  600ps  1.2
…by this much
CPU Time I  500ps
A

Quiz
The results of a program running on an AMD Barcelona has an
instruction count of 2.389E12, an execution time of 750 s.
a) Find the CPI if the clock cycle time is 0.33333 ns
b) Find the increase in CPU time if the number of instructions of the program is
increased by 10% and the CPI is increased by 5%.
c) Suppose that we are developing a new version of the AMD Barcelona processor
with a 4 GHz clock rate. We also develop a new ISA in such a way that the
number of instructions has been reduced by 15%. The execution time is
reduced to 700 s. Find the new CPI.
d) 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.

6
9/23/2024

CPI in More Detail


• If different instruction classes take different numbers
of cycles

n
Clock Cycles   (CPIi  Instruction Count i )
i1

 Weighted average CPI


Clock Cycles n
 Instruction Count i 
CPI     CPIi  
Instruction Count i1  Instruction Count 

Relative frequency

CPI Example
• Alternative compiled code sequences using
instructions in classes A, B, C

Class A B C
CPI for class 1 2 3
IC in sequence 1 2 1 2
IC in sequence 2 4 1 1

 Code Sequence 1:  Sequence 2: IC = 6


IC = 5  Clock Cycles
 Clock Cycles = 4×1 + 1×2 + 1×3
= 2×1 + 1×2 + 2×3 =9
= 10  Avg. CPI = 9/6 = 1.5
 Avg. CPI = 10/5 = 2.0

7
9/23/2024

Performance Summary

Instructions Clock cycles Seconds


CPU Time = 𝑆𝑒𝑐𝑜𝑛𝑑𝑠/𝑃𝑟𝑜𝑔𝑟𝑎𝑚 = × ×
Program Instruction Clock cycle

Program Performance

8
9/23/2024

Quiz
A given application written in Java runs 15 seconds on a
desktop processor. A new Java compiler is released that
requires only 0.6 as many instructions as the old compiler.
Unfortunately, it increases the CPI by 1.1. How fast can we
expect the application to run using this new compiler? Pick
the right answer from the three choices below:

• A: 15*0.6/1.1 = 8.2 sec


• B: 15*0.6*1.1 = 9.9 sec
• C: 1.5*1.1/0.6 = 27.5 sec

Power Trends

• In CMOS IC technology

Power  Capacitive load  Voltage 2  Frequency

×30 5V → 1V ×1000

9
9/23/2024

Reducing Power
• Suppose a new CPU has
• 85% of capacitive load of old CPU
• 15% voltage and 15% frequency reduction

Pnew Cold  0.85  (Vold  0.85)2  Fold  0.85


 2
 0.85 4  0.52
Pold Cold  Vold  Fold

 The power wall


 We can’t reduce voltage further
 We can’t remove more heat
 How else can we improve performance?

Uniprocessor Performance

Constrained by power, instruction-level parallelism,


memory latency

10
9/23/2024

Multiprocessors
• Multicore microprocessors
• More than one processor per chip
• Requires explicitly parallel programming
• Compare with instruction level parallelism
• Hardware executes multiple instructions at once
• Hidden from the programmer
• Hard to do
• Programming for performance
• Load balancing
• Optimizing communication and synchronization

Concluding Remarks
• Cost/performance is improving
• Due to underlying technology development
• Hierarchical layers of abstraction
• In both hardware and software
• Instruction set architecture
• The hardware/software interface
• Execution time: the best performance measure
• Power is a limiting factor
• Use parallelism to improve performance

11
9/23/2024

Number Systems

Why computers use binary


• To get started, we’ll discuss one of the fundamental concepts
underlying digital computer design:
Deep down inside, computers work with just 1s and 0s.

• Computers use voltages to represent information.


• It’s convenient for us to translate these analog voltages into
the discrete, or digital, values 1 and 0.
• They can be represented with a transistor that is
relatively easy to fabricate (in silicon)
• Millions of them can be put in a tiny chip

24

12
9/23/2024

Binary Signals
• It means two-states
• 1 and 0
• true and false
• on and off
• A single “on/off”, “true/false”, “1/0” is called a bit
• Example: Toggle switch
• Digital Systems
• Information is represented in binary form
• They manipulate discrete information
• Examples
• Digital telephones, digital television, and digital cameras
• The most commonly used one is DIGITAL COMPUTERS

25

Analog Signal

26

13
9/23/2024

Binary Signal

27

Byte
• Computer memory is organized into groups of eight
bits
• Each eight bit group is called a byte

28

14
9/23/2024

The Decimal System


• System based on decimal digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
to represent numbers
• For example the number 83 means eight tens plus three:
83 = (8 * 10) + 3
• The number 4728 means four thousands, seven
hundreds, two tens, plus eight:
4728 = (4 * 1000) + (7 * 100) + (2 * 10) + 8
• The decimal system is said to have a base, or radix, of 10.
This means that each digit in the number is multiplied by
10 raised to a power corresponding to that digit’s
position:
83 = (8 * 101) + (3 * 100)
4728 = (4 * 103) + (7 * 102) + (2 * 101) + (8 * 100)

Decimal Fractions
• The same principle holds for decimal fractions, but negative
powers of 10 are used. Thus, the decimal fraction 0.256
stands for 2 tenths plus 5 hundredths plus 6 thousandths:
0.256 = (2 * 10-1) + (5 * 10-2) + (6 * 10-3)
• A number with both an integer and fractional part has digits
raised to both positive and negative powers of 10:
442.256 = (4 * 102) + (4 + 101) + (2 * 100) + (2 * 10-1) + (5 * 10-2)
+ (6 * 10-3)
• Most significant digit
• The leftmost digit (carries the highest value)
• Least significant digit
• The rightmost digit

15
9/23/2024

Table 9.1
Positional Interpretation of a Decimal Number

4 7 2 2 5 6
100s 10s 1s tenths hundredths thousandths
102 101 100 10–1 10–2 10–3
position 2 position 1 position 0 position –1 position –2 position –3

Positional Number Systems


• Each number is represented by a string of digits in which
each digit position i has an associated weight ri, where r
is the radix, or base, of the number system.
• The general form of a number in such a system with
base r is
( . . . .a2a1a0.a-1a-2a-3 . . . )r
where the value of any digit ai is an integer in the range: 0
< ai < r. The dot between a0 and a-1 is called the base
point.
( . . . .a2a1a0.a-1a-2a-3 . . . )r
=… + (a2 * r2) + (a1 + r1) + (a0 * r0) + (a-1 * r-1) + (a-2 * r-2)
+ (a-3 * r-3) +…

16
9/23/2024

The Binary System


• Only two digits, 1 and 0
• Represented to the base 2
• The digits 1 and 0 in binary notation have the same
meaning as in decimal notation:
02 = 010
12 = 110
• To represent larger numbers each digit in a binary
number has a value depending on its position:
102 = (1 * 21) + (0 * 20) = 210
112 = (1 * 21) + (1 * 20) = 310
1002 = (1 * 22) + (0 * 21) + (0 * 20) = 410
and so on. Again, fractional values are represented
with negative powers of the radix:
1001.101 = 23 + 20 + 2-1 + 2-3 = 9.62510

Converting Decimal to Binary


Quotient Remainder
21 = 10 1
2
Quotient Remainder
11 = 5 1 10 =
2 5 0
2
5 = 2 1 5 = 2 1
2 2
2 = 1 0 2 = 1 0
2 2
1 = 0 1 1 = 0 1
2 2
10112 = 1110 10101 2 = 2110

(a) 1110 (b) 2110

17
9/23/2024

Converting Decimal Fraction to


Binary Fraction
Product Integer Part 0.110011 2
0.81 2 = 1.62 1

0.62 2 = 1.24 1

0.24 2 = 0.48 0

0.48 2 = 0.96 0

0.96 2 = 1.92 1
Product Integer Part 0.012
0.25 2 = 0.5 0 0.92 2 = 1.84 1

(a) 0.81 10 = 0.110011 2 (approximately)


0.5 2 = 1.0 1

(b) 0.25 10 = 0.01 2 (exactly)

Base 16
• Binary digits are grouped into sets of four bits, called a nibble
• Each possible combination of four binary digits is given a
symbol, as follows:

0000 = 0 0100 = 4 1000 = 8 1100 = C


0001 = 1 0101 = 5 1001 = 9 1101 = D
0010 = 2 0110 = 6 1010 = A 1110 = E
0011 = 3 0111 = 7 1011 = B 1111 = F

• Because 16 symbols are used, the notation is called


hexadecimal and the 16 symbols are the hexadecimal digits
• Thus:
2C16 = (216 * 161) + (C16 * 160)
= (210 * 161) + (1210 * 160) = 4410

18
9/23/2024

Decimal Binary (base 2) Hexadecimal


(base 10) (base 16)
0 0000 0
1 0001 1
2 0010 2
3 0011 3
4 0100 4
5 0101 5
6 0110 6
7 0111 7

Table 9.3 8
9
1000
1001
8
9
10 1010 A

Decimal, Binary,
11 1011 B
12 1100 C

and Hexadecimal 13
14
1101
1110
D
E
15 1111 F
16 0001 0000 10
17 0001 0001 11
18 0001 0010 12
31 0001 1111 1F
100 0110 0100 64
255 1111 1111 FF
256
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved. 0001 0000 0000 100

Converting Hexadecimal to Decimal

19
9/23/2024

Converting Decimal to Hexadecimal

Base 16 is useful
Not only used for
representing integers but
also as a concise notation
for representing any Reasons for using
sequence of binary digits hexadecimal notation
are:

In most computers,
It is extremely easy to
binary data occupy some
It is more compact than convert between binary
multiple of 4 bits, and
binary notation and hexadecimal
hence some multiple of a
notation
single hexadecimal digit

20
9/23/2024

Binary and hexadecimal conversions


• Converting from hexadecimal to binary is easy: just replace each hex digit
with its equivalent 4-bit binary sequence.
261.3516 = 2 6 1 . 3 516
= 0010 0110 0001 . 0011 01012
• To convert from binary to hex, make groups of 4 bits, starting from the
binary point. Add 0s to the ends of the number if needed. Then, just
convert each bit group to its corresponding hex digit.
10110100.0010112 = 1011 0100 . 0010 11002
= B 4 . 2 C16

Hex Binary Hex Binary Hex Binary Hex Binary


0 0000 4 0100 8 1000 C 1100
1 0001 5 0101 9 1001 D 1101
2 0010 6 0110 A 1010 E 1110
3 0011 7 0111 B 1011 F 1111
41

Number Systems Summary


• Computers are binary devices.
• We’re forced to think in terms of base 2.
• We learned how to convert numbers between binary, decimal and
hexadecimal.
• Also, we have seen:
• We use 0 and 1 as abstractions for analog voltages.
• We showed how to represent numbers using just these two
signals.

21
9/23/2024

Quiz
• Convert these numbers from base 10 to base 2 and 16:
• 2510 = 1916 =110012
• 409710 = 100116 =10000000000012
• 18.7510 = 12.C16 =10010.112
• 75.6810 = 4B.AE147AE147AE147AE14816 =1001011.101011100001010012
• Convert these numbers from base 16 to base 10:
• A1216 =257810
• AB.CD16 =171.8007812510

Next week
• Please do all homework

• Content of next lecture:

• Boolean operations and Logic gates: and, or, xor, not,…

• Simplification by laws of Boolean algebra

• Standard Boolean expression: SOP, POS

22

You might also like