CST131 Tutorial2

Share Embed Donate


Short Description

answer of tutorial of computer organisation...

Description

School of Computer Sciences Universiti Sains Malaysia CST131 – Computer Organisation Academic Session 2014/2015 Semester 1

TUTORIAL 2 (Answer) Computer Evolution, Number Systems and Computer Arithmetic 1.

While browsing at Billy Bob’s computer store, you overhear a customer asking Billy Bob what is the fastest computer in the store that he can buy. Billy Bob replies, “You’re looking at our Macintoshes. The fastest Mac we have runs at a clock speed of 1.2 gigahertz. If you really want the fastest machine, you should buy our 2.4-gigahertz Intel Pentium IV instead.” Is Billy Bob correct? What would you say to help this customer? Even though the Intel machine may have multiple cores, it does not necessarily that the system will perform faster. Different systems cannot be easily compared just by comparing the clock speeds and the number of cores. Other factors such as the system components (memory, buses, and architecture) and the instruction sets must also be taken into account. A more accurate measure is to run both systems on a benchmark. Benchmark programs exist for certain tasks, such as running office applications, performing floating point operations, graphics operations, and so on. The systems can be compared to each other on how long they take to complete these tasks. According to Apple Computer, the G4 processors used in their computers are comparable or better than a higher clock speed Pentium machine on many benchmarks.

2.

A benchmark program is run on a 40 MHz processor. The executed program consists of 100,000 instruction executions, with the following instruction mix and clock cycle count: Instruction Type Instruction Count Cycles per Instruction Integer arithmetic 48,000 1 Data transfer 34,000 2 Floating point 13,000 2 Control transfer 5,000 2 Determine the effective CPI, MIPS rate, and execution time for this program.

n

CPI 

 (CPI i 1

i

Sum for all different instructions [Cycles per instruction x Instruction count]

 Ii )

Ic

Total number of instructions

1

CPI = (48000*1 + 34000*2 + 13000*2 + 5000*2)/100000 = 152000/100000 = 1.52

Ic f MIPSrate   6 T 10 CPI 106

Cycles per second / cycles per instruction = cycle x instruction / second x cycle = instruction / second Change from “instructions” to “millions of instructions”

MIPS = Clock frequency/(CPI*1000000) = (40*1000000)/(1.52*1000000) = 26.3 Execution time (T) = CPI*Instruction count*clock time = CPI*Instruction count/frequency = 1.52*100000/40000000 = 1.52/400 = 3.8 ms

3.

Assume a processor is able to process 50,500,000 instructions in 0.011 seconds. Calculate the MIPS rate. Total number of instructions

Ic f MIPSrate   6 T 10 CPI 106 Total time taken 6

MIPS rate = 50500000 / (0.011 x 10 ) = 4590.91 MIPS Change from “instructions” to “millions of instructions”

2

4.

Consider two different machines, with two different instruction sets, both of which have a clock rate of 200 MHz. The following measurements are recorded on the two machines running a given set of benchmark programs:

Instruction Type

Instruction Count (millions)

Cycles Per Instruction

8 4 2 4

1 3 4 3

10 8 2 4

1 2 4 3

Machine A Arithmetic and logic Load and store Branch Others Machine B Arithmetic and logic Load and store Branch Others

a. Determine the effective CPI, MIPS rate, and execution time for each machine. b. Comment on the results.

a.

CPI A

 CPI 

 Ii

Ic

MIPS A  CPU A  CPI B 

i

 2.22

f 200 10 6   90 CPI A 10 6 2.22 10 6

Ic  CPI A 18 10 6  2.2   0.2 s f 200 10 6

 CPI Ic

MIPS B  CPU B 

8 1 4  3  2  4  4  3 10 6   8  4  2  4  10 6

i

 Ii



10 1 8  2  2  4  4  3 10 6 10  8  2  4  10 6

 1.92

f 200 10 6   104 CPI B 10 6 1.92 10 6

Ic  CPI B 24 10 6 1.92   0.23 s f 200 10 6

b. Although machine B has a higher MIPS than machine A, it requires a longer CPU time to execute the same set of benchmark programs. 

3

5.

A computer with 2 processors is used to execute a program with 100,000 instructions assuming that there are no dependencies in all the instructions. Each instruction requires 1 nanosecond to execute. (a) Calculate the time (in nanoseconds) required to execute all the instructions sequentially.

100000 instructions x 1 nanosec = 100000 nanosec (b) Calculate the time required to execute all the instructions in parallel. In 1 nanosecond, 2 instructions could be executed in parallel. So, for 100000 instructions, time taken is (100000 x 1) / 2 = 50000 nanosec (c) Calculate the speedup obtained when i.

none of the instructions could be executed in parallel

Speedup = Time when all instructions executed sequentially / (Time of sequential portion + Time of parallelizable portion) = 100000 / (100000 + 0) = 1 (i.e. no improvement even with 2 processors) ii. all of the instructions could be executed in parallel Speedup = Time when all instructions executed sequentially / (Time of sequential portion + Time of parallelizable portion) = 100000 / (0 + 50000) = 2 (i.e. with 2 processors, processing is twice as fast) iii. 30% of the instructions could be executed in parallel 30% parallelizable instructions = 30% x 100000 = 30000 instructions Time taken for parallelizable portion: 1 nanosec = 2 instructions So, for 30000 instructions = (30000 x 1) / 2 = 15000 nanosec (1 – 30%) sequential instructions = 70% x 100000 = 70000 instructions Time taken for sequential portion: 70000 instructions x 1 nanosec = 70000 nanosec Speedup = Time when all instructions executed sequentially / (Time of sequential portion + Time of parallelizable portion) = 100000 / (70000 + 15000) = 1.18 (i.e. with some parallelizable instructions, speedup will be between 1 and 2)

4

6.

Fill in the tables with the equivalent values in the requested base: Decimal

Binary

Octal

Hexadecimal

888

(i) ____________

(ii) ___________

(iii) ___________

Decimal

Binary

Octal

Hexadecimal

(iv) ___________

10011001.10

(v) ___________

(vi) ___________

Decimal

Binary

Octal

Hexadecimal

(vii) __________

CAB.FAD

(i) 11011110002 Quotient 888/2 444 444/2 222 222/2 111 111/2 55 55/2 27 27/2 13 13/2 6 6/2 3 3/2 1 ½ 0

Remainder 0 0 0 1 1 1 1 0 1 1

(ii) 11011110002 = 1 101 111 0002 = 15708 (iii) 11011110002 = 11 0111 10002 = 37816 (iv) 10011001.102 = (1x27) + (1x24) + (1x23) + (1x20) + (1x2-1) = 128 + 16 + 8 + 1 + 0.5 = 153.510 (v) 10011001.102 = 10 011 001.1002 = 231.48 (vi) 10011001.102 = 1001 1001.10002 = 99.816 (vii) CAB.FAD16 = 1100 1010 1011 . 1111 1010 11012 = 110 010 101 011 . 111 110 101 1012 = 6253.76558

5

7.

Convert the following decimal numbers to binary: (a) 0.4687510 (b) 0.310 (a) 0.46875 x 2 = 0.9375 0.9375 x 2 = 1.875 0.875 x 2 = 1.75 0.75 x 2 = 1.5 0.5 x 2 = 1 Answer = 0.011112

8.

(b) 0.3 x 2 = 0.6 0.6 x 2 = 1.2 0.2 x 2 = 0.4 0.4 x 2 = 0.8 0.8 x 2 = 1.6 Answer = 0.01001…2

Represent the following decimal numbers in both twos complement and biased representation using 8 bits and 12 bits: (a) 70 (b) – 31

8 BITS 7010 = 0100 01102 (“normal”/unsigned binary) 3110 = 0001 11112 Two’s complement: 7010 = 0100 01102 (same as “normal”/unsigned binary) -3110 = 1110 00012 (invert binary +31 and add 1) Biased representation 7010 = 7010 + 12710 (bias = (2n-1 – 1) = 27 – 1 = 127) = 19710 = 1100 01012 -3110 = -3110 + 12710 = 9610 = 0110 00002 12 BITS 7010 = 0000 0100 01102 (“normal”/unsigned binary) 3110 = 0000 0001 11112 Two’s complement: 7010 = 0000 0100 01102 (same as “normal”/unsigned binary) -3110 = 1111 1110 00012 (invert binary +31 and add 1 OR from 8 bits answer, padded with leading 1s to make 12 bits) Biased representation 7010 = 7010 + 204710 (bias = (2n-1 – 1) = 211 – 1 = 2047) = 211710 = 1000 0100 01012 -3110 = -3110 + 204710 = 201610 = 0111 1110 00002

6

9.

Represent the following twos complement values in decimal: (a) 1101011 (b) 0101101

10.

Assume numbers are represented in 8-bit twos complement representation. Show the calculation of the following: (a) 5 + 12 (b) 5 – 12 (c) –5 – 12 (d) 75 + 57 (a)

0000 0101 + 0000 1100 0001 0001

(b)

(d)

0100 1011 + 0011 1001 1000 0100 (overflow)

0000 0101 + 1111 0100 1111 1001

- oooOooo -

7

(c)

1111 1011 + 1111 0100 1 1110 1111

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF