Assignment 1

Download one of the following benchmark programs and using the input as suggested respectively for them, compile the code without optimization and with the different optimization options -O1, -O2 and -O3 of gcc and record the time taken to run the same program with the different optimizations. Repeat the experiment 5 times for each option and average the results. Make sure you DO NOT use too small or too big an input so that you can see the difference in time without having to wait too long for the results to be obtained. If possible, write a shell script to set up the experiments and write the time taken to an output file. Use the tool gnuplot to plot the graph.


http://www.libquantum.de/downloads

I am giving more detailed instructions for this example:

1. Download the stable version of the code.

2. Untar it.

3. Run the command: ./configure

4. Run the command: make

5. Run the command: make demos

6. Run the program shor as follows: ./shor 300

This should allow you to understand how to run the program and get the timing when using the optimization option "-O2" as this is the default in the default Makefile.

The following are the changes you need to do to get the output asked:

1. Change the Makefile CFLAGS option to not have the "-O2" option it currently has.

2. Once the command line arguments are parsed and before the actual program starts in shor.c, add a call to the function gettimeofday and add one more call to the same function at the end of the program before the print statements. Using the values from these two calls, you can compute the time taken for the program to run.

3. Repeat the above two steps with different options in CFLAGS for -O1, -O2 and -O3 and get the times.

As described earlier, try and run it multiple times and get an average of the results.


http://iphome.hhi.de/suehring/tml/index.htm

Submit a report on what your observations are. If there is no assignment for you to do in IT Lab, use the IT lab time to get this done as a good time management measure.