Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 2 (25 points) Consider that compiler F compiles a high-level program and

ID: 668687 • Letter: P

Question

Problem 2 (25 points) Consider that compiler F compiles a high-level program and generates 1.5 E9 of assembly instructions, while a more advanced compiler G takes the same high-level program and generates only 1.2 E9 assembly instructions. On a given architecture, the assembly program generated by the first compiler takes 1.6 seconds to execute, while CPU execution time for the assembly code generated by the second compiler s only 1.2 seconds. 1) If the processor clock frequency s 2 GHz, what is the average CPI for the two assembly programs above? 2) Now the two assembly programs run on two different processors (different clock frequencies). How much faster needs the CPU clock for the computer executing the code generated by Compiler F needs to be vs. the CPU clock of the computer executing the code generated by Compiler G, for the two executions to finish at the same time?

Explanation / Answer

       Let us please consider that compiler F compiles a High level program and generates 1.5E9 of assembly instructions.

More Advanced Compiler G, accepts the same high level language program and generates only 1.2E9 assembly instructions.

HLL (High Level Language like Visual Basic) --à Compiler F --à Assembly instructions of size 1.5 E9 ( call it Assembly code F)

Same HLL (High Level Language like Visual Basic) --à More advanced Compiler G--à Assembly instructions of size 1.2 E9 9 ( call it assembly code G)

Say Assembly code F takes 2.6 seconds of execution time

Say Assembly code G takes only 1.3 seconds of execution time

Assume it takes 2.6 seconds to produce 1.5 E9 of Assembly code by compiler F

CPI = Time consumed by the CPU / ( Size of the Assembly Code / Clock frequency)

CPI = 2.6 seconds / (1.5E9 / 2 GHZ)

= 4.3333 * 10^-18 seconds square

= 4.3333 microseconds

CPI = 2.6 * 1000000 / (1.5E9 / 2000) microseconds

= 2600000 / 1.5E9

= 2600000 / 1500000000 / 2000

= 2600000 / 1500000 / 2

= 5200000 / 1500000

= 52/15

= 4.3333 microseconds

                The average CPI for assembly program G:

Assume it takes 1.3 seconds to produce 1.2 E9 of Assembly code by compiler G

CPI = 1.3 seconds / ( 1.2 E9 / 2 GHZ)

= 2.1667 * 10^-18 seconds square

= 2.1667 microseconds

CPI = 1.3 * 1000000 / (1.2 E9 / 2000 ) micro seconds

= 1300000 / 1200000000 / 2000

= 1300000 / 1200000 / 2

= 26 / 12

= 2.1667 microseconds

2) The answer is simply the difference between the two

= 4.3333 microseconds - 2.1667 microseconds

= 4.3333 – 2.16667 = 2.1666 microseconds

Which means, the answer in proper wordings is that, the CPU clock for the computer executing the code generated by Compiler F needs to be 2.1666 microseconds faster than the CPU clock of the computer executing the code generated by the compiler G, so that the two executions will finish on the same time