Due Date: In class
In this in-class assignment you will use the
gprof tool to profile a program you will download from the course website. You will need to use your laptop with the virtual machine you are using for the course assignments, and it will be helpful to have a printout or access to the slides from the profiling lecture. Please read and follow these instructions carefully, and turn in the answers to questions asked below the the professor at the end of lecture.
- Download the file from the internet from here.
Change to a directory where you will work:
% cd ~/tmp
Untar the file using the tar command, change to the newly created directory:
% tar xvzf cmpsc311-profile-inclass.tgz % cd cmpsc311-inclass-profile
Build the program using the Makefile and
Run the program and provide the first 10 characters of your first and last name as the sole input parameter (repeat the names if this is less than 10 characters). For example, if I were to run it, I would be run as follows:
% ./profileme patrickmcd
- Run the gprof tool and look at the performance recorded.
Write down the top 3 functions in terms of total run time, and record the percentage of total execution time for the program.
# Function Percent of Execution Time Total Function Execution Time (seconds) 1 2 3
Record the 3 functions called the most during the entire program run.
# Function Number of Calls 1 2 3
Now run the program 5 more times using the following input and record the function that is takes up the most execution time, and record the total program execution time.
Input Function Percent of Execution Time Total Function Execution Time (seconds) Total Program Execution Time (seconds) pennstates bbcdefgccc aaaaaaaaaa fghkpvzpvz iowaboring
Based on the results of the previous question, which function is the best candidate for optimization and why?
Using Amdahl's law, calculate the expected speed up of the program if the function identified in the previous question had a run-time of zero seconds (on input "pennstates").
Speed up =
Edit file profileme.c and edit the function identified in the previous question. Comment out the while loop. Save and make the program.
Re-run the program with the input "iowaboring". Does the performance match the run-time predicted by Amdahl's law? Why are why not?