CSCI 317 - Homework 2

Due: Friday 04 April 2008 in class

The purpose of this assignment is to perform some experiments to investigate the performance of programs on various architectures.

Part 1 - instruction counts

Compile the following code on both occs.cs.oberlin.edu and oldoccs.cs.oberlin.edu. NOTE: oldoccs has your files from winter term and any changes you make there won't be seen on your "real" home directory.

#define NLOOP 20000000

int a[32] = { 1,3,5,7,9,11,13,15,17,19,2,4,6,8,10,12,14,16,18,20, 
              21,22,23,24,25,26,27,28,29,30,31,32 };

int main() { 
    int n,i,j,k;

    for(n=0,i=0,j=1,k=2;n<NLOOP; ++n,i=j,j=k,k= (k+1)&31){ 
        a[i] = a[j]^a[k]; 
    } 
}

Determine the following:

  1. The instruction count of the program unoptimized (-O0) and optimized (-O5). Remember, to get the assembly code output, you need to use the -S flag.
  2. The execution time for each version. (Use the UNIX time command. Choose a value for NLOOP which results in an execution time of at least 2 seconds.)
  3. The MIPS for each machine (million instructions per second).
  4. The CPI for each version. (You'll need to find out the CPU clock rate on each machine you use.)


    I'm told that clock rates for the two machines are as follows:

    Let me know if you can verify this.

Part 2 - Integer vs. floating point

Modify the program to perform floating point operations, by declaring a to be an array of doubles, and by replacing the expression a[j]^a[k] by (a[j]+a[k])/2.0. Again, run the program, optimized and unoptimized, on occs and oldoccs. For comparison purposes, keep NLOOP the same as in part 1 (which might differ between the 2 machines).

  1. Instruction counts
  2. Execution times
  3. MFLOPS (Million Floating Point OPS)
  4. Floating point CPI

Part 3 - Analysis

Answer the following 3 questions based on what you observed above:

  1. How does the use of floating point calculations affect CPI and execution times?
  2. How useful is MFLOPs or MIPS for making comparisons between 2 machines?
  3. How does the use of compiler optimizations affect performance?

Submit your answers in written/electronic form by the end of class Friday, April 4. If you followed the honor code on this assignment, be sure to include it.


Last Modified: March 16, 2008 - Benjamin A. KupermanVI Powered