COA ASsignment
COA ASsignment
ASSIGNMENT NO. 1
EXERCISE:
1.1 Aside from the smart cell phones used by a billion people, list and describe
four other types of computers.
ANSWER:
Personal computers:
Personal computers highlight delivery of good performance to single users, which
is cost-effective. PCs usually execute third-party software as we use in our homes.
Server Computers:
Server computers are used to run large and complex problems. Servers are
usually accessed via a network.
Supercomputers:
These computers are composed of hundreds to thousands of processors. They
have terabytes of memory.
Embedded computer:
Computer designed to run one application or one set of related applications and
integrated into a single system.
1.3 Describe the steps that transform a program written in a high-level language
such as C into a representation that is directly executed by a computer
processor.
ANSWER:
Whenever we run a program written in a high-level language, firstly, the compiler
compiles that program into assembly language. Then, this assembly language
program is assembled by the assembler into machine language. Computer
processors can understand machine language so, this way processors execute the
program.
1.5 Consider three different processors P1, P2, and P3 executing the same
instruction set. P1 has a 3 GHz clock rate and a CPI of 1.5. P2 has a 2.5 GHz clock
rate and a CPI of 1.0. P3 has a 4.0 GHz clock rate and has a CPI of 2.2.
a. Which processor has the highest performance expressed in instructions per
second?
ANSWER:
We know that
CPU time = instructions x CPI/Clock-rate (1)
IPS = instructions/CPU time
IPS= Clock-rate/CPI from looking at 1
Performance of P1= 3 x 109/1.5 =2 x 109
Performance of P2=2.5 x 109/1.0 = 2.5 x 109
Performance of P3= 4 x 109/2.2 = 1.8 x 109
So, the processor P2 has the highest performance that is 2.5 x 109
b. If the processors each execute a program in 10 seconds, find the number of
cycles and the number of instructions.
ANSWER:
Instructions = IPS x CPU time
Clock cycles = CPU time x Clock-rate
Processor Number of Instructions Number of Clock Cycles
P1 2 x 109 x 10 = 2 x 1010 10 x 3GHz = 3 x 1010
P2 2.5 x 109 x 10 = 2.5 x 1010 10 x 2.5GHz = 2.5 x 1010
P3 1.82 x 109 = 1.82 x 1010 10 x 4GHz = 4 x 1010
1GHz=109
c. We are trying to reduce the execution time by 30%, but this leads to an
increase of 20% in the CPI. What clock rate should we have to get this time
reduction?
ANSWER:
Execution time = instruction x CPI/ Clock-rate
As we want to reduce the execution time by 30% so that
New execution time = (100-30)% Old execution time (reducing execution time
by 30%)
New execution time = 70% Old execution time
New execution time = 0.7 Old execution time (70/100=0.7)
So, solving it as
Instructions x CPI/Clock-rate (NEW) = 0.7(Instructions x CPI/Clock-rate)(OLD)
Since the instructions are same so we can ignore them using,
CPI/Clock-rate(NEW) = 0.7(CPI/Clock-rate)(OLD)
As question describes that it leads to 20% increase in CPI so,
NEW CPI is 0.2 times OLD CPI (20/100=0.2)
1.2/Clock-rate(NEW) = 0.7(1/Clock-rate(OLD))
Rearranging,
NEW Clock-rate = 1.2/0.7 x OLD Clock-rate
NEW Clock-rate = 1.71 OLD Clock-rate
So, to get 30% reduce in execution time, we need a 71% increase in clock rate
1.6 Consider two different implementations of the same instruction set
architecture. The instructions can be divided into four classes according to their
CPI (classes A, B, C, and D). P1 with a clock rate of 2.5 GHz and CPIs of 1, 2, 3,
and 3, and P2 with a clock rate of 3 GHz and CPIs of 2, 2, 2, and 2. Given a
program with a dynamic instruction count of 1.0E6 instructions divided into
classes as follows: 10% class A, 20% class B, 50% class C, and 20% class D, which
is faster: P1 or P2?
Clock-rate P1 = 2.5 GHz
Clock-rate P2 = 3 GHz
CPIs P1 = 1,2,3,3
CPIs P2 = 2,2,2,2
Instructions of A = 106 x 10% = 1 x 105
Instructions of B = 106 x 20% = 2 x 105
Instructions of C = 106 x 50% = 5 x 105
Instructions of D = 106 x 20% = 2 x 105
a. Find the clock cycles required in both cases.
ANSWER:
Clock Cycles P1 = (1 x 1 x 105) + (2 x 2 x 105) + (3 x 5 x 105) + (3 x 2 x 105)
= 2.6 x 106
Clock Cycles P1 = (2 x 1 x 105) + (2 x 2 x 105) + (2 x 5 x 105) + (2 x 2 x 105)
= 2 x 106
b. What is the global CPI for each implementation?
ANSWER:
CPI = Clock cycles/instructions
CPI P1 = 2.6 x 106 / 106 = 2.6
CPI P2 = 2 x 106 / 106 = 2
Which is faster P1 or P2?
For this,
CPU time P1 = 2.6 x 106/2.5 GHz = 1.04 x 10-3 = 1.04 ms
CPU time P2 = 2 x 106/3 GHz = .67 x 10-3 = .67 ms
Hence, P2 is faster than P1.
1.7 Compilers can have a profound impact on the performance of an
application. Assume that for a program, compiler A results in a dynamic
instruction count of 1.0E9 and has an execution time of 1.1 s, while compiler B
results in a dynamic instruction count of 1.2E9 and an execution time of 1.5 s.
a. Find the average CPI for each program given that the processor has a clock
cycle time of 1 ns.
ANSWER:
Execution time = instructions x Cycle time x CPI
Rearranging,
CPI = Execution time/instructions x Cycle time (cycle time is given 1 nano)
Using above formula
CPI of A = 1.1 / 109 x 10-9 = 1.1 (1 nano = 10-9)
CPI of B = 1.5 / 1.2 x 109 x 10-9 = 1.25
b. Assume the compiled programs run on two different processors. If the
execution times on the two processors are the same, how much faster is the
clock of the processor running compiler A’s code versus the clock of the
processor running compiler B’s code?
ANSWER:
Given that
Execution time A = Execution time B
Instructions x CPI / Clock-rate (A) = Instructions x CPI / Clock-rate (B)
=> Clock-rate A = [Instructions x CPI (A)/ Instructions x CPI (B)] Clock-rate B
=> Clock-rate A = (109 x 1.1/1.2 x 109 x 1.25) Clock-rate B
=> Clock-rate A = 0.73 Clock-rate B
So, the clock-rate of A is 27% slower than Clock-rate of B
c. A new compiler is developed that uses only 6.0E8 instructions and has an
average CPI of 1.1. What is the speedup of using this new compiler versus using
compiler A or B on the original processor?
ANSWER:
Let the new compiler be C.
Execution time C = instructions x Cycle time x CPI (C)
= 6 x 108 x 1.1 x 10-9
= 0.67 sec
Comparing performance of new compiler C with that of A and B to find speedup
Performance of C/ Performance of A = CPU time A/CPU time C
= 1.1/.67 = 1.67
Performance of C/ Performance of B = CPU time B/CPU time C
= 1.5/.67 = 2.27
Thus, the new compiler is 1.67 times faster than compiler A and 2.27 times faster
than compiler C