Download HPC User Manual - Alabama Supercomputer Authority
Transcript
HPC User Manual - Edition 10.1 Compiling Software Optimizing code is an iterative process requiring the following steps. 1. 2. 3. 4. 5. evaluate the code determine possible areas where optimization techniques can be applied apply the techniques check code performance is code sufficiently optimized? • if not, return to step 1 • if yes, the code is optimized for single CPU performance The evaluation step is most often done using a program called a profiler. In order to use a profiler, first recompile the program with a compiler flag that turns on profiling. Then run a test calculation, which generates an extra output file with profiling data. Then run the profiler, which analyzes the data and outputs information about how the program ran. Usually, there are two crucial pieces of data in the profiler output; how much time was spent executing each subroutine, and how many times each subroutine is called. The most productive optimization is usually making the functions that spend the most time executing run more efficiently. The second most productive optimization is usually cutting down on the number of calls to a function that is called millions of times. On the following page is an example of how to compile a C++ program with the g++ compiler, run a calculation, and profile the code with the gprof profiler. 123