CS250 Assignment 3: Architectural Impacts on Performance

Start date 2 February, due 9 February beginning of class.

Lab Preparation: Binary Representations

In the lab, you will be converting between binary representations. If you were comfortable with Assignment 2, this should be an easy one. If not, you may want to refresh your memory on different representations.

Assignment 3: Architectural Impacts on Performance

The goal of this lab is to evaluate and understand the performance of different sizes/precisions of numeric representations. You may find some unexpected results, and will be asked to explain them.

While the choice of hardware is up to you (and may be interesting to compare), please make sure that it will run in the lab. After further consideration, please use C . Doing so will serve as a refresher on the C language, use of system calls, reading documentation, etc. - to make the next phase of the course easier.

Step 1: Programming

Write a program that measures the time taken to perform a numeric operation. You may choose which operation you want to evaluate, and also if you want to perform unsigned or signed, and integer or floating point, operations.

Hint: To get a reasonable estimate of time, you'll need to perform the operation multiple times and average. I'd suggest looping several thousand times, and dividing the total time by the number of iterations.

While you could use a watch to get times, you'll be better off using clock_gettime() or gettimeofday() to record the time before you start the loop and after it completes, and calculate the difference. Note that if you use clock_gettime(), you'll probably need to link with the real-time library (cc assign3.c -lrt).

Please turn in the code electronically, not on paper.

Step 2: Comparison expectations

Choose two different representations or operations to compare, e.g., add vs. subtract, multiply vs. divide, float vs. double, long vs. short. You should try to keep everything the same except for changing one factor. Write down the operation change and the change in runtime that you expect (e.g., I will compare 16 and 32 bit integer addition, I expect the 16 bit to take half the time.), and briefly why you expect that result. It isn't important that your hypothesis be correct, but that it make sense. Please do this before running the comparison.

Step 3: Run the comparison

You might want to run multiple times to see how much variability occurs. Report the average time and the high/low variability for each of your comparisons. Also record the hardware/OS/programming environment used.

Step 4: Explain your results

Do your results match your hypothesis? If so, elaborate on why. If not, give hypotheses as to why the results may be different. A paragraph is sufficient, but you are welcome to go into more detail if you run into some interesting results.

If you don't understand why you get the results you do, that is okay. As you go through the course, you will learn things that will help to explain what is happening, and by the end you should be able to explain what is happening.

Turning in the Assignment

You will just submit one file: assign3.c. This file should be compilable using "cc assign3.c -lrt". At the end of the file, put as comment a description of your experiment, hypothesis, results, and interpretation.

According to your lab session, you will use one of the following commands to submit your work.

Tue 9:30-11:20 session (TA: Hicham): 
	turnin -v -c cs250=0101 -p assign3 assign3.c
Wed 9:30-11:20 session (TA: David): 
	turnin -v -c cs250=0102 -p assign3 assign3.c
Fri 9:30-11:20 session (TA: Debbie): 
	turnin -v -c cs250=0103 -p assign3 assign3.c

Valid XHTML 1.1!