Question
Hi can you help me with the following questions? For question 2, I will need the execution time for each program at the various optimization
Hi can you help me with the following questions?
For question 2, I will need the execution time for each program at the various optimization level.
For question 3, I will need to know the kinds of optimization used by the compiler in each level in order to make the program faster based on the results in question 2.
Optimizations:
1) High level - Procedure integration (procedure in-lining)
2) Local (within a basic block) - Common expression elimination, Constant propagation, Stack height reduction
3) Global (beyond a basic block) - Global common expression elimination, Copy propagation, Code motion
4) Machine-Dependent- Strength reduction (shift for multiplication), Branch offset optimization, Pipeline scheduling
Examples of optimizations:
Assignment Questions:
This activity will get you familiar with performance measurement, instruction set architecture, and compiler. It should give you a general idea on how a compiler optimize software. In particular, you will learn how architect measure performance of a system.
We will use the free c compiler from the GNU free compiler collection (GCC) project. If you uses Linux or Mac OS X, be sure to install appropriate packets. (For Mac OS X, you may install X-code command-line tool.)
Copy propagation Common-expression elimination /7 before m60; h60 60; d24*m; days = seconds / d; /7 before a -b +c+ d; // after days seconds/ 86400; // after 2. (Optimization) We will use simple fibonacci calculation as a benchmark. Please measure the execution time (using the time command) of this given program when compiling with optimization level O (no optimization), level 1, level 2 and level 3. (Note that some compilers do similar optimization for all level 1, level 2 and level 3. If that is the case, you will see no difference after level 1.) You may want to run each program for few times and use the average value as a result. includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started