Autotuner Tuning Process
As shown in Figure 1, the tuning process consists of two phases: initial compilation and tuning process.
Initial Compilation
In the initial compilation phase before tuning, the Autotuner instructs the compiler to compile the target program code. During the compilation, the BiSheng compiler generates some YAML files that contain all tuning opportunities, and tells us which structures in the target program can be used for tuning, such as module, function, and loop. For example, loop unrolling is one of the most common optimization methods in a compiler. By copying loop body code for multiple times, the loop unrolling achieves optimization effects such as expanding space for instruction scheduling and reducing overheads of loop branch instructions. If the tuning is performed based on the unroll factor, the compiler generates all the loops that can be cyclically unrolled in the YAML file as the tuning opportunities.
Tuning Process
After the tuning opportunities are generated, the tuning process starts.
- The Autotuner reads the YAML files of the tuning opportunities to generate the corresponding search spaces, that is, the parameters and ranges for each tuning opportunity.
- The Autotuner tries a group of parameters based on the specified search algorithm to generate a compilation configuration file in YAML format. In this way, the compiler compiles the target program code to generate a binary file.
- Finally, the Autotuner runs the compiled file in a user-defined manner and obtains the performance information as the feedback.
- After a certain number of iterations, the Autotuner finds the optimal configuration, generates the optimal compilation configuration file, and stores the file in YAML format.
