PHYCS 6730 Lab Exercise: Optimization
This is an exercise for speed demons. It experiments with compiler
optimization flags. In ~p6730/exercises/code_optimize you
should find the code matmult.cc, Makefile. The code
uses the Numerical Recipes matrix class Mat_DP. The code
merely multiplies two large matrices.
Exercise 1 Compilation options
Look at the code. Notice that it times the matrix multiplication and
reports the time it takes as well as the number of floating point
operations and the performance in megaflops (millions of floating
point operations) per second. Notice that there are various make
targets with names that distinguish the different compilers and
compiler optimization flags.
Compile the target mm_g++ which uses no optimization. Run
the code and get the timing. Record the result in your answer file.
Do the same with the other targets. See what difference the
optimization level and choice of compiler makes.
Notice that we aren't using the object files in ~p6730/lib for
this exercise. The object files created by the SUN compiler CC
and by the GNU compiler g++ require different standard
libraries, so can't be mixed. So we simply compile them all at once
here to prevent confusion.
Exercise 2. Challenge
Beat the instructor! See if you can find an optimization for the code
so it runs faster than 37 MF on one of the lab servers. (No fair using
your home supercomputer!) The rules: you are allowed to look up
compiler options in the man pages to see if you can do better. You
are allowed to use any compiler on our system. You may take the
transpose of either matrix in the product. If you succeed, please
e-mail the instructor, explaining what you did.