You are on page 1of 5

ENGG 1203 Tutorial Computer Arithmetic (1)

Computer Systems Convert the following decimal values to


Supplementary Notes binary:
Learning Objectives a) 205 b) 2133
Compute via Computer Arithmetic
Evaluate the performance of parallel processing via Perform the following operations in the 2’s
Amdahl’s law complement system. Use eight bits (including
News the sign bit) for each number.
Revision tutorial (TBD) a) add +9 to +6 b) add +14 to -17 c) add +19 to -24

1 2

Computer Arithmetic (2) Computer Arithmetic (3)

Convert the following decimal values to binary: Perform the following operations in the 2’s
a) 205 b) 2133 complement system. Use eight bits (including the sign
bit) for each number.
20510 = 1 x 27 + 1 x 26 + 1 x 23 a) add +9 to +6 b) add +14 to -17 c) add +19 to -24
+ 1 x 22 + 1 x 20
00001001 = +9 00001110 = +14 00010011 = +19
= 110011012
00000110 = +6 11101111 = −17 11101000 = −24
00001111 = +15 11111101 = −3 11111011 = −5
213310 = 1 x 211 + 1 x 26
+1 x 24 + 1 x 22 + 1 x 20 24 = 00011000 −24 = 11100111(1's complement) = 11101000(2's complement)
= 1000010101012
3 4
Overflow Addition using 2’s Complement (1)

Overflow: Add two positive numbers to get a negative Perform the following computations.
number or two negative numbers to get a positive
Indicate on your answer if an overflow has
number
occurred.
For 2’s complement,
(+1)+(+6)
= +7 OK 01000000 + 01000001 (64 + 65)
(+1)+(+7) 00000111 − 11111001 (7 - -7)
= -8 Overflow
(-1)+(-8)
= +7 Overflow
(-6)+(+7)
= -1 OK
5 6

Addition using 2’s Complement (2) Limitation of Parallel Processing?


01000000 (64)  Fractionenhanced 
ExTimenew = ExTimeold × (1 − Fractionenhanced ) +
+ 01000001 (65)  Speedupenhanced 
---------------- ExTimeold 1
Speedupoverall = =
ExTimenew Fractionenhanced
10000001 (-127) Overflow (1 − Fractionenhanced ) +
Speedupenhanced

Best you could ever hope to do:


00000111 - 11111001 1
00000111 (7) Speedupmaximum =
= 00000111 + (-11111001) =
00000111+00000111
(1 - Fractionenhanced )
+ 00000111 (7)
----------------
00001110 (14) No Overflow

7 8
Limitation of Parallel Processing? Limitation of Parallel Processing?
1
Speedup overall =
Fraction parallel
Major challenge is: % of program inherently (1 − Fraction enhanced ) +
sequential Speedup parallel
Suppose 80X speedup from 100 processors. What 1
fraction of original program can be sequential? 80 =
a. 10% (1 − Fraction parallel ) + Fraction
100
parallel

5%
80 × ((1 − Fraction parallel ) +
b. Fraction parallel
) =1
c. 1% 100
d. <1% 79 = 80 × Fraction parallel − 0.8 × Fraction parallel
Fraction parallel = 79 / 79.2 = 99.75%
9 10

Speed-up via Parallel Computation

A uniprocessor computer can operate in either sequential mode or


parallel mode. In parallel mode, computations can be performed
nine times faster than in sequential mode. A certain benchmark
program took time to run on this computer. Furthermore, suppose
that 25% of was spent in parallel mode whereas the remaining
portion was in sequential mode.
(a) What is the effective speedup of the above execution as compared with the
condition when parallel mode is not used at all?
(b) What is the fraction of parallelized code of the benchmark program?
(c) Suppose we double the speed ratio between parallel mode and the sequential
mode by hardware improvements. What is the new effective speedup?
(d) Suppose the speedup you calculated in (c) is to be obtained by software
improvement alone in terms of parallelization fraction, instead of by any hardware
improvement. What is the new parallelization fraction required?

11 12
Ratio of Speed-up via N Processors

13 14

Ratio of Speed-up with K Parallelized


Tasks
Your company has just bought a new server based on a dual-core
Intel Core i7 processor, and you have been asked to optimize your
software applications for this processor. You will run two
applications on this server, but the resource requirements are not
equal. The first application needs 80% of the resources, and the
other only 20% of the resources. In the answers in Parts (c) and (d) above, we assume that
(a) Given that 40% of the first application is parallelizable, how much each application completely “owns” the whole system (i.e.,
speedup would you achieve with that application if run in isolation? both processor cores) during the time it is running. That is,
(b) Given that 99% of the second application is parallelizable, how much there is no overlapping of the two applications in time-sharing
speedup would this application observe if run in isolation? the two processor cores. However, in reality, this might not be
(c) Given that 40% of the first application is parallelizable, how much the case—there should be some overlapping of execution of
overall system speedup would you observe if you parallelized it?
the two applications in order not to waste the resources. The
(d) Given that 99% of the second application is parallelizable, how much
overall system speedup would you get? following is an alternative way to determine an answer for Part
(c).
15 16
Furthermore, the parallel part requires 0.8T units of time
while the serial part requires 2.4T units of time because,
as we determined in Part (a), the parallel time versus
serial time ratio is 1 to 3 (0.2 vs. 0.6). Most importantly,
as can seen from the diagram, processor core P2 is idle
after the first 0.8T units of time and so it can actually run
In the above timing diagram, we assume that in application 2, as shown. Thus, the overall time is still
completely serial mode, application 1 takes 4T units of 3.2T for running both applications in the system. The
time so that application 2 takes T units of time, due to speed up is therefore 5T/3.2T = 1.5625.
the 80% and 20% requirements, respectively. Now, in
parallel mode for application 1, the total time required is
3.2T because the speedup is 1.25.

17 18

(Appendix)

A tutorial for IEEE Floating Point


representation
http://goo.gl/TjG6M

19

You might also like