Due Date
See the
calendar for due date.
Do not use the UNIX command time (it will add in the time to allocate memory, etc.)
Description:
For this assignment, you will experiment with several of the code tuning techniques we covered in class.
The timing results should be done using Fortran, the system clock and / or a profiler (not the Unix command
time ).
- Create two very short programs or functions for four of the optimizations presented in lecture (8 programs / functions in total). Some of these optimizations include the following techniques:
Rearranging loop order
- Unrolling loops
- Eliminating branches in loops
- Sentinel values
- Testing by the order of frequency
- Minimize page faults and cache misses
- Eliminate loops with low trip counts
- Better algorithms
- Stop testing when you know the answer
- Strengthen reduction
- Caching answers
- Eliminating / replacing system calls
- Pre-compute results
- Reduce the dimensions of arrays
- Minimize array references
- Exploit algebraic identities
- ...
Two of the four, must correspond to a lecture number that you took notes for. For the other two, you can choose other techniques (except #1 which is covered in timing.f90).
For each of the techniques, compare the performance with and without the optimization for a simple problem.
Isolate the different optimizations so that the effects of each are distinguishable.
You must write these programs yourself and NOT use someone else's code.
If you use someone else's code without attribution, this will be considered plagiarism which is an act of academic misconduct.
- Use a profiler to examine the change in execution time between the two codes.
To use the profiler, compile the code using
gfortran -p -g program.f90 -o executable
./executable
gprof -l -b executable
NOTE: Generally, you would not use both -g and -O3 compiler flags at the same time. Aside from the profiling, don't use a program compiled with -g for timing results.
- For each optimization, summarize the results of the two options.
- Time the execution for the original and optimized codes with and without compiler optimization flags (e.g., -O3). Report the timings.
In summary, you should report something like the following:
Technique |
Original |
Hand-optimized |
Original w/ -O3 |
Hand-optimized w/ -O3 |
technique1 |
|
|
|
|
technique2 |
|
|
|
|
technique3 |
|
|
|
|
technique4 |
|
|
|
|
- Turn in the codes and a report with at least the following:
- Which techniques you choose
- The timing for each code (labeled if it was the original or improved version and whether or not a compiler optimization flag was used
- Information about the machine(s) you ran the tests on and the commands used
- Conclusions about the optimizations
Note: You must have non-zero timing results!
Please submit your codes and the report into the appropriate folder in the dropbox for COMS 6100 at
https://elearn.mtsu.edu.
Rubric:
Points Item
---------- --------------------------------------------------------------
_____ / 32 Programs (eight of them)
Report
_____ / 0 + Techniques listed
_____ / 10 + Timing
_____ / 2 + Computer Specifications
_____ / 6 + Conclusions
_____ / 50 Total
_____ Approximate number of hours spent
Submission
Compress your program(s) and report with either
tar or
zip and submit your compressed file into the appropriate folder in the dropbox for COMS 6100 at
https://elearn.mtsu.edu.
To make a tarball, do something like the following:
tar -czf hwkOptimizations-USER.tar.gz hwkOptimizations-USER/*.pl
To use zip, do something like the following:
zip -r hwkOptimizations-USER.zip hwkOptimizations-USER/*.pl