CST131 Tutorial2
CST131 Tutorial2
CST131 Tutorial2
=
CPI
f
T
I
c
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.
6 6
10 10
rate MIPS
=
CPI
f
T
I
c
MIPS rate = 50500000 / (0.011 x 10
6
) = 4590.91 MIPS
Total number of instructions
Total time taken
Change from instructions to
millions of instructions
Cycles per second /
cycles per instruction
= cycle x instruction /
second x cycle
= instruction / second
Change from
instructions to
millions of instructions
3
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
Machine A
Arithmetic and logic 8 1
Load and store 4 3
Branch 2 4
Others 4 3
Machine B
Arithmetic and logic 10 1
Load and store 8 2
Branch 2 4
Others 4 3
a. Determine the effective CPI, MIPS rate, and execution time for each machine.
b. Comment on the results.
a.
CPI
A
=
CPI
i
I
i
I
c
=
8 1+ 4 3+ 2 4 + 4 3
( )
10
6
8 + 4 + 2 + 4
( )
10
6
~ 2.22
MIPS
A
=
f
CPI
A
10
6
=
200 10
6
2.22 10
6
= 90
CPU
A
=
I
c
CPI
A
f
=
18 10
6
2.2
200 10
6
= 0.2 s
CPI
B
=
CPI
i
I
i
I
c
=
10 1+ 8 2 + 2 4 + 4 3
( )
10
6
10 + 8 + 2 + 4
( )
10
6
~1.92
MIPS
B
=
f
CPI
B
10
6
=
200 10
6
1.92 10
6
=104
CPU
B
=
I
c
CPI
B
f
=
24 10
6
1.92
200 10
6
= 0.23 s
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.
4
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)
5
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) 1101111000
2
Quotient Remainder
888/2 444 0
444/2 222 0
222/2 111 0
111/2 55 1
55/2 27 1
27/2 13 1
13/2 6 1
6/2 3 0
3/2 1 1
0 1
(ii) 1101111000
2
= 1 101 111 000
2
= 1570
8
(iii) 1101111000
2
= 11 0111 1000
2
= 378
16
(iv) 10011001.10
2
= (1x2
7
) + (1x2
4
) + (1x2
3
) + (1x2
0
) + (1x2
-1
) = 128 + 16 + 8 + 1 +
0.5 = 153.5
10
(v) 10011001.10
2
= 10 011 001.100
2
= 231.4
8
(vi) 10011001.10
2
= 1001 1001.1000
2
= 99.8
16
(vii) CAB.FAD
16
= 1100 1010 1011 . 1111 1010 1101
2
= 110 010 101 011 . 111 110 101 101
2
= 6253.7655
8
6
7. Convert the following decimal numbers to binary:
(a) 0.46875
10
(b) 0.3
10
(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.01111
2
(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
8. Represent the following decimal numbers in both twos complement and biased
representation using 8 bits and 12 bits:
(a) 70
(b) 31
8 BITS
70
10
= 0100 0110
2
(normal/unsigned binary)
31
10
= 0001 1111
2
Twos complement:
70
10
= 0100 0110
2
(same as normal/unsigned binary)
-31
10
= 1110 0001
2
(invert binary +31 and add 1)
Biased representation
70
10
= 70
10
+ 127
10
(bias = (2
n-1
1) = 2
7
1 = 127)
= 197
10
= 1100 0101
2
-31
10
= -31
10
+ 127
10
= 96
10
= 0110 0000
2
12 BITS
70
10
= 0000 0100 0110
2
(normal/unsigned binary)
31
10
= 0000 0001 1111
2
Twos complement:
70
10
= 0000 0100 0110
2
(same as normal/unsigned binary)
-31
10
= 1111 1110 0001
2
(invert binary +31 and add 1 OR from 8 bits answer,
padded with leading 1s to make 12 bits)
Biased representation
70
10
= 70
10
+ 2047
10
(bias = (2
n-1
1) = 2
11
1 = 2047)
= 2117
10
= 1000 0100 0101
2
-31
10
= -31
10
+ 2047
10
= 2016
10
= 0111 1110 0000
2
7
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 (b) 0000 0101 (c) 1111 1011
+ 0000 1100 + 1111 0100 + 1111 0100
0001 0001 1111 1001 1 1110 1111
(d) 0100 1011
+ 0011 1001
1000 0100 (overflow)
- oooOooo -