1.3. Optimization Flowchart

The flowchart in Figure 1-1 provides a high-level overview of the optimization process:

Figure 1-1. Optimization Overview

In practice, optimization is an incremental and rather subjective process that follows this general flow:

  1. Measure: Use the tools and methods described in Chapter 2 to measure the current performance of the code as it executes and identify the most significant problem area.

  2. Evaluate: Study the problem area to determine the best method of addressing it.

  3. Apply: Use one of the techniques described in this guide to effect the improvement. Recompile as needed.

  4. Test: Check your answers after each code modification to avoid regression, then measure the performance of the modified code to determine whether any improvement has in fact taken place.

  5. Repeat: Repeat steps 1 through 4 until you are satisfied with the results.

Optimization is an iterative process that requires a lot of recompilation and retesting and has no fixed end point. Nor is performance improvement guaranteed; Cray compilers produce highly optimized code by default and manual intervention may actually produce code that runs more slowly.

Therefore, keep the following principles in mind as you work through the optimization process: